problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
returning data from a database aplhabetically : Okay so I've created a database which stores different attributes for a given user. I have implemented an algorithm which takes the username attribute and stores the contents of this attribute and stores it in an array. However for some reason, when printing the array it shows the users in alphabetical order: I want it to return the original order of my database. For context I am using the JDBC API in java which takes mySQL sytax.
I have not implemented an ORDER BY statement, it is just a simple SELECT FROM WHERE statement but it seems to return alphabetically.
public void DisplayUsers() throws SQLException {
String queryCount = "SELECT COUNT(Username) FROM UserInfo";
String query = "SELECT Username FROM UserInfo";
declaringDataBase();
rsObj = statObj.executeQuery(queryCount);
String x = null;
while(rsObj.next()){
x = rsObj.getString(1);
}
int rowNum = Integer.parseInt(x);
rsObj = statObj.executeQuery(query);
String UserArray[] = new String[rowNum];
int counter = 0;
while(rsObj.next()){
String user = rsObj.getString("Username");
UserArray[counter] = user;
System.out.println(UserArray[counter]);
counter++;
}
}
the line *declaringDatabase();* simply calls another method to connect my database to the code. The count statement is taking the number of users under attribute Username and creating an integer to store as the length of the array. But anyway my UserArray[] returns values in alphabetical order? does anybody know why! highly appreciated.
| 0debug
|
static void scsi_generic_purge_requests(SCSIGenericState *s)
{
SCSIGenericReq *r;
while (!QTAILQ_EMPTY(&s->qdev.requests)) {
r = DO_UPCAST(SCSIGenericReq, req, QTAILQ_FIRST(&s->qdev.requests));
if (r->req.aiocb) {
bdrv_aio_cancel(r->req.aiocb);
}
scsi_remove_request(r);
}
}
| 1threat
|
static void cpu_request_exit(void *opaque, int irq, int level)
{
CPUState *cpu = current_cpu;
if (cpu && level) {
cpu_exit(cpu);
}
}
| 1threat
|
how to prove O(max{ f (n),g(n)}) = O( f (n)+g(n))? : I find a rule about algorithms for analysis.
O(max{f(n),g(n)}) = O(f(n)+g(n))
how to prove it?
I know
max{f(n),g(n)} <= f(n)+g(n) <= 2 * max{f(n),g(n)}
thus
max{f(n),g(n)} is O(f(n)+g(n))
max{f(n),g(n)} is O(max{f(n),g(n)})
f(n)+g(n) is O(max{f(n),g(n)})
then?
| 0debug
|
static void vfio_probe_rtl8168_bar2_window_quirk(VFIOPCIDevice *vdev, int nr)
{
PCIDevice *pdev = &vdev->pdev;
VFIOQuirk *quirk;
if (pci_get_word(pdev->config + PCI_VENDOR_ID) != PCI_VENDOR_ID_REALTEK ||
pci_get_word(pdev->config + PCI_DEVICE_ID) != 0x8168 || nr != 2) {
return;
}
quirk = g_malloc0(sizeof(*quirk));
quirk->vdev = vdev;
quirk->data.bar = nr;
memory_region_init_io(&quirk->mem, OBJECT(vdev), &vfio_rtl8168_window_quirk,
quirk, "vfio-rtl8168-window-quirk", 8);
memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,
0x70, &quirk->mem, 1);
QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);
trace_vfio_probe_rtl8168_bar2_window_quirk(vdev->vbasedev.name);
}
| 1threat
|
New to programming, function does not work inside class : <pre><code><?php
class spel {
function randomWoord() {
$woorden = array(
'Juan',
'Luis',
'Pedro',
// and so on
);
return $woorden[rand ( 0 , count($woorden) -1)];
}
print randomWoord();
}
?>
</code></pre>
<p>New to programming, function does not work inside class. When I remove the class, it does work. How can I fix this.</p>
| 0debug
|
How can I remove Description Label in ios-chart? : <p>I am trying to remove <code>Description Label</code> in <code>ios-chart</code> library. You can see it on the image below:</p>
<p><a href="https://i.stack.imgur.com/FWEK1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FWEK1.png" alt="enter image description here"></a></p>
<p>And I know that, on Android (<code>MPAndroidChart</code> library which is the predecessor of ios-chart), I can do the following:</p>
<pre><code>barchart.setDescription(" ");
</code></pre>
<p>but I am trying to do the same on Swift:</p>
<pre><code>barchart.description = ""
</code></pre>
<p>and I am getting the following error:</p>
<blockquote>
<p>Cannot assign to property: 'description' is immutable</p>
</blockquote>
<p>I have looked on the Internet and here in StackOverflow but could not see anything to remove it. </p>
<p>Is it possible to remove that <code>Description Label</code> on <code>ios-chart</code> library?</p>
<p>Thanks in advance!</p>
| 0debug
|
How to extract text from a pdf file : <p>What is the best way to extract text from a pdf file.....
I have tried some
PyPDF2 -----> it only returns an empty string for all pages
tabula -----> it returns a weird table of NaN
the pdf I am trying to scrap is
<a href="http://imdagrimet.gov.in/sites/default/files/daas_bulletin/Vaishali_46.pdf" rel="nofollow noreferrer">http://imdagrimet.gov.in/sites/default/files/daas_bulletin/Vaishali_46.pdf</a></p>
| 0debug
|
Insert a character to a string with Python : <p>How do I add a character to a string with Python? For example, I like to add a ":" to the middle of string: "0900" between 09 & 00.</p>
| 0debug
|
How to make simple "linq" request? : I want to make "LINQ" request, where I have two lists (you can see on picture). Request should work with List<G> and i want to get GW2-GW5. I want to see it in style like "model.Select<G>( ... ).Where( ... ) ..."

