problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
The data couldn’t be read because it isn’t in the correct format [swift 3] : <p>I've json data that have json string(value) that that look like this</p>
<pre><code>{
"Label" : "NY Home1",
"Value" : "{\"state\":\"NY\",\"city\":\"NY\",\"postalCode\":\"22002\",\"value\":\"Fifth Avenue1\nNY NY 22002\nUSA\",\"iosIdentifier\":\"71395A78-604F-47BE-BC3C-7F932263D397\",\"street\":\"Fifth Avenue1\",\"country\":\"USA\"}",
}
</code></pre>
<p>I take the jsonString using swiftyjson</p>
<pre><code>let value = sub["Value"].string ?? ""
</code></pre>
<p>After that I convert this jsonString to Dictionary with this below code but it always show this error message <code>The data couldn’t be read because it isn’t in the correct format</code></p>
<pre><code>if let data = value.data(using: String.Encoding.utf8) {
do {
let a = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
print("check \(a)")
} catch {
print("ERROR \(error.localizedDescription)")
}
}
</code></pre>
<p>I think this happen because "\n", how to convert jsonstring to dictionary that have "\n" ?</p>
| 0debug |
There is no Download dSYM option on iTunes connect : <p>I need to download dSYM file from iTunes Connect.</p>
<p>I can see "Include symbols" is Yes, but there is no link to download the dSYM file.</p>
<p>Any idea why the option is not there? </p>
| 0debug |
static void rgb24_to_yuvj444p(AVPicture *dst, AVPicture *src,
int width, int height)
{
int src_wrap, x, y;
int r, g, b;
uint8_t *lum, *cb, *cr;
const uint8_t *p;
lum = dst->data[0];
cb = dst->data[1];
cr = dst->data[2];
src_wrap = src->linesize[0] - width * BPP;
p = src->data[0];
for(y=0;y<height;y++) {
for(x=0;x<width;x++) {
RGB_IN(r, g, b, p);
lum[0] = RGB_TO_Y(r, g, b);
cb[0] = RGB_TO_U(r, g, b, 0);
cr[0] = RGB_TO_V(r, g, b, 0);
cb++;
cr++;
lum++;
}
p += src_wrap;
lum += dst->linesize[0] - width;
cb += dst->linesize[1] - width;
cr += dst->linesize[2] - width;
}
}
| 1threat |
how to hold the back button in Internet explorer to doAnything but without do it in refresh? : ** I need to use the back button in IE but when i use it with onload function it call the function in refresh or in back button or changing the URL i need it just when i need it call just when i clicked the back button **
------------------------------------------------------------------------
<pre>
<!DOCTYPE html>
<html>
<head>
<h1>try the back button in IE</h1>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<SCRIPT type="text/javascript">
function doBack()
{
alert("you are clicking back "+window.location.href);
}
</SCRIPT>
</head>
<body onload="doBack();">
</body>
</html>
</pre> | 0debug |
document.getElementById('input').innerHTML = user_input; | 1threat |
mouseover sometimes fires instead of touchstart - why? : <p>I have found a very strange behavior that I cannot explain. Want to do the following:</p>
<p>A handler needs to react to a <code>touchstart</code> <strong>or</strong> <code>mouseover</code> event, depending on the type of input device. Note that I want to support hybrid devices (with both mouse and touchscreen) and I cannot rely on pointer events.</p>
<p>Now, I just setup both <code>touchstart</code> and <code>mouseover</code>events. And for the most part it works just fine. Also use <code>preventDefault</code> to prohibit simulated "mouse" events firing after touch events. But what is totally confusing to me is that <em>sometimes</em> there is a still a <code>mouseover</code> event occuring, and if I remove the preventDefault, it even seems that the <code>mouseover</code>is firing <strong>instead</strong> of a <code>touchstart</code>. Why oh why is this happening?</p>
<p>Furthermore, this is reproducible with both Android and iOS! Though it seems to be more easily triggered with Android (using Chrome).</p>
<p>I have prepared a little testcase so you can try for yourselves. Note that this behavior seems only triggered when you tap somewhere on the border between the red DIV (which has the events) and the background. Just tapping in the center works 100%. And you may need more or less tries until it happens.</p>
<p>Any help greatly appreciated!</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<title>Touchtest</title>
<style>
body {
background: #222;
color: white;
position: relative;
font-size: .9em;
font-family: Arial, Helvetica, sans-serif;
}
#test {
position: fixed;
top: 100px;
right: 100px;
bottom: 100px;
left: 100px;
background: red;
}
</style>
</head>
<body>
<div id="test"></div>
<script type="text/javascript">
function testEvent(event) {
console.log("testEvent", event);
if (event.type === "mouseover") {
alert("MOUSEOVER DETECTED");
}
event.preventDefault();
}
var ele = document.getElementById("test");
ele.addEventListener("touchstart", testEvent);
ele.addEventListener("mouseover", testEvent);
</script>
</body>
</html></code></pre>
</div>
</div>
</p>
| 0debug |
int nbd_receive_negotiate(QIOChannel *ioc, const char *name,
QCryptoTLSCreds *tlscreds, const char *hostname,
QIOChannel **outioc, NBDExportInfo *info,
Error **errp)
{
char buf[256];
uint64_t magic;
int rc;
bool zeroes = true;
trace_nbd_receive_negotiate(tlscreds, hostname ? hostname : "<null>");
rc = -EINVAL;
if (outioc) {
*outioc = NULL;
}
if (tlscreds && !outioc) {
error_setg(errp, "Output I/O channel required for TLS");
goto fail;
}
if (nbd_read(ioc, buf, 8, errp) < 0) {
error_prepend(errp, "Failed to read data");
goto fail;
}
buf[8] = '\0';
if (strlen(buf) == 0) {
error_setg(errp, "Server connection closed unexpectedly");
goto fail;
}
magic = ldq_be_p(buf);
trace_nbd_receive_negotiate_magic(magic);
if (memcmp(buf, "NBDMAGIC", 8) != 0) {
error_setg(errp, "Invalid magic received");
goto fail;
}
if (nbd_read(ioc, &magic, sizeof(magic), errp) < 0) {
error_prepend(errp, "Failed to read magic");
goto fail;
}
magic = be64_to_cpu(magic);
trace_nbd_receive_negotiate_magic(magic);
if (magic == NBD_OPTS_MAGIC) {
uint32_t clientflags = 0;
uint16_t globalflags;
bool fixedNewStyle = false;
if (nbd_read(ioc, &globalflags, sizeof(globalflags), errp) < 0) {
error_prepend(errp, "Failed to read server flags");
goto fail;
}
globalflags = be16_to_cpu(globalflags);
trace_nbd_receive_negotiate_server_flags(globalflags);
if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) {
fixedNewStyle = true;
clientflags |= NBD_FLAG_C_FIXED_NEWSTYLE;
}
if (globalflags & NBD_FLAG_NO_ZEROES) {
zeroes = false;
clientflags |= NBD_FLAG_C_NO_ZEROES;
}
clientflags = cpu_to_be32(clientflags);
if (nbd_write(ioc, &clientflags, sizeof(clientflags), errp) < 0) {
error_prepend(errp, "Failed to send clientflags field");
goto fail;
}
if (tlscreds) {
if (fixedNewStyle) {
*outioc = nbd_receive_starttls(ioc, tlscreds, hostname, errp);
if (!*outioc) {
goto fail;
}
ioc = *outioc;
} else {
error_setg(errp, "Server does not support STARTTLS");
goto fail;
}
}
if (!name) {
trace_nbd_receive_negotiate_default_name();
name = "";
}
if (fixedNewStyle) {
int result;
if (structured_reply) {
result = nbd_request_simple_option(ioc,
NBD_OPT_STRUCTURED_REPLY,
errp);
if (result < 0) {
goto fail;
}
info->structured_reply = result == 1;
}
result = nbd_opt_go(ioc, name, info, errp);
if (result < 0) {
goto fail;
}
if (result > 0) {
return 0;
}
if (nbd_receive_query_exports(ioc, name, errp) < 0) {
goto fail;
}
}
if (nbd_send_option_request(ioc, NBD_OPT_EXPORT_NAME, -1, name,
errp) < 0) {
goto fail;
}
if (nbd_read(ioc, &info->size, sizeof(info->size), errp) < 0) {
error_prepend(errp, "Failed to read export length");
goto fail;
}
be64_to_cpus(&info->size);
if (nbd_read(ioc, &info->flags, sizeof(info->flags), errp) < 0) {
error_prepend(errp, "Failed to read export flags");
goto fail;
}
be16_to_cpus(&info->flags);
} else if (magic == NBD_CLIENT_MAGIC) {
uint32_t oldflags;
if (name) {
error_setg(errp, "Server does not support export names");
goto fail;
}
if (tlscreds) {
error_setg(errp, "Server does not support STARTTLS");
goto fail;
}
if (nbd_read(ioc, &info->size, sizeof(info->size), errp) < 0) {
error_prepend(errp, "Failed to read export length");
goto fail;
}
be64_to_cpus(&info->size);
if (nbd_read(ioc, &oldflags, sizeof(oldflags), errp) < 0) {
error_prepend(errp, "Failed to read export flags");
goto fail;
}
be32_to_cpus(&oldflags);
if (oldflags & ~0xffff) {
error_setg(errp, "Unexpected export flags %0x" PRIx32, oldflags);
goto fail;
}
info->flags = oldflags;
} else {
error_setg(errp, "Bad magic received");
goto fail;
}
trace_nbd_receive_negotiate_size_flags(info->size, info->flags);
if (zeroes && nbd_drop(ioc, 124, errp) < 0) {
error_prepend(errp, "Failed to read reserved block");
goto fail;
}
rc = 0;
fail:
return rc;
} | 1threat |
static void palmte_init(MachineState *machine)
{
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
MemoryRegion *address_space_mem = get_system_memory();
struct omap_mpu_state_s *mpu;
int flash_size = 0x00800000;
int sdram_size = palmte_binfo.ram_size;
static uint32_t cs0val = 0xffffffff;
static uint32_t cs1val = 0x0000e1a0;
static uint32_t cs2val = 0x0000e1a0;
static uint32_t cs3val = 0xe1a0e1a0;
int rom_size, rom_loaded = 0;
MemoryRegion *flash = g_new(MemoryRegion, 1);
MemoryRegion *cs = g_new(MemoryRegion, 4);
mpu = omap310_mpu_init(address_space_mem, sdram_size, machine->cpu_type);
memory_region_init_ram(flash, NULL, "palmte.flash", flash_size,
&error_fatal);
memory_region_set_readonly(flash, true);
memory_region_add_subregion(address_space_mem, OMAP_CS0_BASE, flash);
memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val, "palmte-cs0",
OMAP_CS0_SIZE - flash_size);
memory_region_add_subregion(address_space_mem, OMAP_CS0_BASE + flash_size,
&cs[0]);
memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val, "palmte-cs1",
OMAP_CS1_SIZE);
memory_region_add_subregion(address_space_mem, OMAP_CS1_BASE, &cs[1]);
memory_region_init_io(&cs[2], NULL, &static_ops, &cs2val, "palmte-cs2",
OMAP_CS2_SIZE);
memory_region_add_subregion(address_space_mem, OMAP_CS2_BASE, &cs[2]);
memory_region_init_io(&cs[3], NULL, &static_ops, &cs3val, "palmte-cs3",
OMAP_CS3_SIZE);
memory_region_add_subregion(address_space_mem, OMAP_CS3_BASE, &cs[3]);
palmte_microwire_setup(mpu);
qemu_add_kbd_event_handler(palmte_button_event, mpu);
palmte_gpio_setup(mpu);
if (nb_option_roms) {
rom_size = get_image_size(option_rom[0].name);
if (rom_size > flash_size) {
fprintf(stderr, "%s: ROM image too big (%x > %x)\n",
__FUNCTION__, rom_size, flash_size);
rom_size = 0;
}
if (rom_size > 0) {
rom_size = load_image_targphys(option_rom[0].name, OMAP_CS0_BASE,
flash_size);
rom_loaded = 1;
}
if (rom_size < 0) {
fprintf(stderr, "%s: error loading '%s'\n",
__FUNCTION__, option_rom[0].name);
}
}
if (!rom_loaded && !kernel_filename && !qtest_enabled()) {
fprintf(stderr, "Kernel or ROM image must be specified\n");
exit(1);
}
palmte_binfo.kernel_filename = kernel_filename;
palmte_binfo.kernel_cmdline = kernel_cmdline;
palmte_binfo.initrd_filename = initrd_filename;
arm_load_kernel(mpu->cpu, &palmte_binfo);
}
| 1threat |
void qerror_report(const char *fmt, ...)
{
va_list va;
QError *qerror;
va_start(va, fmt);
qerror = qerror_from_info(fmt, &va);
va_end(va);
if (monitor_cur_is_qmp()) {
monitor_set_error(cur_mon, qerror);
} else {
qerror_print(qerror);
QDECREF(qerror);
}
}
| 1threat |
How to format numbers from 0 to 000 in php? : <p>I need to change the format of the integer. I know that needs to apply <code>sprintf</code> function but not sure how to apply properly.</p>
<p>The format turn 0 to 000. </p>
<p><strong>E.g turn 1 to 001 & 19 to 019.</strong></p>
<p>i get item code from URL.</p>
<pre><code>$catCode=isset($_GET["cat"]) ? $_GET["cat"] : "ac";
$itemCode=isset($_GET["itemCode"]) ? $_GET["itemCode"] : "001";
foreach ($productArr[$catCode] as $imgNumber => $productDetail) {
array_push($arr, $imgNumber);
$imgNumber = $arr;
}
//count the total number of items in the array
$totalItem = count($arr);
$prevItem = ($itemCode + $totalItem - 2) % $totalItem + 1;
$nextItem = $itemCode % $totalItem + 1;
if ($itemCode > $totalItem || $itemCode < 1) {
$itemCode = 1;
}
echo"<a href='http://localhost/collectionDetail.php?cat={$catCode}&itemCode={$prevItem}' ><img src='images/arrow_left.jpg'> </a>";
echo"<a href='http://localhost/collectionDetail.php?cat={$catCode}&itemCode={$nextItem}' ><img src='images/arrow_right.jpg'> </a>";
</code></pre>
| 0debug |
What is the default timeout for NPM request module (REST client)? : <p>Following will be my node.js call to retrive some data, which is taking more than 1 minute. Here this will be timeout at 1 minute (60 seconds). I put a console log for the latency also. However I have configured the timeout for 120 seconds but it is not reflecting. I know the default level nodejs server timeout is 120 seconds but still I get the timeout (of 60 seconds) from this <a href="https://www.npmjs.com/package/request" rel="noreferrer">request</a> module for this call. Please provide your insights on this.</p>
<pre><code>var options = {
method: 'post',
url:url,
timeout: 120000,
json: true,
headers: {
"Content-Type": "application/json",
"X-Authorization": "abc",
"Accept-Encoding":"gzip"
}
}
var startTime = new Date();
request(options, function(e, r, body) {
var endTime = new Date();
var latencyTime = endTime - startTime;
console.log("Ended. latencyTime:"+latencyTime/1000);
res.status(200).send(body);
});
</code></pre>
| 0debug |
how to convert my asm code into readable code. E.g. Visual Basic : I want to understand an algorythm, written in assembler.
The Code looks like:
MOV EAX,DWORD PTR SS:[ESP] - Put Value, entered into EAX
Mov ECX, EAX - Copy value from EAX to ECX
AND EAX,0xBBD13D22 - add ???
NOT ECX - ???
NOT EAX - ???
AND ECX,EAX - ???
IMUL ECX,ECX,0x74ACD16 - multiply ECX with &H74ACD16 and put result to ECX - but it's DWORD ???????
ROL ECX,0x10 - Rotate Left, but ????
IMUL ECX,ECX,0xBBB38D0 - result ???
Could please anybody explain to me, how this Code would look like in, let's say Visual Basic.
It's a mathematic operation, but I just know very little of assembler.
Could please anybody help me with that?
Sorry for my bad english, but still learning. | 0debug |
static void fw_cfg_mem_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = fw_cfg_mem_realize;
dc->props = fw_cfg_mem_properties;
} | 1threat |
int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
AVPacket *avpkt,
const AVFrame *frame,
int *got_packet_ptr)
{
int ret;
AVPacket user_pkt = *avpkt;
int needs_realloc = !user_pkt.data;
*got_packet_ptr = 0;
if(CONFIG_FRAME_THREAD_ENCODER &&
avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))
return ff_thread_video_encode_frame(avctx, avpkt, frame, got_packet_ptr);
if ((avctx->flags&CODEC_FLAG_PASS1) && avctx->stats_out)
avctx->stats_out[0] = '\0';
if (!(avctx->codec->capabilities & CODEC_CAP_DELAY) && !frame) {
av_free_packet(avpkt);
av_init_packet(avpkt);
avpkt->size = 0;
return 0;
}
if (av_image_check_size(avctx->width, avctx->height, 0, avctx))
return AVERROR(EINVAL);
av_assert0(avctx->codec->encode2);
ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
av_assert0(ret <= 0);
if (avpkt->data && avpkt->data == avctx->internal->byte_buffer) {
needs_realloc = 0;
if (user_pkt.data) {
if (user_pkt.size >= avpkt->size) {
memcpy(user_pkt.data, avpkt->data, avpkt->size);
} else {
av_log(avctx, AV_LOG_ERROR, "Provided packet is too small, needs to be %d\n", avpkt->size);
avpkt->size = user_pkt.size;
ret = -1;
}
avpkt->buf = user_pkt.buf;
avpkt->data = user_pkt.data;
#if FF_API_DESTRUCT_PACKET
FF_DISABLE_DEPRECATION_WARNINGS
avpkt->destruct = user_pkt.destruct;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
} else {
if (av_dup_packet(avpkt) < 0) {
ret = AVERROR(ENOMEM);
}
}
}
if (!ret) {
if (!*got_packet_ptr)
avpkt->size = 0;
else if (!(avctx->codec->capabilities & CODEC_CAP_DELAY))
avpkt->pts = avpkt->dts = frame->pts;
if (needs_realloc && avpkt->data) {
ret = av_buffer_realloc(&avpkt->buf, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
if (ret >= 0)
avpkt->data = avpkt->buf->data;
}
avctx->frame_number++;
}
if (ret < 0 || !*got_packet_ptr)
av_free_packet(avpkt);
else
av_packet_merge_side_data(avpkt);
emms_c();
return ret;
} | 1threat |
If display(15) i want the result 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24 : <p>I have code and if display(15) i want the result is 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24 please help me </p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function daz(num){
for(var i = 1; i < num; i++){
if(num % 7 === 0 || num % 11 === 0 || num % 14 === 0){return false}
if(num % 2 === 0 || num % 3 === 0 || num % 4 ===0 || num % 5 === 0){
return true;
}
}
}
function display(n){
var zumba = [1];
for(var i = 1; i<=n;i++){
if(daz(i)){
zumba.push(i);
}
}
document.write(zumba);
}
display(15)</code></pre>
</div>
</div>
</p>
| 0debug |
Swagger UI with Multiple Urls : <p>I saw in the swagger ui documentation that you can provide a urls parameter which is:</p>
<blockquote>
<p>An array of API definition objects ({url: "", name: ""}) used by Topbar plugin. When used and Topbar plugin is enabled, the url parameter will not be parsed. Names and URLs must be unique among all items in this array, since they're used as identifiers.</p>
</blockquote>
<p>I was hoping that this will give me a selector from which I can chose which of my yaml files to process. Unfortunately, it doesn't seem to do anything.</p>
<p>Here is my code:</p>
<pre><code>window.onload = function() {
// Build a system
const ui = SwaggerUIBundle({
urls: [
{url:"http://test.dev/documentation/microservices/microservices.yaml",name:"All Microservices"},
{url:"http://test.dev/documentation/microservices/plans.yaml",name:"Plans"},
],
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
window.ui = ui
}
</code></pre>
<p>I'd also like to set the primaryName to All Microservices.</p>
<p>Any ideas on where I'm going wrong?</p>
| 0debug |
Check if string cointains another string : <p>am trying to do a code which would check if my string contains a substring. </p>
<p>However, I have specific needs and String.contains does not match my needs. Parameter "comp" and String "computer" should return false, parameter "comp" and String "comp science" should also return false and parameter "comp" and String "comp, science" should return true. Thanks</p>
| 0debug |
Is `seqn` the `sequenceA` limited to monad? : sequenceA :: Applicative f => [f a] -> f [a]
sequenceA [] = pure []
sequenceA (x:xs) = pure (:) <*> x <*> sequenceA xs
and
seqn :: Monad m => [m a] -> m [a]
and what is its implementation?
Since a monad is an applicative, is `seqn` the `sequenceA` limited to monad?
Thanks. | 0debug |
static int flac_read_header(AVFormatContext *s)
{
int ret, metadata_last=0, metadata_type, metadata_size, found_streaminfo=0;
uint8_t header[4];
uint8_t *buffer=NULL;
FLACDecContext *flac = s->priv_data;
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_FLAC;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
if (avio_rl32(s->pb) != MKTAG('f','L','a','C')) {
avio_seek(s->pb, -4, SEEK_CUR);
return 0;
}
while (!avio_feof(s->pb) && !metadata_last) {
avio_read(s->pb, header, 4);
flac_parse_block_header(header, &metadata_last, &metadata_type,
&metadata_size);
switch (metadata_type) {
case FLAC_METADATA_TYPE_STREAMINFO:
case FLAC_METADATA_TYPE_CUESHEET:
case FLAC_METADATA_TYPE_PICTURE:
case FLAC_METADATA_TYPE_VORBIS_COMMENT:
case FLAC_METADATA_TYPE_SEEKTABLE:
buffer = av_mallocz(metadata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!buffer) {
return AVERROR(ENOMEM);
}
if (avio_read(s->pb, buffer, metadata_size) != metadata_size) {
RETURN_ERROR(AVERROR(EIO));
}
break;
default:
ret = avio_skip(s->pb, metadata_size);
if (ret < 0)
return ret;
}
if (metadata_type == FLAC_METADATA_TYPE_STREAMINFO) {
uint32_t samplerate;
uint64_t samples;
if (found_streaminfo) {
RETURN_ERROR(AVERROR_INVALIDDATA);
}
if (metadata_size != FLAC_STREAMINFO_SIZE) {
RETURN_ERROR(AVERROR_INVALIDDATA);
}
found_streaminfo = 1;
st->codecpar->extradata = buffer;
st->codecpar->extradata_size = metadata_size;
buffer = NULL;
samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4;
samples = (AV_RB64(st->codecpar->extradata + 13) >> 24) & ((1ULL << 36) - 1);
if (samplerate > 0) {
avpriv_set_pts_info(st, 64, 1, samplerate);
if (samples > 0)
st->duration = samples;
}
} else if (metadata_type == FLAC_METADATA_TYPE_CUESHEET) {
uint8_t isrc[13];
uint64_t start;
const uint8_t *offset;
int i, chapters, track, ti;
if (metadata_size < 431)
RETURN_ERROR(AVERROR_INVALIDDATA);
offset = buffer + 395;
chapters = bytestream_get_byte(&offset) - 1;
if (chapters <= 0)
RETURN_ERROR(AVERROR_INVALIDDATA);
for (i = 0; i < chapters; i++) {
if (offset + 36 - buffer > metadata_size)
RETURN_ERROR(AVERROR_INVALIDDATA);
start = bytestream_get_be64(&offset);
track = bytestream_get_byte(&offset);
bytestream_get_buffer(&offset, isrc, 12);
isrc[12] = 0;
offset += 14;
ti = bytestream_get_byte(&offset);
if (ti <= 0) RETURN_ERROR(AVERROR_INVALIDDATA);
offset += ti * 12;
avpriv_new_chapter(s, track, st->time_base, start, AV_NOPTS_VALUE, isrc);
}
av_freep(&buffer);
} else if (metadata_type == FLAC_METADATA_TYPE_PICTURE) {
ret = ff_flac_parse_picture(s, buffer, metadata_size);
av_freep(&buffer);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Error parsing attached picture.\n");
return ret;
}
} else if (metadata_type == FLAC_METADATA_TYPE_SEEKTABLE) {
const uint8_t *seekpoint = buffer;
int i, seek_point_count = metadata_size/SEEKPOINT_SIZE;
flac->found_seektable = 1;
if ((s->flags&AVFMT_FLAG_FAST_SEEK)) {
for(i=0; i<seek_point_count; i++) {
int64_t timestamp = bytestream_get_be64(&seekpoint);
int64_t pos = bytestream_get_be64(&seekpoint);
bytestream_get_be16(&seekpoint);
av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);
}
}
av_freep(&buffer);
}
else {
if (!found_streaminfo) {
RETURN_ERROR(AVERROR_INVALIDDATA);
}
if (metadata_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
AVDictionaryEntry *chmask;
ret = ff_vorbis_comment(s, &s->metadata, buffer, metadata_size, 1);
if (ret < 0) {
av_log(s, AV_LOG_WARNING, "error parsing VorbisComment metadata\n");
} else if (ret > 0) {
s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
}
chmask = av_dict_get(s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
if (chmask) {
uint64_t mask = strtol(chmask->value, NULL, 0);
if (!mask || mask & ~0x3ffffULL) {
av_log(s, AV_LOG_WARNING,
"Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n");
} else {
st->codecpar->channel_layout = mask;
av_dict_set(&s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
}
}
}
av_freep(&buffer);
}
}
ret = ff_replaygain_export(st, s->metadata);
if (ret < 0)
return ret;
reset_index_position(avio_tell(s->pb), st);
return 0;
fail:
av_free(buffer);
return ret;
}
| 1threat |
int do_subchannel_work_virtual(SubchDev *sch)
{
SCSW *s = &sch->curr_status.scsw;
if (s->ctrl & SCSW_FCTL_CLEAR_FUNC) {
sch_handle_clear_func(sch);
} else if (s->ctrl & SCSW_FCTL_HALT_FUNC) {
sch_handle_halt_func(sch);
} else if (s->ctrl & SCSW_FCTL_START_FUNC) {
sch_handle_start_func_virtual(sch);
}
css_inject_io_interrupt(sch);
return 0;
}
| 1threat |
Two sql query statements ,only choose one : There are two query statements,if query 1 has result ,then just return the result,if query 1 don't ,then execute query 2.These two querys' from the same table ,but query conditions can't co-exist.How can I realize? | 0debug |
Order function by increasing growth rate? : <p><strong>What is the order of the functions by increasing growth rate:</strong></p>
<p>1^(nlogn), n^logn, 2^5, sqrt(logn), 2^(n!), 1/n, n^2, 2^logn, n!, 100^n</p>
<p><strong>Here's my attempt:</strong></p>
<p>1^(nlogn)</p>
<p>2^5</p>
<p>1/n</p>
<p>sqrt(logn)</p>
<p>n^2</p>
<p>n^logn</p>
<p>2^logn</p>
<p>100^n</p>
<p>n!</p>
<p>2^(n!)</p>
| 0debug |
vcard_emul_replay_insertion_events(void)
{
VReaderListEntry *current_entry;
VReaderListEntry *next_entry = NULL;
VReaderList *list = vreader_get_reader_list();
for (current_entry = vreader_list_get_first(list); current_entry;
current_entry = next_entry) {
VReader *vreader = vreader_list_get_reader(current_entry);
next_entry = vreader_list_get_next(current_entry);
vreader_queue_card_event(vreader);
}
} | 1threat |
static int decode_end(AVCodecContext *avctx)
{
H264Context *h = avctx->priv_data;
MpegEncContext *s = &h->s;
free_tables(h);
MPV_common_end(s);
return 0;
} | 1threat |
How to access global variable from a function when the name is same as argument name in JavaScript? : <p>How to access global variable from a function when the name is same as argument name in JavaScript ?</p>
<pre><code>var name = null;
function func(name) {
// How to set the global variable with the passed value
}
</code></pre>
| 0debug |
File upload, change name : <p>I have a file upload script which works fine, however it currently saves the document under the original file name, I want to rename this on upload, ideally adding an ID number before it (from GET variable, below)</p>
<pre><code>$employee=$_GET["id"];
</code></pre>
<p>The file upload script, where the name comes from is below:</p>
<pre><code>$file_name = $key.$_FILES['files']['name'][$key];
</code></pre>
<p>How can I add the ID number before the name upon saving?</p>
| 0debug |
static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
int n, int coded, int intra, int rvlc)
{
int level, i, last, run;
int dc_pred_dir;
RLTable * rl;
RL_VLC_ELEM * rl_vlc;
const uint8_t * scan_table;
int qmul, qadd;
if(intra) {
if(s->use_intra_dc_vlc){
if(s->partitioned_frame){
level = s->dc_val[0][ s->block_index[n] ];
if(n<4) level= FASTDIV((level + (s->y_dc_scale>>1)), s->y_dc_scale);
else level= FASTDIV((level + (s->c_dc_scale>>1)), s->c_dc_scale);
dc_pred_dir= (s->pred_dir_table[s->mb_x + s->mb_y*s->mb_stride]<<n)&32;
}else{
level = mpeg4_decode_dc(s, n, &dc_pred_dir);
if (level < 0)
return -1;
}
block[0] = level;
i = 0;
}else{
i = -1;
ff_mpeg4_pred_dc(s, n, 0, &dc_pred_dir, 0);
}
if (!coded)
goto not_coded;
if(rvlc){
rl = &rvlc_rl_intra;
rl_vlc = rvlc_rl_intra.rl_vlc[0];
}else{
rl = &rl_intra;
rl_vlc = rl_intra.rl_vlc[0];
}
if (s->ac_pred) {
if (dc_pred_dir == 0)
scan_table = s->intra_v_scantable.permutated;
else
scan_table = s->intra_h_scantable.permutated;
} else {
scan_table = s->intra_scantable.permutated;
}
qmul=1;
qadd=0;
} else {
i = -1;
if (!coded) {
s->block_last_index[n] = i;
return 0;
}
if(rvlc) rl = &rvlc_rl_inter;
else rl = &rl_inter;
scan_table = s->intra_scantable.permutated;
if(s->mpeg_quant){
qmul=1;
qadd=0;
if(rvlc){
rl_vlc = rvlc_rl_inter.rl_vlc[0];
}else{
rl_vlc = rl_inter.rl_vlc[0];
}
}else{
qmul = s->qscale << 1;
qadd = (s->qscale - 1) | 1;
if(rvlc){
rl_vlc = rvlc_rl_inter.rl_vlc[s->qscale];
}else{
rl_vlc = rl_inter.rl_vlc[s->qscale];
}
}
}
{
OPEN_READER(re, &s->gb);
for(;;) {
UPDATE_CACHE(re, &s->gb);
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
if (level==0) {
if(rvlc){
if(SHOW_UBITS(re, &s->gb, 1)==0){
av_log(s->avctx, AV_LOG_ERROR, "1. marker bit missing in rvlc esc\n");
return -1;
}; SKIP_CACHE(re, &s->gb, 1);
last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
run= SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
SKIP_COUNTER(re, &s->gb, 1+1+6);
UPDATE_CACHE(re, &s->gb);
if(SHOW_UBITS(re, &s->gb, 1)==0){
av_log(s->avctx, AV_LOG_ERROR, "2. marker bit missing in rvlc esc\n");
return -1;
}; SKIP_CACHE(re, &s->gb, 1);
level= SHOW_UBITS(re, &s->gb, 11); SKIP_CACHE(re, &s->gb, 11);
if(SHOW_UBITS(re, &s->gb, 5)!=0x10){
av_log(s->avctx, AV_LOG_ERROR, "reverse esc missing\n");
return -1;
}; SKIP_CACHE(re, &s->gb, 5);
level= level * qmul + qadd;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_CACHE(re, &s->gb, 1);
SKIP_COUNTER(re, &s->gb, 1+11+5+1);
i+= run + 1;
if(last) i+=192;
}else{
int cache;
cache= GET_CACHE(re, &s->gb);
if(IS_3IV1)
cache ^= 0xC0000000;
if (cache&0x80000000) {
if (cache&0x40000000) {
SKIP_CACHE(re, &s->gb, 2);
last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
run= SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
SKIP_COUNTER(re, &s->gb, 2+1+6);
UPDATE_CACHE(re, &s->gb);
if(IS_3IV1){
level= SHOW_SBITS(re, &s->gb, 12); LAST_SKIP_BITS(re, &s->gb, 12);
}else{
if(SHOW_UBITS(re, &s->gb, 1)==0){
av_log(s->avctx, AV_LOG_ERROR, "1. marker bit missing in 3. esc\n");
return -1;
}; SKIP_CACHE(re, &s->gb, 1);
level= SHOW_SBITS(re, &s->gb, 12); SKIP_CACHE(re, &s->gb, 12);
if(SHOW_UBITS(re, &s->gb, 1)==0){
av_log(s->avctx, AV_LOG_ERROR, "2. marker bit missing in 3. esc\n");
return -1;
}; LAST_SKIP_CACHE(re, &s->gb, 1);
SKIP_COUNTER(re, &s->gb, 1+12+1);
}
#if 0
if(s->error_resilience >= FF_ER_COMPLIANT){
const int abs_level= FFABS(level);
if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
const int run1= run - rl->max_run[last][abs_level] - 1;
if(abs_level <= rl->max_level[last][run]){
av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, vlc encoding possible\n");
return -1;
}
if(s->error_resilience > FF_ER_COMPLIANT){
if(abs_level <= rl->max_level[last][run]*2){
av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 1 encoding possible\n");
return -1;
}
if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){
av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 2 encoding possible\n");
return -1;
}
}
}
}
#endif
if (level>0) level= level * qmul + qadd;
else level= level * qmul - qadd;
if((unsigned)(level + 2048) > 4095){
if(s->error_resilience > FF_ER_COMPLIANT){
if(level > 2560 || level<-2560){
av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
return -1;
}
}
level= level<0 ? -2048 : 2047;
}
i+= run + 1;
if(last) i+=192;
} else {
#if MIN_CACHE_BITS < 20
LAST_SKIP_BITS(re, &s->gb, 2);
UPDATE_CACHE(re, &s->gb);
#else
SKIP_BITS(re, &s->gb, 2);
#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
i+= run + rl->max_run[run>>7][level/qmul] +1;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
} else {
#if MIN_CACHE_BITS < 19
LAST_SKIP_BITS(re, &s->gb, 1);
UPDATE_CACHE(re, &s->gb);
#else
SKIP_BITS(re, &s->gb, 1);
#endif
GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
i+= run;
level = level + rl->max_level[run>>7][(run-1)&63] * qmul;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
}
} else {
i+= run;
level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
LAST_SKIP_BITS(re, &s->gb, 1);
}
if (i > 62){
i-= 192;
if(i&(~63)){
av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
block[scan_table[i]] = level;
break;
}
block[scan_table[i]] = level;
}
CLOSE_READER(re, &s->gb);
}
not_coded:
if (intra) {
if(!s->use_intra_dc_vlc){
block[0] = ff_mpeg4_pred_dc(s, n, block[0], &dc_pred_dir, 0);
i -= i>>31;
}
mpeg4_pred_ac(s, block, n, dc_pred_dir);
if (s->ac_pred) {
i = 63;
}
}
s->block_last_index[n] = i;
return 0;
}
| 1threat |
def Diff(li1,li2):
return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))
| 0debug |
Style: Ending code blocks with `pass` vs `return`/`continue` vs nothing : <p>The <code>pass</code> statement in python does nothing except fill space. However, I've found it useful for designating the end of a long, complicated block of code, before the program continues:</p>
<pre><code>...
if condition is True:
...
pass
...
</code></pre>
<p>essentially, the same effect as putting the <code>}</code> on its own line would have, in a language like C or Java.</p>
<p>Similarly, I've developed the habit of replacing <code>pass</code> with <code>continue</code> at the end of loops, or <code>return</code> at the end of functions that wouldn't otherwise return anything, for the same reason - and to make it more clear which block of code is ending:</p>
<pre><code>def someFunc():
...
while someCondition is True:
# complicated things
...
continue
...
return
</code></pre>
<p>When code is spaced either very narrowly or very widely, or when the code takes up a lot of vertical space, I think that putting these statements at the end of a code block makes the control flow clearer. I've done some searching, and haven't found a good source that said whether this is good or bad style (making good search keywords for this subject is annoyingly difficult). Moreover, PEP8 says nothing on the matter. I was hoping to get opinions on the subject and find what the general consensus is, if there is one.</p>
| 0debug |
Using lists in foreach R : <p>I am trying to parallelize the extraction of data saved in some html documents and to store it into data.frames (some millions of documents, hence the usefulness of the parallelization).</p>
<p>In a first step, on the machine where I do register the queue, I select a subset of the html files and lapply to them the read_html function (from the rvest package, I have also tried the similar function from the XML package but I was getting memory leak problems) to obtain a unique list storing the content of many html pages.</p>
<p>Then I use an iterator on this list to obtain smaller chunks of it to be feeded to the foreach.</p>
<p>Inside the foreach I build up the data.frame(s) (using html_table function and some basic data manipulation) and I return a list whose elements are the cleaned data.frames.</p>
<p>I have tried to use both the doSNOW backend on win 8 and the doRedis one on ubuntu 16.04.</p>
<p>In the first case a list of empty lists is returned while in the second one an error of memory mapping is thrown; you can find the traceback at the very bottom of the question.</p>
<p>To my understanding the (chunks of) lists that I am sending to the cores are not behaving as I expect. I have gathered around that the list object may be just a set of pointers but I have not been able to confirm it; maybe this could be the issue?
Is there an alternative to the "list way" to "encapsulate" the data of multiple html pages? </p>
<p>Below you can find some code reproducing the issue.
I am a completely new to stack overflow, new to parallel programming and fairly new to R programming: any advice for improvement is welcome.
Thank you all in advance.</p>
<pre><code>library(rvest)
library(foreach)
#wikipedia pages of olympic medalist between 1992 and 2016 are
# downloaded for reproducibility
for(i in seq(1992, 2016, by=4)){
html = paste("https://en.wikipedia.org/wiki/List_of_", i, "_Summer_Olympics_medal_winners", sep="")
con = url(html)
htmlCode = readLines(con)
writeLines(htmlCode, con=paste(i, "medalists", sep="_"))
close(con)
}
#declaring the redis backend (doSNOW code is also included below)
#note that I am using the package from
#devtools::install_github("bwlewis/doRedis") due to a "nodelay error"
#(more info on that here: https://github.com/bwlewis/doRedis/issues/24)
# if it is not your case please drop the nodelay and timeout options
#Registering cores ---Ubuntu---
cores=2
library('doRedis')
options('redis:num'=TRUE)
registerDoRedis("jobs", nodelay=FALSE)
startLocalWorkers(n=cores, "jobs", timeout=2, nodelay=FALSE)
foreachOpt <- list(preschedule=FALSE)
#Registering cores ---Win---
#cores=2
#library("doSNOW")
#registerDoSNOW(makeCluster(cores, type = "SOCK"))
#defining the iterator
iterator <- function(x, ...) {
i <- 1
it <- idiv(length(x), ...)
if(exists("chunks")){
nextEl <- function() {
n <- nextElem(it)
ix <- seq(i, length=n)
i <<- i + n
x[ix]
}
}else{
nextEl <- function() {
n <- nextElem(it)
ix <- seq(i, i+n-1)
i <<- i + n
x[ix]
}
}
obj <- list(nextElem=nextEl)
class(obj) <- c(
'ivector', 'abstractiter','iter')
obj
}
#reading files
names_files<-list.files()
html_list<-lapply(names_files, read_html)
#creating iterator
ChunkSize_html_list<-2
iter<-iterator(html_list, chunkSize=ChunkSize_html_list)
#defining expanding list (thanks StackOverflow and many thanks to
#JanKanis's answer : http://stackoverflow.com/questions/2436688/append-an-object-to-a-list-in-r-in-amortized-constant-time-o1 )
expanding_list <- function(capacity = 10) {
buffer <- vector('list', capacity)
length <- 0
methods <- list()
methods$double.size <- function() {
buffer <<- c(buffer, vector('list', capacity))
capacity <<- capacity * 2
}
methods$add <- function(val) {
if(length == capacity) {
methods$double.size()
}
length <<- length + 1
buffer[[length]] <<- val
}
methods$as.list <- function() {
b <- buffer[0:length]
return(b)
}
methods
}
#parallelized part
clean_data<-foreach(ite=iter, .packages=c("itertools", "rvest"), .combine=c,
.options.multicore=foreachOpt, .options.redis=list(chunkSize=1)) %dopar% {
temp_tot <- expanding_list()
for(g in 1:length(ite)){
#extraction of data from tables
tables <- html_table(ite[[g]], fill=T, header = T)
for(i in 1:length(tables)){
#just some basic data manipulation
temp<-lapply(tables, function(d){d[nrow(d),]})
temp_tot$add(temp)
rm(temp)
gc(verbose = F)
}
}
#returning the list of cleaned data.frames to the foreach
temp_tot$as.list()
}
</code></pre>
<p>Error thrown when using the redis backend:</p>
<pre><code>*** caught segfault ***
address 0x60, cause 'memory not mapped'
Traceback:
1: .Call("xml2_doc_namespaces", PACKAGE = "xml2", doc)
2: doc_namespaces(doc)
3: xml_ns.xml_document(x)
4: xml_ns(x)
5: xpath_search(x$node, x$doc, xpath = xpath, nsMap = ns, num_results = Inf)
6: xml_find_all.xml_node(x, ".//table")
7: xml2::xml_find_all(x, ".//table")
8: html_table.xml_document(ite[[g]], fill = T, header = T)
9: html_table(ite[[g]], fill = T, header = T)
10: eval(expr, envir, enclos)
11: eval(.doRedisGlobals$expr, envir = .doRedisGlobals$exportenv)
12: doTryCatch(return(expr), name, parentenv, handler)
13: tryCatchOne(expr, names, parentenv, handlers[[1L]])
14: tryCatchList(expr, classes, parentenv, handlers)
15: tryCatch({ lapply(names(args), function(n) assign(n, args[[n]], pos = .doRedisGlobals$exportenv)) if (exists(".Random.seed", envir = .doRedisGlobals$exportenv)) { assign(".Random.seed", .doRedisGlobals$exportenv$.Random.seed, envir = globalenv()) } tryCatch({ if (exists("set.seed.worker", envir = .doRedisGlobals$exportenv)) do.call("set.seed.worker", list(0), envir = .doRedisGlobals$exportenv) }, error = function(e) cat(as.character(e), "\n")) eval(.doRedisGlobals$expr, envir = .doRedisGlobals$exportenv)}, error = function(e) e)
16: FUN(X[[i]], ...)
17: lapply(work[[1]]$argsList, .evalWrapper)
18: redisWorker(queue = "jobs", host = "localhost", port = 6379, iter = Inf, linger = 30, log = stdout(), timeout = 2, nodelay = FALSE)
aborting ...
</code></pre>
| 0debug |
static void qvirtio_pci_set_queue_address(QVirtioDevice *d, uint32_t pfn)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
qpci_io_writel(dev->pdev, dev->addr + VIRTIO_PCI_QUEUE_PFN, pfn);
}
| 1threat |
How to remove duplicate categories from dataframe : I am trying to calculate the total number of companies associated with each active investor.
'df' represents my original dataframe, in which the 'active_investors' column displays a list of active investors for each company listed. For example, one row might contain Company A, listing investors 1,2,3,4.
What I am trying to do is split the dataframe such that it displays company A as four separate rows i.e. for each investor 1, 2, 3 and 4.
So far, I have the following code:
```
#Separate names of investors for each company
df1 = df %>% separate_rows(active_investors, sep = ",")
#Total number of companies each investor has invested in
investor = aggregate(data.frame(count = df1$company_name), list(active_investors = df1$active_investors), length)
```
The problem is that some investors are listed twice i.e. the same investor name, but are listed as two separate investors. I am unsure how to compile the frequencies (i.e. total companies the investor has invested in) such that these duplicates are removed. | 0debug |
React Native rounded image with a border : <p>I want to create a rounded image with a border. If I add <code>borderColor: 'green', borderWidth:1</code>, border is visible only in top left part of the rounded image.</p>
<p><a href="https://i.stack.imgur.com/4wq5R.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4wq5R.png" alt="enter image description here"></a></p>
<pre><code><TouchableHighlight
style={[styles.profileImgContainer, { borderColor: 'green', borderWidth:1 }]}
>
<Image source={{ uri:"https://www.t-nation.com/system/publishing/articles/10005529/original/6-Reasons-You-Should-Never-Open-a-Gym.png" }} style={styles.profileImg} />
</TouchableHighlight>
export default styles = StyleSheet.create({
profileImgContainer: {
marginLeft: 8,
height: 80,
width: 80,
borderRadius: 40,
},
profileImg: {
height: 80,
width: 80,
borderRadius: 40,
},
});
</code></pre>
| 0debug |
Elipsis after two lines : <p>I want elipsis after two lines i have got one solution but it's not working in IE browser.</p>
<p>I want like this: </p>
<p>Amazon Childproofs Echo Speakers,
Adds Age-Appropriate Audio Content...</p>
| 0debug |
Weird question, but how do I make a python script to check if python is installed? : <p>Before you get confused, I am going to compile it with the auto-py-to-exe module after, its just the source code is in python. How do I do this?</p>
| 0debug |
Is there any super interface of all interfaces in Java? : <p>As we have Object class as super class of all the classes. So do we also have super Interface of all the interfaces?</p>
| 0debug |
Warning: definition of implicit copy constructor is deprecated : <p>I have a warning in my C++11 code that I would like to fix correctly but I don't really know how. I have created my own exception class that is derived from <code>std::runtime_error</code>:</p>
<pre><code>class MyError : public std::runtime_error
{
public:
MyError(const std::string& str, const std::string& message)
: std::runtime_error(message),
str_(str)
{ }
virtual ~MyError()
{ }
std::string getStr() const
{
return str_;
}
private:
std::string str_;
};
</code></pre>
<p>When I compile that code with clang-cl using <code>/Wall</code> I get the following warning:</p>
<pre><code>warning: definition of implicit copy constructor for 'MyError' is deprecated
because it has a user-declared destructor [-Wdeprecated]
</code></pre>
<p>So because I have defined a destructor in <code>MyError</code> no copy constructor will be generated for <code>MyError</code>. I don't fully understand if this will cause any issues...</p>
<p>Now I could get rid of that warning by simply removing the virtual destructor but I always thought that derived classes should have virtual destructors if the base class (in this case <code>std::runtime_error</code>) has a virtual destructor.</p>
<p>Hence I guess it is better not to remove the virtual destructor but to define the copy constructor. But if I need to define the copy constructor maybe I should also define the copy assignment operator and the move constructor and the move assignment operator. But this seems overkill for my simple exception class!?</p>
<p>Any ideas how to best fix this issue?</p>
| 0debug |
How create a regex for simpleDateFormat : <p>How to create a regex for simpledateformat with this pattern <code>yyyyMMdd_HHmmss</code> should I check only digits, can anyone write a valid regex for it, or is there a web site somewhere that generates a regex for this pattern, I need to check if a string contains a date, but sometimes the time is different, so I decided that it is good idea to checks if string contains a regex.</p>
| 0debug |
static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
{
int tag = track->enc->codec_tag;
if (track->mode == MODE_MP4 || track->mode == MODE_PSP) {
if (!codec_get_tag(ff_mp4_obj_type, track->enc->codec_id))
return 0;
if (track->enc->codec_id == CODEC_ID_H264) tag = MKTAG('a','v','c','1');
else if (track->enc->codec_id == CODEC_ID_AC3) tag = MKTAG('a','c','-','3');
else if (track->enc->codec_id == CODEC_ID_DIRAC) tag = MKTAG('d','r','a','c');
else if (track->enc->codec_id == CODEC_ID_MOV_TEXT) tag = MKTAG('t','x','3','g');
else if (track->enc->codec_type == CODEC_TYPE_VIDEO) tag = MKTAG('m','p','4','v');
else if (track->enc->codec_type == CODEC_TYPE_AUDIO) tag = MKTAG('m','p','4','a');
} else if (track->mode == MODE_IPOD) {
if (track->enc->codec_type == CODEC_TYPE_SUBTITLE &&
(tag == MKTAG('t','x','3','g') ||
tag == MKTAG('t','e','x','t')))
track->tag = tag;
else
tag = codec_get_tag(codec_ipod_tags, track->enc->codec_id);
if (!match_ext(s->filename, "m4a") && !match_ext(s->filename, "m4v"))
av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v "
"Quicktime/Ipod might not play the file\n");
} else if (track->mode & MODE_3GP) {
tag = codec_get_tag(codec_3gp_tags, track->enc->codec_id);
} else if (!tag || (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&
(tag == MKTAG('d','v','c','p') ||
track->enc->codec_id == CODEC_ID_RAWVIDEO))) {
if (track->enc->codec_id == CODEC_ID_DVVIDEO) {
if (track->enc->height == 480)
if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','n');
else tag = MKTAG('d','v','c',' ');
else if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p');
else if (track->enc->pix_fmt == PIX_FMT_YUV420P) tag = MKTAG('d','v','c','p');
else tag = MKTAG('d','v','p','p');
} else if (track->enc->codec_id == CODEC_ID_RAWVIDEO) {
tag = codec_get_tag(mov_pix_fmt_tags, track->enc->pix_fmt);
if (!tag)
tag = track->enc->codec_tag;
} else {
if (track->enc->codec_type == CODEC_TYPE_VIDEO) {
tag = codec_get_tag(codec_movvideo_tags, track->enc->codec_id);
if (!tag) {
tag = codec_get_tag(codec_bmp_tags, track->enc->codec_id);
if (tag)
av_log(s, AV_LOG_INFO, "Warning, using MS style video codec tag, "
"the file may be unplayable!\n");
}
} else if (track->enc->codec_type == CODEC_TYPE_AUDIO) {
tag = codec_get_tag(codec_movaudio_tags, track->enc->codec_id);
if (!tag) {
int ms_tag = codec_get_tag(codec_wav_tags, track->enc->codec_id);
if (ms_tag) {
tag = MKTAG('m', 's', ((ms_tag >> 8) & 0xff), (ms_tag & 0xff));
av_log(s, AV_LOG_INFO, "Warning, using MS style audio codec tag, "
"the file may be unplayable!\n");
}
}
} else if (track->enc->codec_type == CODEC_TYPE_SUBTITLE) {
tag = codec_get_tag(ff_codec_movsubtitle_tags, track->enc->codec_id);
}
}
}
return tag;
}
| 1threat |
static int virtio_ccw_hcall_notify(const uint64_t *args)
{
uint64_t subch_id = args[0];
uint64_t queue = args[1];
SubchDev *sch;
int cssid, ssid, schid, m;
if (ioinst_disassemble_sch_ident(subch_id, &m, &cssid, &ssid, &schid)) {
sch = css_find_subch(m, cssid, ssid, schid);
if (!sch || !css_subch_visible(sch)) {
virtio_queue_notify(virtio_ccw_get_vdev(sch), queue);
return 0;
| 1threat |
static TraceEvent* find_trace_event_by_name(const char *tname)
{
unsigned int i;
if (!tname) {
return NULL;
}
for (i = 0; i < NR_TRACE_EVENTS; i++) {
if (!strcmp(trace_list[i].tp_name, tname)) {
return &trace_list[i];
}
}
return NULL;
}
| 1threat |
What is a cluster in MongoDB? : <p>I am someone new to mongoDB and has absolutely no knowledge regarding databases so would like to know what is a cluster in MongoDB and what is the point of connecting to one in MongoDB? Is it a must to connect to one or can we just connect to the localhost?</p>
| 0debug |
I want to add css styling to a button by adding two different flat colors to that button : <p>I want to add css styling to a button by adding two different flat colors to that button. left half of the button must be in blue and right half of the button have to be red. </p>
| 0debug |
how to search with no of occurences in factor in R? : Find the date on which three movies had launched on the same day and store it in the variable date_three
releasedate<-count(bollywood$Rdate)
> releasedate
x freq
1 01-05-2015 1
2 02-10-2015 2
3 03-07-2015 1
4 04-09-2015 1
5 04-12-2015 1
6 05-06-2015 1
7 06-02-2015 1
8 06-03-2015 1
9 07-08-2015 1
10 08-05-2015 2
11 09-01-2015 1
12 09-10-2015 1
13 10-04-2015 1
14 11-09-2015 1
15 12-06-2015 1
16 12-11-2015 1
17 13-02-2015 1
18 13-03-2015 1
19 14-08-2015 1
20 15-05-2015 1
21 16-01-2015 1
22 16-10-2015 1
23 17-04-2015 1
24 17-07-2015 1
25 18-09-2015 1
26 18-12-2015 2
27 19-06-2015 1
28 20-02-2015 1
29 20-03-2015 1
30 21-08-2015 2
31 22-05-2015 1
32 22-10-2015 1
33 23-01-2015 2
34 25-09-2015 2
35 26-06-2015 1
36 27-02-2015 2
37 27-11-2015 1
38 28-05-2015 1
39 28-08-2015 1
40 30-01-2015 2
41 30-10-2015 3
42 31-07-2015 1
>subset(releasedate$x,releasedate$freq==3)
>[1] 30-10-2015
42 Levels: 01-05-2015 02-10-2015 03-07-2015 04-09-2015 04-12-2015 ... 31-07-2015
Is there any other way I can search elements in vector by their no of occurence ? | 0debug |
How to prevent material icon text from showing up when Google's JS fails to convert them? : <p>How do you prevent material icon text from showing up when Google's JS fails to convert them to icons?</p>
<p>Icons are defined in markup as such:</p>
<pre><code><span class="material-icons">icon_name</span>
</code></pre>
<p>Example: <a href="https://archive.fo/CKqKG/scr.png" rel="noreferrer">https://archive.fo/CKqKG/scr.png</a> (see the top row of buttons).</p>
<p>Material Icons Documentation: <a href="https://material.io/icons/" rel="noreferrer">https://material.io/icons/</a></p>
<p>This is also an issue in Google search where Google will actually read and save the div's text instead of ignoring it.</p>
<p>Example: <a href="https://i.imgur.com/TixS06y.png" rel="noreferrer">https://i.imgur.com/TixS06y.png</a></p>
<p>I understand that one solution is to simply switch to .PNGs (supplied by Google). I'd like to do whatever results in less (network) load on the user's system.</p>
<p>Thanks!</p>
| 0debug |
Querying XML Datastores with XPath-5 : <p>Assume that you have been provided the fragment of XML, shown below. Your task is to write the XPath selector for picking up the shelf of the movie named 'Transformers'. </p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><collection shelf="Classics">
<movie title="The Enemy" shelf="A">
<type>War, Thriller</type>
<format>DVD</format>
<year>2001</year>
<rating>PG</rating>
<popularity>10</popularity>
<description>Talk about a war</description>
</movie>
<movie title="Transformers" shelf="B">
<type>Science Fiction</type>
<format>DVD</format>
<year>1980</year>
<rating>R</rating>
<popularity>7</popularity>
<description>Science Fiction</description>
</movie>
<movie title="Trigun" shelf="B">
<type>Action</type>
<format>DVD</format>
<episodes>4</episodes>
<rating>PG</rating>
<popularity>10</popularity>
<description>Quite a bit of action!</description>
</movie>
<movie title="Ishtar" shelf="A">
<type>Comedy</type>
<format>VHS</format>
<rating>PG</rating>
<popularity>2</popularity>
<description>Boring</description>
</movie>
</collection></code></pre>
</div>
</div>
</p>
| 0debug |
How to make number ranging from 5 to -5 instead range from 5 to 10? : <p>No specific language, just need to know if there are any techniques to doing it!
Number in question is the result of a sine wave, which will vary from 5 to -5.</p>
| 0debug |
static int mp_pacl_setxattr(FsContext *ctx, const char *path, const char *name,
void *value, size_t size, int flags)
{
char *buffer;
int ret;
buffer = rpath(ctx, path);
ret = lsetxattr(buffer, MAP_ACL_ACCESS, value, size, flags);
g_free(buffer);
return ret;
}
| 1threat |
do_gen_eob_worker(DisasContext *s, bool inhibit, bool recheck_tf, TCGv jr)
{
gen_update_cc_op(s);
if (inhibit && !(s->flags & HF_INHIBIT_IRQ_MASK)) {
gen_set_hflag(s, HF_INHIBIT_IRQ_MASK);
} else {
gen_reset_hflag(s, HF_INHIBIT_IRQ_MASK);
}
if (s->tb->flags & HF_RF_MASK) {
gen_helper_reset_rf(cpu_env);
}
if (s->singlestep_enabled) {
gen_helper_debug(cpu_env);
} else if (recheck_tf) {
gen_helper_rechecking_single_step(cpu_env);
tcg_gen_exit_tb(0);
} else if (s->tf) {
gen_helper_single_step(cpu_env);
} else if (!TCGV_IS_UNUSED(jr)) {
TCGv vaddr = tcg_temp_new();
tcg_gen_add_tl(vaddr, jr, cpu_seg_base[R_CS]);
tcg_gen_lookup_and_goto_ptr(vaddr);
tcg_temp_free(vaddr);
} else {
tcg_gen_exit_tb(0);
}
s->is_jmp = DISAS_TB_JUMP;
}
| 1threat |
Connecting to database in perl? : I am beginner at perl programming. And I am trying to connect to mysql database. I found this script in other website and i am trying to use it in my pc and hosting. but it dosn't show any output. Please have a look at this code.I am running perl at xampp.
#!C:\xampp\perl\bin\perl.exe
print "Content-type: text/html\n\n";
use DBI;
use strict;
my $driver = "localhost";
my $database = "data";
my $dsn = "DBI:$driver:database = $database";
my $userid = "root";
my $password = "";
my $dbh = DBI->connect($dsn, $userid, $password ) or die $DBI::errstr;
I am using same database with php.
| 0debug |
static void host_signal_handler(int host_signum, siginfo_t *info,
void *puc)
{
int sig;
target_siginfo_t tinfo;
if ((host_signum == SIGSEGV || host_signum == SIGBUS)
&& info->si_code > 0) {
if (cpu_signal_handler(host_signum, info, puc))
return;
}
sig = host_to_target_signal(host_signum);
if (sig < 1 || sig > TARGET_NSIG)
return;
#if defined(DEBUG_SIGNAL)
fprintf(stderr, "qemu: got signal %d\n", sig);
#endif
host_to_target_siginfo_noswap(&tinfo, info);
if (queue_signal(thread_env, sig, &tinfo) == 1) {
cpu_interrupt(thread_env, CPU_INTERRUPT_EXIT);
}
}
| 1threat |
How I can make my mandelbrot plotter faster?? (Python) : ## Python code ##
How I can make my programm faster?
This programm calculates you the mandelbrotset and draws it with turtle.
I think the problem is in the for loop. Maybe the steps are taking too taking too much time.
----------
import numpy as np
import turtle
turtle.ht()
turtle.pu()
turtle.speed(0)
turtle.delay(0) turtle.colormode(255)
i= int(input("iteration = "))
g = int(input("accuracy = "))
xmin = float(input("X-min: "))
xmax = float(input("X-max: "))
ymin = float(input("Y-min: "))
ymax = float(input("Y-max: "))
cmode = int(255/i)
input("PRESS TO START")
for x in np.arange(xmin,xmax,1/g):
for y in np.arange(ymin,ymax,1/g):
c = x + y * 1j
z = 0
t = 1
for e in range(i):
z = z * z + c
if abs(z) > 3:
turtle.setx(g*c.real)
turtle.sety(g*c.imag)
turtle.dot(2,e*cmode,e*cmode,e*cmode)
t = 0
if t == 1:
turtle.setx(g*c.real)
turtle.sety(g*c.imag)
turtle.dot(2,"black")
input("Calculated!")
turtle.mainloop()
[Here is an example][1]
[1]: https://i.stack.imgur.com/gacT8.png | 0debug |
dont know how to use awk to print every word from a whole string : i declared variable (string) containing k names of queues i want to delete.
how can i "loop" through the string and delete each queue?
I'm having trouble with the awk command.
thanks a lot! | 0debug |
static void mips_qemu_write (void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned size)
{
if ((addr & 0xffff) == 0 && val == 42)
qemu_system_reset_request ();
else if ((addr & 0xffff) == 4 && val == 42)
qemu_system_shutdown_request ();
}
| 1threat |
Bootstrap 4 remove caret from dropdown button : <p>In Bootstrap 3 you could easily remove the "caret" (small arrow that points down) from a dropdown button, I can't see how to do it in Bootstrap 4 though because they no longer use <code><span class="caret"></span></code>. </p>
<pre><code><div class="input-group mb-3">
<div class="input-group-prepend">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
<div role="separator" class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Separated link</a>
</div>
</div>
<input type="text" class="form-control" aria-label="Text input with dropdown button">
</div>
</code></pre>
| 0debug |
can not found ip address from other network (iis) : I'm attempting to create a server using IIS.
I created a site. Configured the firewall. It's available in the browser as localhost(http://localhost:8555/) and static IP(http://10.12.66.79:8555/) too
But from another network like my phone. I tried accessing using the static ip but it failed. then i tried using the virtual ip then it show me the login page of my service provider.
what I can do next ? | 0debug |
static int config_props(AVFilterLink *link)
{
YADIFContext *yadif = link->src->priv;
link->time_base.num = link->src->inputs[0]->time_base.num;
link->time_base.den = link->src->inputs[0]->time_base.den * 2;
link->w = link->src->inputs[0]->w;
link->h = link->src->inputs[0]->h;
if(yadif->mode&1)
link->frame_rate = av_mul_q(link->src->inputs[0]->frame_rate, (AVRational){2,1});
return 0;
}
| 1threat |
CSS not applied properly on custom components in Angular : <p>I have a custom component and I'm using a number of those in the markup of the parent. When I declare a style <strong>within</strong> the custom component, it performs as expected. However, when I set the style in the parent component selecting each of the custom one, the formatting takes place but doesn't target the custom component - instead it gets a hit outside of it and not in relation of it.</p>
<p>In the <a href="https://stackblitz.com/edit/angular-ui8zwm?file=src%2Fapp%2Fapp.component.html" rel="nofollow noreferrer">Blitzy example</a>, the border can be seen not <strong>around</strong> the hellows, but <strong>outside</strong> of them.</p>
<p>I don't understand why it happens, let alone how to resolve it.</p>
| 0debug |
NotReadableError: Could not start source : <p>I have added this piece of code in my project</p>
<pre><code>if (navigator.mediaDevices === undefined) {
navigator.mediaDevices = {};
}
if (navigator.mediaDevices.getUserMedia === undefined) {
navigator.mediaDevices.getUserMedia = function (constraints) {
var getUserMedia = (
navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia
);
if (!getUserMedia) {
return Promise.reject(new Error('getUserMedia is not implemented in this browser'));
}
return new Promise(function (resolve, reject) {
getUserMedia.call(navigator, constraints, resolve, reject);
});
};
}
</code></pre>
<p>Then I'm trying to access a video stream using <code>getUserMedia</code></p>
<pre><code>navigator.mediaDevices.getUserMedia({
video: true,
audio: false
}).then(stream => {
// do stuff
}).catch(error => {
console.log(error.name + " " + error.message);
});
</code></pre>
<p>When I test this in my emulators it works on android versions 5 and up, however when I run it on an actual device I get this error</p>
<blockquote>
<p>NotReadableError Could not start source</p>
</blockquote>
<p>I have added the <code>cordova-plugin-media-capture</code> plugin to make sure my app will request the appropriate permissions, however I don't want to use the plugin I'd rather use the <code>getUserMedia</code> API.</p>
<p>So far my researches show that the reason for this error is that some other app is already using the camera but that's not the case, I even went a step further and restarted the device, then opened my app, making sure there are no other running apps and I still got the error.</p>
<p>Has anyone had this issue?</p>
| 0debug |
TypeError: can't pickle _thread.lock objects : <p>Trying to run two different functions at the same time with shared queue and get an error...how can I run two functions at the same time with a shared queue? This is Python version 3.6 on Windows 7. </p>
<pre><code>from multiprocessing import Process
from queue import Queue
import logging
def main():
x = DataGenerator()
try:
x.run()
except Exception as e:
logging.exception("message")
class DataGenerator:
def __init__(self):
logging.basicConfig(filename='testing.log', level=logging.INFO)
def run(self):
logging.info("Running Generator")
queue = Queue()
Process(target=self.package, args=(queue,)).start()
logging.info("Process started to generate data")
Process(target=self.send, args=(queue,)).start()
logging.info("Process started to send data.")
def package(self, queue):
while True:
for i in range(16):
datagram = bytearray()
datagram.append(i)
queue.put(datagram)
def send(self, queue):
byte_array = bytearray()
while True:
size_of__queue = queue.qsize()
logging.info(" queue size %s", size_of_queue)
if size_of_queue > 7:
for i in range(1, 8):
packet = queue.get()
byte_array.append(packet)
logging.info("Sending datagram ")
print(str(datagram))
byte_array(0)
if __name__ == "__main__":
main()
</code></pre>
<p>The logs indicate an error, I tried running console as administrator and I get the same message...</p>
<pre><code>INFO:root:Running Generator
ERROR:root:message
Traceback (most recent call last):
File "test.py", line 8, in main
x.run()
File "test.py", line 20, in run
Process(target=self.package, args=(queue,)).start()
File "C:\ProgramData\Miniconda3\lib\multiprocessing\process.py", line 105, in start
self._popen = self._Popen(self)
File "C:\ProgramData\Miniconda3\lib\multiprocessing\context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\ProgramData\Miniconda3\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "C:\ProgramData\Miniconda3\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
reduction.dump(process_obj, to_child)
File "C:\ProgramData\Miniconda3\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
TypeError: can't pickle _thread.lock objects
</code></pre>
| 0debug |
"Quantize" Tensorflow Graph to float16 : <p>How do you convert a Tensorflow graph from using <code>float32</code> to <code>float16</code>? Currently there are graph optimizations for quantization and conversion to eight bit ints. </p>
<p>Trying to load <code>float32</code> weights into a <code>float16</code> graph fails with:</p>
<pre><code>DataLossError (see above for traceback): Invalid size in bundle entry: key model/conv5_1/biases; stored size 1536; expected size 768
[[Node: save/RestoreV2_16 = RestoreV2[dtypes=[DT_HALF], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/RestoreV2_16/tensor_names, save/RestoreV2_16/shape_and_slices)]]
[[Node: save/RestoreV2_3/_39 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_107_save/RestoreV2_3", tensor_type=DT_HALF, _device="/job:localhost/replica:0/task:0/gpu:0"]()]]
</code></pre>
| 0debug |
Simple 'Def and If' in exam that i could not figure out. : this question came out in my Python exam and i could not answer it.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
x = 7
y = 3
def a(x):
return b(x)
def b(y):
if y == 6:
return x - y
return a(x-1)
print(a(4))
<!-- end snippet -->
The answer is 1.
But i'm not sure how it is derived.
Hope someone can give me a clear explanation. Thanks in advance. | 0debug |
static int ehci_state_execute(EHCIQueue *q)
{
EHCIPacket *p = QTAILQ_FIRST(&q->packets);
int again = 0;
assert(p != NULL);
assert(p->qtdaddr == q->qtdaddr);
if (ehci_qh_do_overlay(q) != 0) {
return -1;
}
if (!q->async) {
int transactCtr = get_field(q->qh.epcap, QH_EPCAP_MULT);
if (!transactCtr) {
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
again = 1;
goto out;
}
}
if (q->async) {
ehci_set_usbsts(q->ehci, USBSTS_REC);
}
p->usb_status = ehci_execute(p, "process");
if (p->usb_status == USB_RET_PROCERR) {
again = -1;
goto out;
}
if (p->usb_status == USB_RET_ASYNC) {
ehci_flush_qh(q);
trace_usb_ehci_packet_action(p->queue, p, "async");
p->async = EHCI_ASYNC_INFLIGHT;
ehci_set_state(q->ehci, q->async, EST_HORIZONTALQH);
again = (ehci_fill_queue(p) == USB_RET_PROCERR) ? -1 : 1;
goto out;
}
ehci_set_state(q->ehci, q->async, EST_EXECUTING);
again = 1;
out:
return again;
}
| 1threat |
LocalDate and LocalDateTime depend on ZonedDateTime : <p>Why are the methods:<br><br>
<code>public ZonedDateTime atStartOfDay(ZoneId zone)</code> from class <strong>LocalDate</strong><br>
<br>and<br><br>
<code>public ZonedDateTime atZone(ZoneId zone)</code> from class <strong>LocalDateTime</strong><br>
<br>adding dependencies to <strong>ZonedDateTime</strong>?<br><br>
They look like "util" methods from <strong>ZonedDateTime</strong> and are in fact creating dependencies from classes (<strong>LocalDate</strong> and <strong>LocalDateTime</strong>) that shouldn't know anything about time zones.<br><br> Also, there are a lot more "util" methods that could be added to those classes to "help" with time zones.<br><br>
Is this the best approach in terms of architecture?</p>
| 0debug |
i get a segmentation fault (core dumped) error but only when half my code runs : the goal of this code is to manipulate an ASCII "image" that comes in the form of a really long string that i print out on different lines
.............
.............
.XXX.....X...
.XXX.....X...
.XXX.........
.XXX.........
.XXXXXXX.....
.XXXXXXX.....
.XXXXXXX.....
...........
it looks like this
` #include <iostream>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <vector>
#include <string>
#include <cassert>
int main (int argc, char* argv[]) {
std::fstream img(argv[1]);
std::vector<char> path;
char x;
while (img >> x) {
path.push_back(x);
}
for (char i = 0; i < path.size(); ++i){
if (i%13==0){
std::cout << path[i] << std::endl;
}
else{
std::cout << path[i];
}
}
std::string replace = "replace";
std::string dilation1 = "dilation";
std::string erosion1 = "erosion";
std::string floodfill1 = "floodfill";
char old_char = argv[4][0];
char new_char = argv[5][0];
if (argv[3] == replace) {
for (char n=0; n<path.size(); ++n){
if(path[n]==old_char){
path[n]=new_char;
}
}
for (char i = 0; i < path.size(); ++i){
if (i%13==0){
std::cout << path[i] << std::endl;
}
else{
std::cout << path[i];
}
}
}
if (argv[3] == dilation1) {
std::cout << "this is ok" << std::endl;
}
}`
here is my code
the replace part of the code is meant to take this as the input from the console
./image_processing.out input4.txt output4_replace.txt replace X O
and replace the X's with O's
and it works
but then i move onto the dilation function which takes this as input from the console
./image_processing.out input4.txt output4_dilation.txt dilation X
nevermind wat it does yet i havent even gotten that far because whenever i try to run the code with the second "if" statement i get this
.............
.............
.XXX.....X...
.XXX.....X...
.XXX.........
.XXX.........
.XXXXXXX.....
.XXXXXXX.....
.XXXXXXX.....
Segmentation fault (core dumped)
i dont know why it does this and i dont know why it only gets as far as the last line before it does that, when i comment out the second if statement the code runs fine however it only does replace | 0debug |
Angular 6 [WDS] Disconnected Error on Firefox : <p>I use Angular and i get console error only on Firefox "<strong>[WDS] Disconnected!</strong>".</p>
<p><strong><a href="https://i.stack.imgur.com/TBvrX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TBvrX.png" alt="Firefox console error message is here"></a></strong></p>
<p>Here is my Angular-Cli version.</p>
<pre><code>Angular CLI: 6.0.1
Node: 8.11.1
OS: win32 x64
Angular: 6.0.1
... cli, common, compiler, compiler-cli, core, forms, http
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.6.1
@angular-devkit/build-angular 0.6.1
@angular-devkit/build-optimizer 0.6.1
@angular-devkit/core 0.6.1
@angular-devkit/schematics 0.6.1
@angular/animations 6.0.4
@ngtools/webpack 6.0.1
@schematics/angular 0.6.1
@schematics/update 0.6.1
rxjs 6.2.0
typescript 2.7.2
webpack 4.6.0
</code></pre>
| 0debug |
Class method which includes another class method is undefined when setting a variable to be the original class method : <p>Why is the following throwing an error, and how would I go about trying to fix.</p>
<pre class="lang-js prettyprint-override"><code>class Foo {
bar() {
console.log("bar");
}
fizz() {
this.bar(); // TypeError: this is undefined
}
}
let foo = new Foo();
let buzz = foo.fizz;
buzz();
</code></pre>
| 0debug |
i am getting an error: local variable 'get_input_args referenced before assignment : def main():
# TODO 0: Measures total program runtime by collecting start time
start_time = time()
# creates and retrieves command Line Arguments
in_arg = get_input_args()
# Function that checks command line arguments using in_arg
check_command_line_arguments(in_arg)
# Creates pet image labels by creating a dictionary
answers_dic = pet_labels()
check_creating_pet_image_labels(answers_dic)
# Creates classifier labels with classifier function, compares labbels and createsa results
# dictionary
result_dic = classify_images(in_arg.dir, answers_dic, in_arg.arch)
# Function that checks results dictionary result_dic
check_classifying_images(result_dic)
# Adjusts the results dictionary to determine if classifier correctly classified images 'a dog'
# or 'not a dog'
adjust_results4_isadog(result_dic,in_arg.dogfile)
# Function that checks results dictionary for is-a -dog adjustment - result-dic
check_classifying_labels_as_dogs(result_dic)
# Calculates results of run and puts statistics in results_stats_dic
results_stats_dic = calculates_results_stats(result_dic)
# Function that checks results stats dictionary - results_stats_dic
check_calculating_results(result_dic,results_stats_dic)
# Prints Summary results, incorrect classifications of dogs and breeds if requested
prints_results(result_dic, results_stats_dic, in_arg.arch)
# Measure total program runtime by collecting end time
end_time = time()
# Computes overall runtime in seconds and prints it hh:mm:ss format
tot_time = end_time - start_time
print('\n** Total elapsed runtime:', str(int((tot_time / 3600))) + ':' + str(int((tot_time % 3600) / 60))
+ ':' +str(int((tot_time % 3600) % 60)))
Traceback (most recent call last):
File 'check_images.py' , line 417, in main
in_arg = get_input_args()
Unboundlocal error:Local variable 'get_input_args' referenced before assignment
| 0debug |
static void virtqueue_map_iovec(VirtIODevice *vdev, struct iovec *sg,
hwaddr *addr, unsigned int *num_sg,
unsigned int max_size, int is_write)
{
unsigned int i;
hwaddr len;
#ifdef NDEBUG
#error building with NDEBUG is not supported
#endif
assert(*num_sg <= max_size);
for (i = 0; i < *num_sg; i++) {
len = sg[i].iov_len;
sg[i].iov_base = dma_memory_map(vdev->dma_as,
addr[i], &len, is_write ?
DMA_DIRECTION_FROM_DEVICE :
DMA_DIRECTION_TO_DEVICE);
if (!sg[i].iov_base) {
error_report("virtio: error trying to map MMIO memory");
exit(1);
}
if (len != sg[i].iov_len) {
error_report("virtio: unexpected memory split");
exit(1);
}
}
}
| 1threat |
Upgrade process for fontawesome from 4 to 5 : <p>We contributed to font-awesome 5 (yea), and we are looking from moving from our existing icons (Symbol set) to font-awesome. Will the naming of icons and usage of font-awesome 5 be backwards compatible with font-awesome 4.7?</p>
<p><code>IE: Should we go to 4.7 now, and have very easy upgrade to 5.0?
OR should we hold off until font-awesome 5 comes out?</code></p>
| 0debug |
static void gd_update_cursor(GtkDisplayState *s, gboolean override)
{
GdkWindow *window;
bool on_vga;
window = gtk_widget_get_window(GTK_WIDGET(s->drawing_area));
on_vga = (gtk_notebook_get_current_page(GTK_NOTEBOOK(s->notebook)) == 0);
if ((override || on_vga) && kbd_mouse_is_absolute()) {
gdk_window_set_cursor(window, s->null_cursor);
} else {
gdk_window_set_cursor(window, NULL);
}
}
| 1threat |
is this table is correct? or i should put unsignedBigInteger for tag_id too? and remove.->unsigned and index? : /**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('post_tags', function (Blueprint $table) {
$table->unsignedBigInteger('post_id');
$table->integer('tag_id')->unsigned()->index();
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('post_tags');
} | 0debug |
javascript | google sheets - missing name after . operator. : I get this error when debugging/running my code on line 10. Any chance anyone know the workaround?
function codebook_level() {
if(!require(pacman)) {
install.packages("pacman"); require(pacman)}
p_load(magrittr, data.table)
require(dplyr)
read_add_name_col <- function(file){
rn <- gsub(".csv", "", file, ignore.case=T)
spl <- strsplit(rn, "/") %>% unlist()
svy <- spl[length(spl)]
df <- fread(file)
df$survey_series <- svy
return(df)
.... | 0debug |
void net_host_device_remove(Monitor *mon, int vlan_id, const char *device)
{
VLANState *vlan;
VLANClientState *vc;
vlan = qemu_find_vlan(vlan_id);
if (!vlan) {
monitor_printf(mon, "can't find vlan %d\n", vlan_id);
return;
}
for(vc = vlan->first_client; vc != NULL; vc = vc->next)
if (!strcmp(vc->name, device))
break;
if (!vc) {
monitor_printf(mon, "can't find device %s\n", device);
return;
}
qemu_del_vlan_client(vc);
}
| 1threat |
Detect 3 fingers pan gesture even outside a macOS app's window perpetually : <p>How can I detect a 3 fingers pan gesture on my mac trackpad everywhere on the screen (not only in my app's window) perpetually (without having the focus on my app's window) ?</p>
<p>Thanks !</p>
| 0debug |
How can I resolve a main class error from cmd : <p>I wrote a simple java program that will require external jar file to compile and run. I've successfully compiled the .java file but i keep getting "Error: could not find or load main class 'Simple' " whenever i try to run the .class file using java command</p>
| 0debug |
static int vfio_msi_setup(VFIOPCIDevice *vdev, int pos)
{
uint16_t ctrl;
bool msi_64bit, msi_maskbit;
int ret, entries;
if (pread(vdev->vbasedev.fd, &ctrl, sizeof(ctrl),
vdev->config_offset + pos + PCI_CAP_FLAGS) != sizeof(ctrl)) {
return -errno;
}
ctrl = le16_to_cpu(ctrl);
msi_64bit = !!(ctrl & PCI_MSI_FLAGS_64BIT);
msi_maskbit = !!(ctrl & PCI_MSI_FLAGS_MASKBIT);
entries = 1 << ((ctrl & PCI_MSI_FLAGS_QMASK) >> 1);
trace_vfio_msi_setup(vdev->vbasedev.name, pos);
ret = msi_init(&vdev->pdev, pos, entries, msi_64bit, msi_maskbit);
if (ret < 0) {
if (ret == -ENOTSUP) {
return 0;
}
error_report("vfio: msi_init failed");
return ret;
}
vdev->msi_cap_size = 0xa + (msi_maskbit ? 0xa : 0) + (msi_64bit ? 0x4 : 0);
return 0;
}
| 1threat |
How to pass environment variable to docker-compose up : <p>I am trying to run a container. I already have the image uploaded to private Docker registry. I want to write a compose file to download and deploy the image. But I want to pass the TAG name as a variable from the docker-compose run command.My compose file looks like below. How can I pass the value for KB_DB_TAG_VERSION as part of docker-compose up command?</p>
<pre><code>version: '3'
services:
db:
#build: k-db
user: "1000:50"
volumes:
- /data/mysql:/var/lib/mysql
container_name: k-db
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
image: XX:$KB_DB_TAG_VERSION
image: k-db
ports:
- "3307:3306"
</code></pre>
| 0debug |
static int r3d_read_red1(AVFormatContext *s)
{
AVStream *st = avformat_new_stream(s, NULL);
char filename[258];
int tmp;
int av_unused tmp2;
AVRational framerate;
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_JPEG2000;
tmp = avio_r8(s->pb);
tmp2 = avio_r8(s->pb);
av_dlog(s, "version %d.%d\n", tmp, tmp2);
tmp = avio_rb16(s->pb);
av_dlog(s, "unknown1 %d\n", tmp);
tmp = avio_rb32(s->pb);
avpriv_set_pts_info(st, 32, 1, tmp);
tmp = avio_rb32(s->pb);
av_dlog(s, "filenum %d\n", tmp);
avio_skip(s->pb, 32);
st->codec->width = avio_rb32(s->pb);
st->codec->height = avio_rb32(s->pb);
tmp = avio_rb16(s->pb);
av_dlog(s, "unknown2 %d\n", tmp);
framerate.num = avio_rb16(s->pb);
framerate.den = avio_rb16(s->pb);
if (framerate.num && framerate.den)
st->r_frame_rate = st->avg_frame_rate = framerate;
tmp = avio_r8(s->pb);
av_dlog(s, "audio channels %d\n", tmp);
if (tmp > 0) {
AVStream *ast = avformat_new_stream(s, NULL);
if (!ast)
return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_id = CODEC_ID_PCM_S32BE;
ast->codec->channels = tmp;
avpriv_set_pts_info(ast, 32, 1, st->time_base.den);
}
avio_read(s->pb, filename, 257);
filename[sizeof(filename)-1] = 0;
av_dict_set(&st->metadata, "filename", filename, 0);
av_dlog(s, "filename %s\n", filename);
av_dlog(s, "resolution %dx%d\n", st->codec->width, st->codec->height);
av_dlog(s, "timescale %d\n", st->time_base.den);
av_dlog(s, "frame rate %d/%d\n",
framerate.num, framerate.den);
return 0;
}
| 1threat |
Cant Deploy To Real Android Device Xamarin : <p>My problem is related to this post
<a href="https://stackoverflow.com/questions/26794862/failure-install-failed-update-incompatible-even-if-app-appears-to-not-be-insta">Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE] even if app appears to not be installed</a></p>
<p>I am not able to deploy my app on a real device it works properly on the emulator , i get deployment error, but nothing in the errors tab.</p>
<p>This is from build output</p>
<blockquote>
<p>2>Build succeeded.</p>
<p>2>An error occured. See full exception on logs for more details.</p>
<p>2>The installed package is incompatible. Please manually uninstall and
try again.</p>
<p>2></p>
<p>========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========</p>
</blockquote>
<p>even after uninstalling the app i was not able to deploy my app on my real device , other apps install fine thorough VS.</p>
| 0debug |
Android “Only the original thread that created a view hierarchy can touch its views.” error in for loop : <p>I am trying to run the for loop in every half second.The loop is changing something in the view every time it is called,but the changes are made by another class i.e Speedometer.</p>
<pre><code>Thread thread=new Thread(){
@Override
public void run() {
float i;
try {
for ( i = 0; i <= 100; i++) {
Speedometer1.onSpeedChanged(Speedometer1.getCurrentSpeed(i) + 8);
Speedometer2.onSpeedChanged(Speedometer2.getCurrentSpeed(i) + 8);
Speedometer3.onSpeedChanged(Speedometer3.getCurrentSpeed(i) + 8);
Speedometer4.onSpeedChanged(Speedometer4.getCurrentSpeed(i) + 8);
Speedometer5.onSpeedChanged(Speedometer5.getCurrentSpeed(i) + 8);
Speedometer6.onSpeedChanged(Speedometer6.getCurrentSpeed(i) + 8);
sleep(500);
}
}
catch (InterruptedException e)
{e.printStackTrace();}
}
};thread.start();
</code></pre>
| 0debug |
void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg)
{
const uint8_t type_code[] = {
[GDB_BREAKPOINT_HW] = 0x0,
[GDB_WATCHPOINT_WRITE] = 0x1,
[GDB_WATCHPOINT_ACCESS] = 0x3
};
const uint8_t len_code[] = {
[1] = 0x0, [2] = 0x1, [4] = 0x3, [8] = 0x2
};
int n;
if (kvm_sw_breakpoints_active(env))
dbg->control |= KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP;
if (nb_hw_breakpoint > 0) {
dbg->control |= KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_HW_BP;
dbg->arch.debugreg[7] = 0x0600;
for (n = 0; n < nb_hw_breakpoint; n++) {
dbg->arch.debugreg[n] = hw_breakpoint[n].addr;
dbg->arch.debugreg[7] |= (2 << (n * 2)) |
(type_code[hw_breakpoint[n].type] << (16 + n*4)) |
(len_code[hw_breakpoint[n].len] << (18 + n*4));
}
}
env->xcr0 = 1;
}
| 1threat |
AutoMapper.Mapper does not contain definition for CreateMap : <p>This might be a basic question but wondering I am not getting AutoMapper.Mapper.CreateMap method. </p>
<p><a href="https://i.stack.imgur.com/Iprvy.jpg"><img src="https://i.stack.imgur.com/Iprvy.jpg" alt="enter image description here"></a></p>
<p>Am I using wrong AutoMapper reference/package? Thanks</p>
| 0debug |
Wicket Framework connect in database : <p>I am recently new here. I have a problem about Apache Wicket Framework version 1.6.0 using IDE netbeans 8.0 to Create Login Form and to connect in mysql database .I have many errors please reply on my problem</p>
| 0debug |
How to render string with html tags in Angular 4+? : <p>In my angular 4 app, I have a string like</p>
<pre><code>comment: string;
comment = "<p><em><strong>abc</strong></em></p>";
</code></pre>
<p>When I serve this text in my html, like</p>
<pre><code>{{comment}}
</code></pre>
<p>Then it displays: </p>
<pre><code><p><em><strong>abc</strong></em></p>
</code></pre>
<p>But I need to display the text "abc" in bold and italic form, like
<strong><em>abc</em></strong></p>
<p>How can I do this?</p>
| 0debug |
void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
TraceEvent *ev, bool state)
{
TraceEventVCPUID vcpu_id;
bool state_pre;
assert(trace_event_get_state_static(ev));
assert(trace_event_is_vcpu(ev));
vcpu_id = trace_event_get_vcpu_id(ev);
state_pre = test_bit(vcpu_id, vcpu->trace_dstate);
if (state_pre != state) {
if (state) {
trace_events_enabled_count++;
set_bit(vcpu_id, vcpu->trace_dstate);
(*ev->dstate)++;
} else {
trace_events_enabled_count--;
clear_bit(vcpu_id, vcpu->trace_dstate);
(*ev->dstate)--;
}
}
}
| 1threat |
static uint64_t mv88w8618_audio_read(void *opaque, target_phys_addr_t offset,
unsigned size)
{
mv88w8618_audio_state *s = opaque;
switch (offset) {
case MP_AUDIO_PLAYBACK_MODE:
return s->playback_mode;
case MP_AUDIO_CLOCK_DIV:
return s->clock_div;
case MP_AUDIO_IRQ_STATUS:
return s->status;
case MP_AUDIO_IRQ_ENABLE:
return s->irq_enable;
case MP_AUDIO_TX_STATUS:
return s->play_pos >> 2;
default:
return 0;
}
}
| 1threat |
How to find latitude and longitude lies within radius? : <p>I have latitude and longitude of place. How to find these latitude and longitude lies within some other locations radius? </p>
<p>for example having (6.8914,79.8522) (lat,long) of location,and find within location (6.9584218,80.1783008) of radius 10.</p>
<p>please help me.</p>
| 0debug |
Decode Base64 to Hexadecimal string with javascript : <p>Needing to convert a Base64 string to Hexadecimal with javascript.</p>
<p>Example: </p>
<pre><code>var base64Value = "oAAABTUAAg=="
</code></pre>
<p>Need conversion method </p>
<p>Output (Decoded data (hexadecimal)) <code>A0000005350002</code></p>
<p>I know this is correct because I can use this website <a href="http://tomeko.net/online_tools/base64.php?lang=en" rel="noreferrer">http://tomeko.net/online_tools/base64.php?lang=en</a></p>
<p>and punch in Base64 string of <code>oAAABTUAAg==</code> and get <code>A0000005350002</code></p>
<p>What have I tried? </p>
<p><a href="https://github.com/carlo/jquery-base64" rel="noreferrer">https://github.com/carlo/jquery-base64</a><br>
<a href="https://jsfiddle.net/gabrieleromanato/qaght/" rel="noreferrer">https://jsfiddle.net/gabrieleromanato/qaght/</a></p>
<p>I have found a lot of questions </p>
| 0debug |
static int mxf_read_source_package(MXFPackage *package, ByteIOContext *pb, int tag)
{
switch(tag) {
case 0x4403:
package->tracks_count = get_be32(pb);
if (package->tracks_count >= UINT_MAX / sizeof(UID))
return -1;
package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));
if (!package->tracks_refs)
return -1;
url_fskip(pb, 4);
get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));
break;
case 0x4401:
url_fskip(pb, 16);
get_buffer(pb, package->package_uid, 16);
break;
case 0x4701:
get_buffer(pb, package->descriptor_ref, 16);
break;
}
return 0;
}
| 1threat |
Strange behaviour of Array.reduce() : Data:
arr = [0, 0, 0, 1, 1]
Code:
###1
!arr[0] + !arr[1] + !arr[2] + !arr[3] + !arr[4]
// 3, correct!
but ...
###2
arr.reduce((a, b) => (!a + !b));
// 1, bullshit?!
Question:
Why is **1**. and **2**. not the same? Makes no sense to me? How can I reduce() my array to give me the same as in **1**.
| 0debug |
Angular save file as csv result in Failed- network error Only on Chrome : <p>I'm using the following code to save file as csv.</p>
<pre><code>$scope.saveCSVFile = function (result)
{
var a = document.createElement('a');
a.href = 'data:application/csv;charset=utf-8,' + encodeURIComponent(result.data);
a.target = '_blank';
a.download = $scope.getFileNameFromHttpResponse(result);
document.body.appendChild(a);
a.click();
$scope.isReportInProgress = false;
};
</code></pre>
<p>The file is working on most of the cases but for some reason when the file is larger than 10MB i get "Failed - Network Error".</p>
<p>It happens only on chrome.</p>
<p>I tried to search the web for this issue and couldn't find anything relevant.</p>
<p>Can you think of an idea why does it happens? or maybe use a different save file method that will work on chrome/firefox/IE instead of my function?</p>
| 0debug |
Trace: The node type SpreadProperty has been renamed to SpreadElement at Object.isSpreadProperty : <p>I'm launching a react app, and here's my Webpack configuration:</p>
<pre><code>'use strict'
const ExtractPlugin = require('extract-text-webpack-plugin')
const HTMLPlugin = require('html-webpack-plugin')
module.exports = {
devtool: 'eval',
entry: `${__dirname}/src/main.js`,
output: {
filename: 'bundle-[hash].js',
path: `${__dirname}/build`,
publicPath: '/',
},
mode: 'development',
performance: {
hints: false
},
plugins: [
new HTMLPlugin(),
new ExtractPlugin('bundle-[hash].css'),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_module/,
loader: 'babel-loader',
},
{
test: /\.scss$/,
loader: ExtractPlugin.extract(['css-loader', 'sass-loader']),
},
],
},
}
</code></pre>
<p>Then, I have a package.json file, here are the dependencies:</p>
<pre><code>"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/preset-env": "^7.1.6",
"@babel/preset-react": "^7.0.0",
"and": "0.0.3",
"babel-cli": "^6.26.0",
"babel-core": "^7.0.0-bridge.0",
"babel-loader": "^8.0.4",
"eslint": "^5.9.0",
"install": "^0.12.2",
"jest": "^23.6.0",
"npm": "^6.4.1",
"webpack-cli": "^3.1.2"
},
"dependencies": {
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"css-loader": "^1.0.1",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"html-webpack-plugin": "^3.2.0",
"node-sass": "^4.11.0",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"resolve-url-loader": "^3.0.0",
"sass-loader": "^7.1.0",
"webpack": "^4.25.1",
"webpack-dev-server": "^3.1.10"
}
</code></pre>
<p>I have tried plenty of ways of updating babel packages up to 7th version, changing babelrc config, what ever.</p>
<p>The project though compiles, but in the beginning of compilation I get the following message:</p>
<p>Trace: The node type SpreadProperty has been renamed to SpreadElement
at Object.isSpreadProperty</p>
<p>And about of hundred rows like that. After all that rows being printed out, the compilation process proceeds and is completed successfully.</p>
<p>What's that and how can I get rid of this rows?</p>
| 0debug |
static int v9fs_synth_remove(FsContext *ctx, const char *path)
{
errno = EPERM;
return -1;
}
| 1threat |
Anomaly in printf() function : <p>I am seeing anomalous behavior in print function while dealing with int and float numbers.</p>
<pre><code>float y = 9/5;
printf("%f", y);
printf("%f", 9/5);
</code></pre>
<p>First print statement outputs 1.000000 which is acceptable while other outputs 0.000000.
Why outputs are different in both cases?</p>
| 0debug |
How to check a palindrome number without using a string? : <p>Without using a string how to check if a number is palindrome or not.
Palindrome numbers are those which are read same from backwards also.
Ex- 121</p>
| 0debug |
Context Deadline Exceeded - prometheus : <p>I have prometheus configuration with many jobs where i am scraping metrics over http. But I have one job where i need to scrape the metrics over https. </p>
<p>When i access:</p>
<p><a href="https://ip-address:port/metrics" rel="noreferrer">https://ip-address:port/metrics</a></p>
<p>I can see the metrics.
The job that I have added in the prometheus.yml configuration is:</p>
<pre><code>- job_name: 'test-jvm-metrics'
scheme: https
static_configs:
- targets: ['ip:port']
</code></pre>
<p>When i restart the prometheus I can see error on my target that says: </p>
<blockquote>
<p>context deadline exceeded</p>
</blockquote>
<p>I have read that maybe the scrape_timeout is the problem, but I have set it to 50 sec and still the same problem.</p>
<p>What can cause this problem and how to fix it?
Thank you!</p>
| 0debug |
static void spr_write_sdr1 (void *opaque, int sprn)
{
DisasContext *ctx = opaque;
gen_op_store_sdr1();
RET_STOP(ctx);
}
| 1threat |
SQL Query to retrieve the informations from another table knowing the ids : I have two tables in my db:
Table Flights:
ID
ID_Destination
ID_Source
Table Locations:
ID (that relatesto the id of source and destination)
Name
Country
Etc..
Now I need a query that gives me the information of all flights from a certain source to certain destination. I have tried long in the query editor but inner join does not work here.
What should I use instead?
I would need as a result something like:
1st flight: Naples Italy |London England
2nd flight: Rome Italy | Mailand Italy
etc..
Thanks for help. | 0debug |
static void rv30_loop_filter(RV34DecContext *r, int row)
{
MpegEncContext *s = &r->s;
int mb_pos, mb_x;
int i, j, k;
uint8_t *Y, *C;
int loc_lim, cur_lim, left_lim = 0, top_lim = 0;
mb_pos = row * s->mb_stride;
for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
int mbtype = s->current_picture_ptr->mb_type[mb_pos];
if(IS_INTRA(mbtype) || IS_SEPARATE_DC(mbtype))
r->deblock_coefs[mb_pos] = 0xFFFF;
if(IS_INTRA(mbtype))
r->cbp_chroma[mb_pos] = 0xFF;
}
mb_pos = row * s->mb_stride;
for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos]];
if(mb_x)
left_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos - 1]];
for(j = 0; j < 16; j += 4){
Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize + 4 * !mb_x;
for(i = !mb_x; i < 4; i++, Y += 4){
int ij = i + j;
loc_lim = 0;
if(r->deblock_coefs[mb_pos] & (1 << ij))
loc_lim = cur_lim;
else if(!i && r->deblock_coefs[mb_pos - 1] & (1 << (ij + 3)))
loc_lim = left_lim;
else if( i && r->deblock_coefs[mb_pos] & (1 << (ij - 1)))
loc_lim = cur_lim;
if(loc_lim)
rv30_weak_loop_filter(Y, 1, s->linesize, loc_lim);
}
}
for(k = 0; k < 2; k++){
int cur_cbp, left_cbp = 0;
cur_cbp = (r->cbp_chroma[mb_pos] >> (k*4)) & 0xF;
if(mb_x)
left_cbp = (r->cbp_chroma[mb_pos - 1] >> (k*4)) & 0xF;
for(j = 0; j < 8; j += 4){
C = s->current_picture_ptr->f.data[k + 1] + mb_x*8 + (row*8 + j) * s->uvlinesize + 4 * !mb_x;
for(i = !mb_x; i < 2; i++, C += 4){
int ij = i + (j >> 1);
loc_lim = 0;
if (cur_cbp & (1 << ij))
loc_lim = cur_lim;
else if(!i && left_cbp & (1 << (ij + 1)))
loc_lim = left_lim;
else if( i && cur_cbp & (1 << (ij - 1)))
loc_lim = cur_lim;
if(loc_lim)
rv30_weak_loop_filter(C, 1, s->uvlinesize, loc_lim);
}
}
}
}
mb_pos = row * s->mb_stride;
for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos]];
if(row)
top_lim = rv30_loop_filt_lim[s->current_picture_ptr->qscale_table[mb_pos - s->mb_stride]];
for(j = 4*!row; j < 16; j += 4){
Y = s->current_picture_ptr->f.data[0] + mb_x*16 + (row*16 + j) * s->linesize;
for(i = 0; i < 4; i++, Y += 4){
int ij = i + j;
loc_lim = 0;
if(r->deblock_coefs[mb_pos] & (1 << ij))
loc_lim = cur_lim;
else if(!j && r->deblock_coefs[mb_pos - s->mb_stride] & (1 << (ij + 12)))
loc_lim = top_lim;
else if( j && r->deblock_coefs[mb_pos] & (1 << (ij - 4)))
loc_lim = cur_lim;
if(loc_lim)
rv30_weak_loop_filter(Y, s->linesize, 1, loc_lim);
}
}
for(k = 0; k < 2; k++){
int cur_cbp, top_cbp = 0;
cur_cbp = (r->cbp_chroma[mb_pos] >> (k*4)) & 0xF;
if(row)
top_cbp = (r->cbp_chroma[mb_pos - s->mb_stride] >> (k*4)) & 0xF;
for(j = 4*!row; j < 8; j += 4){
C = s->current_picture_ptr->f.data[k+1] + mb_x*8 + (row*8 + j) * s->uvlinesize;
for(i = 0; i < 2; i++, C += 4){
int ij = i + (j >> 1);
loc_lim = 0;
if (r->cbp_chroma[mb_pos] & (1 << ij))
loc_lim = cur_lim;
else if(!j && top_cbp & (1 << (ij + 2)))
loc_lim = top_lim;
else if( j && cur_cbp & (1 << (ij - 2)))
loc_lim = cur_lim;
if(loc_lim)
rv30_weak_loop_filter(C, s->uvlinesize, 1, loc_lim);
}
}
}
}
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.