problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void coroutine_fn v9fs_write(void *opaque)
{
ssize_t err;
int32_t fid;
uint64_t off;
uint32_t count;
int32_t len = 0;
int32_t total = 0;
size_t offset = 7;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
QEMUIOVector qiov_full;
QEMUIOVector qiov;
err = pdu_unmarshal(pdu, offset, "dqd", &fid, &off, &count);
if (err < 0) {
pdu_complete(pdu, err);
return;
}
offset += err;
v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset, count, true);
trace_v9fs_write(pdu->tag, pdu->id, fid, off, count, qiov_full.niov);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (fidp->fid_type == P9_FID_FILE) {
if (fidp->fs.fd == -1) {
err = -EINVAL;
goto out;
}
} else if (fidp->fid_type == P9_FID_XATTR) {
err = v9fs_xattr_write(s, pdu, fidp, off, count,
qiov_full.iov, qiov_full.niov);
goto out;
} else {
err = -EINVAL;
goto out;
}
qemu_iovec_init(&qiov, qiov_full.niov);
do {
qemu_iovec_reset(&qiov);
qemu_iovec_concat(&qiov, &qiov_full, total, qiov_full.size - total);
if (0) {
print_sg(qiov.iov, qiov.niov);
}
do {
len = v9fs_co_pwritev(pdu, fidp, qiov.iov, qiov.niov, off);
if (len >= 0) {
off += len;
total += len;
}
} while (len == -EINTR && !pdu->cancelled);
if (len < 0) {
err = len;
goto out_qiov;
}
} while (total < count && len > 0);
offset = 7;
err = pdu_marshal(pdu, offset, "d", total);
if (err < 0) {
goto out;
}
err += offset;
trace_v9fs_write_return(pdu->tag, pdu->id, total, err);
out_qiov:
qemu_iovec_destroy(&qiov);
out:
put_fid(pdu, fidp);
out_nofid:
qemu_iovec_destroy(&qiov_full);
pdu_complete(pdu, err);
}
| 1threat
|
RUBY: How Can Either Convert A String Into A Hash or Add It Into A Hash : So in basic RUBY I am trying to figure out how to either Convert a string into a hash or put a string into a hash. I want the pokemon item as the key and a integer for the value.
Something like this
hash = {}
pokemon_list = "pikachu charizard jigglypuff bulbasaur"
def create_poke_list(string)
hash << string.split
end
create_poke_list
| 0debug
|
Can someone answer for conversion in java? : Can someone guide me how to convert a string value(which is "15000000" to string "150.00"?
what I am trying is :
public static String truncate(String str, int length) {
// Ensure String length is longer than requested size.
str = str.trim();
if (str.length() > length) {
str = str.substring(0, length - 1);
}
return str;
}
private void populateDetails() throws BusinessObjectException, ParseException {
List<PolicyProducerDetails> policyProducerDetailsList = null;;
if (results!=null) {
policyProducerDetailsList = new ArrayList<PolicyProducerDetails>();
for (Iterator<PolhierPprModel> iterator = results.iterator(); iterator.hasNext();) {
PolhierPprModel resultPolhierPprModel = (PolhierPprModel) iterator.next();
{
String test = resultPolhierPprModel.getCommRate().toString();
String test1 =truncate(test,4);
Float test2 = Float.parseFloat(test1);
String test3 = String.valueOf(test2);
policyProducerDetailsLocal.setCommRateOverride(test3);
}
Right now I am getting a 150.0 but I want to make it 150.00...Also I dont want it to be hardcoded as i have done.
Any Help will be great.
| 0debug
|
operator overload to preety print enum class : <p>I am trying to print the enum class(will use some kind of map to print car, house).</p>
<p>In below code where should I stick the function to operator overload << ?</p>
<p>PS: this is a contrived example.</p>
<pre><code>#include <iostream>
#include <vector>
#include <memory>
enum class property_type {CAR, HOUSE};
class Property
{
public:
virtual property_type type() = 0;
};
class Car : public Property
{
public:
Car(std::string name) : mName(name) {}
std::string mName;
property_type type() {return property_type::CAR;}
};
class House : public Property
{
public:
House(std::string name) : mName(name) {}
std::string mName;
property_type type() {return property_type::HOUSE;}
};
class Person
{
public:
std::vector< std::shared_ptr<Property> > properties;
};
int main()
{
Person x;
auto y = std::shared_ptr<Property>(new Car("my car"));
auto z = std::shared_ptr<Property>(new House("my house"));
x.properties.push_back(y);
x.properties.push_back(z);
for (auto i : x.properties) {
std::cout << i->type() << std::endl;
}
return 0;
}
</code></pre>
| 0debug
|
Im a bit of noob, i want to change the title text to an image : I need some help. i want to change the following text logo into a logo, currently used by a theme on wordpress
It looks like this now:[header image on website][1]
any suggestions, my logo is currently on the server at: content/uploads/2016/07/cropped-Site_Logo-1.png
`<div id="ribbon" class="span12 center none">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<h1 class="text_logo"><a href="/wp-content/uploads/2016/07/cropped-Site_Logo-1.png">StrtUp</a></h1>
<a class="btn btn-navbar" data-toggle="collapse" data-target="#mobile_menu">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="clear"></div>`
[1]: http://i.stack.imgur.com/2Xi1G.png
| 0debug
|
IndexError: index 151 is out of bounds for axis 0 with size 151 : help me with error please? and how to save the output from print function to dataframe?
from haversine import haversine
import pandas as pd
dataframe = pd.read_csv("gpsdataedit.csv", delimiter = None)
dataset = dataframe.values
n = 0
c = 0
b = 1
a = dataset
for value in enumerate(dataset) :
c = c + 1
b = b +1
n = n + 1
distance = haversine(a[c], a[b]).km
print(distance)
Traceback (most recent call last):
File "/home/rr/PycharmProjects/GPS/trydistance.py", line 32, in <module>
distance = haversine(a[c], a[b]).km
IndexError: index 151 is out of bounds for axis 0 with size 151
| 0debug
|
How to rename actors in draw.io : <p>I am using draw.io online tool for drawing UML diagrams. When I am dragging an Actor from left panel to the canvas, there I found no options to rename the actor. For example I want to rename the default label 'Actor' to 'User' but no luck. How to rename an Actor?</p>
<p><a href="https://i.stack.imgur.com/T3zWx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/T3zWx.png" alt="enter image description here"></a></p>
| 0debug
|
node.js How recieve field value? : with node.js i create server. Than i build http form on the specific adress(i gona do diferent form for diferent adress).
I want to recieve data from the user in specific field(i give them diferent ID).
But I cant recieve it like:
document.getElementById() becouse DOM in node.js undefined.
So. Can you advise a specific module for solving this problem, or some usefull method?
var server = new http.Server(function(req, res){
if (req.url=='/') {
res.statusCode=200;
auth(res);
res.end();
} else {
res.statusCode=404;
res.end("Page not found");
}
})
function auth(res) {
res.writeHead(200, {
'Content-Type': 'text/html',
});
var body = '';
body= '<form action="/" method="post">'+
'<thead>Connection details </thead>' +
'<br>'+
'<textarea id ="text" name="text" rows="1" cols="50"></textarea><br>'+
'<input value="localhost" id="host">Host</input><br>' +
'<input value="root" id="user">User </input><br>' +
'<input value="********" id="pass">Pasword </input><br>' +
'<input type="submit" value="Connect" id="scheme"></input><br></body></html>'
var toWrite = header + body;
res.write(toWrite);
| 0debug
|
how i can support more than one pattern @ datetimeformat : [enter image description here][1]
[1]: https://i.stack.imgur.com/Qv1G2.jpg
how i can support more than one pattern
like yyyyMMdd and yyyy-MM-dd
| 0debug
|
How to properly mask a numpy 2D array? : <p>Say I have a two dimensional array of coordinates that looks something like</p>
<p><code>x = array([[1,2],[2,3],[3,4]])</code></p>
<p>Previously in my work so far, I generated a mask that ends up looking something like</p>
<p><code>mask = [False,False,True]</code></p>
<p>When I try to use this mask on the 2D coordinate vector, I get an error</p>
<pre><code>newX = np.ma.compressed(np.ma.masked_array(x,mask))
>>>numpy.ma.core.MaskError: Mask and data not compatible: data size
is 6, mask size is 3.`
</code></pre>
<p>which makes sense, I suppose. So I tried to simply use the following mask instead:</p>
<pre><code>mask2 = np.column_stack((mask,mask))
newX = np.ma.compressed(np.ma.masked_array(x,mask2))
</code></pre>
<p>And what I get is close:</p>
<p><code>>>>array([1,2,2,3])</code></p>
<p>to what I would expect (and want):</p>
<p><code>>>>array([[1,2],[2,3]])</code></p>
<p>There must be an easier way to do this?</p>
| 0debug
|
How to run multiple functions inside a foreach loop : <p>I would like to run a foreach loop with three functions inside of it but only the first function runs.</p>
<p>Here is my code</p>
<pre><code>function import_events() {
global $wpdb;
$query_name = $wpdb->prefix . 'options';
$options = $wpdb->get_results("SELECT option_name, option_value FROM $query_name WHERE option_name LIKE 'event_url%'");
// array of option names
$i=1;
foreach ($options as $key => $row) {
$url = $row->option_value;
$city_name = $row->option_name;
import_venues($url);
import_organizers($url);
import_events_calendar($url);
}
echo"The Import Is Finished";
wp_die();
}
</code></pre>
<p>Any help is appreciated! </p>
| 0debug
|
My html and css are not linking ( i have searched everything and i cant solve this) : <p>I recently started learning HTML and CSS. I've been trying to link my css for hours. I've searched more than 10 forums but nothing seems to be solving my issue. Ive tried to change the order of the [href="stylesheet.css" rel="stylesheet" type="text/css"], I've tried using other browsers, I've tried to clean my cache and obviously my html and my css are in the same folder.</p>
<p>Here is a screenshot of my html:
<a href="https://i.stack.imgur.com/PRYNU.png" rel="nofollow noreferrer">https://i.stack.imgur.com/PRYNU.png</a>
Here is a screenshot of my css:
<a href="https://i.stack.imgur.com/v5fvP.png" rel="nofollow noreferrer">https://i.stack.imgur.com/v5fvP.png</a>
Here is the live preview of my html:
<a href="https://i.stack.imgur.com/fP9LJ.png" rel="nofollow noreferrer">https://i.stack.imgur.com/fP9LJ.png</a></p>
<p>Thanks in advance</p>
| 0debug
|
How to solve the red line's of taskSnapshot : [How to solve the red line's problem]How to solve the red line's problem of taskSnapshots[1]
[1]: https://i.stack.imgur.com/e72l1.png
| 0debug
|
static void emulate_spapr_hypercall(PPCVirtualHypervisor *vhyp,
PowerPCCPU *cpu)
{
CPUPPCState *env = &cpu->env;
if (msr_pr) {
hcall_dprintf("Hypercall made with MSR[PR]=1\n");
env->gpr[3] = H_PRIVILEGE;
} else {
env->gpr[3] = spapr_hypercall(cpu, env->gpr[3], &env->gpr[4]);
}
}
| 1threat
|
static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
{
CDXLDemuxContext *cdxl = s->priv_data;
AVIOContext *pb = s->pb;
uint32_t current_size, video_size, image_size;
uint16_t audio_size, palette_size, width, height;
int64_t pos;
int ret;
if (pb->eof_reached)
return AVERROR_EOF;
pos = avio_tell(pb);
if (!cdxl->read_chunk &&
avio_read(pb, cdxl->header, CDXL_HEADER_SIZE) != CDXL_HEADER_SIZE)
return AVERROR_EOF;
if (cdxl->header[0] != 1) {
av_log(s, AV_LOG_ERROR, "non-standard cdxl file\n");
return AVERROR_INVALIDDATA;
}
current_size = AV_RB32(&cdxl->header[2]);
width = AV_RB16(&cdxl->header[14]);
height = AV_RB16(&cdxl->header[16]);
palette_size = AV_RB16(&cdxl->header[20]);
audio_size = AV_RB16(&cdxl->header[22]);
image_size = FFALIGN(width, 16) * height * cdxl->header[19] / 8;
video_size = palette_size + image_size;
if (palette_size > 512)
return AVERROR_INVALIDDATA;
if (current_size < (uint64_t)audio_size + video_size + CDXL_HEADER_SIZE)
return AVERROR_INVALIDDATA;
if (cdxl->read_chunk && audio_size) {
if (cdxl->audio_stream_index == -1) {
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = 0;
st->codec->codec_id = CODEC_ID_PCM_S8;
st->codec->channels = cdxl->header[1] & 0x10 ? 2 : 1;
st->codec->sample_rate = cdxl->sample_rate;
st->start_time = 0;
cdxl->audio_stream_index = st->index;
avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate);
}
ret = av_get_packet(pb, pkt, audio_size);
if (ret < 0)
return ret;
pkt->stream_index = cdxl->audio_stream_index;
pkt->pos = pos;
pkt->duration = audio_size;
cdxl->read_chunk = 0;
} else {
if (cdxl->video_stream_index == -1) {
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_tag = 0;
st->codec->codec_id = CODEC_ID_CDXL;
st->codec->width = width;
st->codec->height = height;
st->start_time = 0;
cdxl->video_stream_index = st->index;
if (cdxl->framerate)
avpriv_set_pts_info(st, 64, cdxl->fps.den, cdxl->fps.num);
else
avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate);
}
if (av_new_packet(pkt, video_size + CDXL_HEADER_SIZE) < 0)
return AVERROR(ENOMEM);
memcpy(pkt->data, cdxl->header, CDXL_HEADER_SIZE);
ret = avio_read(pb, pkt->data + CDXL_HEADER_SIZE, video_size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
}
pkt->stream_index = cdxl->video_stream_index;
pkt->flags |= AV_PKT_FLAG_KEY;
pkt->pos = pos;
pkt->duration = cdxl->framerate ? 1 : audio_size ? audio_size : 220;
cdxl->read_chunk = audio_size;
}
if (!cdxl->read_chunk)
avio_skip(pb, current_size - audio_size - video_size - CDXL_HEADER_SIZE);
return ret;
}
| 1threat
|
static int proxy_opendir(FsContext *ctx,
V9fsPath *fs_path, V9fsFidOpenState *fs)
{
int serrno, fd;
fs->dir = NULL;
fd = v9fs_request(ctx->private, T_OPEN, NULL, "sd", fs_path, O_DIRECTORY);
if (fd < 0) {
errno = -fd;
return -1;
}
fs->dir = fdopendir(fd);
if (!fs->dir) {
serrno = errno;
close(fd);
errno = serrno;
return -1;
}
return 0;
}
| 1threat
|
static void fw_cfg_bootsplash(FWCfgState *s)
{
int boot_splash_time = -1;
const char *boot_splash_filename = NULL;
char *p;
char *filename, *file_data;
int file_size;
int file_type = -1;
const char *temp;
QemuOptsList *plist = qemu_find_opts("boot-opts");
QemuOpts *opts = QTAILQ_FIRST(&plist->head);
if (opts != NULL) {
temp = qemu_opt_get(opts, "splash");
if (temp != NULL) {
boot_splash_filename = temp;
}
temp = qemu_opt_get(opts, "splash-time");
if (temp != NULL) {
p = (char *)temp;
boot_splash_time = strtol(p, (char **)&p, 10);
}
}
if (boot_splash_time >= 0) {
if (boot_splash_time > 0xffff) {
error_report("splash time is big than 65535, force it to 65535.");
boot_splash_time = 0xffff;
}
qemu_extra_params_fw[0] = (uint8_t)(boot_splash_time & 0xff);
qemu_extra_params_fw[1] = (uint8_t)((boot_splash_time >> 8) & 0xff);
fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
}
if (boot_splash_filename != NULL) {
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, boot_splash_filename);
if (filename == NULL) {
error_report("failed to find file '%s'.", boot_splash_filename);
return;
}
file_data = read_splashfile(filename, &file_size, &file_type);
if (file_data == NULL) {
g_free(filename);
return;
}
if (boot_splash_filedata != NULL) {
g_free(boot_splash_filedata);
}
boot_splash_filedata = (uint8_t *)file_data;
boot_splash_filedata_size = file_size;
if (file_type == JPG_FILE) {
fw_cfg_add_file(s, "bootsplash.jpg",
boot_splash_filedata, boot_splash_filedata_size);
} else {
fw_cfg_add_file(s, "bootsplash.bmp",
boot_splash_filedata, boot_splash_filedata_size);
}
g_free(filename);
}
}
| 1threat
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
Cannot concatenate 'str' and 'int' objects. Python : <pre><code>if int(gtin) == barcode[1]:
print "You have ordered", item[1]
**quantity1 = raw_input("Please select a quantity of 100mm bolts")
quantitybolt = int(quantity1)
quantity1 += quantitybolt**
</code></pre>
<p>TypeError:cannot concatenate 'str' and 'int' objects. Python</p>
<p>Please help :) </p>
| 0debug
|
dyld: Library not loaded SwiftUI when app runs on iOS 12 using @available(iOS 13.0, *) : <p>I decided to implement a few views using SwiftUI in my app. The app is backwards compatible to iOS 12.</p>
<p>Everything works perfectly until I run it on an iOS 12 device. The app crashes immediately and the warning I get says SwiftUI cannot be loaded.</p>
<pre><code>dyld: Library not loaded: /System/Library/Frameworks/SwiftUI.framework/SwiftUI
Referenced from: /var/containers/Bundle/Application/MyApp.app/MyApp
Reason: image not found
</code></pre>
<p>I'm using @available(iOS 13.0, *) in all the correct places and there are no compiler warnings and the app runs perfectly on iOS 13</p>
<p>How can I get this to work for iOS 12?</p>
| 0debug
|
How to join tables on values : Table 1:
Col A | Col B | Col C | Col D
Cat 1 | Bla a | C-1 | D-1
Cat 1 | Bla a | C-2 | D-2
Cat 1 | Bla a | C-3 | D-3
Cat 2 | Bla b | C-4 | D-4
Cat 2 | Bla b | C-5 | D-5
Table 2:
Col A | Col B | Col E
Cat 1 | Bla a | E-1
Cat 2 | Bla b | E-2
Cat 2 | Bla b | E-3
Cat 2 | Bla b | E-4
Desired Table:
Col A | Col B | Col C | Col D | Col E
Cat 1 | Bla a | C-1 | D-1 | E-1
Cat 1 | Bla a | C-2 | D-2 | NULL
Cat 1 | Bla a | C-3 | D-3 | NULL
Cat 2 | Bla b | C-4 | D-4 | E-2
Cat 2 | Bla b | C-5 | D-5 | E-3
Cat 2 | Bla b | NULL | NULL | E-4
I want to add Column E of Table 1 to Table 2. I want to Match Columns A and B of both Tables. There is no correlation between columns C and D to Column E. I have tried Inner and outer joins, What I get is:
Wrong Table:
Col A | Col B | Col C | Col D | Col E
Cat 1 | Bla a | C-1 | D-1 | E-1
Cat 1 | Bla a | C-2 | D-2 | E-1
Cat 1 | Bla a | C-3 | D-3 | E-1
Cat 2 | Bla b | C-4 | D-4 | E-2
Cat 2 | Bla b | C-4 | D-4 | E-3
Cat 2 | Bla b | C-4 | D-4 | E-4
Cat 2 | Bla b | C-5 | D-5 | E-2
Cat 2 | Bla b | C-5 | D-5 | E-3
Cat 2 | Bla b | C-5 | D-5 | E-4
Please Help. Thank You
| 0debug
|
3 variables (collumns) to be combined in 1 variable (collumn) : [1] click on the photo to see the demo data
Either in Excel or in SPSS
To combine the 3 colluns into 1 and to be able then to calculate the statistics of the collumn. Mean Median Moden Frequencies and all these.
Anny help would be appreciated.
Thank you in advance.
[1]: http://i.stack.imgur.com/B5BPz.jpg
| 0debug
|
static int get_packet_size(const uint8_t *buf, int size)
{
int score, fec_score, dvhs_score;
if (size < (TS_FEC_PACKET_SIZE * 5 + 1))
return AVERROR_INVALIDDATA;
score = analyze(buf, size, TS_PACKET_SIZE, NULL);
dvhs_score = analyze(buf, size, TS_DVHS_PACKET_SIZE, NULL);
fec_score = analyze(buf, size, TS_FEC_PACKET_SIZE, NULL);
av_dlog(NULL, "score: %d, dvhs_score: %d, fec_score: %d \n",
score, dvhs_score, fec_score);
if (score > fec_score && score > dvhs_score)
return TS_PACKET_SIZE;
else if (dvhs_score > score && dvhs_score > fec_score)
return TS_DVHS_PACKET_SIZE;
else if (score < fec_score && dvhs_score < fec_score)
return TS_FEC_PACKET_SIZE;
else
return AVERROR_INVALIDDATA;
}
| 1threat
|
R: Handling of sf objects in raster package : <p>Previously I was using <code>raster::crop</code> and <code>raster::mask</code> with shapefiles of class Spatial*, read in using <code>rgal::readOGR</code>. </p>
<p>I am just "upgrading" my scripts to use <code>sf</code> for reading and manipulating polygons. </p>
<h3>raster::crop</h3>
<p><code>raster::crop</code> expects an 'extent' object as second argument. Up to now, this was automatically extracted from a Spatial* object. So I could just do <code>raster::crop(raster, polygon)</code>.<br>
To get this working with an <code>sf</code> object, I can call <code>raster::crop(raster, as.vector(st_bbox(polygon)))</code> as an ugly workaround.</p>
<h3>raster::mask</h3>
<p>Since <code>raster::mask</code> clearly expects a <code>Raster* object or a Spatial* object</code> the only solution was to coerce the <code>sf</code> object back to a Spatial* object using <code>as("Spatial")</code>. </p>
<p>I assume this problem generalized to all <code>raster</code> functions? Did I overlook something or is it just the case that the <code>raster</code> package does not (yet) work with <code>sf</code> objects? </p>
| 0debug
|
SQL server 2008 : When I attempt to restore the back up (.bak 1,32GO) database into SQL server 2008 .I get the following message:CREATE DATABASE or ALTER DATABASE failed because the cumulative size of the resulting database will exceed the license limits of 4096 MB per database
Any suggestion?
| 0debug
|
Creating a catalogue template : <p>I'm making my first steps learning to code. I have been taking some courses on internet about css, html, javascript, php and mysql. Since some months ago I decided to continue learning while I experiment with wordpress.</p>
<p>As a beginner I always start watching templates, which I decompose to analize and then I see what can I do. </p>
<p>I'm looking for a template with a really basic structure. I would like to use my content as an ipad magazine does:</p>
<p><a href="https://i.stack.imgur.com/CPPfu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CPPfu.png" alt="enter image description here"></a></p>
<p>Do you have some suggestion about a template with a similar structure? Or at least fiddle that could give me a clue about how can I proceed?</p>
<p>Thank you</p>
| 0debug
|
how to make video stabilizer? : <p>I'm new at this topic. All i want is some information about video stabilization that how it works and how we can develop a software to stabilize a video, also is there any site which provides a detailed study about video stabilization ? Hoping for a helpful answer.</p>
| 0debug
|
static int ape_tag_read_field(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
uint8_t key[1024], *value;
uint32_t size, flags;
int i, c;
size = avio_rl32(pb);
flags = avio_rl32(pb);
for (i = 0; i < sizeof(key) - 1; i++) {
c = avio_r8(pb);
if (c < 0x20 || c > 0x7E)
break;
else
key[i] = c;
}
key[i] = 0;
if (c != 0) {
av_log(s, AV_LOG_WARNING, "Invalid APE tag key '%s'.\n", key);
return -1;
}
if (size > INT32_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {
av_log(s, AV_LOG_ERROR, "APE tag size too large.\n");
return AVERROR_INVALIDDATA;
}
if (flags & APE_TAG_FLAG_IS_BINARY) {
uint8_t filename[1024];
enum AVCodecID id;
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
size -= avio_get_str(pb, size, filename, sizeof(filename));
if (size <= 0) {
av_log(s, AV_LOG_WARNING, "Skipping binary tag '%s'.\n", key);
return 0;
}
av_dict_set(&st->metadata, key, filename, 0);
if ((id = ff_guess_image2_codec(filename)) != AV_CODEC_ID_NONE) {
AVPacket pkt;
int ret;
ret = av_get_packet(s->pb, &pkt, size);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Error reading cover art.\n");
return ret;
}
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = id;
st->attached_pic = pkt;
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
} else {
if (ff_get_extradata(st->codec, s->pb, size) < 0)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
}
} else {
value = av_malloc(size+1);
if (!value)
return AVERROR(ENOMEM);
c = avio_read(pb, value, size);
if (c < 0) {
av_free(value);
return c;
}
value[c] = 0;
av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL);
}
return 0;
}
| 1threat
|
Hug subviews in SwiftUI : <p>Dave Abrahams explained some of the mechanics of SwiftUI layouts in his WWDC19 talk about Custom Views, but he left out some bits and I have trouble getting my views properly sized. </p>
<p><strong>Is there a way for a View to tell its container that it is not making any space demands, but it will use all the space it is given? Another way to say it is that the container should hug its subviews.</strong></p>
<p>Concrete example, I want something like c:</p>
<p><a href="https://i.stack.imgur.com/nuA4r.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nuA4r.png" alt="Some Texts inside a VStack"></a></p>
<p>If you have some <code>Text</code>s inside a <code>VStack</code> like in a), the <code>VStack</code> will adopt it's width to the widest subview.</p>
<p>If you add a <code>Rectangle</code> though as in b), it will expand as much as it can, until the <code>VStack</code> fills <em>its</em> container.</p>
<p>This indicates that <code>Text</code>s and <code>Rectangle</code>s are in different categories when it comes to layout, <code>Text</code> has a fixed size and a <code>Rectangle</code> is greedy. <strong>But how can I communicate this to my container if I'm making my own <code>View</code>?</strong></p>
<p>The result I actually want to achieve is c). VStack should ignore Rectangle (or my custom view) when it determines its size, and then once it has done that, <em>then</em> it should tell Rectangle, or my custom view, how much space it can have.</p>
<p>Given that SwiftUI seems to layout bottom-up, maybe this is impossible, but it seems that there should be <code>some</code> way to achieve this.</p>
| 0debug
|
document.write('<script src="evil.js"></script>');
| 1threat
|
Is there any solution to use only 1 findViewById in different method : I have 2 different method.
Method a will display textview1.
Method b also will display textview1.
Both method I need to include findViewById(R.id.textview1). When I am doing like this, I need to put twice findViewById in the code.
| 0debug
|
If String array contains a specific string : I have a string array(String []words) which gets populated during runtime and contains almost 400k members. I tried to check if the array contains a specific string :
boolean check=Arrays.asList(words).contains ("code");
I know the "code" is already within the array, but i never get the check true as if the checking process isn't even taking place. I also tried with Hash sets but with no success. Can anyone tell where the problem is???
| 0debug
|
Simple way to use looping in java : <p>This is example for my looping code:</p>
<pre><code>int outsideLoop = 0;
for (int i = 1; i < 11; i++)
{
outsideLoop += i;
System.out.println("Count is: " + i);
}
System.out.println("Outside loop is: " + outsideLoop);
</code></pre>
<p>My friend is said that using <code>int i = 1; i < 11; i++</code> is a primitive ways.
is there any quick way to looping than to use this code?</p>
| 0debug
|
Failed to resolve target intent service, Error while delivering the message: ServiceIntent not found : <p>I try to make <strong>gcm</strong> work.</p>
<p>When our server sends a push notification I got these two errors in my app's log:</p>
<blockquote>
<p>E/GcmReceiver(8049): Failed to resolve target intent service, skipping
classname enforcement E/GcmReceiver(8049): Error while delivering the
message: ServiceIntent not found.</p>
</blockquote>
<p>In my app's folder I got the <code>google-services.json</code> file.</p>
<p>I have added the <strong>2 needed services and the receiver</strong> to my Manifest:</p>
<pre><code> <receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.myapppackage.application" />
</intent-filter>
</receiver>
<service
android:name="com.myapppackage.application.gcm.newgcm.RegisterGCMTokenService"
android:exported="false">
</service>
<service
android:name="com.myapppackage.application.gcm.newgcm.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
</code></pre>
<p>I have <strong>also added these two as java classes.</strong> The gcm token providing and uploading to our server's is fine. <strong>I also got the push 'event' but somehow I got those 2 errors above, and no messages.</strong></p>
<p><strong>I have added my project number</strong> from google api console to <code>strings.xml</code> as <code>'google_app_id'</code></p>
<p>The API keys should be all right because <strong>I do get the push event, but somehow the message is not provided.</strong></p>
<p>My gradle's <strong>app level dependencies have:</strong></p>
<pre><code>compile 'com.google.android.gms:play-services:8.+'
</code></pre>
<p>My gradle's <strong>project level dependencies have:</strong></p>
<pre><code>classpath 'com.google.gms:google-services:1.3.1'
</code></pre>
<p>So <strong>what the heck?!</strong> Please help me if you can.</p>
| 0debug
|
static void test_visitor_out_native_list_int(TestOutputVisitorData *data,
const void *unused)
{
test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER);
}
| 1threat
|
canvas to WebGL : <p>I tried to study WebGL, but I have nothing.
I do not want to use the library, they are too big.
I wrote what I want on the canvas, help me to do it on WebGL</p>
<p><a href="https://jsfiddle.net/g9tx903c/" rel="nofollow">https://jsfiddle.net/g9tx903c/</a></p>
<pre><code><canvas id="canvas" width="500" height="200"></canvas>
<script type='text/javascript'>
function DrawPoint(x, y, size, blur, opacity) {
var c = document.getElementById('canvas');
var ctx = c.getContext('2d');
var halfSize = size / 2;
var radgrad = ctx.createRadialGradient(halfSize + x, halfSize + y, 0, halfSize + x, halfSize + y, halfSize);
radgrad.addColorStop(blur, 'rgba(255, 255, 255, ' + opacity +')');
radgrad.addColorStop(1, 'rgba(255, 255, 255, 0)');
ctx.fillStyle = radgrad;
ctx.fillRect(x, y, size, size);
}
function DrawcGradient() {
var w = 500;
var h = 200;
var pointR = w / 2;
var x = (w / 2);
var y = (h / 2);
var c = document.getElementById('canvas');
var ctx = c.getContext('2d');
var grd = ctx.createRadialGradient(x, y, 0, x, y, pointR);
grd.addColorStop(0, '#5A6977');
grd.addColorStop(1, '#000');
ctx.fillStyle = grd;
ctx.fillRect(0, 0, w, h);
}
DrawcGradient();
DrawPoint(50, 100, 50, 0.5, 0.2);
DrawPoint(70, 10, 150, 0.93, 0.2);
</script>
</code></pre>
| 0debug
|
static av_cold int vp9_decode_free(AVCodecContext *ctx)
{
VP9Context *s = ctx->priv_data;
int i;
for (i = 0; i < 2; i++) {
if (s->frames[i].tf.f->data[0])
vp9_unref_frame(ctx, &s->frames[i]);
av_frame_free(&s->frames[i].tf.f);
}
for (i = 0; i < 8; i++) {
if (s->refs[i].f->data[0])
ff_thread_release_buffer(ctx, &s->refs[i]);
av_frame_free(&s->refs[i].f);
if (s->next_refs[i].f->data[0])
ff_thread_release_buffer(ctx, &s->next_refs[i]);
av_frame_free(&s->next_refs[i].f);
}
av_freep(&s->above_partition_ctx);
av_freep(&s->c_b);
s->c_b_size = 0;
av_freep(&s->b_base);
av_freep(&s->block_base);
return 0;
}
| 1threat
|
void ff_avg_h264_qpel8_mc22_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_mid_and_aver_dst_8w_msa(src - (2 * stride) - 2,
stride, dst, stride, 8);
}
| 1threat
|
static void hmp_handle_error(Monitor *mon, Error **errp)
{
if (error_is_set(errp)) {
monitor_printf(mon, "%s\n", error_get_pretty(*errp));
error_free(*errp);
}
}
| 1threat
|
static int amr_nb_decode_frame(AVCodecContext * avctx,
void *data, int *data_size,
uint8_t * buf, int buf_size)
{
AMRContext *s = avctx->priv_data;
uint8_t*amrData=buf;
int offset=0;
UWord8 toc, q, ft;
Word16 serial[SERIAL_FRAMESIZE];
Word16 *synth;
UWord8 *packed_bits;
static Word16 packed_size[16] = {12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0};
int i;
synth=data;
{
toc=amrData[offset];
q = (toc >> 2) & 0x01;
ft = (toc >> 3) & 0x0F;
offset++;
packed_bits=amrData+offset;
offset+=packed_size[ft];
s->rx_type = UnpackBits(q, ft, packed_bits, &s->mode, &serial[1]);
s->frameCount++;
if (s->rx_type == RX_NO_DATA)
{
s->mode = s->speech_decoder_state->prev_mode;
}
else {
s->speech_decoder_state->prev_mode = s->mode;
}
if (s->reset_flag_old == 1)
{
s->reset_flag = decoder_homing_frame_test_first(&serial[1], s->mode);
}
if ((s->reset_flag != 0) && (s->reset_flag_old != 0))
{
for (i = 0; i < L_FRAME; i++)
{
synth[i] = EHF_MASK;
}
}
else
{
Speech_Decode_Frame(s->speech_decoder_state, s->mode, &serial[1], s->rx_type, synth);
}
*data_size+=160*2;
synth+=160;
if (s->reset_flag_old == 0)
{
s->reset_flag = decoder_homing_frame_test(&serial[1], s->mode);
}
if (s->reset_flag != 0)
{
Speech_Decode_Frame_reset(s->speech_decoder_state);
}
s->reset_flag_old = s->reset_flag;
}
return offset;
}
| 1threat
|
def find(n,m):
q = n//m
return (q)
| 0debug
|
int kvm_arch_remove_hw_breakpoint(target_ulong addr, target_ulong len, int type)
{
return -EINVAL;
}
| 1threat
|
void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)
{
QEMUResetEntry *re;
TAILQ_FOREACH(re, &reset_handlers, entry) {
if (re->func == func && re->opaque == opaque) {
TAILQ_REMOVE(&reset_handlers, re, entry);
qemu_free(re);
return;
}
}
}
| 1threat
|
static void gen_arith (CPUState *env, DisasContext *ctx, uint32_t opc,
int rd, int rs, int rt)
{
const char *opn = "arith";
TCGv t0 = tcg_temp_local_new(TCG_TYPE_TL);
TCGv t1 = tcg_temp_local_new(TCG_TYPE_TL);
if (rd == 0 && opc != OPC_ADD && opc != OPC_SUB
&& opc != OPC_DADD && opc != OPC_DSUB) {
MIPS_DEBUG("NOP");
goto out;
}
gen_load_gpr(t0, rs);
if (rt == 0 && (opc == OPC_ADDU || opc == OPC_DADDU
|| opc == OPC_SUBU || opc == OPC_DSUBU)) {
gen_store_gpr(t0, rd);
goto out;
}
gen_load_gpr(t1, rt);
switch (opc) {
case OPC_ADD:
{
TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_TL);
TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
int l1 = gen_new_label();
save_cpu_state(ctx, 1);
tcg_gen_ext32s_tl(r_tmp1, t0);
tcg_gen_ext32s_tl(r_tmp2, t1);
tcg_gen_add_tl(t0, r_tmp1, r_tmp2);
tcg_gen_xor_tl(r_tmp1, r_tmp1, t1);
tcg_gen_xori_tl(r_tmp1, r_tmp1, -1);
tcg_gen_xor_tl(r_tmp2, t0, t1);
tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
tcg_temp_free(r_tmp2);
tcg_gen_shri_tl(r_tmp1, r_tmp1, 31);
tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp1, 0, l1);
tcg_temp_free(r_tmp1);
generate_exception(ctx, EXCP_OVERFLOW);
gen_set_label(l1);
tcg_gen_ext32s_tl(t0, t0);
}
opn = "add";
break;
case OPC_ADDU:
tcg_gen_ext32s_tl(t0, t0);
tcg_gen_ext32s_tl(t1, t1);
tcg_gen_add_tl(t0, t0, t1);
tcg_gen_ext32s_tl(t0, t0);
opn = "addu";
break;
case OPC_SUB:
{
TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_TL);
TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
int l1 = gen_new_label();
save_cpu_state(ctx, 1);
tcg_gen_ext32s_tl(r_tmp1, t0);
tcg_gen_ext32s_tl(r_tmp2, t1);
tcg_gen_sub_tl(t0, r_tmp1, r_tmp2);
tcg_gen_xor_tl(r_tmp2, r_tmp1, t1);
tcg_gen_xor_tl(r_tmp1, r_tmp1, t0);
tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
tcg_temp_free(r_tmp2);
tcg_gen_shri_tl(r_tmp1, r_tmp1, 31);
tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp1, 0, l1);
tcg_temp_free(r_tmp1);
generate_exception(ctx, EXCP_OVERFLOW);
gen_set_label(l1);
tcg_gen_ext32s_tl(t0, t0);
}
opn = "sub";
break;
case OPC_SUBU:
tcg_gen_ext32s_tl(t0, t0);
tcg_gen_ext32s_tl(t1, t1);
tcg_gen_sub_tl(t0, t0, t1);
tcg_gen_ext32s_tl(t0, t0);
opn = "subu";
break;
#if defined(TARGET_MIPS64)
case OPC_DADD:
{
TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_TL);
TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
int l1 = gen_new_label();
save_cpu_state(ctx, 1);
tcg_gen_mov_tl(r_tmp1, t0);
tcg_gen_add_tl(t0, t0, t1);
tcg_gen_xor_tl(r_tmp1, r_tmp1, t1);
tcg_gen_xori_tl(r_tmp1, r_tmp1, -1);
tcg_gen_xor_tl(r_tmp2, t0, t1);
tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
tcg_temp_free(r_tmp2);
tcg_gen_shri_tl(r_tmp1, r_tmp1, 63);
tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp1, 0, l1);
tcg_temp_free(r_tmp1);
generate_exception(ctx, EXCP_OVERFLOW);
gen_set_label(l1);
}
opn = "dadd";
break;
case OPC_DADDU:
tcg_gen_add_tl(t0, t0, t1);
opn = "daddu";
break;
case OPC_DSUB:
{
TCGv r_tmp1 = tcg_temp_local_new(TCG_TYPE_TL);
TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_TL);
int l1 = gen_new_label();
save_cpu_state(ctx, 1);
tcg_gen_mov_tl(r_tmp1, t0);
tcg_gen_sub_tl(t0, t0, t1);
tcg_gen_xor_tl(r_tmp2, r_tmp1, t1);
tcg_gen_xor_tl(r_tmp1, r_tmp1, t0);
tcg_gen_and_tl(r_tmp1, r_tmp1, r_tmp2);
tcg_temp_free(r_tmp2);
tcg_gen_shri_tl(r_tmp1, r_tmp1, 63);
tcg_gen_brcondi_tl(TCG_COND_EQ, r_tmp1, 0, l1);
tcg_temp_free(r_tmp1);
generate_exception(ctx, EXCP_OVERFLOW);
gen_set_label(l1);
}
opn = "dsub";
break;
case OPC_DSUBU:
tcg_gen_sub_tl(t0, t0, t1);
opn = "dsubu";
break;
#endif
case OPC_SLT:
gen_op_lt(t0, t1);
opn = "slt";
break;
case OPC_SLTU:
gen_op_ltu(t0, t1);
opn = "sltu";
break;
case OPC_AND:
tcg_gen_and_tl(t0, t0, t1);
opn = "and";
break;
case OPC_NOR:
tcg_gen_or_tl(t0, t0, t1);
tcg_gen_not_tl(t0, t0);
opn = "nor";
break;
case OPC_OR:
tcg_gen_or_tl(t0, t0, t1);
opn = "or";
break;
case OPC_XOR:
tcg_gen_xor_tl(t0, t0, t1);
opn = "xor";
break;
case OPC_MUL:
tcg_gen_ext32s_tl(t0, t0);
tcg_gen_ext32s_tl(t1, t1);
tcg_gen_mul_tl(t0, t0, t1);
tcg_gen_ext32s_tl(t0, t0);
opn = "mul";
break;
case OPC_MOVN:
{
int l1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
gen_store_gpr(t0, rd);
gen_set_label(l1);
}
opn = "movn";
goto print;
case OPC_MOVZ:
{
int l1 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_NE, t1, 0, l1);
gen_store_gpr(t0, rd);
gen_set_label(l1);
}
opn = "movz";
goto print;
case OPC_SLLV:
tcg_gen_ext32u_tl(t0, t0);
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_andi_tl(t0, t0, 0x1f);
tcg_gen_shl_tl(t0, t1, t0);
tcg_gen_ext32s_tl(t0, t0);
opn = "sllv";
break;
case OPC_SRAV:
tcg_gen_ext32s_tl(t1, t1);
tcg_gen_andi_tl(t0, t0, 0x1f);
tcg_gen_sar_tl(t0, t1, t0);
tcg_gen_ext32s_tl(t0, t0);
opn = "srav";
break;
case OPC_SRLV:
switch ((ctx->opcode >> 6) & 0x1f) {
case 0:
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_andi_tl(t0, t0, 0x1f);
tcg_gen_shr_tl(t0, t1, t0);
tcg_gen_ext32s_tl(t0, t0);
opn = "srlv";
break;
case 1:
if (env->insn_flags & ISA_MIPS32R2) {
int l1 = gen_new_label();
int l2 = gen_new_label();
tcg_gen_andi_tl(t0, t0, 0x1f);
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
{
TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);
TCGv r_tmp2 = tcg_temp_new(TCG_TYPE_I32);
tcg_gen_trunc_tl_i32(r_tmp1, t0);
tcg_gen_trunc_tl_i32(r_tmp2, t1);
tcg_gen_rotr_i32(r_tmp1, r_tmp1, r_tmp2);
tcg_temp_free(r_tmp1);
tcg_temp_free(r_tmp2);
tcg_gen_br(l2);
}
gen_set_label(l1);
tcg_gen_mov_tl(t0, t1);
gen_set_label(l2);
opn = "rotrv";
} else {
tcg_gen_ext32u_tl(t1, t1);
tcg_gen_andi_tl(t0, t0, 0x1f);
tcg_gen_shr_tl(t0, t1, t0);
tcg_gen_ext32s_tl(t0, t0);
opn = "srlv";
}
break;
default:
MIPS_INVAL("invalid srlv flag");
generate_exception(ctx, EXCP_RI);
break;
}
break;
#if defined(TARGET_MIPS64)
case OPC_DSLLV:
tcg_gen_andi_tl(t0, t0, 0x3f);
tcg_gen_shl_tl(t0, t1, t0);
opn = "dsllv";
break;
case OPC_DSRAV:
tcg_gen_andi_tl(t0, t0, 0x3f);
tcg_gen_sar_tl(t0, t1, t0);
opn = "dsrav";
break;
case OPC_DSRLV:
switch ((ctx->opcode >> 6) & 0x1f) {
case 0:
tcg_gen_andi_tl(t0, t0, 0x3f);
tcg_gen_shr_tl(t0, t1, t0);
opn = "dsrlv";
break;
case 1:
if (env->insn_flags & ISA_MIPS32R2) {
int l1 = gen_new_label();
int l2 = gen_new_label();
tcg_gen_andi_tl(t0, t0, 0x3f);
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
{
tcg_gen_rotr_tl(t0, t1, t0);
tcg_gen_br(l2);
}
gen_set_label(l1);
tcg_gen_mov_tl(t0, t1);
gen_set_label(l2);
opn = "drotrv";
} else {
tcg_gen_andi_tl(t0, t0, 0x3f);
tcg_gen_shr_tl(t0, t1, t0);
opn = "dsrlv";
}
break;
default:
MIPS_INVAL("invalid dsrlv flag");
generate_exception(ctx, EXCP_RI);
break;
}
break;
#endif
default:
MIPS_INVAL(opn);
generate_exception(ctx, EXCP_RI);
goto out;
}
gen_store_gpr(t0, rd);
print:
MIPS_DEBUG("%s %s, %s, %s", opn, regnames[rd], regnames[rs], regnames[rt]);
out:
tcg_temp_free(t0);
tcg_temp_free(t1);
}
| 1threat
|
int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
target_phys_addr_t addr)
{
Rom *rom;
int rc, fd = -1;
rom = qemu_mallocz(sizeof(*rom));
rom->name = qemu_strdup(file);
rom->path = qemu_find_file(QEMU_FILE_TYPE_BIOS, rom->name);
if (rom->path == NULL) {
rom->path = qemu_strdup(file);
}
fd = open(rom->path, O_RDONLY | O_BINARY);
if (fd == -1) {
fprintf(stderr, "Could not open option rom '%s': %s\n",
rom->path, strerror(errno));
goto err;
}
rom->fw_dir = fw_dir ? qemu_strdup(fw_dir) : NULL;
rom->fw_file = fw_file ? qemu_strdup(fw_file) : NULL;
rom->addr = addr;
rom->romsize = lseek(fd, 0, SEEK_END);
rom->data = qemu_mallocz(rom->romsize);
lseek(fd, 0, SEEK_SET);
rc = read(fd, rom->data, rom->romsize);
if (rc != rom->romsize) {
fprintf(stderr, "rom: file %-20s: read error: rc=%d (expected %zd)\n",
rom->name, rc, rom->romsize);
goto err;
}
close(fd);
rom_insert(rom);
return 0;
err:
if (fd != -1)
close(fd);
qemu_free(rom->data);
qemu_free(rom->path);
qemu_free(rom->name);
qemu_free(rom);
return -1;
}
| 1threat
|
How to exclude year from date? : <p>I'm trying to take a year out of today's date to be able to make some simple calculations with age. Something like if I would like to know in what year somebody gonna be 100 years old if I know their age. Would appreciate some help.</p>
| 0debug
|
static int qsv_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
{
InputStream *ist = s->opaque;
QSVContext *qsv = ist->hwaccel_ctx;
int i;
for (i = 0; i < qsv->nb_surfaces; i++) {
if (qsv->surface_used[i])
continue;
frame->buf[0] = av_buffer_create((uint8_t*)qsv->surface_ptrs[i], sizeof(*qsv->surface_ptrs[i]),
buffer_release, &qsv->surface_used[i], 0);
if (!frame->buf[0])
return AVERROR(ENOMEM);
frame->data[3] = (uint8_t*)qsv->surface_ptrs[i];
qsv->surface_used[i] = 1;
return 0;
}
return AVERROR(ENOMEM);
}
| 1threat
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
static int qemu_laio_process_requests(void *opaque)
{
struct qemu_laio_state *s = opaque;
struct qemu_laiocb *laiocb, *next;
int res = 0;
QLIST_FOREACH_SAFE (laiocb, &s->completed_reqs, node, next) {
if (laiocb->async_context_id == get_async_context_id()) {
qemu_laio_process_completion(s, laiocb);
QLIST_REMOVE(laiocb, node);
res = 1;
}
}
return res;
}
| 1threat
|
int qemu_loadvm_state(QEMUFile *f)
{
LIST_HEAD(, LoadStateEntry) loadvm_handlers =
LIST_HEAD_INITIALIZER(loadvm_handlers);
LoadStateEntry *le, *new_le;
uint8_t section_type;
unsigned int v;
int ret;
v = qemu_get_be32(f);
if (v != QEMU_VM_FILE_MAGIC)
return -EINVAL;
v = qemu_get_be32(f);
if (v == QEMU_VM_FILE_VERSION_COMPAT) {
fprintf(stderr, "SaveVM v2 format is obsolete and don't work anymore\n");
return -ENOTSUP;
}
if (v != QEMU_VM_FILE_VERSION)
return -ENOTSUP;
while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) {
uint32_t instance_id, version_id, section_id;
SaveStateEntry *se;
char idstr[257];
int len;
switch (section_type) {
case QEMU_VM_SECTION_START:
case QEMU_VM_SECTION_FULL:
section_id = qemu_get_be32(f);
len = qemu_get_byte(f);
qemu_get_buffer(f, (uint8_t *)idstr, len);
idstr[len] = 0;
instance_id = qemu_get_be32(f);
version_id = qemu_get_be32(f);
se = find_se(idstr, instance_id);
if (se == NULL) {
fprintf(stderr, "Unknown savevm section or instance '%s' %d\n", idstr, instance_id);
ret = -EINVAL;
goto out;
}
if (version_id > se->version_id) {
fprintf(stderr, "savevm: unsupported version %d for '%s' v%d\n",
version_id, idstr, se->version_id);
ret = -EINVAL;
goto out;
}
le = qemu_mallocz(sizeof(*le));
le->se = se;
le->section_id = section_id;
le->version_id = version_id;
LIST_INSERT_HEAD(&loadvm_handlers, le, entry);
ret = vmstate_load(f, le->se, le->version_id);
if (ret < 0) {
fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n",
instance_id, idstr);
goto out;
}
break;
case QEMU_VM_SECTION_PART:
case QEMU_VM_SECTION_END:
section_id = qemu_get_be32(f);
LIST_FOREACH(le, &loadvm_handlers, entry) {
if (le->section_id == section_id) {
break;
}
}
if (le == NULL) {
fprintf(stderr, "Unknown savevm section %d\n", section_id);
ret = -EINVAL;
goto out;
}
ret = vmstate_load(f, le->se, le->version_id);
if (ret < 0) {
fprintf(stderr, "qemu: warning: error while loading state section id %d\n",
section_id);
goto out;
}
break;
default:
fprintf(stderr, "Unknown savevm section type %d\n", section_type);
ret = -EINVAL;
goto out;
}
}
ret = 0;
out:
LIST_FOREACH_SAFE(le, &loadvm_handlers, entry, new_le) {
LIST_REMOVE(le, entry);
qemu_free(le);
}
if (qemu_file_has_error(f))
ret = -EIO;
return ret;
}
| 1threat
|
How to trigger a button multiple times in jQuery : currently i clone or duplicate a div on button click it works perfectly.
but the problem is that i also want to duplicate a div according to url parameters value for example (localhost/app/index-2.html?zipCode=78001&**empNo=15**)
if empNo= 3 then clone 3 time , else if 4 then 4 times.
| 0debug
|
Google Beacon Not Recognized : <p>I recently received 2 Beacons from Google for my small business. I followed the installation instructions that came in the box. To activate it, I followed the link in the box, which brought me to a Google form page to enter in the activation code. I then downloaded the Beacon tools app for Android to start using them. However, when I searched for the Beacons in the app, it said there wasn't any unregistered or registered Beacons in the area. I was standing right under them so proximity isn't the issue. I also waited a day in case they needed time to activate, but they still are not recognized.</p>
<p>Does anyone know how to fix this issue? Is there something I am missing to register my Beacons? I looked everywhere for a support page on Google's page about their Beacons and this was all that came up. Any help would be appreciated. Thank you!</p>
| 0debug
|
static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, uint8_t *buf, int buf_size)
{
AC3DecodeContext *ctx = (AC3DecodeContext *)avctx->priv_data;
ac3_audio_block *ab = &ctx->audio_block;
int frame_start;
int i, j, k, l, value;
float tmp_block_first_half[128], tmp_block_second_half[128];
int16_t *out_samples = (int16_t *)data;
int nfchans;
frame_start = ac3_synchronize(buf, buf_size);
if (frame_start == -1) {
av_log(avctx, AV_LOG_ERROR, "frame is not synchronized\n");
*data_size = 0;
return buf_size;
}
init_get_bits(&(ctx->gb), buf + frame_start, (buf_size - frame_start) * 8);
if (!ac3_parse_sync_info(ctx)) {
av_log(avctx, AV_LOG_ERROR, "\n");
*data_size = 0;
return -1;
}
if (ac3_parse_bsi(ctx)) {
av_log(avctx, AV_LOG_ERROR, "bsid is not valid\n");
*data_size = 0;
return -1;
}
for (i = 0; i < MAX_BLOCKS; i++)
memset(ctx->delay[i], 0, sizeof(ctx->delay[i]));
avctx->sample_rate = ctx->sync_info.sampling_rate;
avctx->bit_rate = ctx->sync_info.bit_rate;
if (avctx->channels == 0) {
ctx->output = AC3_OUTPUT_UNMODIFIED;
}
else if ((ctx->bsi.nfchans + ((ctx->bsi.flags & AC3_BSI_LFEON) ? 1 : 0)) < avctx->channels) {
av_log(avctx, AV_LOG_INFO, "ac3_decoder: AC3 Source Channels Are Less Then Specified %d: Output to %d Channels\n",
avctx->channels, (ctx->bsi.nfchans + ((ctx->bsi.flags & AC3_BSI_LFEON) ? 1 : 0)));
ctx->output = AC3_OUTPUT_UNMODIFIED;
}
else if (avctx->channels == 1) {
ctx->output = AC3_OUTPUT_MONO;
} else if (avctx->channels == 2) {
if (ctx->bsi.dsurmod == 0x02)
ctx->output = AC3_OUTPUT_DOLBY;
else
ctx->output = AC3_OUTPUT_STEREO;
}
av_log(avctx, AV_LOG_INFO, "channels = %d \t bit rate = %d \t sampling rate = %d \n", avctx->channels, avctx->sample_rate, avctx->bit_rate);
*data_size = 0;
for (i = 0; i < 6; i++) {
if (ac3_parse_audio_block(ctx, i)) {
av_log(avctx, AV_LOG_ERROR, "error parsing the audio block\n");
*data_size = 0;
return -1;
}
av_log(NULL, AV_LOG_INFO, "doing imdct\n");
if (ctx->bsi.flags & AC3_BSI_LFEON) {
ff_imdct_calc(&ctx->imdct_ctx_512, ctx->tmp_output, ab->transform_coeffs[0], ctx->tmp_imdct);
for (l = 0; l < 256; l++)
ab->block_output[0][l] = ctx->tmp_output[l] * window[l] + ctx->delay[0][l] * window[255 -l];
memcpy(ctx->delay[0], ctx->tmp_output + 256, sizeof(ctx->delay[0]));
}
for (j = 0; j < ctx->bsi.nfchans; j++) {
if (ctx->audio_block.blksw & (1 << j)) {
for (k = 0; k < 128; k++) {
tmp_block_first_half[k] = ab->transform_coeffs[j + 1][2 * k];
tmp_block_second_half[k] = ab->transform_coeffs[j + 1][2 * k + 1];
}
ff_imdct_calc(&ctx->imdct_ctx_256, ctx->tmp_output, tmp_block_first_half, ctx->tmp_imdct);
for (l = 0; l < 256; l++)
ab->block_output[j + 1][l] = ctx->tmp_output[l] * window[l] + ctx->delay[j + 1][l] * window[255 - l];
ff_imdct_calc(&ctx->imdct_ctx_256, ctx->delay[j + 1], tmp_block_second_half, ctx->tmp_imdct);
} else {
ff_imdct_calc(&ctx->imdct_ctx_512, ctx->tmp_output, ab->transform_coeffs[j + 1], ctx->tmp_imdct);
for (l = 0; l < 256; l++)
ab->block_output[j + 1][l] = ctx->tmp_output[l] * window[l] + ctx->delay[j + 1][l] * window[255 - l];
memcpy(ctx->delay[j + 1], ctx->tmp_output + 256, sizeof(ctx->delay[j + 1]));
}
}
if (ctx->bsi.flags & AC3_BSI_LFEON) {
for (l = 0; l < 256; l++) {
value = lrint(ab->block_output[0][l]);
if (value < -32768)
value = -32768;
else if (value > 32767)
value = 32767;
*(out_samples++) = value;
}
*data_size += 256 * sizeof(int16_t);
}
do_downmix(ctx);
if (ctx->output == AC3_OUTPUT_UNMODIFIED)
nfchans = ctx->bsi.nfchans;
else
nfchans = avctx->channels;
for (k = 0; k < nfchans; k++)
for (l = 0; l < 256; l++) {
value = lrint(ab->block_output[k + 1][l]);
if (value < -32768)
value = -32768;
else if (value > 32767)
value = 32767;
*(out_samples++) = value;
}
*data_size += nfchans * 256 * sizeof (int16_t);
}
return ctx->sync_info.framesize;
}
| 1threat
|
static void netfilter_finalize(Object *obj)
{
NetFilterState *nf = NETFILTER(obj);
NetFilterClass *nfc = NETFILTER_GET_CLASS(obj);
if (nfc->cleanup) {
nfc->cleanup(nf);
}
if (nf->netdev && !QTAILQ_EMPTY(&nf->netdev->filters) &&
nf->next.tqe_prev) {
QTAILQ_REMOVE(&nf->netdev->filters, nf, next);
}
g_free(nf->netdev_id);
}
| 1threat
|
How can I create Android Intent with Action on Google(android assistant)? : <p>I want to create Android Intent with Google Assistant.
I'll ask "Ok Google, show me some specific information from my app" and google assistant should open my app via Android intent.
Anyone faced with this issue?</p>
| 0debug
|
static int usb_bt_initfn(USBDevice *dev)
{
struct USBBtState *s = DO_UPCAST(struct USBBtState, dev, dev);
s->dev.speed = USB_SPEED_HIGH;
return 0;
}
| 1threat
|
How do you get the HTTP host with Laravel 5 : <p>I'm trying to get the hostname from an HTTP request using Laravel 5, including the subdomain (e.g., <code>dev.site.com</code>). I can't find anything about this in <a href="https://laravel.com/docs/5.3/requests#request-path-and-method" rel="noreferrer">the docs</a>, but I would think that should be pretty simple. Anyone know how to do this?</p>
| 0debug
|
static int decode_seq_header(AVSContext *h) {
MpegEncContext *s = &h->s;
int frame_rate_code;
int width, height;
h->profile = get_bits(&s->gb,8);
h->level = get_bits(&s->gb,8);
skip_bits1(&s->gb);
width = get_bits(&s->gb,14);
height = get_bits(&s->gb,14);
if ((s->width || s->height) && (s->width != width || s->height != height)) {
av_log_missing_feature(s, "Width/height changing in CAVS is", 0);
return -1;
s->width = width;
s->height = height;
skip_bits(&s->gb,2);
skip_bits(&s->gb,3);
h->aspect_ratio = get_bits(&s->gb,4);
frame_rate_code = get_bits(&s->gb,4);
skip_bits(&s->gb,18);
skip_bits1(&s->gb);
skip_bits(&s->gb,12);
s->low_delay = get_bits1(&s->gb);
h->mb_width = (s->width + 15) >> 4;
h->mb_height = (s->height + 15) >> 4;
h->s.avctx->time_base.den = avpriv_frame_rate_tab[frame_rate_code].num;
h->s.avctx->time_base.num = avpriv_frame_rate_tab[frame_rate_code].den;
h->s.avctx->width = s->width;
h->s.avctx->height = s->height;
if(!h->top_qp)
ff_cavs_init_top_lines(h);
return 0;
| 1threat
|
Switch node_modules folder when I change git branch : <p>I'm working with two branches, <code>master</code> and <code>feature-1</code></p>
<p>In the master branch I'm using a lib <code>xyz@1.0</code></p>
<p>In the branch <code>feature-1</code> I've installed a new version from lib <code>xyz</code> version <code>2.0</code></p>
<p><code>feature-1</code> was not merged yet on <code>master</code> branch, because it's not done. Then when I switch to <code>master</code> again I've to re-install the <code>lib@1.0</code>, and if I switch again to <code>feature-1</code> I've to re-install the <code>lib@2.0</code></p>
<p>What's the best workflow approach in theses cases?</p>
| 0debug
|
Git commit count a day : <p>I have a branch called <code>development</code>. Now I want to know how many commits are happened per day (i.e) each day.</p>
<p>I want Toal number of commits (i.e) count of commits in a day.</p>
<p>I tried this command, but it is giving all commits count from the branch</p>
<pre><code>git shortlog -s -n
</code></pre>
<p>My question is count number of commits in a day</p>
| 0debug
|
static uint32_t openpic_cpu_read_internal(void *opaque, hwaddr addr,
int idx)
{
OpenPICState *opp = opaque;
IRQ_src_t *src;
IRQ_dst_t *dst;
uint32_t retval;
int n_IRQ;
DPRINTF("%s: cpu %d addr " TARGET_FMT_plx "\n", __func__, idx, addr);
retval = 0xFFFFFFFF;
if (idx < 0) {
return retval;
}
if (addr & 0xF)
return retval;
dst = &opp->dst[idx];
addr &= 0xFF0;
switch (addr) {
case 0x80:
retval = dst->pctp;
break;
case 0x90:
retval = idx;
break;
case 0xA0:
DPRINTF("Lower OpenPIC INT output\n");
qemu_irq_lower(dst->irqs[OPENPIC_OUTPUT_INT]);
n_IRQ = IRQ_get_next(opp, &dst->raised);
DPRINTF("PIAC: irq=%d\n", n_IRQ);
if (n_IRQ == -1) {
retval = opp->spve;
} else {
src = &opp->src[n_IRQ];
if (!(src->ipvp & IPVP_ACTIVITY_MASK) ||
!(IPVP_PRIORITY(src->ipvp) > dst->pctp)) {
src->ipvp &= ~IPVP_ACTIVITY_MASK;
retval = opp->spve;
} else {
IRQ_setbit(&dst->servicing, n_IRQ);
retval = IPVP_VECTOR(opp, src->ipvp);
}
IRQ_resetbit(&dst->raised, n_IRQ);
dst->raised.next = -1;
if (!(src->ipvp & IPVP_SENSE_MASK)) {
src->ipvp &= ~IPVP_ACTIVITY_MASK;
src->pending = 0;
}
if ((n_IRQ >= opp->irq_ipi0) && (n_IRQ < (opp->irq_ipi0 + MAX_IPI))) {
src->ide &= ~(1 << idx);
if (src->ide && !(src->ipvp & IPVP_SENSE_MASK)) {
openpic_set_irq(opp, n_IRQ, 1);
openpic_set_irq(opp, n_IRQ, 0);
src->ipvp |= IPVP_ACTIVITY_MASK;
}
}
}
break;
case 0xB0:
retval = 0;
break;
default:
break;
}
DPRINTF("%s: => %08x\n", __func__, retval);
return retval;
}
| 1threat
|
Since List is an interface and how we are creating instance without any anonymous class : <p>In java collections, Since List is an interface and how the "new" keyword is used to declare it without any anonymous class.</p>
<p>Please explain how the following line works.
List listTry= new ArrayList();</p>
<p>How the instance is created for ArrayList interface.</p>
| 0debug
|
Convert TimeStamp String to DayName-Month-year at 4:00 pm in android? : <p>i am stuck at this ,i have timestamp as string variable , and i want to convert it to this pattern DayName-Month-year at 04:00 pm ,the problem is i am targeting older version of android so when use SimpleDateFormat it shows error as required higher android API .
please help</p>
| 0debug
|
void cpu_watchpoint_remove_all(CPUState *env, int mask)
{
CPUWatchpoint *wp, *next;
TAILQ_FOREACH_SAFE(wp, &env->watchpoints, entry, next) {
if (wp->flags & mask)
cpu_watchpoint_remove_by_ref(env, wp);
}
}
| 1threat
|
static void aux_register_types(void)
{
type_register_static(&aux_bus_info);
type_register_static(&aux_slave_type_info);
type_register_static(&aux_to_i2c_type_info);
}
| 1threat
|
How to add claims in a mock ClaimsPrincipal : <p>I am trying to unit test my controller code which gets the information from the ClaimsPrincipal.Current.
In the controller code I</p>
<pre><code>public class HomeController {
public ActionResult GetName() {
return Content(ClaimsPrincipal.Current.FindFirst("name").Value);
}
}
</code></pre>
<p>And I am trying to mock my ClaimsPrincipal with claims but I still don't have any mock value from the claim.</p>
<pre><code>// Arrange
IList<Claim> claimCollection = new List<Claim>
{
new Claim("name", "John Doe")
};
var identityMock = new Mock<ClaimsIdentity>();
identityMock.Setup(x => x.Claims).Returns(claimCollection);
var cp = new Mock<ClaimsPrincipal>();
cp.Setup(m => m.HasClaim(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
cp.Setup(m => m.Identity).Returns(identityMock.Object);
var sut = new HomeController();
var contextMock = new Mock<HttpContextBase>();
contextMock.Setup(ctx => ctx.User).Returns(cp.Object);
var controllerContextMock = new Mock<ControllerContext>();
controllerContextMock.Setup(con => con.HttpContext).Returns(contextMock.Object);
controllerContextMock.Setup(con => con.HttpContext.User).Returns(cp.Object);
sut.ControllerContext = controllerContextMock.Object;
// Act
var viewresult = sut.GetName() as ContentResult;
// Assert
Assert.That(viewresult.Content, Is.EqualTo("John Doe"));
</code></pre>
<p>The viewresult.Content is empty as I run the unit test. Any help if I can add the mock claim. Thanks.</p>
| 0debug
|
Location of .bashrc in linux : <p>I made some changes in the <code>.bashrc</code> file some time ago.
In which directory is this file supposed to be located exactly?</p>
| 0debug
|
AWS Application Load Balancer transforms all headers to lower case : <p>I've a REST API application running in two EC2 instance and was using AWS Classic Load Balancer for a long time. The clients of REST API rely on the response headers (e.g. such as <code>Location</code>). </p>
<p>I know that HTTP headers are case-insensitive by definition, however (unfortunately) some clients are ignoring this and checking the headers in a case-sensitive way (e.g. they expect <code>Location</code> to start with upper case).</p>
<p>Recently I've changed to AWS Application Load Balancer and now I see that it transforms all response headers to lower case, as a result clients are failing to handle the response properly.</p>
<p>I've couple of questions here.</p>
<ol>
<li>Is it expected behavior of Application Load Balancer?</li>
<li>Is there a way to configure it to return headers as they have been built by the application?</li>
</ol>
| 0debug
|
Cannot deserialize value of type `java.util.Date` from String : <p>Using Spring 1.5.8.RELEASE
Jackson mapper giving the following exception.</p>
<pre><code>Cannot deserialize value of type `java.util.Date` from String "2018-09-04T10:44:46": expected format "yyyy-MM-dd'T'HH:mm:ss.SSS"
</code></pre>
<p>at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: com.copart.conversationapi.calldisposition.model.vo.CallLogEntity["callEndTime"])</p>
<p>CallEntity.java</p>
<pre><code>@JsonProperty("callEndTime")
@Column(name = "call_end_ts")
@JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ss.SSS")
private Date callEndTime;
</code></pre>
<p>DAO.java</p>
<pre><code>ObjectMapper mapper = new ObjectMapper();
HashMap<String, Object> finalHashMap;
finalHashMap = convertMultiToString(requestMap);
mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
CallLogEntity callLogEntity = mapper.convertValue(finalHashMap, CallEntity.class);
</code></pre>
<p>pom.xml</p>
<pre><code><dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.0</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
</code></pre>
| 0debug
|
To Wirte Junit Test Case for generic array :
> I am new to Junit , kindly let me know how can I write a test case the below method which generic.
public <T> T getValueAtIndex(int i) {
return (T) values[i];
}
| 0debug
|
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ZmbvContext * const c = avctx->priv_data;
int zret = Z_OK;
int len = buf_size;
int hi_ver, lo_ver, ret;
uint8_t *tmp;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
c->flags = buf[0];
buf++; len--;
if (c->flags & ZMBV_KEYFRAME) {
hi_ver = buf[0];
lo_ver = buf[1];
c->comp = buf[2];
c->fmt = buf[3];
c->bw = buf[4];
c->bh = buf[5];
c->decode_intra = NULL;
c->decode_xor = NULL;
buf += 6;
len -= 6;
av_log(avctx, AV_LOG_DEBUG,
"Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",
c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh);
if (hi_ver != 0 || lo_ver != 1) {
avpriv_request_sample(avctx, "Version %i.%i", hi_ver, lo_ver);
return AVERROR_PATCHWELCOME;
}
if (c->bw == 0 || c->bh == 0) {
avpriv_request_sample(avctx, "Block size %ix%i", c->bw, c->bh);
return AVERROR_PATCHWELCOME;
}
if (c->comp != 0 && c->comp != 1) {
avpriv_request_sample(avctx, "Compression type %i", c->comp);
return AVERROR_PATCHWELCOME;
}
switch (c->fmt) {
case ZMBV_FMT_8BPP:
c->bpp = 8;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_8;
break;
case ZMBV_FMT_15BPP:
case ZMBV_FMT_16BPP:
c->bpp = 16;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_16;
break;
#ifdef ZMBV_ENABLE_24BPP
case ZMBV_FMT_24BPP:
c->bpp = 24;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_24;
break;
#endif
case ZMBV_FMT_32BPP:
c->bpp = 32;
c->decode_intra = zmbv_decode_intra;
c->decode_xor = zmbv_decode_xor_32;
break;
default:
c->decode_intra = NULL;
c->decode_xor = NULL;
avpriv_request_sample(avctx, "Format %i", c->fmt);
return AVERROR_PATCHWELCOME;
}
zret = inflateReset(&c->zstream);
if (zret != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
return AVERROR_UNKNOWN;
}
tmp = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8));
if (!tmp)
return AVERROR(ENOMEM);
c->cur = tmp;
tmp = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8));
if (!tmp)
return AVERROR(ENOMEM);
c->prev = tmp;
c->bx = (c->width + c->bw - 1) / c->bw;
c->by = (c->height + c->bh - 1) / c->bh;
}
if (c->decode_intra == NULL) {
av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
return AVERROR_INVALIDDATA;
}
if (c->comp == 0) {
if (c->decomp_size < len) {
av_log(avctx, AV_LOG_ERROR, "Buffer too small\n");
return AVERROR_INVALIDDATA;
}
memcpy(c->decomp_buf, buf, len);
} else {
c->zstream.total_in = c->zstream.total_out = 0;
c->zstream.next_in = buf;
c->zstream.avail_in = len;
c->zstream.next_out = c->decomp_buf;
c->zstream.avail_out = c->decomp_size;
zret = inflate(&c->zstream, Z_SYNC_FLUSH);
if (zret != Z_OK && zret != Z_STREAM_END) {
av_log(avctx, AV_LOG_ERROR, "inflate error %d\n", zret);
return AVERROR_INVALIDDATA;
}
c->decomp_len = c->zstream.total_out;
}
if (c->flags & ZMBV_KEYFRAME) {
frame->key_frame = 1;
frame->pict_type = AV_PICTURE_TYPE_I;
c->decode_intra(c);
} else {
frame->key_frame = 0;
frame->pict_type = AV_PICTURE_TYPE_P;
if (c->decomp_len)
c->decode_xor(c);
}
{
uint8_t *out, *src;
int i, j;
out = frame->data[0];
src = c->cur;
switch (c->fmt) {
case ZMBV_FMT_8BPP:
for (j = 0; j < c->height; j++) {
for (i = 0; i < c->width; i++) {
out[i * 3 + 0] = c->pal[(*src) * 3 + 0];
out[i * 3 + 1] = c->pal[(*src) * 3 + 1];
out[i * 3 + 2] = c->pal[(*src) * 3 + 2];
src++;
}
out += frame->linesize[0];
}
break;
case ZMBV_FMT_15BPP:
for (j = 0; j < c->height; j++) {
for (i = 0; i < c->width; i++) {
uint16_t tmp = AV_RL16(src);
src += 2;
out[i * 3 + 0] = (tmp & 0x7C00) >> 7;
out[i * 3 + 1] = (tmp & 0x03E0) >> 2;
out[i * 3 + 2] = (tmp & 0x001F) << 3;
}
out += frame->linesize[0];
}
break;
case ZMBV_FMT_16BPP:
for (j = 0; j < c->height; j++) {
for (i = 0; i < c->width; i++) {
uint16_t tmp = AV_RL16(src);
src += 2;
out[i * 3 + 0] = (tmp & 0xF800) >> 8;
out[i * 3 + 1] = (tmp & 0x07E0) >> 3;
out[i * 3 + 2] = (tmp & 0x001F) << 3;
}
out += frame->linesize[0];
}
break;
#ifdef ZMBV_ENABLE_24BPP
case ZMBV_FMT_24BPP:
for (j = 0; j < c->height; j++) {
memcpy(out, src, c->width * 3);
src += c->width * 3;
out += frame->linesize[0];
}
break;
#endif
case ZMBV_FMT_32BPP:
for (j = 0; j < c->height; j++) {
for (i = 0; i < c->width; i++) {
uint32_t tmp = AV_RL32(src);
src += 4;
AV_WB24(out+(i*3), tmp);
}
out += frame->linesize[0];
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "Cannot handle format %i\n", c->fmt);
}
FFSWAP(uint8_t *, c->cur, c->prev);
}
*got_frame = 1;
return buf_size;
}
| 1threat
|
How to make Paging library work with reverse recyclerview? : <p>How to use the latest paging with endless reverse recyclerview for the purpose of chat?</p>
<p>I have linear layout with reverse layout true:</p>
<pre><code>LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true);
</code></pre>
<p>and inside scroll listener : </p>
<pre><code>@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int visibleItemCount = layoutManager.getChildCount();
int totalItemCount = layoutManager.getItemCount();
int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
if (!isLoading && !isLastPage) {
if ((visibleItemCount + firstVisibleItemPosition) >= totalItemCount
&& firstVisibleItemPosition >= 0
&& totalItemCount >= PAGE_SIZE) {
loadMoreItems();
}
}
}
</code></pre>
<p>The query for fetching messages:</p>
<pre><code>SELECT * FROM Message WHERE chatId = :chatId ORDER BY dbId ASC
</code></pre>
<p>Used for the room like below;</p>
<pre><code>@Query("SELECT * FROM Message WHERE chatId = :chatId ORDER BY dbId ASC")
DataSource.Factory<Integer,Message> fetchAll(String chatId);
</code></pre>
<p>The problem is that if I use ASC in the query, the list is automatically scrolling and fetching other messages. if used DESC, then message list is not coming in order.</p>
<p>Can anyone please help?</p>
| 0debug
|
swap tensor axis in keras : <p>I want to swap tensor axis of image batches from (batch_size, row, col, ch) to
(batch_size, ch, row, col). </p>
<p>in numpy, this can be done with </p>
<pre><code>X_batch = np.moveaxis( X_batch, 3, 1)
</code></pre>
<p>How would I do that in Keras? </p>
| 0debug
|
Is the call to super(props) in an ES6 class important? : <p>Suppose I've the following class:</p>
<pre><code>class Tabs extends React.Component {
displayName: Tabs;
static propTypes = {
selected: React.PropTypes.number,
children: React.PropTypes.oneOfType([
React.PropTypes.array,
React.PropTypes.element
]).isRequired
};
constructor() {
super();
this.state = {
selected: 0,
maxSelected: 0
};
render() {
return(
<div>
{this.props.selected}
{this.props.children}
</div>
);
}
};
</code></pre>
<p>I want to know that if passing the following constructor is important:</p>
<pre><code>constructor(props) {
super(props);
}
</code></pre>
<p>My current code works just fine but I wanted to know if this is a good practice.</p>
| 0debug
|
logical operators in C C+ K&R (Polish Reverse Calculator) :
int getop(char s[])
{
int i, c;
while ((s[0] = c = getch()) == ' ' || c == '\t')
;
s[1] = '\0';
i = 0;
if (isalpha(c)) //math function found.
{
while (isalpha(s[++i] = c = getch()))
;
s[i] = '\0';
if (c != 'EOF')
ungetch(c);
return MATHLIB;
}
if ((c != '.'&&c != '-') &&!isdigit(c)) /*operand found*/
return c;
if (c == '-')
{
if (!isdigit(c = getch()))
{
ungetch(c);
return '-';
}
else
{
ungetch(c);
}
}
if (isdigit(c)) /*number found*/
{
{
while (isdigit(s[++i] = c = getch()))
;
}
if (c == '.')
{
while (isdigit(s[++i] = c = getch()))
;
}
s[i] = '\0';
if (c != EOF)
ungetch(c);
return NUMBER;
}
}
This is part of my Reverse Polish Calculator code, which is in working order.
Problem is, I tried to change the line
if ((c != '.'&&c != '-') &&!isdigit(c)) /*operand found*/
to
if ((c != '.'&&c != '-') && (c == '+' || c == '*' || c == '/' || c == '%'))
And even though I thought it was going to work correctly,
It didn't at all.
The switch function in main() won't catch operators at all.
On top of it, every return value was going to default: printf("error");
I don't understand why it didn't work and it bothers me.
Any advice?
| 0debug
|
Why the decrypted key is not the same as the encrypted key? : I wrote function to encrypt or to decrypt a word
Why the decrypted key is not the same as the encrypted key ?
function cryptage(action, password) {
var method = "AES-256-CBC";
if(action=="encrypt") {
var cipher = crypto.createCipher(method,password)
var crypted = cipher.update(password,'utf8','hex')
crypted += cipher.final('hex');
return crypted;
} else if (action=="decrypt") {
var decipher = crypto.createDecipher(method,password)
decipher.setAutoPadding(false);
var decrypted = decipher.update(password,'hex','utf8')
decrypted += decipher.final('utf8');
return decrypted;
}
}
When I call `var crypted = cryptage("encrypt", "test")`, it returns me
> cc1fbd73cb93106c3358636ff619bdbd
When I call `cryptage("decrypt", crypted)`, it returns me exactly
> Te�~��IӠ~{ }m
but no "text". Why ?
| 0debug
|
int qcow2_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
{
BDRVQcowState *s = bs->opaque;
QCowSnapshot sn;
int snapshot_index, ret;
snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id);
if (snapshot_index < 0) {
return -ENOENT;
}
sn = s->snapshots[snapshot_index];
memmove(s->snapshots + snapshot_index,
s->snapshots + snapshot_index + 1,
(s->nb_snapshots - snapshot_index - 1) * sizeof(sn));
s->nb_snapshots--;
ret = qcow2_write_snapshots(bs);
if (ret < 0) {
return ret;
}
g_free(sn.id_str);
g_free(sn.name);
ret = qcow2_update_snapshot_refcount(bs, sn.l1_table_offset,
sn.l1_size, -1);
if (ret < 0) {
return ret;
}
qcow2_free_clusters(bs, sn.l1_table_offset, sn.l1_size * sizeof(uint64_t));
ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 0);
if (ret < 0) {
return ret;
}
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(bs, &result);
}
#endif
return 0;
}
| 1threat
|
static uint16_t qvirtio_pci_config_readw(QVirtioDevice *d, uint64_t off)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
uint16_t value;
value = qpci_io_readw(dev->pdev, CONFIG_BASE(dev) + off);
if (qvirtio_is_big_endian(d)) {
value = bswap16(value);
}
return value;
}
| 1threat
|
how to get numbers from a string in java script : I have a variable which it contains a telephone number in a sentence, to know it better it is like this `"tel1": "Tél: 01.78.99.93.06",` now I need to get just numbers and put in another variable the out put should be like this `var nom="0178999306"` how I can do it with jquery and java script?
Appreciate very much
| 0debug
|
Why do glob.glob and pathlib.Path.glob treat hidden files differently? : <p>Consider this folder containing two files:</p>
<pre><code>test/
foo
.bar
</code></pre>
<p>Calling <a href="https://docs.python.org/3/library/glob.html#glob.glob" rel="noreferrer"><code>glob.glob('*')</code></a> on this folder won't list the hidden <code>.bar</code> file:</p>
<pre><code>>>> glob.glob('test/*')
['test/foo']
</code></pre>
<p>But <a href="https://docs.python.org/3/library/pathlib.html#pathlib.Path.glob" rel="noreferrer"><code>pathlib.Path.glob('*')</code></a> will:</p>
<pre><code>>>> list(Path('test').glob('*'))
[PosixPath('test/.bar'), PosixPath('test/foo')]
</code></pre>
<p>I'd like to know if this is intended or possibly a bug/oversight.</p>
<hr>
<p>The <a href="https://docs.python.org/3/library/glob.html" rel="noreferrer"><code>glob</code> module documentation</a> states that files starting with a dot are special cased:</p>
<blockquote>
<p>glob treats filenames beginning with a dot (.) as special cases</p>
</blockquote>
<p>Meaning that the result given by <code>glob.glob('*')</code> is intended. But what about pathlib's <code>glob</code>? I couldn't find any relevant information in the docs. Is this the intended behavior? Shouldn't both functions produce the same results?</p>
| 0debug
|
How do I loop a statement til condition is met ?Java : <pre><code> Scanner scanner = new Scanner(System.in);
System.out.println("1. Do you like computers?");
String input = scanner.nextLine();
if (input.equals("no")) {
System.out.println("You should!");
if (input.equals("yes")){
System.out.println("I like computers too!");
</code></pre>
<p>If the user inputs anything else than "yes" or "no", how would i repeat the question til the user inputs "yes" or "no". I am new to java so detailed explanations will help.</p>
| 0debug
|
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
| 1threat
|
bool qemu_net_queue_flush(NetQueue *queue)
{
while (!QTAILQ_EMPTY(&queue->packets)) {
NetPacket *packet;
int ret;
packet = QTAILQ_FIRST(&queue->packets);
QTAILQ_REMOVE(&queue->packets, packet, entry);
ret = qemu_net_queue_deliver(queue,
packet->sender,
packet->flags,
packet->data,
packet->size);
if (ret == 0) {
queue->nq_count++;
QTAILQ_INSERT_HEAD(&queue->packets, packet, entry);
return false;
}
if (packet->sent_cb) {
packet->sent_cb(packet->sender, ret);
}
g_free(packet);
}
return true;
}
| 1threat
|
Singleton Class or Class with only static fields? : <p>what is the better approach? </p>
<p>Let us assume a scenario in which there is a utility class that is used by other classes. What is better to use in this case, a singleton class which can be instantiated exactly once or should i make all the fieds static?</p>
| 0debug
|
JAVA Ask user to enter word until they enter "exit" : Ask user to enter word until they enter "exit", when they enter exit display all of their entered words without the "exit". I'm confused how to combine all of their words and display it at the end, I know I will need another loop for that
import java.util.*;
public class testprac {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (true) {
System.out.println("Enter a word: ");
String word = input.nextLine();
if (word.equals("exit")) {
System.out.println("Exited");
System.out.println("You entered: ");
break;
}
}
}
}
| 0debug
|
Python loops and dinamic stacks : I know that the titel is very unspecific, but that`s because I don´t even know right now how to articulate my question.
My problem is the following:
I want to creat a loop. This loop is supposed to do an iteration. The only thing I need is the last Iteration it does. I was wondering wether I could creat a dinamic stack for that, so that I don´t define a matric before hand, which uses memory. How could I don that?
Thank you for your answers!
| 0debug
|
Trouble Indexing with a Multi-index in Pandas : The following example from the docs works as expected:
s = pd.Series([1, 2, 3, 4, 5, 6],index=pd.MultiIndex.from_product([["A", "B"], ["c", "d", "e"]]))
s['A']
c 1
d 2
e 3
However, for this example, from my data, such indexing raises an error:
df = pd.DataFrame({'client_id': {('foo', '2018-01-29'): '1',
('bar', '2018-01-29'): '1',
('baz', '2018-01-29'): '1',
('alice', '2018-01-29'): '1',
('bob', '2018-01-29'): '1'}})
df['alice']
KeyError: 'alice'
What am I doing wrong?
| 0debug
|
code ran into segmentation fault error.how to fix? : <p>The attached image is the code on hackerrank for a problem i dont know why but it runs into segmentation fault error.Please help me to fix this problem.<a href="https://i.stack.imgur.com/ezoLQ.png" rel="nofollow noreferrer">Code</a>
The error shown is in this link<a href="https://i.stack.imgur.com/QKWky.png" rel="nofollow noreferrer">Error</a></p>
| 0debug
|
Ordering numbers by random : <p>i have some list with 5 numbers (exp. 1 2 3 4 5) i want to order them in random ordering each time (page refresh) examples: (2 4 3 1 5) (1 3 5 4 2) (5 1 2 3 4)... code in C#, Thanks</p>
<pre><code>var loadcards = (from card in db.GameCards
select card).Take(5).ToList();
foreach (var item in loadcards)
{
Response.Write("<script>alert('" + item.cardId + "');</script>");
}
</code></pre>
| 0debug
|
int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
{
if (len > 6) {
if (AV_RB32(data) == 0x00000001 ||
AV_RB24(data) == 0x000001) {
uint8_t *buf=NULL, *end, *start;
uint32_t sps_size=0, pps_size=0;
uint8_t *sps=0, *pps=0;
int ret = ff_avc_parse_nal_units_buf(data, &buf, &len);
if (ret < 0)
return ret;
start = buf;
end = buf + len;
while (buf < end) {
unsigned int size;
uint8_t nal_type;
size = AV_RB32(buf);
nal_type = buf[4] & 0x1f;
if (nal_type == 7) {
sps = buf + 4;
sps_size = size;
} else if (nal_type == 8) {
pps = buf + 4;
pps_size = size;
}
buf += size + 4;
}
assert(sps);
assert(pps);
avio_w8(pb, 1);
avio_w8(pb, sps[1]);
avio_w8(pb, sps[2]);
avio_w8(pb, sps[3]);
avio_w8(pb, 0xff);
avio_w8(pb, 0xe1);
avio_wb16(pb, sps_size);
avio_write(pb, sps, sps_size);
avio_w8(pb, 1);
avio_wb16(pb, pps_size);
avio_write(pb, pps, pps_size);
av_free(start);
} else {
avio_write(pb, data, len);
}
}
return 0;
}
| 1threat
|
How to fix MySQL State [2002] Database "Connection Refused " C panel : i am setting a new live server for my Laravel application its work perfectly on localhost but not on live server. Now its showing SQL State [2002] connection refused. i also try with mysqli_connect and PDO but error remains same.
<?php
$servername = "examrunner.com";
$database = "XXXXXXXX";
$username = "XXXXXXX";
$password = "XXXXXXXXXX";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
| 0debug
|
why is the value of b when printed 23 and not 46? : var a = 23;
var b = a;
a = 46;
console.log(a);
console.log(b);
**why is the value of b when printed 23 and not 46 ?
O/P : a=46, b=23, why?
**
| 0debug
|
Cannot resolve symbol ViewModelProviders on AppCompatActivity : <p>Hey I'm trying to get my ViewModel working, but no luck so far.
Android Studio shows error <code>Cannot resolve symbol 'ViewModelProviders'</code>. </p>
<p>Every other question I found on this topic was correcting <code>extends Activity</code> to <code>extends AppCompatActivity</code>, but I am extending the right one. Not sure what I'm missing...<br>
My code is based on <a href="https://youtu.be/c9-057jC1ZA" rel="noreferrer">This YouTube video</a></p>
<p><strong>MainActivity.java</strong> </p>
<pre><code>public class MainActivity extends AppCompatActivity implements
TileAdapter.TileAdapterOnClickHandler {
private BaseViewModel viewModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//set Toolbar
Toolbar myToolbar = findViewById(R.id.toolbar);
setSupportActionBar(myToolbar);
//initialize viewModel
viewModel = ViewModelProviders.of(this).get(BaseViewModel.class);
</code></pre>
<p><strong>BaseViewModel.java</strong></p>
<pre><code>public class BaseViewModel extends ViewModel {
private Movie[] mMovie;
public void init (Movie[] movies){
this.mMovie = movies;
}
public Movie[] getMovie() {
return mMovie;
}
</code></pre>
| 0debug
|
Is it possilbe in Git to simutaneously create a local branch that tracks a currently non-existing remote branch AND switch to it all at the same time? : **I want a yes or no answer to this one guys!**
I've tried this command which the official Git documentation says should work, with respect to the question I am asking:
> git checkout --track origin/my_branch_name
When I do this though, I get the following error:
> fatal: Cannot update paths and switch to branch 'web-2574' at the same >time.
>Did you intend to checkout 'origin/web-2574' which can not be resolved as >commit?
FRUSTRATED BEYOND ALL BELIEF AS TO HOW HARD IT IS TO GET STRAIGHT FORWARD ANSWERS TO BASIC GIT QUESTIONS.
**Just a simple yes or no PLEASE!!** NO complex explanations or, "oh I know, if you jump through these 50 hoops and ladders you can accomplish what you ask!!"
**I am simply asking if it is possible. If the answer is yes, please share the command that does this.** THANK YOU...and sorry for being so upset. Reason why I am mad though...is because it seems to me like it SHOULD be the DEFAULT behavior for all branches created locally to ALSO be created on the remote repo so you can just push seamlessly without all the BS overhead. Doesn't anyone else feel the same or am I some kind of alien on this planet using Git?? [end rant]
| 0debug
|
Angular 4 - Error: formControlName must be used with a parent formGroup directive : <p>I am adding <code>form</code> input fields using component -</p>
<p><em>engine-add-contact-form.html</em></p>
<pre><code><form (ngSubmit)="onSubmit()" [formGroup]="contact_form">
<md-tab-group>
<md-tab label="Form">
<ang-form></ang-form>
</md-tab>
<md-tab label="Email">
<ang-email></ang-email>
</md-tab>
<md-tab label="Message">
<ang-message></ang-message>
</md-tab>
</md-tab-group>
<button md-raised-button type="submit">Publish</button>
</code></pre>
<p></p>
<p><em>ang-form.html</em></p>
<pre><code><div class="form-grid form-title">
<md-input-container>
<input formControlName="contact_form_title"
class="form-title-field" mdInput placeholder="Title" value="">
</md-input-container>
</div>
</code></pre>
<p>Using same way i added other components (<code>ang-email ang-message</code>) html.</p>
<p>I added <code>[formGroup]</code> directive at <code>engine-add-form.ts</code> </p>
<pre><code>export class EngineAddFormComponent{
contact_form: any;
form_value: any;
constructor(){
this.contact_form = new FormGroup({
contact_form_title: new FormControl('', Validators.minLength(2)),
........
........
});
}
onSubmit(){
this.form_value = JSON.stringify(this.contact_form.value);
console.log(this.form_value);
}
}
</code></pre>
<p>I get following error - </p>
<blockquote>
<p>Error: formControlName must be used with a parent formGroup directive.
You'll want to add a formGroup
directive and pass it an existing FormGroup instance (you can create one in your class).</p>
</blockquote>
<p>I can't understand what is wrong with my code.</p>
| 0debug
|
Is there a way to call a function stored as a property using bracket notation in JS? : <p>I am building an object that contains properties where the key is a string and the value is a function. I understand that if the key was not a string, I could use dot notation to call this function. For example:</p>
<pre><code>const obj = new Object();
obj.prop1 = function () {return true}
//what I want to emulate
obj.prop1()
</code></pre>
<p>In this situation I could just call obj.prop1() to run the function. However, I am adding properties to this object dynamically, and thus need to pass a string when creating properties. Example below: </p>
<pre><code>obj['prop1'] = function() {return true}
//Unfortunately I cannot call the function stored in prop1 using the example below
obj['prop1']()
</code></pre>
<p>How can I call the function using bracket notation?</p>
| 0debug
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
static int virtio_scsi_parse_req(VirtIOSCSIReq *req,
unsigned req_size, unsigned resp_size)
{
VirtIODevice *vdev = (VirtIODevice *) req->dev;
size_t in_size, out_size;
if (iov_to_buf(req->elem.out_sg, req->elem.out_num, 0,
&req->req, req_size) < req_size) {
return -EINVAL;
}
if (qemu_iovec_concat_iov(&req->resp_iov,
req->elem.in_sg, req->elem.in_num, 0,
resp_size) < resp_size) {
return -EINVAL;
}
req->resp_size = resp_size;
if ((vdev->guest_features & (1 << VIRTIO_F_ANY_LAYOUT)) == 0) {
req_size = req->elem.out_sg[0].iov_len;
resp_size = req->elem.in_sg[0].iov_len;
}
out_size = qemu_sgl_concat(req, req->elem.out_sg,
&req->elem.out_addr[0], req->elem.out_num,
req_size);
in_size = qemu_sgl_concat(req, req->elem.in_sg,
&req->elem.in_addr[0], req->elem.in_num,
resp_size);
if (out_size && in_size) {
return -ENOTSUP;
}
if (out_size) {
req->mode = SCSI_XFER_TO_DEV;
} else if (in_size) {
req->mode = SCSI_XFER_FROM_DEV;
}
return 0;
}
| 1threat
|
Split string into array based on delimiters, using Regex? : <p>I am trying to split the following string:</p>
<pre><code>s = "Whyy noot this thing? Noot!"
</code></pre>
<p>into an array using the following delimiters:</p>
<pre><code>delimiters = [
' ',
'?',
'!'
];
</code></pre>
<p>I believe that I can use this type of expression:</p>
<pre><code>var array = string.split();
</code></pre>
<p>and that I can use RegEx.</p>
<p>But I don't know what to write between the parentheses in split().</p>
| 0debug
|
create table sql in access : this is my query in sql it seems to say i have a syntax error im used to coding in sql server not access fo i expected this outcome if anyone could help me correct my code id really apprisiate it
create table M (
NMR_METER_PT_REF Varchar (50) ,
NMR_ST_METER_READ_DATE Datetime,
NMR_END_METER_READ_DATE datetime,
NMR_ST_METER_READING Int,
NMR_END_METER_READING int,
RCH_RECONCILIATION_QTY int,
METERS_THROUGH_ZEROS_COUNT int);
INSERT M (
SELECT
NMR_METER_PT_REF
, NMR_ST_METER_READ_DATE
, NMR_END_METER_READ_DATE
, NMR_ST_METER_READING
, NMR_END_METER_READING
, RCH_RECONCILIATION_QTY
, METERS_THROUGH_ZEROS_COUNT
FROM G
WHERE (((NMR.ST.METER_READING) <= NMR.ST.METER_READING)))
drop table M
select * from M
;
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.