| 0debug
|
nested JSON object and JSON array in android : {
"ocrNumber":0123456
"userName":dddd
"photo":[
{
"lat":13.1234
"long":7.1234
"imagepath":sd/image/demo.jpg
}
]
}
please ignore the syntax if wrong
| 0debug
|
How to make Keras use Tensorflow backend in Anaconda? : <p>I have install tensorflow-gpu in my Anaconda environment. They both work well. </p>
<p>Now I am trying to install Keras with Tensorflow backend. According to the <a href="https://keras.io/#installation" rel="noreferrer">instruction</a> I just run:</p>
<pre><code>pip install keras
</code></pre>
<p>But it doesn't install keras, then I tried:</p>
<pre><code>conda install -c conda-forge keras=2.0.2
</code></pre>
<p>Then I am now able import keras in python. But the problem is, it always use the Theano backend. I am trying to change this, but not knowing how to do it.</p>
<p>I also tried edit the file <strong>~/.keras</strong>, but actually default backend was tensorflow already.</p>
<p>Please help.. Thank you so much!</p>
| 0debug
|
static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) {
NUTContext * priv = avf->priv_data;
ByteIOContext * bc = &avf->pb;
nut_demuxer_opts_t dopts = {
.input = {
.priv = bc,
.seek = av_seek,
.read = av_read,
.eof = NULL,
.file_pos = 0,
},
.alloc = { av_malloc, av_realloc, av_free },
.read_index = 1,
.cache_syncpoints = 1,
};
nut_context_t * nut = priv->nut = nut_demuxer_init(&dopts);
nut_stream_header_t * s;
int ret, i;
if ((ret = nut_read_headers(nut, &s, NULL))) {
if (ret < 0) av_log(avf, AV_LOG_ERROR, " NUT error: %s\n", nut_error(-ret));
nut_demuxer_uninit(nut);
return -1;
}
priv->s = s;
for (i = 0; s[i].type != -1 && i < 2; i++) {
AVStream * st = av_new_stream(avf, i);
int j;
for (j = 0; j < s[i].fourcc_len && j < 8; j++) st->codec->codec_tag |= s[i].fourcc[j]<<(j*8);
st->codec->has_b_frames = s[i].decode_delay;
st->codec->extradata_size = s[i].codec_specific_len;
if (st->codec->extradata_size) {
st->codec->extradata = av_mallocz(st->codec->extradata_size);
memcpy(st->codec->extradata, s[i].codec_specific, st->codec->extradata_size);
}
av_set_pts_info(avf->streams[i], 60, s[i].time_base.nom, s[i].time_base.den);
st->start_time = 0;
st->duration = s[i].max_pts;
st->codec->codec_id = codec_get_id(nut_tags, st->codec->codec_tag);
switch(s[i].type) {
case NUT_AUDIO_CLASS:
st->codec->codec_type = CODEC_TYPE_AUDIO;
if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_wav_id(st->codec->codec_tag);
st->codec->channels = s[i].channel_count;
st->codec->sample_rate = s[i].samplerate_nom / s[i].samplerate_denom;
break;
case NUT_VIDEO_CLASS:
st->codec->codec_type = CODEC_TYPE_VIDEO;
if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_bmp_id(st->codec->codec_tag);
st->codec->width = s[i].width;
st->codec->height = s[i].height;
st->codec->sample_aspect_ratio.num = s[i].sample_width;
st->codec->sample_aspect_ratio.den = s[i].sample_height;
break;
}
if (st->codec->codec_id == CODEC_ID_NONE) av_log(avf, AV_LOG_ERROR, "Unknown codec?!\n");
}
return 0;
}
| 1threat
|
static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
{
AVStream *st = s->streams[pkt->stream_index];
int size = pkt->size;
uint8_t *buf = pkt->data;
uint8_t *data = NULL;
MpegTSWrite *ts = s->priv_data;
MpegTSWriteStream *ts_st = st->priv_data;
const int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE) * 2;
int64_t dts = pkt->dts, pts = pkt->pts;
if (ts->reemit_pat_pmt) {
av_log(s, AV_LOG_WARNING,
"resend_headers option is deprecated, use -mpegts_flags resend_headers\n");
ts->reemit_pat_pmt = 0;
ts->flags |= MPEGTS_FLAG_REEMIT_PAT_PMT;
}
if (ts->flags & MPEGTS_FLAG_REEMIT_PAT_PMT) {
ts->pat_packet_count = ts->pat_packet_period - 1;
ts->sdt_packet_count = ts->sdt_packet_period - 1;
ts->flags &= ~MPEGTS_FLAG_REEMIT_PAT_PMT;
}
if (ts->copyts < 1) {
if (pts != AV_NOPTS_VALUE)
pts += delay;
if (dts != AV_NOPTS_VALUE)
dts += delay;
}
if (ts_st->first_pts_check && pts == AV_NOPTS_VALUE) {
av_log(s, AV_LOG_ERROR, "first pts value must be set\n");
return AVERROR_INVALIDDATA;
}
ts_st->first_pts_check = 0;
if (st->codec->codec_id == AV_CODEC_ID_H264) {
const uint8_t *p = buf, *buf_end = p + size;
uint32_t state = -1;
int extradd = (pkt->flags & AV_PKT_FLAG_KEY) ? st->codec->extradata_size : 0;
int ret = ff_check_h264_startcode(s, st, pkt);
if (ret < 0)
return ret;
if (extradd && AV_RB24(st->codec->extradata) > 1)
extradd = 0;
do {
p = avpriv_find_start_code(p, buf_end, &state);
av_log(s, AV_LOG_TRACE, "nal %d\n", state & 0x1f);
if ((state & 0x1f) == 7)
extradd = 0;
} while (p < buf_end && (state & 0x1f) != 9 &&
(state & 0x1f) != 5 && (state & 0x1f) != 1);
if ((state & 0x1f) != 5)
extradd = 0;
if ((state & 0x1f) != 9) {
data = av_malloc(pkt->size + 6 + extradd);
if (!data)
return AVERROR(ENOMEM);
memcpy(data + 6, st->codec->extradata, extradd);
memcpy(data + 6 + extradd, pkt->data, pkt->size);
AV_WB32(data, 0x00000001);
data[4] = 0x09;
data[5] = 0xf0;
buf = data;
size = pkt->size + 6 + extradd;
}
} else if (st->codec->codec_id == AV_CODEC_ID_AAC) {
if (pkt->size < 2) {
av_log(s, AV_LOG_ERROR, "AAC packet too short\n");
return AVERROR_INVALIDDATA;
}
if ((AV_RB16(pkt->data) & 0xfff0) != 0xfff0) {
int ret;
AVPacket pkt2;
if (!ts_st->amux) {
av_log(s, AV_LOG_ERROR, "AAC bitstream not in ADTS format "
"and extradata missing\n");
return AVERROR_INVALIDDATA;
}
av_init_packet(&pkt2);
pkt2.data = pkt->data;
pkt2.size = pkt->size;
av_assert0(pkt->dts != AV_NOPTS_VALUE);
pkt2.dts = av_rescale_q(pkt->dts, st->time_base, ts_st->amux->streams[0]->time_base);
ret = avio_open_dyn_buf(&ts_st->amux->pb);
if (ret < 0)
return AVERROR(ENOMEM);
ret = av_write_frame(ts_st->amux, &pkt2);
if (ret < 0) {
ffio_free_dyn_buf(&ts_st->amux->pb);
return ret;
}
size = avio_close_dyn_buf(ts_st->amux->pb, &data);
ts_st->amux->pb = NULL;
buf = data;
}
} else if (st->codec->codec_id == AV_CODEC_ID_HEVC) {
int ret = check_hevc_startcode(s, st, pkt);
if (ret < 0)
return ret;
}
if (pkt->dts != AV_NOPTS_VALUE) {
int i;
for(i=0; i<s->nb_streams; i++) {
AVStream *st2 = s->streams[i];
MpegTSWriteStream *ts_st2 = st2->priv_data;
if ( ts_st2->payload_size
&& (ts_st2->payload_dts == AV_NOPTS_VALUE || dts - ts_st2->payload_dts > delay/2)) {
mpegts_write_pes(s, st2, ts_st2->payload, ts_st2->payload_size,
ts_st2->payload_pts, ts_st2->payload_dts,
ts_st2->payload_flags & AV_PKT_FLAG_KEY);
ts_st2->payload_size = 0;
}
}
}
if (ts_st->payload_size && (ts_st->payload_size + size > ts->pes_payload_size ||
(dts != AV_NOPTS_VALUE && ts_st->payload_dts != AV_NOPTS_VALUE &&
av_compare_ts(dts - ts_st->payload_dts, st->time_base,
s->max_delay, AV_TIME_BASE_Q) >= 0))) {
mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_size,
ts_st->payload_pts, ts_st->payload_dts,
ts_st->payload_flags & AV_PKT_FLAG_KEY);
ts_st->payload_size = 0;
}
if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || size > ts->pes_payload_size) {
av_assert0(!ts_st->payload_size);
mpegts_write_pes(s, st, buf, size, pts, dts,
pkt->flags & AV_PKT_FLAG_KEY);
av_free(data);
return 0;
}
if (!ts_st->payload_size) {
ts_st->payload_pts = pts;
ts_st->payload_dts = dts;
ts_st->payload_flags = pkt->flags;
}
memcpy(ts_st->payload + ts_st->payload_size, buf, size);
ts_st->payload_size += size;
av_free(data);
return 0;
}
| 1threat
|
LINQ: SingleOrDefault with or without Where : <p>These two Entity Framework Core queries in .Net Core brings the same results.</p>
<pre><code> 1) var _folders = _box.Folders.Where(b => b.Id == box.Id).SingleOrDefault();
2) var _folders = _box.Folders.SingleOrDefault(b => b.Id == box.Id);
</code></pre>
<p>The first one uses SingleOrDefault at the end, with Where after the child object, and the second one doesn't use Where.
What's the difference between both? There is a benefit of using one over the other?</p>
| 0debug
|
Can a GraphQL input type inherit from another type or interface? : <p>Is it possible to use inheritance with GraphQL input types?</p>
<p>Something like that (this, of course, doesn't work with input types):</p>
<pre><code>interface UserInputInterface {
firstName: String
lastName: String
}
input UserInput implements UserInputInterface {
password: String!
}
input UserChangesInput implements UserInputInterface {
id: ID!
password: String
}
</code></pre>
| 0debug
|
Spotlight reveal animation from centre of page with CSS/jQuery? : <p>Does anyone know how I might make a circular 'reveal' effect, so that my DOM elements are revealed from the page centre with a circle getting bigger and bigger.</p>
| 0debug
|
static int pnm_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
PNMContext * const s = avctx->priv_data;
AVFrame * const p = data;
int i, j, n, linesize, h, upgrade = 0, is_mono = 0;
unsigned char *ptr;
int components, sample_len, ret;
unsigned int maskval = 0;
s->bytestream_start =
s->bytestream = (uint8_t *)buf;
s->bytestream_end = (uint8_t *)buf + buf_size;
if ((ret = ff_pnm_decode_header(avctx, s)) < 0)
return ret;
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
return ret;
p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1;
switch (avctx->pix_fmt) {
default:
return AVERROR(EINVAL);
case AV_PIX_FMT_RGBA64BE:
n = avctx->width * 8;
components=4;
sample_len=16;
goto do_read;
case AV_PIX_FMT_RGB48BE:
n = avctx->width * 6;
components=3;
sample_len=16;
goto do_read;
case AV_PIX_FMT_RGBA:
n = avctx->width * 4;
components=4;
sample_len=8;
goto do_read;
case AV_PIX_FMT_RGB24:
n = avctx->width * 3;
components=3;
sample_len=8;
goto do_read;
case AV_PIX_FMT_GRAY8:
n = avctx->width;
components=1;
sample_len=8;
if (s->maxval < 255) {
upgrade = 1;
maskval = (2 << av_log2(s->maxval)) - 1;
}
goto do_read;
case AV_PIX_FMT_GRAY8A:
n = avctx->width * 2;
components=2;
sample_len=8;
goto do_read;
case AV_PIX_FMT_GRAY16BE:
case AV_PIX_FMT_GRAY16LE:
n = avctx->width * 2;
components=1;
sample_len=16;
if (s->maxval < 65535) {
upgrade = 2;
maskval = (2 << av_log2(s->maxval)) - 1;
}
goto do_read;
case AV_PIX_FMT_MONOWHITE:
case AV_PIX_FMT_MONOBLACK:
n = (avctx->width + 7) >> 3;
components=1;
sample_len=1;
is_mono = 1;
do_read:
ptr = p->data[0];
linesize = p->linesize[0];
if (s->bytestream + n * avctx->height > s->bytestream_end)
return AVERROR_INVALIDDATA;
if(s->type < 4 || (is_mono && s->type==7)){
for (i=0; i<avctx->height; i++) {
PutBitContext pb;
init_put_bits(&pb, ptr, linesize);
for(j=0; j<avctx->width * components; j++){
unsigned int c=0;
int v=0;
if(s->type < 4)
while(s->bytestream < s->bytestream_end && (*s->bytestream < '0' || *s->bytestream > '9' ))
s->bytestream++;
if(s->bytestream >= s->bytestream_end)
return AVERROR_INVALIDDATA;
if (is_mono) {
v = (*s->bytestream++)&1;
} else {
do {
v = 10*v + c;
c = (*s->bytestream++) - '0';
} while (c <= 9);
}
put_bits(&pb, sample_len, (((1<<sample_len)-1)*v + (s->maxval>>1))/s->maxval);
}
flush_put_bits(&pb);
ptr+= linesize;
}
}else{
for (i = 0; i < avctx->height; i++) {
if (!upgrade)
memcpy(ptr, s->bytestream, n);
else if (upgrade == 1) {
unsigned int j, f = (255 * 128 + s->maxval / 2) / s->maxval;
for (j = 0; j < n; j++)
ptr[j] = ((s->bytestream[j] & maskval) * f + 64) >> 7;
} else if (upgrade == 2) {
unsigned int j, v, f = (65535 * 32768 + s->maxval / 2) / s->maxval;
for (j = 0; j < n / 2; j++) {
v = av_be2ne16(((uint16_t *)s->bytestream)[j]) & maskval;
((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
}
}
s->bytestream += n;
ptr += linesize;
}
}
break;
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV420P9BE:
case AV_PIX_FMT_YUV420P10BE:
{
unsigned char *ptr1, *ptr2;
n = avctx->width;
ptr = p->data[0];
linesize = p->linesize[0];
if (s->maxval >= 256)
n *= 2;
if (s->bytestream + n * avctx->height * 3 / 2 > s->bytestream_end)
return AVERROR_INVALIDDATA;
for (i = 0; i < avctx->height; i++) {
memcpy(ptr, s->bytestream, n);
s->bytestream += n;
ptr += linesize;
}
ptr1 = p->data[1];
ptr2 = p->data[2];
n >>= 1;
h = avctx->height >> 1;
for (i = 0; i < h; i++) {
memcpy(ptr1, s->bytestream, n);
s->bytestream += n;
memcpy(ptr2, s->bytestream, n);
s->bytestream += n;
ptr1 += p->linesize[1];
ptr2 += p->linesize[2];
}
}
break;
case AV_PIX_FMT_YUV420P16:
{
uint16_t *ptr1, *ptr2;
const int f = (65535 * 32768 + s->maxval / 2) / s->maxval;
unsigned int j, v;
n = avctx->width * 2;
ptr = p->data[0];
linesize = p->linesize[0];
if (s->bytestream + n * avctx->height * 3 / 2 > s->bytestream_end)
return AVERROR_INVALIDDATA;
for (i = 0; i < avctx->height; i++) {
for (j = 0; j < n / 2; j++) {
v = av_be2ne16(((uint16_t *)s->bytestream)[j]);
((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
}
s->bytestream += n;
ptr += linesize;
}
ptr1 = (uint16_t*)p->data[1];
ptr2 = (uint16_t*)p->data[2];
n >>= 1;
h = avctx->height >> 1;
for (i = 0; i < h; i++) {
for (j = 0; j < n / 2; j++) {
v = av_be2ne16(((uint16_t *)s->bytestream)[j]);
ptr1[j] = (v * f + 16384) >> 15;
}
s->bytestream += n;
for (j = 0; j < n / 2; j++) {
v = av_be2ne16(((uint16_t *)s->bytestream)[j]);
ptr2[j] = (v * f + 16384) >> 15;
}
s->bytestream += n;
ptr1 += p->linesize[1] / 2;
ptr2 += p->linesize[2] / 2;
}
}
break;
}
*got_frame = 1;
return s->bytestream - s->bytestream_start;
}
| 1threat
|
How to have a external JSON config file in react jsx : <p>I want to have a external configuration file (JSON) in my React based project. That is the ultimate outcome or when I deliver it (public folder and the bundle.js) my configuration file also should be given. The User should be able to change the configurations according to his or her wish and use my app. That is there without recompiling my code one should be able to use it. In other words configuration file should not bundle with my app.</p>
| 0debug
|
static av_cold int bmp_encode_close(AVCodecContext *avctx)
{
av_frame_free(&avctx->coded_frame);
return 0;
}
| 1threat
|
def count_first_elements(test_tup):
for count, ele in enumerate(test_tup):
if isinstance(ele, tuple):
break
return (count)
| 0debug
|
Split Access database in separat files : I want to export each table of one database in separt accdb-files and I don't get it.
With the following code -> https://www.devhut.net/2012/09/27/ms-access-vba-export-database-objects-to-another-database/ the destination database must already exist.
How can I create e.g. for table1 the file table1.accdb and export only one table in to this database. If the main database has 10 table 10 files should be created and the belonging table should exported as well.
| 0debug
|
Spark SQL: How to consume json data from a REST service as DataFrame : <p>I need to read some JSON data from a web service thats providing REST interfaces to query the data from my SPARK SQL code for analysis. I am able to read a JSON stored in the blob store and use it.</p>
<p>I was wondering what is the best way to read the data from a REST service and use it like a any other <code>DataFrame</code>. </p>
<p>BTW I am using <code>SPARK 1.6 of Linux cluster on HD insight</code> if that helps. Also would appreciate if someone can share any code snippets for the same as I am still very new to SPARK environment.</p>
| 0debug
|
BlockAIOCB *thread_pool_submit_aio(ThreadPool *pool,
ThreadPoolFunc *func, void *arg,
BlockCompletionFunc *cb, void *opaque)
{
ThreadPoolElement *req;
req = qemu_aio_get(&thread_pool_aiocb_info, NULL, cb, opaque);
req->func = func;
req->arg = arg;
req->state = THREAD_QUEUED;
req->pool = pool;
QLIST_INSERT_HEAD(&pool->head, req, all);
trace_thread_pool_submit(pool, req, arg);
qemu_mutex_lock(&pool->lock);
if (pool->idle_threads == 0 && pool->cur_threads < pool->max_threads) {
spawn_thread(pool);
}
QTAILQ_INSERT_TAIL(&pool->request_list, req, reqs);
qemu_mutex_unlock(&pool->lock);
qemu_sem_post(&pool->sem);
return &req->common;
}
| 1threat
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
How to open and PDF or word document in the [Flutter] : <p>Question is simple, I would like to open any pdf or doc file via default App with using Flutter. </p>
<p>Think a Raised button that related my pdf asset, when user press it, pdf will be opened via Acrobat reader or etc. I don't want to use any web_view for it.</p>
<p>is it supported in Flutter?</p>
| 0debug
|
How to hide javascript with cryptography? : <p>I am looking for method to hide my plugin's javascript with complex obfuscator but i read everywhere that it is not possible to hide javascript completely.
I want to know that is there any way to hide java script with cryptography?
can any one make the algorithm which can be adopt by every web hosting like they have php , jommla, java, magneto etc in which we can encrypt our javascript with our own secret key and we add this key in our license manager in our hosting and on user side we can add license manager client in our applications which need to connect our server and get that key to run our application.</p>
| 0debug
|
How do you mock typeorm's getManager using testdouble? : <p>When creating unit tests for <a href="https://github.com/typeorm/typeorm" rel="noreferrer">typeorm</a>, I want to mock my connection to the database so that I can run unit tests without actually ever connecting to the DB (a good thing!)</p>
<p>I see <a href="https://github.com/typeorm/typeorm/issues/171#issuecomment-347724850" rel="noreferrer">places</a> where people have mocked typeorm's repositories using <a href="https://github.com/testdouble/testdouble.js" rel="noreferrer">testdouble</a> (which I am also using), but I am trying to do this with <a href="https://github.com/typeorm/typeorm/blob/master/docs/working-with-entity-manager.md" rel="noreferrer">getManager</a> and am having an issue figuring out how to make it work.</p>
<p>Here's an example. I have a class that, in the constructor, creates an EntityManager by using getManager() for a connection called 'test':</p>
<pre><code>export class TestClass {
constructor() {
const test: EntityManager = getManager('test');
}
}
</code></pre>
<p>Now I want to test that I can simply create this class. Here's a sample (using mocha, chai, and testdouble):</p>
<pre><code>describe('data transformer tests', () => {
it('can create the test class', () => {
// somehow mock getManager here
const testClass: TestClass = new TestClass();
chai.expect(testClass, 'could not create TestClass').to.not.be.null;
});
});
</code></pre>
<p>When I try this, I get this error message from typeorm:</p>
<pre><code>ConnectionNotFoundError: Connection "test" was not found.
</code></pre>
<p>Here are some of the things I've tried to mock getManager:</p>
<pre><code>td.func(getManager)
</code></pre>
<p>same error as above.</p>
<pre><code>td.when(getManager).thenReturn(td.object('EntityMananger'));
</code></pre>
<p>gets the message:</p>
<pre><code>Error: testdouble.js - td.when - No test double invocation call detected for `when()`.
</code></pre>
<p>Any ideas what the magic sauce is here for mocking <code>getManager</code>?</p>
| 0debug
|
Logical negation in front of variable c++ : <p>I got this statement in a program.</p>
<p>I don't know what is the use of "!".</p>
<pre><code> while(ams && !ev);
</code></pre>
| 0debug
|
Convert a word document with different but grouped line responses to an excel/csv document? : I'm tried to convert ~4,000 user entries (ex. from a user database in MS word) to a workable excel/csv document. Each entry, if fully completed, would be in the following format:
State
Full Name
Email
Organization
Position
The entries I have are variations of the above format (meaning that not all the fields were entered). The 1st line is almost always the state, every entry has a full name, not all entries have emails, organization listed, or the position.
For instance the first page of data might look like the following (Each entry is separated by a blank line):
_________________________________________________________________
California
John Doe
johndoe@gmail.com
Jane Smith
janesmith@yahoo.com
Apple Inc.
Alabama
Mark Stein
markstein@hotmail.com
Yahoo Corporation
Data Manager
_______________________________________________________________________
How do I convert the following above entries (in microsoft word) to an excel doc/csv that would look like the following:
[Final Format in MS Excel][1]
[1]: https://i.stack.imgur.com/7IBAT.png
| 0debug
|
How is python assignment operator creating deep copy ? : a =2
b = a
b = 3
print (b,a)
3 2
I expect the value of "a" also to change to 3 , if b is only pointing to a's memory space and does not have it's own memory.
I am sure there is a very simple explanation which i am missing.
Thanks already!!
| 0debug
|
Passing sensitive information to cloud functions : <p>Is there an "official" solution for passing sensitive information, such as API keys, to Google Cloud Functions? In particular it would be nice to avoid passing this information as arguments to the function since it will be the same for every invocation. AWS Lambda has a <a href="http://docs.aws.amazon.com/lambda/latest/dg/tutorial-env_console.html" rel="noreferrer">built-in solution</a> using encrypted environment variables for this. Is there some similar approach for Google Cloud Functions?</p>
<p>I could imagine using a cloud storage bucket or cloud datastore for this, but that feels very manual.</p>
| 0debug
|
Apply a discount from second product with Woocommerce : <p>I simply need <strong>to add a 10% discount to every product in the cart starting from the second one.</strong> </p>
<p>I tried many discount plugins but none of them suits my customer's needs.</p>
<p>I.e. I need this scenario: </p>
<p><strong>Variable product 1</strong> - <em>€ 100</em>
<strong>Variable product 2</strong> - <em>€ 200</em>
<strong>Variable product 3</strong> - <em>€ 300</em></p>
<p><strong>Case 1</strong></p>
<p>User buys <strong>product 2</strong>
He pays <em>€ 100</em></p>
<p><strong>Case 2</strong> </p>
<p>User buys product 3
He pays € 300</p>
<p><strong>Case 3 (with discount)</strong></p>
<p>User buys <strong>product 3 and product 1</strong>
He pays <em>€ 390</em>
(10% discount <em>calculated on lowest price</em>)</p>
<p><strong>Case 4 (with discount)</strong></p>
<p>User buys <strong>product 3 and product 2</strong>
He pays <em>€ 480</em>
(10% discount <em>calculated on lowest price</em>)</p>
<p><strong>Case 5 (with discount)</strong>
User buys <strong>products 3,2,1</strong>
He pays <em>€ 570</em>
(10% discount <em>calculated on product 2 and 1</em>)</p>
<p>Is it possible to create such a system? </p>
<p>Thank you in advance.</p>
| 0debug
|
Minusing 3 characters from the end of a string in Java : <p>I have a string oCustomerOrderNumber which I am passing a value into iCustomerOrderNumber. I would like to remove the last 3 characters from this iCustomerOrderNumber but unable to get this to work. Error I get is that it does not like the -.</p>
<p>Code:</p>
<pre><code> oCustomerOrderNumber = iCustomerOrderNumber.trim() -
(iCustomerOrderNumber.length() -3);
</code></pre>
<p>Example. ICustomerOrderNumber is 1234567 I want oCustomerOrderNumber to be 1234.</p>
| 0debug
|
Pushing variables onto an array inside an object? : <p>I am trying to push data at the end of the student tags array which is in an object, I was wondering how I could do this? </p>
<pre><code>var tags = "2019 Student"
{
"first_name": "Thomas",
"last_name": "Lee",
"email": "tjhunt03@gmail.com",
"student_tags":
["2020 Student"]
}
</code></pre>
| 0debug
|
Parse error: syntax error, unexpected '$result' (T_VARIABLE) in C:\xampp\htdocs\login.php on line 6 : <p>My php code is</p>
<pre><code><?php
require "conn.php";
$user_name = "";
$user_pass = "";
$mysql_qry = "select * from logindetails where User_id like '$user_name' and
Password '$user_pass';"
$result = mysqli_query($conn ,$mysql_qry);
if(mysqli_num_rows($result) > 0){
echo "login success";
}
else{
echo "login not success";
}
?>
</code></pre>
<p>error is Parse error: syntax error, unexpected '$result' (T_VARIABLE) in C:\xampp\htdocs\login.php on line 6</p>
| 0debug
|
Show users presence status of cisco jabber in web page : I want to fetch the presence status of any users connected to Cisco jabber IM.
The status can be online,offline and away. Could any one tell me the api to achieve this.
Thanks in advance.
| 0debug
|
static int wav_write_header(AVFormatContext *s)
{
WAVContext *wav = s->priv_data;
AVIOContext *pb = s->pb;
int64_t fmt, fact;
ffio_wfourcc(pb, "RIFF");
avio_wl32(pb, 0);
ffio_wfourcc(pb, "WAVE");
fmt = ff_start_tag(pb, "fmt ");
if (ff_put_wav_header(pb, s->streams[0]->codec) < 0) {
av_log(s, AV_LOG_ERROR, "%s codec not supported in WAVE format\n",
s->streams[0]->codec->codec ? s->streams[0]->codec->codec->name : "NONE");
av_free(wav);
return -1;
}
ff_end_tag(pb, fmt);
if (s->streams[0]->codec->codec_tag != 0x01
&& s->pb->seekable) {
fact = ff_start_tag(pb, "fact");
avio_wl32(pb, 0);
ff_end_tag(pb, fact);
}
av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
wav->maxpts = wav->last_duration = 0;
wav->minpts = INT64_MAX;
wav->data = ff_start_tag(pb, "data");
avio_flush(pb);
return 0;
}
| 1threat
|
static void trace(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3,
uint64_t x4, uint64_t x5, uint64_t x6)
{
TraceRecord *rec = &trace_buf[trace_idx];
if (!trace_list[event].state) {
return;
}
rec->event = event;
rec->timestamp_ns = get_clock();
rec->x1 = x1;
rec->x2 = x2;
rec->x3 = x3;
rec->x4 = x4;
rec->x5 = x5;
rec->x6 = x6;
if (++trace_idx == TRACE_BUF_LEN) {
st_flush_trace_buffer();
}
}
| 1threat
|
How to loop each line in Scala : <p>I am a beginner to Scala and I want to loop through each line which I am reading as below:</p>
<pre><code>val data = sc.textFile("D:/Data.csv")
</code></pre>
<p>Data.csv is like below:</p>
<pre><code>1,462,0,NA,0,1,0,Friday,1,5
1,147,33,NA,0,1,0,Friday,1,5
1,105,58,NA,0,1,0,Friday,1,5
1,276,96,NA,0,1,0,Friday,1,5
1,466,1,NA,0,1,0,Friday,1,5
1,466,1,NA,0,1,0,Friday,1,5
1,466,1,NA,0,1,0,Friday,1,5
</code></pre>
<p>I want to iterate through each line in the above csv and print the 1st and 3 rd column values in each row.Any help is appreciated.</p>
| 0debug
|
int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
int vnet_hdr_required, int mq_required)
{
struct ifreq ifr;
int fd, ret;
int len = sizeof(struct virtio_net_hdr);
TFR(fd = open(PATH_NET_TUN, O_RDWR));
if (fd < 0) {
error_report("could not open %s: %m", PATH_NET_TUN);
return -1;
}
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
if (*vnet_hdr) {
unsigned int features;
if (ioctl(fd, TUNGETFEATURES, &features) == 0 &&
features & IFF_VNET_HDR) {
*vnet_hdr = 1;
ifr.ifr_flags |= IFF_VNET_HDR;
} else {
*vnet_hdr = 0;
}
if (vnet_hdr_required && !*vnet_hdr) {
error_report("vnet_hdr=1 requested, but no kernel "
"support for IFF_VNET_HDR available");
close(fd);
return -1;
}
ioctl(fd, TUNSETVNETHDRSZ, &len);
}
if (mq_required) {
unsigned int features;
if ((ioctl(fd, TUNGETFEATURES, &features) != 0) ||
!(features & IFF_MULTI_QUEUE)) {
error_report("multiqueue required, but no kernel "
"support for IFF_MULTI_QUEUE available");
close(fd);
return -1;
} else {
ifr.ifr_flags |= IFF_MULTI_QUEUE;
}
}
if (ifname[0] != '\0')
pstrcpy(ifr.ifr_name, IFNAMSIZ, ifname);
else
pstrcpy(ifr.ifr_name, IFNAMSIZ, "tap%d");
ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
if (ret != 0) {
if (ifname[0] != '\0') {
error_report("could not configure %s (%s): %m", PATH_NET_TUN, ifr.ifr_name);
} else {
error_report("could not configure %s: %m", PATH_NET_TUN);
}
close(fd);
return -1;
}
pstrcpy(ifname, ifname_size, ifr.ifr_name);
fcntl(fd, F_SETFL, O_NONBLOCK);
return fd;
}
| 1threat
|
static int http_read(URLContext *h, uint8_t *buf, int size)
{
HTTPContext *s = h->priv_data;
int size1, len;
size1 = size;
while (size > 0) {
len = s->buf_end - s->buf_ptr;
if (len > 0) {
if (len > size)
len = size;
memcpy(buf, s->buf_ptr, len);
s->buf_ptr += len;
} else {
len = url_read (s->hd, buf, size);
if (len < 0) {
return len;
} else if (len == 0) {
break;
}
}
size -= len;
buf += len;
}
return size1 - size;
}
| 1threat
|
highest card wins is my program and now i want to compare cards : I am using Android studio for my highest card wins Game. I have three java classes called Cards, Deck, Gamelogic. everything is going good so far but i am just having a little trouble starting a function for my comparing cards method. this is what i have so far ...
import android.graphics.Color;
/**
* Created by azib2 on 12/1/2016.
*/
enum Suite {
Heart, diamond, spades, clubs;
public String toString()
{
switch (this) {
case Heart:
return "Heart";
case diamond:
return "diamond";
case spades:
return "spades";
case clubs:
return "clubs";
default:
return "Wrong type";
}
}
public String symbol(){
switch (this) {
case Heart:
return "\u2764";
case diamond:
return "\u2666";
case spades:
return "\u2660";
case clubs:
return "\u2663";
default:
return "Wrong type";
}
}
public int colors() {
switch (this) {
case Heart:
case diamond:
return Color.RED;
case spades:
case clubs:
return Color.BLACK;
}
return 0;
}
}
public class Cards {
private int cardnum;
private Suite suitetype;
public Cards(int cardnum, Suite suitetype){
this.cardnum = cardnum;
this.suitetype = suitetype;
}
public String CardType(int num){
switch(num){
case 1: return "A";
case 2: return "2";
case 3 : return"3";
case 4: return "4";
case 5: return "5";
case 6: return "6";
case 7: return "7";
case 8: return "8";
case 9: return "9";
case 10: return "10";
case 11: return "J";
case 12: return "Q";
case 13: return "K";
default: return " error invaild ";
}
}
public void CompareCards(){
}
public int Getcardnum (){
return cardnum;
}
public Suite getsuite(){
return suitetype;
}
}
What should i do to compare cards ????
| 0debug
|
can we use XAMPP for AWS-EC2 as a database : Can we use localhost for Amazon Web Service (Elastic cloud computing) as a database? Because i cannot able to buy a database service from amazon so i need a alternative way
I hosted a website in Amazon Web Service (Elastic cloud computing) now i'm going to try out some features which using the database can i make localhost as a database and connect it with my website it will work?
The data that are all enter in the remote user side can store in the database
| 0debug
|
static inline void set_bit(uint32_t *field, int bit)
{
field[bit >> 5] |= 1 << (bit & 0x1F);
}
| 1threat
|
Android Auto Google Play Rejection : <p>Google keeps rejecting my app for the following reason:
"During review, we found that if audio is playing on the device while plugging into the Android Auto experience, the music continues to play through the car speakers without user intent. We see this as a driver distraction, and isn't appropriate for Android Auto apps."</p>
<p>I thought I had taken the appropriate steps to resolve this by following the documentation from here: <a href="https://developer.android.com/training/auto/audio/index.html#isconnected">https://developer.android.com/training/auto/audio/index.html#isconnected</a></p>
<p>However, they rejected me again for the same reason.</p>
<p>In my MediaBrowserServiceCompat StreamService class, I've added the following code:</p>
<pre><code>private IntentFilter androidAutoConnectionIntentFilter = new IntentFilter("com.google.android.gms.car.media.STATUS");
private AndroidAutoConnectionStatusReceiver androidAutoConnectionStatusReceiver = new AndroidAutoConnectionStatusReceiver();
</code></pre>
<p>In the onCreate(), I've added:</p>
<pre><code>registerReceiver(androidAutoConnectionStatusReceiver, androidAutoConnectionIntentFilter);
</code></pre>
<p>and added this class to the service as well:</p>
<pre><code>private class AndroidAutoConnectionStatusReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
System.out.println("*** ANDROID AUTO CONNECTED: " + intent);
String status = intent.getStringExtra("media_connection_status");
boolean isConnectedToCar = "media_connected".equals(status);
if (isConnectedToCar) {
// android auto connected so stop playback
Intent stopIntent = new Intent(context, StreamService.class);
stopIntent.setAction(StreamService.ACTION_PLAYER_STOP);
context.startService(stopIntent);
}
}
}
</code></pre>
<p>Any idea how I can update my app to resolve this rejection?</p>
| 0debug
|
new to php and at a roadblock on this question : <p>Write a small program to calculate all the word frequency in the any given link, and print the result with frequency sort by alphabet.</p>
<p>For example, a link has an article like this: "what makes a developer bad, what makes a them good," the result should be:
a 1
bad 1
developer 1
good 1
makes 2
them 1
what 2</p>
<p>New to php and at a roadblock. What i have so far:</p>
<pre><code><h2>PHP Form Validation Example</h2>
<p><span class="error">* required field</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Name: <input type="text" name="name" value="<?php echo $name;?>">
<span class="error">* <?php echo $nameErr;?></span>
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
// define variables and set to empty values
$nameErr = "";
$name = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["name"]);
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<?php
echo("$name");
?>
</code></pre>
| 0debug
|
Learn to manipulate the DOM using JavaScript : <p>I am currently attempting to get into Web Development. I would like to be a Full Stack Developer. I had knowledge of HTML/CSS from 5 years ago but I recently did a refresh on <a href="http://codecademy.com" rel="nofollow">Codecademy</a>. I also completed the JavaScript course but that only teaches you the basic building blocks that are needed. I decided to start reading a series of books called <em><a href="https://github.com/getify/You-Dont-Know-JS" rel="nofollow">You Don't Know JS</a></em> on GitHub. My question is, should I read the entire series to be able to learn how to work with DOM or should basic knowledge be enough to start going down that path? Thank you!</p>
| 0debug
|
int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
{
int ret = 0;
if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) {
AVIOContext pb;
RTSPState *rt = s->priv_data;
AVDictionary *opts = NULL;
int len = strlen(p) * 6 / 8;
char *buf = av_mallocz(len);
av_base64_decode(buf, p, len);
if (rtp_asf_fix_header(buf, len) < 0)
av_log(s, AV_LOG_ERROR,
"Failed to fix invalid RTSP-MS/ASF min_pktsize\n");
init_packetizer(&pb, buf, len);
if (rt->asf_ctx) {
avformat_close_input(&rt->asf_ctx);
}
if (!(rt->asf_ctx = avformat_alloc_context()))
return AVERROR(ENOMEM);
rt->asf_ctx->pb = &pb;
av_dict_set(&opts, "no_resync_search", "1", 0);
ret = avformat_open_input(&rt->asf_ctx, "", &ff_asf_demuxer, &opts);
av_dict_free(&opts);
if (ret < 0)
return ret;
av_dict_copy(&s->metadata, rt->asf_ctx->metadata, 0);
rt->asf_pb_pos = avio_tell(&pb);
av_free(buf);
rt->asf_ctx->pb = NULL;
}
return ret;
}
| 1threat
|
Jquery or javascript auto click automatically : <p>I need to Code auto mouse click automatically
action after several seconds of entering the site without interference from me.</p>
| 0debug
|
Could not find manifest-merger.jar (com.android.tools.build:manifest-merger:26.1.2) error after gradle 4.4 upgrade : <p>After updrading to gradle 4.4:</p>
<p><em>gradle-wrapper.properties</em></p>
<pre><code>distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
</code></pre>
<p>Android project compilation fails with the following error:</p>
<pre><code>Could not find manifest-merger.jar (com.android.tools.build:manifest-merger:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/manifest-merger/26.1.2/manifest-merger-26.1.2.jar
</code></pre>
| 0debug
|
How to make items hover in recylerview? : [![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/4Eagy.png
This is my app...in this i want that when i click on any of the cardview the background should blur and 3 buttons should appear on selected one over the blur appearance and when the user clicks any one of buttons the user gets to new activity.
Help me to get Started. Thank you
| 0debug
|
Notepad ++ some weird regex : <p>I want to remove a few things in a text file, but it would be waaay too much work to do it manually, i think im in need of a regex</p>
<p>Myname:Wow11:myemail@bsomeemail.com:2017-02-11:TT:D:none:John Doe</p>
<p>I want to remove everything except Wow11:myemail@someemail.com</p>
<p>How would that be possible ? thank you very much</p>
| 0debug
|
How i get groups of Datetimes by interval : i want to cluster the list of dateTimes in the groups.
every times that are near each other in interval of 30 sec for ins.
12:00:05,
12:00:10,
12:00:15,
12:30:15,
12:30:25
MainBookmarksList.Add(dt1);
MainBookmarksList.Add(dt2);
MainBookmarksList.Add(dt3);
MainBookmarksList.Add(dt4);
MainBookmarksList.Add(dt5);
i have a list of the times- MainBookmarksList
now i expect to have a groups like this
12:00:05,
12:00:10,
12:00:15,
********
12:30:15,
12:30:25
thanks in advance
i tried this :
TimeSpan interval = new TimeSpan(0, 0, 15);
var groupedTimes = from dt in MainBookmarksList
group dt by dt.Ticks / interval.Ticks
into g
select new { Begin = new DateTime(g.Key * interval.Ticks), Values = g.ToList() };
not what i needed
| 0debug
|
What is the TypeScript return type of a React stateless component? : <p>What would the return type be here?</p>
<pre><code>const Foo
: () => // ???
= () => (
<div>
Foobar
</div>
)
</code></pre>
| 0debug
|
Why do always must to read the last element we write with C unions? : I'm reading some slides on `enum`s and `unions`, and one slide says:
> You must always read the last element you write.
and then there's the following code:
union Value {
int int_value;
float float_value;
char *str_value;
};
int main(int argc, char *argv[]) {
union Value v;
v.str_value = "ciao";
v.int_value = 100;
printf("v = %s\n", v.str_value); /* undefined behavior! */
}
What does it mean that we have always to read the last element we write? Why accessing the field `str_value` of the union `v` is undefined behaviour?
| 0debug
|
AWS SAM - Failed to create the changeset: Waiter ChangeSetCreateComplete failed : <p>AWS SAM deploying codebase to AWS cloud using aws-sam-cli but it throw me below error.</p>
<p><code>Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Requires capabilities : [CAPABILITY_IAM]</code></p>
| 0debug
|
void aio_notify_accept(AioContext *ctx)
{
if (atomic_xchg(&ctx->notified, false)) {
event_notifier_test_and_clear(&ctx->notifier);
}
}
| 1threat
|
lookup_scalar(const OptsVisitor *ov, const char *name, Error **errp)
{
if (ov->repeated_opts == NULL) {
GQueue *list;
list = lookup_distinct(ov, name, errp);
return list ? g_queue_peek_tail(list) : NULL;
}
return g_queue_peek_head(ov->repeated_opts);
}
| 1threat
|
uint32_t helper_efdctui (uint64_t val)
{
CPU_DoubleU u;
u.ll = val;
if (unlikely(float64_is_nan(u.d)))
return 0;
return float64_to_uint32(u.d, &env->vec_status);
}
| 1threat
|
void ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
{
MpegEncContext * const s = &h->s;
MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
int mmco_index = 0, i;
assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
if (h->short_ref_count &&
h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&
!(FIELD_PICTURE && !s->first_field &&
s->current_picture_ptr->f.reference)) {
mmco[0].opcode = MMCO_SHORT2UNUSED;
mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;
mmco_index = 1;
if (FIELD_PICTURE) {
mmco[0].short_pic_num *= 2;
mmco[1].opcode = MMCO_SHORT2UNUSED;
mmco[1].short_pic_num = mmco[0].short_pic_num + 1;
mmco_index = 2;
}
}
if (first_slice) {
h->mmco_index = mmco_index;
} else if (!first_slice && mmco_index >= 0 &&
(mmco_index != h->mmco_index ||
(i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {
av_log(h->s.avctx, AV_LOG_ERROR,
"Inconsistent MMCO state between slices [%d, %d, %d]\n",
mmco_index, h->mmco_index, i);
return AVERROR_INVALIDDATA;
}
}
| 1threat
|
Chrome memory issue - File API + AngularJS : <p>I have a web app that needs to upload large files to Azure BLOB storage. My solution uses HTML5 File API to slice into chunks which are then put as blob blocks, the IDs of the blocks are stored in an array and then the blocks are committed as a blob. </p>
<p>The solution works fine in IE. On 64 bit Chrome I have successfully uploaded 4Gb files but see very heavy memory usage (2Gb+). On 32 bit Chrome the specific chrome process will get to around 500-550Mb and then crash.</p>
<p>I can't see any obvious memory leaks or things I can change to help garbage collection. I store the block IDs in an array so obviously there will be some memory creeep but this shouldn't be massive. It's almost as if the File API is holding the whole file it slices into memory.</p>
<p>It's written as an Angular service called from a controller, I think just the service code is pertinent:</p>
<pre><code>(function() {
'use strict';
angular
.module('app.core')
.factory('blobUploadService',
[
'$http', 'stringUtilities',
blobUploadService
]);
function blobUploadService($http, stringUtilities) {
var defaultBlockSize = 1024 * 1024; // Default to 1024KB
var stopWatch = {};
var state = {};
var initializeState = function(config) {
var blockSize = defaultBlockSize;
if (config.blockSize) blockSize = config.blockSize;
var maxBlockSize = blockSize;
var numberOfBlocks = 1;
var file = config.file;
var fileSize = file.size;
if (fileSize < blockSize) {
maxBlockSize = fileSize;
}
if (fileSize % maxBlockSize === 0) {
numberOfBlocks = fileSize / maxBlockSize;
} else {
numberOfBlocks = parseInt(fileSize / maxBlockSize, 10) + 1;
}
return {
maxBlockSize: maxBlockSize,
numberOfBlocks: numberOfBlocks,
totalBytesRemaining: fileSize,
currentFilePointer: 0,
blockIds: new Array(),
blockIdPrefix: 'block-',
bytesUploaded: 0,
submitUri: null,
file: file,
baseUrl: config.baseUrl,
sasToken: config.sasToken,
fileUrl: config.baseUrl + config.sasToken,
progress: config.progress,
complete: config.complete,
error: config.error,
cancelled: false
};
};
/* config: {
baseUrl: // baseUrl for blob file uri (i.e. http://<accountName>.blob.core.windows.net/<container>/<blobname>),
sasToken: // Shared access signature querystring key/value prefixed with ?,
file: // File object using the HTML5 File API,
progress: // progress callback function,
complete: // complete callback function,
error: // error callback function,
blockSize: // Use this to override the defaultBlockSize
} */
var upload = function(config) {
state = initializeState(config);
var reader = new FileReader();
reader.onloadend = function(evt) {
if (evt.target.readyState === FileReader.DONE && !state.cancelled) { // DONE === 2
var uri = state.fileUrl + '&comp=block&blockid=' + state.blockIds[state.blockIds.length - 1];
var requestData = new Uint8Array(evt.target.result);
$http.put(uri,
requestData,
{
headers: {
'x-ms-blob-type': 'BlockBlob',
'Content-Type': state.file.type
},
transformRequest: []
})
.success(function(data, status, headers, config) {
state.bytesUploaded += requestData.length;
var percentComplete = ((parseFloat(state.bytesUploaded) / parseFloat(state.file.size)) * 100
).toFixed(2);
if (state.progress) state.progress(percentComplete, data, status, headers, config);
uploadFileInBlocks(reader, state);
})
.error(function(data, status, headers, config) {
if (state.error) state.error(data, status, headers, config);
});
}
};
uploadFileInBlocks(reader, state);
return {
cancel: function() {
state.cancelled = true;
}
};
};
function cancel() {
stopWatch = {};
state.cancelled = true;
return true;
}
function startStopWatch(handle) {
if (stopWatch[handle] === undefined) {
stopWatch[handle] = {};
stopWatch[handle].start = Date.now();
}
}
function stopStopWatch(handle) {
stopWatch[handle].stop = Date.now();
var duration = stopWatch[handle].stop - stopWatch[handle].start;
delete stopWatch[handle];
return duration;
}
var commitBlockList = function(state) {
var uri = state.fileUrl + '&comp=blocklist';
var requestBody = '<?xml version="1.0" encoding="utf-8"?><BlockList>';
for (var i = 0; i < state.blockIds.length; i++) {
requestBody += '<Latest>' + state.blockIds[i] + '</Latest>';
}
requestBody += '</BlockList>';
$http.put(uri,
requestBody,
{
headers: {
'x-ms-blob-content-type': state.file.type
}
})
.success(function(data, status, headers, config) {
if (state.complete) state.complete(data, status, headers, config);
})
.error(function(data, status, headers, config) {
if (state.error) state.error(data, status, headers, config);
// called asynchronously if an error occurs
// or server returns response with an error status.
});
};
var uploadFileInBlocks = function(reader, state) {
if (!state.cancelled) {
if (state.totalBytesRemaining > 0) {
var fileContent = state.file.slice(state.currentFilePointer,
state.currentFilePointer + state.maxBlockSize);
var blockId = state.blockIdPrefix + stringUtilities.pad(state.blockIds.length, 6);
state.blockIds.push(btoa(blockId));
reader.readAsArrayBuffer(fileContent);
state.currentFilePointer += state.maxBlockSize;
state.totalBytesRemaining -= state.maxBlockSize;
if (state.totalBytesRemaining < state.maxBlockSize) {
state.maxBlockSize = state.totalBytesRemaining;
}
} else {
commitBlockList(state);
}
}
};
return {
upload: upload,
cancel: cancel,
startStopWatch: startStopWatch,
stopStopWatch: stopStopWatch
};
};
})();
</code></pre>
<p>Are there any ways I can move the scope of objects to help with Chrome GC? I have seen other people mentioning similar issues but understood Chromium had resolved some.</p>
<p>I should say my solution is heavily based on Gaurav Mantri's blog post here:</p>
<p><a href="http://gauravmantri.com/2013/02/16/uploading-large-files-in-windows-azure-blob-storage-using-shared-access-signature-html-and-javascript/#comment-47480" rel="noreferrer">http://gauravmantri.com/2013/02/16/uploading-large-files-in-windows-azure-blob-storage-using-shared-access-signature-html-and-javascript/#comment-47480</a></p>
| 0debug
|
static int local_post_create_passthrough(FsContext *fs_ctx, const char *path,
FsCred *credp)
{
if (chmod(rpath(fs_ctx, path), credp->fc_mode & 07777) < 0) {
return -1;
}
if (chown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid) < 0) {
return -1;
}
return 0;
}
| 1threat
|
Same STL files with different compilers : <p>There are two binary files obtained from the same source file: one compiled with clang++-3.6 and the other one with g++-4.8. In a call to a function from the stl (std::unique, in particular) gdb brings me to the same file: /usr/include/c++/4.8/bits/stl_algo.h.</p>
<p>I expected that the implementations would be different for each compiler though. Do clang and gcc share parts of their C++ implementations?</p>
| 0debug
|
void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3)
{
uint64_t addr = env->regs[r1];
uint64_t subcode = env->regs[r3];
IplParameterBlock *iplb;
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, ILEN_LATER_INC);
return;
}
if ((subcode & ~0x0ffffULL) || (subcode > 6)) {
program_interrupt(env, PGM_SPECIFICATION, ILEN_LATER_INC);
return;
}
switch (subcode) {
case 0:
modified_clear_reset(s390_env_get_cpu(env));
if (tcg_enabled()) {
cpu_loop_exit(CPU(s390_env_get_cpu(env)));
}
break;
case 1:
load_normal_reset(s390_env_get_cpu(env));
if (tcg_enabled()) {
cpu_loop_exit(CPU(s390_env_get_cpu(env)));
}
break;
case 3:
s390_reipl_request();
if (tcg_enabled()) {
cpu_loop_exit(CPU(s390_env_get_cpu(env)));
}
break;
case 5:
if ((r1 & 1) || (addr & 0x0fffULL)) {
program_interrupt(env, PGM_SPECIFICATION, ILEN_LATER_INC);
return;
}
if (!address_space_access_valid(&address_space_memory, addr,
sizeof(IplParameterBlock), false)) {
program_interrupt(env, PGM_ADDRESSING, ILEN_LATER_INC);
return;
}
iplb = g_malloc0(sizeof(IplParameterBlock));
cpu_physical_memory_read(addr, iplb, sizeof(iplb->len));
if (!iplb_valid_len(iplb)) {
env->regs[r1 + 1] = DIAG_308_RC_INVALID;
goto out;
}
cpu_physical_memory_read(addr, iplb, be32_to_cpu(iplb->len));
if (!iplb_valid_ccw(iplb) && !iplb_valid_fcp(iplb)) {
env->regs[r1 + 1] = DIAG_308_RC_INVALID;
goto out;
}
s390_ipl_update_diag308(iplb);
env->regs[r1 + 1] = DIAG_308_RC_OK;
out:
g_free(iplb);
return;
case 6:
if ((r1 & 1) || (addr & 0x0fffULL)) {
program_interrupt(env, PGM_SPECIFICATION, ILEN_LATER_INC);
return;
}
if (!address_space_access_valid(&address_space_memory, addr,
sizeof(IplParameterBlock), true)) {
program_interrupt(env, PGM_ADDRESSING, ILEN_LATER_INC);
return;
}
iplb = s390_ipl_get_iplb();
if (iplb) {
cpu_physical_memory_write(addr, iplb, be32_to_cpu(iplb->len));
env->regs[r1 + 1] = DIAG_308_RC_OK;
} else {
env->regs[r1 + 1] = DIAG_308_RC_NO_CONF;
}
return;
default:
hw_error("Unhandled diag308 subcode %" PRIx64, subcode);
break;
}
}
| 1threat
|
Can I create AWS Quicksight dashboard programmatically? : <p>I want to create the dashboard dynamically using dynamic MySQL query. Is it possible?</p>
| 0debug
|
OpenCV not working properly with python on Linux with anaconda. Getting error that cv2.imshow() is not implemented : <p>This is the exact error that I am getting. My OS is Ubuntu 16.10.</p>
<p><strong>OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /feedstock_root/build_artefacts/work/opencv-3.1.0/modules/highgui/src/window.cpp, line 545
Traceback (most recent call last):
File "untitled.py", line 7, in
cv2.imshow('image',img)
cv2.error: /feedstock_root/build_artefacts/work/opencv-3.1.0/modules/highgui/src/window.cpp:545: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage</strong></p>
<p>my code is:</p>
<pre><code>import numpy as np
import cv2
# Load an color image in grayscale
img = cv2.imread('0002.png',0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
</code></pre>
<p>0002.png is an image in the same directory as the program.
I first installed anaconda with python 3.5, then I installed opencv by using the command </p>
<pre><code>conda install -c conda-forge opencv
</code></pre>
<p>I installed libgtk2.0-dev just as the error said to but I still get the same error.
Any help would be much appreciated. I've been trying to solve this for several hours.</p>
| 0debug
|
static void phys_sections_clear(void)
{
phys_sections_nb = 0;
}
| 1threat
|
License key generator using c# : in this line there is a some mistake want to know the correct line, "int value = km.LoadSuretyFile(string.Format(@"{0}key.lic", Application.StartupPath), ref lic);"
| 0debug
|
qcrypto_tls_creds_x509_init(Object *obj)
{
object_property_add_bool(obj, "loaded",
qcrypto_tls_creds_x509_prop_get_loaded,
qcrypto_tls_creds_x509_prop_set_loaded,
}
| 1threat
|
Combobox items does not display title in C# WPF MVVM : <p>I have main view model which contains:</p>
<pre><code>public class MainViewModel: INotifyPropertyChanged
{
public MainViewModel() { Categories = LoadCategories(); }
public ObservableCollection<CategoryViewModel> Categories {get;}
public FileData Data {get; set;}
}
public class FileData: INotifyPropertyChanged
{
public string Title {get {...} set {...}}
public CategoryViewModel Category {get {...} set{...}}
}
</code></pre>
<p>and</p>
<pre><code>public class CategoryViewModel
{
public string Title {get;set;}
public EMyEnum Value {get;set;}
}
</code></pre>
<p>and xaml:</p>
<pre><code><ComboBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Stretch" FontSize="16"
SelectedItem="{Binding Data.Category, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Categories}"
DisplayMemberPath="{Binding Title}"/>
</code></pre>
<p>Seems that dropdown list does not show <code>Title</code> value. In debug, the <code>Title</code> is populated and is not empty.</p>
<p>If I remove <code>DisplayMemberPath</code> then in list will display full namespace to <code>CategoryViewModel</code> class.</p>
<p>What can do here ? Where's my mistake ?</p>
| 0debug
|
static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
BdrvCheckMode fix, uint16_t **refcount_table,
int64_t *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
int64_t i;
QCowSnapshot *sn;
int ret;
if (!*refcount_table) {
*refcount_table = g_try_new0(uint16_t, *nb_clusters);
if (*nb_clusters && *refcount_table == NULL) {
res->check_errors++;
return -ENOMEM;
}
}
ret = inc_refcounts(bs, res, refcount_table, nb_clusters,
0, s->cluster_size);
if (ret < 0) {
return ret;
}
ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters,
s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO);
if (ret < 0) {
return ret;
}
for (i = 0; i < s->nb_snapshots; i++) {
sn = s->snapshots + i;
ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters,
sn->l1_table_offset, sn->l1_size, 0);
if (ret < 0) {
return ret;
}
}
ret = inc_refcounts(bs, res, refcount_table, nb_clusters,
s->snapshots_offset, s->snapshots_size);
if (ret < 0) {
return ret;
}
ret = inc_refcounts(bs, res, refcount_table, nb_clusters,
s->refcount_table_offset,
s->refcount_table_size * sizeof(uint64_t));
if (ret < 0) {
return ret;
}
return check_refblocks(bs, res, fix, refcount_table, nb_clusters);
}
| 1threat
|
In Navbar in bootstrap 4 hamburger menu is not working. : I have written the code in vs code editor but it is not working.
(https://i.stack.imgur.com/CayiJ.png)
| 0debug
|
static PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
{
int dom, bus;
unsigned slot;
if (!devaddr) {
*devfnp = -1;
return pci_find_bus(0);
}
if (pci_parse_devaddr(devaddr, &dom, &bus, &slot) < 0) {
return NULL;
}
*devfnp = slot << 3;
return pci_find_bus(bus);
}
| 1threat
|
How to build a comma separated array in python : <p>I have a list of user id's in a list in python
<code>['user1', 'user2' , 'user3',...]</code>
and i am trying to build an array from these list of user id's and then trying to pass this new array into a shell command in python. I am able to do all the other steps but i am stuck with this building an array thing. </p>
<p>I have tried this so far, </p>
<pre><code>my_list = ['user1', 'user2' , 'user3'
string = "user_id="
var = [string + x for x in my_list]
</code></pre>
<p>But what i actually need is something like this</p>
<pre><code>var = "(|(user_id=user1)(user_id=user2)(user_id=user3))"
</code></pre>
<p>and this list goes for many other values.
I am stuck here how to build this value <code>(user_id=user1)(user_id=user2)(user_id=user3)</code> in python.</p>
<p>Can anyone suggest some ideas?</p>
| 0debug
|
static void rtas_ibm_configure_pe(PowerPCCPU *cpu,
sPAPREnvironment *spapr,
uint32_t token, uint32_t nargs,
target_ulong args, uint32_t nret,
target_ulong rets)
{
sPAPRPHBState *sphb;
sPAPRPHBClass *spc;
uint64_t buid;
int ret;
if ((nargs != 3) || (nret != 1)) {
goto param_error_exit;
}
buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2);
sphb = find_phb(spapr, buid);
if (!sphb) {
goto param_error_exit;
}
spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb);
if (!spc->eeh_configure) {
goto param_error_exit;
}
ret = spc->eeh_configure(sphb);
rtas_st(rets, 0, ret);
return;
param_error_exit:
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
}
| 1threat
|
Django 1.11 TypeError context must be a dict rather than Context : <p>Just received the Sentry error <code>TypeError context must be a dict rather than Context.</code> on one of my forms. I know it has something to do with Django 1.11, but I am not sure what to change to fix it.</p>
<p><strong>Offending line</strong></p>
<p><code>message = get_template('email_forms/direct_donation_form_email.html').render(Context(ctx))</code></p>
<p><strong>Entire View</strong></p>
<pre><code>def donation_application(request):
if request.method == 'POST':
form = DirectDonationForm(data=request.POST)
if form.is_valid():
stripe.api_key = settings.STRIPE_SECRET_KEY
name = request.POST.get('name', '')
address = request.POST.get('address', '')
city = request.POST.get('city', '')
state = request.POST.get('state', '')
zip = request.POST.get('zip', '')
phone_number = request.POST.get('phone_number', '')
support = request.POST.get('support', '')
agree = request.POST.get('agree', '')
email_address = request.POST.get('email_address', '')
number = request.POST.get('number', '')
cvc = request.POST.get('cvc', '')
exp = request.POST.get('exp', '')
# token = form.cleaned_data['stripe_token'],
# exp_m = int(request.POST.get('exp_month', ''))
# exp_y = int(request.POST.get('exp_year', ''))
exp_month = exp[0:2]
exp_year = exp[5:9]
subject = 'New Donation'
from_email = settings.DEFAULT_FROM_EMAIL
recipient_list = ['deniselarkins@/////\\\\\.com',
'charles@/////\\\\\.net',
'marcmunic@/////\\\\\.com',
]
token = stripe.Token.create(
card={
'number': number,
'exp_month': exp_month,
'exp_year': exp_year,
'cvc': cvc
},
)
customer = stripe.Customer.create(
email=email_address,
source=token,
)
total_support = decimal.Decimal(support) / 100
total_charge = decimal.Decimal(int(support)) / 100
# Charge the user's card:
charge = stripe.Charge.create(
amount=total_charge,
currency='usd',
description='Donation',
customer=customer.id
)
ctx = {
'name': name,
'address': address,
'city': city,
'state': state,
'zip': zip,
'phone_number': phone_number,
'email_address': email_address,
'agree': agree,
'charge': charge,
'customer': customer,
'total_support': total_support,
'total_charge': total_charge
}
message = get_template('email_forms/direct_donation_form_email.html').render(Context(ctx))
msg = EmailMessage(subject, message, from_email=from_email, to=recipient_list)
msg.content_subtype = 'html'
msg.send(fail_silently=True)
return redirect(
'/contribute/donation-support-thank-you/?name=' + name +
'&address=' + address +
'&state=' + state +
'&city=' + city +
'&zip=' + zip +
'&phone_number=' + phone_number +
'&email_address=' + email_address +
'&total_support=' + str(total_support) +
'&total_charge=' + str(total_charge)
)
context = {
'title': 'Donation Pledge',
}
return render(request, 'contribute/_donation-application.html', context)
</code></pre>
| 0debug
|
How to get multiple instances of dictionaries with classes : <p>I have the following python code:</p>
<pre><code>class C:
b={}
c1=C()
c2=C()
c1.b[1]='s1'
c2.b[1]='s2'
print(c1.b[1])
</code></pre>
<p>I expected the output to be "s1" but it actually outputs "s2". Why and how can i get around this? Sorry i'm a complete newbie to python this is probably a trivial question....</p>
| 0debug
|
HOW TO CALL SAP CRYSTAL REPORT FROM C#.NET CLASS FILE : I am new to crystal report. I donno how to call existing crystal report from my c# class file. I have a method in class file with parameter string **CallCrystal(string num)**. and i have the crystal report in D: drive> Reports folder> **EmployeDetails** which displays the employe detail by passing string input.<br> Now inside the method the code should call crystal report and send this string parameter(num) to crystal report and the report should be printed with employee details.
| 0debug
|
Difference between UTC and GMT : <p>Hi i have few queries regarding the Time zones:</p>
<ol>
<li>Can the time be captured in UTC alone?</li>
<li>Is UTC -6 and GMT -6 the same, and does that mean it is US local time?</li>
<li>Say, I have UTC time as "02-01-2018 00:03" does that mean my US local time is "01-01-2018 18:00"?</li>
</ol>
<p>I have searched on Wikipedia and many related websites but haven't found a relevant explanation </p>
| 0debug
|
Replacing '(' with '-' in C++ : <p>I've tried:</p>
<pre><code>versionString = versionString.replace(versionString.begin(), versionString.end(), '(' , '-' );
</code></pre>
<p>The result is: "--------------". Basically replacing all the characters. What is that?</p>
<p>versionString is a basic string.</p>
| 0debug
|
Why is this code NOT returning false? : <p>Referencing this straightforward conversation:
<a href="https://stackoverflow.com/questions/31044/is-there-an-exists-function-for-jquery?rq=1">Is there an "exists" function for jQuery?</a></p>
<p>The following code is seeing a zero but still evaluating to 'true' for the first case. </p>
<p>Here is the console result:</p>
<blockquote>
<p>Found listView: 0 / 14</p>
</blockquote>
<p>The code is in a dialog window...so perhaps it might see the element on the underlying page. But the zero in the log says otherwise...</p>
<p>Really frustrating edge case (or I've just lost my mind). Help appreciated.</p>
<pre><code>if (('#listViewMenu').length) { // We are on taskpane list view
console.log('Found listView: ' + $('#listViewMenu').length + ' / ' + ('#tableViewMenu').length);
addList(); //hardcoded to list view only - auto load if there is an existing choice for Group
}
if (('#tableViewMenu').length) { // We are in dialog window table view
addTable();
}
</code></pre>
| 0debug
|
Multi-threading C# : I am finding it difficult to make the following code go any faster. Currently it takes a few hours to update :(
Some background information:
The code selects records from a local database, then updates 3 separate databases all on the same server. When updating the 3 other databases, it does them in single updates.
After updating the records in all 3 database, it them updates the local database with a fresh copy of the data.
It's basically updating prices, and saving the old price.
I tried implementing Multi-threading, but could not get it to work :(
Here is my code:
public string ExportPrices(bool _restorePrices = false)
{
System.IO.File.AppendAllText(System.Web.HttpContext.Current.Server.MapPath("~/Logs/PriceUpdateErrorList.txt"), "Error Messages" + Environment.NewLine);
var db = new UniStockContext();
//fetch all databases to export to
IList<AccDatabase> accDBCol = db.AccDatabases.Where(x => (x.Active == true) && (x.Deleted == false)).ToList();
//fetch all inventory list
IList<Domain.Tables.Inventory> inventoryDBCol = db.Inventories.Where(x => (x.Active == true) && (x.Deleted == false)).ToList();
if (inventoryDBCol.Count > 0)
{
//string xmlResult = "<InventoryExportResponse>";
//loop through databases and export
foreach (AccDatabase accDB in accDBCol)
{
//check database type and call appropriate accounting system method
if ((accDB.Type == AccDatabaseType.SageEvolution) && string.IsNullOrEmpty(accDB.EvolutionCommon))
{
//////////////////////////////////////////
//////////////Sage Evolution//////////////
//////////////////////////////////////////
foreach (AccDatabase accDB2 in accDBCol)
{
if ((accDB2.Type == AccDatabaseType.SageEvolution) && !string.IsNullOrEmpty(accDB2.EvolutionCommon))
{
//pass db and common db to export method for Sage Evolution
try
{
if (!string.IsNullOrEmpty(accDB.DBName))
{
inventoryDBCol = _sageInventory.ExportPrices(accDB, accDB2, inventoryDBCol, restorPrices: false);//this call updates 13000 records
}
}
catch (Exception exExportPrices)
{
System.IO.File.AppendAllText(System.Web.HttpContext.Current.Server.MapPath("~/Logs/_sageInventoryExportPricesCallError.txt"), exExportPrices.ToString());
}
break;
}
}
}
}
//end foreach
//return (xmlResult + "</InventoryExportResponse>");
}
UpdatePricesFromInventoryListBulk(_inventoryCollection);//this call will update 40000 records in local DB.
return "Stock prices synched to accounting system!";
}
public void UpdatePricesFromInventoryListBulk(IList<Domain.Tables.Inventory> invList)
{
var db = new UniStockContext();
db.Configuration.AutoDetectChangesEnabled = false;
foreach (var inventory in invList)
{
Domain.Tables.Inventory _inventory = db.Inventories
.Single(x => x.InventoryID == inventory.InventoryID);
if (inventory.Cost.HasValue)
_inventory.Cost = inventory.Cost.Value;
else
_inventory.Cost = 0;
foreach (var inventoryPrices in inventory.AccInventoryPrices)
{
foreach (var _inventoryPrices in _inventory.AccInventoryPrices)
{
if (_inventoryPrices.AccInventoryPriceID == inventoryPrices.AccInventoryPriceID)
{
_inventoryPrices.ApplyDiscount = inventoryPrices.ApplyDiscount;
_inventoryPrices.ApplyMarkup = inventoryPrices.ApplyMarkup;
if (inventoryPrices.Price.HasValue)
_inventoryPrices.Price = inventoryPrices.Price.Value;
else
_inventoryPrices.Price = _inventory.Cost;
if (inventoryPrices.OldPrice.HasValue)
{
_inventoryPrices.OldPrice = inventoryPrices.OldPrice;
}
}
}
}
db.Inventories.Attach(_inventory);
db.Entry(_inventory).State = System.Data.Entity.EntityState.Modified;
}
db.SaveChanges();
db.Dispose();
}
| 0debug
|
ow to create DOM model in IPHONE SDK : How to create DOM model in IPHONE SDK to update changes in html file.I am making a project so where i have html file to convert PDF format so first i am create html file and then programmatically update dynamic data in html file.
So how i'm use DOM model in objective c IOS to change HTMl file data.
| 0debug
|
how to make a tkinter program with a login input, an input panel, and a submit button : I have no idea that how to make a program in python the makes a login input, an input panel, and a submit button and saves to these variables:
e_id = #email id
pw = # password
sv = #the input
| 0debug
|
simple_form with Devise sign In : I'm working on a simple_form with devise, and I'm having a problem with the form submissions. If a user don't give email id and password while sign in then I have to display error message to user like "Email can't be blank" but it won't show any error messages it will remain on same sign in page with no errors. What can i do? I am using devise version "3.5.6" and simple_form version "3.2.1".
| 0debug
|
Why can't I open a tab with a html-button while being on the chrome web store? : <p>I have got a page in my frontend with different buttons, all buttons, on their own, work perfectly, but if I click the button that opens an extension in the chrome web store and click on another button afterwards, the page doesn't open.</p>
<p>Here is an exmaple of what I am talking about. If you click the buttons without closing the tabs that are opening, the button you click after the chrome web store opens won't have an effect.
Does anybody know why that is and how to work around that?</p>
<p><a href="https://html-ichr7r.stackblitz.io" rel="noreferrer">https://html-ichr7r.stackblitz.io</a></p>
<p>Here is the code for it.</p>
<pre><code><button id="button1" onclick="window.open('https://www.facebook.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button><br>
<button id="button2" onclick="window.open('https://www.google.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button>
<button id="button3" onclick="window.open('https://chrome.google.com/webstore/detail/dark-mode/dmghijelimhndkbmpgbldicpogfkceaj?hl=de','popup','width=700,height=300');"><strong>CONTINUAR</strong></button><br>
<button id="button4" onclick="window.open('https://www.9gag.com/','popup','width=700,height=300');"><strong>CONTINUAR</strong></button>
</code></pre>
<p>Any help is appreciated!</p>
<p><strong>EDIT</strong>: I just figured out that it works in firefox, still don't know why it doesn't work in Chrome though.</p>
| 0debug
|
Django channels and socket.io-client : <p>I'm trying to use them for the first time and wonder I'm headed to the right direction.</p>
<p>Here are my understandings, </p>
<p>socket.io is a wrapper around websocket, and falls back to sub-optimal solutions when websocket is not available.</p>
<p>Django channels can talk websocket as well.<br>
(I think it converts django as a message queue like system. although this understanding or misunderstanding should affect this question)</p>
<p>So I'm trying to use Django channels on the server and socket.io-client on the client.</p>
<p>socket.io has api which looks like </p>
<p><code>socket.on(type, (payload)=> {})</code></p>
<p>Whereas Django channels has a form of</p>
<p><code>message.reply_channel.send({
"text": json
})
</code></p>
<p>is the "text" <code>type</code> of <code>socket.on(type)</code>?</p>
<p>Can Django channels and socket.io-client talk to each other?</p>
| 0debug
|
static void pc_q35_init(QEMUMachineInitArgs *args)
{
ram_addr_t below_4g_mem_size, above_4g_mem_size;
Q35PCIHost *q35_host;
PCIHostState *phb;
PCIBus *host_bus;
PCIDevice *lpc;
BusState *idebus[MAX_SATA_PORTS];
ISADevice *rtc_state;
ISADevice *floppy;
MemoryRegion *pci_memory;
MemoryRegion *rom_memory;
MemoryRegion *ram_memory;
GSIState *gsi_state;
ISABus *isa_bus;
int pci_enabled = 1;
qemu_irq *cpu_irq;
qemu_irq *gsi;
qemu_irq *i8259;
int i;
ICH9LPCState *ich9_lpc;
PCIDevice *ahci;
DeviceState *icc_bridge;
PcGuestInfo *guest_info;
icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
object_property_add_child(qdev_get_machine(), "icc-bridge",
OBJECT(icc_bridge), NULL);
pc_cpus_init(args->cpu_model, icc_bridge);
pc_acpi_init("q35-acpi-dsdt.aml");
kvmclock_create();
if (args->ram_size >= 0xb0000000) {
above_4g_mem_size = args->ram_size - 0xb0000000;
below_4g_mem_size = 0xb0000000;
} else {
above_4g_mem_size = 0;
below_4g_mem_size = args->ram_size;
}
if (pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", INT64_MAX);
rom_memory = pci_memory;
} else {
pci_memory = NULL;
rom_memory = get_system_memory();
}
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
guest_info->has_pci_info = has_pci_info;
guest_info->isapc_ram_fw = false;
if (!xen_enabled()) {
pc_memory_init(get_system_memory(),
args->kernel_filename, args->kernel_cmdline,
args->initrd_filename,
below_4g_mem_size, above_4g_mem_size,
rom_memory, &ram_memory, guest_info);
}
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_irqchip_in_kernel()) {
kvm_pc_setup_irq_routing(pci_enabled);
gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
GSI_NUM_PINS);
} else {
gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}
q35_host = Q35_HOST_DEVICE(qdev_create(NULL, TYPE_Q35_HOST_DEVICE));
object_property_add_child(qdev_get_machine(), "q35", OBJECT(q35_host), NULL);
q35_host->mch.ram_memory = ram_memory;
q35_host->mch.pci_address_space = pci_memory;
q35_host->mch.system_memory = get_system_memory();
q35_host->mch.address_space_io = get_system_io();
q35_host->mch.below_4g_mem_size = below_4g_mem_size;
q35_host->mch.above_4g_mem_size = above_4g_mem_size;
q35_host->mch.guest_info = guest_info;
qdev_init_nofail(DEVICE(q35_host));
phb = PCI_HOST_BRIDGE(q35_host);
host_bus = phb->bus;
lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV,
ICH9_LPC_FUNC), true,
TYPE_ICH9_LPC_DEVICE);
ich9_lpc = ICH9_LPC_DEVICE(lpc);
ich9_lpc->pic = gsi;
ich9_lpc->ioapic = gsi_state->ioapic_irq;
pci_bus_irqs(host_bus, ich9_lpc_set_irq, ich9_lpc_map_irq, ich9_lpc,
ICH9_LPC_NB_PIRQS);
pci_bus_set_route_irq_fn(host_bus, ich9_route_intx_pin_to_irq);
isa_bus = ich9_lpc->isa_bus;
isa_bus_irqs(isa_bus, gsi);
if (kvm_irqchip_in_kernel()) {
i8259 = kvm_i8259_init(isa_bus);
} else if (xen_enabled()) {
i8259 = xen_interrupt_controller_init();
} else {
cpu_irq = pc_allocate_cpu_irq();
i8259 = i8259_init(isa_bus, cpu_irq[0]);
}
for (i = 0; i < ISA_NUM_IRQS; i++) {
gsi_state->i8259_irq[i] = i8259[i];
}
if (pci_enabled) {
ioapic_init_gsi(gsi_state, NULL);
}
qdev_init_nofail(icc_bridge);
pc_register_ferr_irq(gsi[13]);
pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, false);
ich9_lpc_pm_init(lpc);
ahci = pci_create_simple_multifunction(host_bus,
PCI_DEVFN(ICH9_SATA1_DEV,
ICH9_SATA1_FUNC),
true, "ich9-ahci");
idebus[0] = qdev_get_child_bus(&ahci->qdev, "ide.0");
idebus[1] = qdev_get_child_bus(&ahci->qdev, "ide.1");
if (usb_enabled(false)) {
ehci_create_ich9_with_companions(host_bus, 0x1d);
}
smbus_eeprom_init(ich9_smb_init(host_bus,
PCI_DEVFN(ICH9_SMB_DEV, ICH9_SMB_FUNC),
0xb100),
8, NULL, 0);
pc_cmos_init(below_4g_mem_size, above_4g_mem_size, args->boot_device,
floppy, idebus[0], idebus[1], rtc_state);
pc_vga_init(isa_bus, host_bus);
pc_nic_init(isa_bus, host_bus);
if (pci_enabled) {
pc_pci_device_init(host_bus);
}
if (has_pvpanic) {
pvpanic_init(isa_bus);
}
}
| 1threat
|
XCODE 11 Broke DateFormatter? : One day, the app worked. The next day I updated to Xcode 11 and now the app crashes with "unexpectedly found nil" on line 27 (when executing line 15) in the picture.
I asked my co-worker who doesn't yet have Xcode 11, and his doesn't crash. we are on the same branch/commit...everything.
Any advice? any way around this? my code should appear in that image link... need 10 rep to post images.
https://i.stack.imgur.com/103AU.png
[1]: https://i.stack.imgur.com/103AU.png
| 0debug
|
int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
AVPacket *avpkt,
const AVFrame *frame,
int *got_packet_ptr)
{
int ret;
int user_packet = !!avpkt->data;
*got_packet_ptr = 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);
if (!ret) {
if (!*got_packet_ptr)
avpkt->size = 0;
else if (!(avctx->codec->capabilities & CODEC_CAP_DELAY))
avpkt->pts = avpkt->dts = frame->pts;
if (!user_packet && avpkt->data) {
uint8_t *new_data = av_realloc(avpkt->data, avpkt->size);
if (new_data)
avpkt->data = new_data;
}
avctx->frame_number++;
}
if (ret < 0 || !*got_packet_ptr)
av_free_packet(avpkt);
emms_c();
return ret;
}
| 1threat
|
Android live data - observe always fires after config change : <p>I'm currently refactoring my code to include ViewModel with LiveData provided by android.arch library. I have a simple activity that sends request for a password change to server and acts according to HTTP response code. </p>
<p>For that purpose I have created class that extends ViewModel for data and a repository class to call server. My ViewModel class has one MutableLiveData field which I'm subscribing to from my activity using .observe(...) method. The issue is that code inside .observe(...) fires all the time after configuration changes (i.e. screen rotation) and I have no idea why.</p>
<p>Here is the code of ViewModel, Repository and Activity classes accordingly:</p>
<p>ChangePasswordViewModel</p>
<pre><code>public class ChangePasswordViewModel extends ViewModel{
private MutableLiveData<Integer> responseCode;
private PasswordChangeRepository passwordChangeRepository;
public ChangePasswordViewModel() {
responseCode = new MutableLiveData<>();
passwordChangeRepository = new PasswordChangeRepositoryImpl();
}
public MutableLiveData<Integer> responseCodeLiveData() {
return responseCode;
}
public void sendChangePasswordRequest(String newPassword){
passwordChangeRepository.changePassword(newPassword, passChangeCallback());
}
// Callback that fires after server sends a response
private Callback passChangeCallback(){
...
responseCode.postValue(serverResponse)
...
}
</code></pre>
<p>PasswordChangeRepository</p>
<pre><code>public class PasswordChangeRepositoryImpl {
public void changePassword(String newPassword, Callback<Void> callback){
//Sending new password to server and processing response in callback
ServerCalls.changePassword(newPassword, callback);
}
}
</code></pre>
<p>Activity</p>
<pre><code>public class ChangePasswordActivity extends AppCompatActivity{
...
private void init(){
//Getting appropriate view model
passwordViewModel = ViewModelProviders.of(this).get(ChangePasswordViewModel.class);
// Starting to observe LiveData
passwordViewModel.getResponseCode().observe(this, responseCode -> {
Log.info("Server response is " + responseCode);
});
//Sending new password to server
buttonPassChange.setOnClickListener(view ->
passwordViewModel.sendChangePasswordRequest("newPass")
);
}
...
}
</code></pre>
<p>Problem is that after the first time I send request to server using sendChangePasswordRequest(...) observe code in activity</p>
<pre><code>passwordViewModel.getResponseCode().observe(this, responseCode -> {
Log.info("Server response is " + responseCode);
});
</code></pre>
<p>fires every time after I rotate the screen. Why is that happening? Value of MutableLiveData responseCode hasn't been updated since the last server call, so why does .observe() fires if there were no changes to live data?</p>
| 0debug
|
Firebase Cloud Messaging AppDelegate Error : <p>This is code in the Firebase Docs.</p>
<pre><code>if #available(iOS 10.0, *) {
let authOptions : UNAuthorizationOptions = [.Alert, .Badge, .Sound]
UNUserNotificationCenter.currentNotificationCenter().requestAuthorizationWithOptions(
authOptions,
completionHandler: {_,_ in })
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.currentNotificationCenter().delegate = self
// For iOS 10 data message (sent via FCM)
FIRMessaging.messaging().remoteMessageDelegate = self
} else {
let settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
</code></pre>
<p>I didn't modified any line of code. But Xcode says "Use of undeclared type <code>UNAuthorizationOptions</code>, <code>UNUserNotificationCenter</code>, <code>FIRMessagingDelegate</code>"</p>
<p>and I have one more line.</p>
<pre><code>NotificationCenter.defaultCenter.addObserver(self,selector: #selector(self.tokenRefreshNotification),name: kFIRInstanceIDTokenRefreshNotification,object: nil)
</code></pre>
<p>It says "Value of Type AppDelegate has no member <code>tokenRefreshNotification</code>"</p>
<p>I just copied and pasted my code from firebase docs but there is error!</p>
| 0debug
|
Multiple checkboxes to variable logic : <p>I am looking to create a simple page using HTML and (probably) PHP or JQuery. The page should allow for multiple checkbox selection, and give a variable a value based on which boxes are checked. This can be on submit or can render live on the page. </p>
<p>i.e.
<br>Checkbox 1
<br>Checkbox 2
<br>Checkbox 3</p>
<p>If checkbox 1 is checked, variable = X
<br>If checkbox 1 & 2 are checked, variable = Y
<br>If no checkboxes are checked, variable = Z</p>
<p>What is the best way to approach doing this?</p>
| 0debug
|
static void ram_decompress_close(RamDecompressState *s)
{
inflateEnd(&s->zstream);
}
| 1threat
|
Missing write access in mac to /usr/local/lib/node_modules : <p>I am trying to install angular cli but it's show me Missing write access to /usr/local/lib/node_modules
so, how can I fix it in my mac i try it may time but, not getting exact answer </p>
<pre><code> npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
</code></pre>
| 0debug
|
How do I get a substring in C? : <p>For example if:</p>
<pre><code>z = "xxxx; yyyy";
</code></pre>
<p>How can I get the substrings so that</p>
<pre><code>x = "xxxx"
</code></pre>
<p>and</p>
<pre><code>y = "yyyy"
</code></pre>
<p>where "xxxx" and "yyyy" can be any string of any length?</p>
| 0debug
|
why we cannot perform this operation in vector : When we passing vector in function why we cant do it like an array for example.
#include<bits/stdc++.h>
using namespace std;
void func(vector<int> vect)
{
vect.push_back(30);
}
int main()
{
vector<int> vect;
vect.push_back(10);
vect.push_back(20);
func(vect);
for (int i=0; i<vect.size(); i++)
cout << vect[i] << " ";
return 0;
}
In this example, it works fine.
But if I do it like this why it doesn't work like array.
#include<bits/stdc++.h>
using namespace std;
void func(vector<int> *vect)
{
vect.push_back(30);
}
int main()
{
vector<int> vect;
vect.push_back(10);
vect.push_back(20);
func(&vect[0]);
for (int i=0; i<vect.size(); i++)
cout << vect[i] << " ";
return 0;
}
Just like array why this is not possible.
| 0debug
|
I have created a textbox in html how to get the ansers on that search? : Hi my question is how i put things into the code so if i search for it in the textbox it will show the results from for example wikipedia?
<head></head>
<body>
<form name="test">
<input type=" name=textie">
</form>
</body>
this is the code for the textbox. i use the programm brackets and if i run it it gives me a textbox. if i want to search for something it obviously gives me nothing. it just resets. how do i import the information from wikipedia so it will be shown if i search for it? its kind of like the coding challenge for the wikipedia API (Coding challenge #75) from the coding train.
Thank you very much!
| 0debug
|
static uint64_t mcf_intc_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
int offset;
mcf_intc_state *s = (mcf_intc_state *)opaque;
offset = addr & 0xff;
if (offset >= 0x40 && offset < 0x80) {
return s->icr[offset - 0x40];
}
switch (offset) {
case 0x00:
return (uint32_t)(s->ipr >> 32);
case 0x04:
return (uint32_t)s->ipr;
case 0x08:
return (uint32_t)(s->imr >> 32);
case 0x0c:
return (uint32_t)s->imr;
case 0x10:
return (uint32_t)(s->ifr >> 32);
case 0x14:
return (uint32_t)s->ifr;
case 0xe0:
return s->active_vector;
case 0xe1: case 0xe2: case 0xe3: case 0xe4:
case 0xe5: case 0xe6: case 0xe7:
hw_error("mcf_intc_read: LnIACK not implemented\n");
default:
return 0;
}
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.