problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void vc1_inv_trans_4x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
{
int i;
int dc = block[0];
const uint8_t *cm;
dc = (17 * dc + 4) >> 3;
dc = (12 * dc + 64) >> 7;
cm = ff_cropTbl + MAX_NEG_CROP + dc;
for(i = 0; i < 8; i++){
dest[0] = cm[dest[0]];
dest[1] = cm[dest[1]];
dest[2] = cm[dest[2]];
dest[3] = cm[dest[3]];
dest += linesize;
}
}
| 1threat
|
static void disas_ldst_reg_imm9(DisasContext *s, uint32_t insn,
int opc,
int size,
int rt,
bool is_vector)
{
int rn = extract32(insn, 5, 5);
int imm9 = sextract32(insn, 12, 9);
int idx = extract32(insn, 10, 2);
bool is_signed = false;
bool is_store = false;
bool is_extended = false;
bool is_unpriv = (idx == 2);
bool iss_valid = !is_vector;
bool post_index;
bool writeback;
TCGv_i64 tcg_addr;
if (is_vector) {
size |= (opc & 2) << 1;
if (size > 4 || is_unpriv) {
unallocated_encoding(s);
return;
}
is_store = ((opc & 1) == 0);
if (!fp_access_check(s)) {
return;
}
} else {
if (size == 3 && opc == 2) {
if (is_unpriv) {
unallocated_encoding(s);
return;
}
return;
}
if (opc == 3 && size > 1) {
unallocated_encoding(s);
return;
}
is_store = (opc == 0);
is_signed = extract32(opc, 1, 1);
is_extended = (size < 3) && extract32(opc, 0, 1);
}
switch (idx) {
case 0:
case 2:
post_index = false;
writeback = false;
break;
case 1:
post_index = true;
writeback = true;
break;
case 3:
post_index = false;
writeback = true;
break;
}
if (rn == 31) {
gen_check_sp_alignment(s);
}
tcg_addr = read_cpu_reg_sp(s, rn, 1);
if (!post_index) {
tcg_gen_addi_i64(tcg_addr, tcg_addr, imm9);
}
if (is_vector) {
if (is_store) {
do_fp_st(s, rt, tcg_addr, size);
} else {
do_fp_ld(s, rt, tcg_addr, size);
}
} else {
TCGv_i64 tcg_rt = cpu_reg(s, rt);
int memidx = is_unpriv ? get_a64_user_mem_index(s) : get_mem_index(s);
bool iss_sf = disas_ldst_compute_iss_sf(size, is_signed, opc);
if (is_store) {
do_gpr_st_memidx(s, tcg_rt, tcg_addr, size, memidx,
iss_valid, rt, iss_sf, false);
} else {
do_gpr_ld_memidx(s, tcg_rt, tcg_addr, size,
is_signed, is_extended, memidx,
iss_valid, rt, iss_sf, false);
}
}
if (writeback) {
TCGv_i64 tcg_rn = cpu_reg_sp(s, rn);
if (post_index) {
tcg_gen_addi_i64(tcg_addr, tcg_addr, imm9);
}
tcg_gen_mov_i64(tcg_rn, tcg_addr);
}
}
| 1threat
|
change opencart to woocommerce manually : <p>There's a client that ask me to import a database from opencart to a wordpress woocommerce website</p>
<p>I know there is an automated migration, but I would like to change it manually</p>
<p>So I thought of changing the opencart database to a csv file, then I just upload it to the wordpress woocommerce, is this method possible? if not, can someone tell me how to manually change from opencart database to woocommerce, thank you in advance</p>
| 0debug
|
static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts)
{
CharDriverState *chr;
WinStdioCharState *stdio;
DWORD dwMode;
int is_console = 0;
chr = g_malloc0(sizeof(CharDriverState));
stdio = g_malloc0(sizeof(WinStdioCharState));
stdio->hStdIn = GetStdHandle(STD_INPUT_HANDLE);
if (stdio->hStdIn == INVALID_HANDLE_VALUE) {
fprintf(stderr, "cannot open stdio: invalid handle\n");
exit(1);
}
is_console = GetConsoleMode(stdio->hStdIn, &dwMode) != 0;
chr->opaque = stdio;
chr->chr_write = win_stdio_write;
chr->chr_close = win_stdio_close;
if (is_console) {
if (qemu_add_wait_object(stdio->hStdIn,
win_stdio_wait_func, chr)) {
fprintf(stderr, "qemu_add_wait_object: failed\n");
}
} else {
DWORD dwId;
stdio->hInputReadyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
stdio->hInputDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
stdio->hInputThread = CreateThread(NULL, 0, win_stdio_thread,
chr, 0, &dwId);
if (stdio->hInputThread == INVALID_HANDLE_VALUE
|| stdio->hInputReadyEvent == INVALID_HANDLE_VALUE
|| stdio->hInputDoneEvent == INVALID_HANDLE_VALUE) {
fprintf(stderr, "cannot create stdio thread or event\n");
exit(1);
}
if (qemu_add_wait_object(stdio->hInputReadyEvent,
win_stdio_thread_wait_func, chr)) {
fprintf(stderr, "qemu_add_wait_object: failed\n");
}
}
dwMode |= ENABLE_LINE_INPUT;
if (is_console) {
dwMode |= ENABLE_PROCESSED_INPUT;
}
SetConsoleMode(stdio->hStdIn, dwMode);
chr->chr_set_echo = qemu_chr_set_echo_win_stdio;
qemu_chr_fe_set_echo(chr, false);
return chr;
}
| 1threat
|
Flutter: Is it somehow possible to create App Widgets (Android) and Today Extensions (iOS)? : <p>I took a look at flutter for building a mobile app. Is it possible to create <code>Widgets</code> (not flutter-widgets, but <code>App Widgets</code> (Android) and <code>Today Extensions</code> (iOS)) in a flutter app? I guess it can't be done with dart, but is there a way of implementing them native in Java/Swift and include them in the flutter-app?</p>
<p>Thanks!</p>
| 0debug
|
Android : Change layout dynamically in the MainActivity : I'm working on an Android app about mobile network. I can get the serving cell information. I display the information in a CardView but i have a different layout for the CardView for each technology (2G, 3G, 4G).
What i want to know is how should i code this?
Should i create 3 Fragments and update the MainActivity with the good fragment when the radio technology changes? Is there a cleaner way to do this? It feels like it will take a lot of files if i do it like this.
Thanks
| 0debug
|
static int showspectrumpic_request_frame(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
ShowSpectrumContext *s = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
int ret;
ret = ff_request_frame(inlink);
if (ret == AVERROR_EOF && s->outpicref) {
int samples = av_audio_fifo_size(s->fifo);
int consumed = 0;
int y, x = 0, sz = s->orientation == VERTICAL ? s->w : s->h;
int ch, spf, spb;
AVFrame *fin;
spf = s->win_size * (samples / ((s->win_size * sz) * ceil(samples / (float)(s->win_size * sz))));
spb = (samples / (spf * sz)) * spf;
fin = ff_get_audio_buffer(inlink, s->win_size);
if (!fin)
return AVERROR(ENOMEM);
while (x < sz) {
ret = av_audio_fifo_peek(s->fifo, (void **)fin->extended_data, s->win_size);
if (ret < 0) {
av_frame_free(&fin);
return ret;
}
av_audio_fifo_drain(s->fifo, spf);
if (ret < s->win_size) {
for (ch = 0; ch < s->nb_display_channels; ch++) {
memset(fin->extended_data[ch] + ret * sizeof(float), 0,
(s->win_size - ret) * sizeof(float));
}
}
ctx->internal->execute(ctx, run_channel_fft, fin, NULL, s->nb_display_channels);
acalc_magnitudes(s);
consumed += spf;
if (consumed >= spb) {
int h = s->orientation == VERTICAL ? s->h : s->w;
scale_magnitudes(s, 1. / (consumed / spf));
plot_spectrum_column(inlink, fin);
consumed = 0;
x++;
for (ch = 0; ch < s->nb_display_channels; ch++)
memset(s->magnitudes[ch], 0, h * sizeof(float));
}
}
av_frame_free(&fin);
s->outpicref->pts = 0;
if (s->legend) {
int multi = (s->mode == SEPARATE && s->color_mode == CHANNEL);
float spp = samples / (float)sz;
uint8_t *dst;
drawtext(s->outpicref, 2, outlink->h - 10, "CREATED BY LIBAVFILTER", 0);
dst = s->outpicref->data[0] + (s->start_y - 1) * s->outpicref->linesize[0] + s->start_x - 1;
for (x = 0; x < s->w + 1; x++)
dst[x] = 200;
dst = s->outpicref->data[0] + (s->start_y + s->h) * s->outpicref->linesize[0] + s->start_x - 1;
for (x = 0; x < s->w + 1; x++)
dst[x] = 200;
for (y = 0; y < s->h + 2; y++) {
dst = s->outpicref->data[0] + (y + s->start_y - 1) * s->outpicref->linesize[0];
dst[s->start_x - 1] = 200;
dst[s->start_x + s->w] = 200;
}
if (s->orientation == VERTICAL) {
int h = s->mode == SEPARATE ? s->h / s->nb_display_channels : s->h;
for (ch = 0; ch < (s->mode == SEPARATE ? s->nb_display_channels : 1); ch++) {
for (y = 0; y < h; y += 20) {
dst = s->outpicref->data[0] + (s->start_y + h * (ch + 1) - y - 1) * s->outpicref->linesize[0];
dst[s->start_x - 2] = 200;
dst[s->start_x + s->w + 1] = 200;
}
for (y = 0; y < h; y += 40) {
dst = s->outpicref->data[0] + (s->start_y + h * (ch + 1) - y - 1) * s->outpicref->linesize[0];
dst[s->start_x - 3] = 200;
dst[s->start_x + s->w + 2] = 200;
}
dst = s->outpicref->data[0] + (s->start_y - 2) * s->outpicref->linesize[0] + s->start_x;
for (x = 0; x < s->w; x+=40)
dst[x] = 200;
dst = s->outpicref->data[0] + (s->start_y - 3) * s->outpicref->linesize[0] + s->start_x;
for (x = 0; x < s->w; x+=80)
dst[x] = 200;
dst = s->outpicref->data[0] + (s->h + s->start_y + 1) * s->outpicref->linesize[0] + s->start_x;
for (x = 0; x < s->w; x+=40) {
dst[x] = 200;
}
dst = s->outpicref->data[0] + (s->h + s->start_y + 2) * s->outpicref->linesize[0] + s->start_x;
for (x = 0; x < s->w; x+=80) {
dst[x] = 200;
}
for (y = 0; y < h; y += 40) {
float hertz = y * (inlink->sample_rate / 2) / (float)(1 << (int)ceil(log2(h)));
char *units;
if (hertz == 0)
units = av_asprintf("DC");
else
units = av_asprintf("%.2f", hertz);
if (!units)
return AVERROR(ENOMEM);
drawtext(s->outpicref, s->start_x - 8 * strlen(units) - 4, h * (ch + 1) + s->start_y - y - 4, units, 0);
av_free(units);
}
}
for (x = 0; x < s->w; x+=80) {
float seconds = x * spp / inlink->sample_rate;
char *units;
if (x == 0)
units = av_asprintf("0");
else if (log10(seconds) > 6)
units = av_asprintf("%.2fh", seconds / (60 * 60));
else if (log10(seconds) > 3)
units = av_asprintf("%.2fm", seconds / 60);
else
units = av_asprintf("%.2fs", seconds);
if (!units)
return AVERROR(ENOMEM);
drawtext(s->outpicref, s->start_x + x - 4 * strlen(units), s->h + s->start_y + 6, units, 0);
drawtext(s->outpicref, s->start_x + x - 4 * strlen(units), s->start_y - 12, units, 0);
av_free(units);
}
drawtext(s->outpicref, outlink->w / 2 - 4 * 4, outlink->h - s->start_y / 2, "TIME", 0);
drawtext(s->outpicref, s->start_x / 7, outlink->h / 2 - 14 * 4, "FREQUENCY (Hz)", 1);
} else {
int w = s->mode == SEPARATE ? s->w / s->nb_display_channels : s->w;
for (y = 0; y < s->h; y += 20) {
dst = s->outpicref->data[0] + (s->start_y + y) * s->outpicref->linesize[0];
dst[s->start_x - 2] = 200;
dst[s->start_x + s->w + 1] = 200;
}
for (y = 0; y < s->h; y += 40) {
dst = s->outpicref->data[0] + (s->start_y + y) * s->outpicref->linesize[0];
dst[s->start_x - 3] = 200;
dst[s->start_x + s->w + 2] = 200;
}
for (ch = 0; ch < (s->mode == SEPARATE ? s->nb_display_channels : 1); ch++) {
dst = s->outpicref->data[0] + (s->start_y - 2) * s->outpicref->linesize[0] + s->start_x + w * ch;
for (x = 0; x < w; x+=40)
dst[x] = 200;
dst = s->outpicref->data[0] + (s->start_y - 3) * s->outpicref->linesize[0] + s->start_x + w * ch;
for (x = 0; x < w; x+=80)
dst[x] = 200;
dst = s->outpicref->data[0] + (s->h + s->start_y + 1) * s->outpicref->linesize[0] + s->start_x + w * ch;
for (x = 0; x < w; x+=40) {
dst[x] = 200;
}
dst = s->outpicref->data[0] + (s->h + s->start_y + 2) * s->outpicref->linesize[0] + s->start_x + w * ch;
for (x = 0; x < w; x+=80) {
dst[x] = 200;
}
for (x = 0; x < w; x += 80) {
float hertz = x * (inlink->sample_rate / 2) / (float)(1 << (int)ceil(log2(w)));
char *units;
if (hertz == 0)
units = av_asprintf("DC");
else
units = av_asprintf("%.2f", hertz);
if (!units)
return AVERROR(ENOMEM);
drawtext(s->outpicref, s->start_x - 4 * strlen(units) + x + w * ch, s->start_y - 12, units, 0);
drawtext(s->outpicref, s->start_x - 4 * strlen(units) + x + w * ch, s->h + s->start_y + 6, units, 0);
av_free(units);
}
}
for (y = 0; y < s->h; y+=40) {
float seconds = y * spp / inlink->sample_rate;
char *units;
if (x == 0)
units = av_asprintf("0");
else if (log10(seconds) > 6)
units = av_asprintf("%.2fh", seconds / (60 * 60));
else if (log10(seconds) > 3)
units = av_asprintf("%.2fm", seconds / 60);
else
units = av_asprintf("%.2fs", seconds);
if (!units)
return AVERROR(ENOMEM);
drawtext(s->outpicref, s->start_x - 8 * strlen(units) - 4, s->start_y + y - 4, units, 0);
av_free(units);
}
drawtext(s->outpicref, s->start_x / 7, outlink->h / 2 - 4 * 4, "TIME", 1);
drawtext(s->outpicref, outlink->w / 2 - 14 * 4, outlink->h - s->start_y / 2, "FREQUENCY (Hz)", 0);
}
for (ch = 0; ch < (multi ? s->nb_display_channels : 1); ch++) {
int h = multi ? s->h / s->nb_display_channels : s->h;
for (y = 0; y < h; y++) {
float out[3] = { 0., 127.5, 127.5};
int chn;
for (chn = 0; chn < (s->mode == SEPARATE ? 1 : s->nb_display_channels); chn++) {
float yf, uf, vf;
int channel = (multi) ? s->nb_display_channels - ch - 1 : chn;
float lout[3];
color_range(s, channel, &yf, &uf, &vf);
pick_color(s, yf, uf, vf, y / (float)h, lout);
out[0] += lout[0];
out[1] += lout[1];
out[2] += lout[2];
}
memset(s->outpicref->data[0]+(s->start_y + h * (ch + 1) - y - 1) * s->outpicref->linesize[0] + s->w + s->start_x + 20, av_clip_uint8(out[0]), 10);
memset(s->outpicref->data[1]+(s->start_y + h * (ch + 1) - y - 1) * s->outpicref->linesize[1] + s->w + s->start_x + 20, av_clip_uint8(out[1]), 10);
memset(s->outpicref->data[2]+(s->start_y + h * (ch + 1) - y - 1) * s->outpicref->linesize[2] + s->w + s->start_x + 20, av_clip_uint8(out[2]), 10);
}
for (y = 0; ch == 0 && y < h; y += h / 10) {
float value = 120.0 * log10(1. - y / (float)h);
char *text;
if (value < -120)
break;
text = av_asprintf("%.0f dB", value);
if (!text)
continue;
drawtext(s->outpicref, s->w + s->start_x + 35, s->start_y + y - 5, text, 0);
av_free(text);
}
}
}
ret = ff_filter_frame(outlink, s->outpicref);
s->outpicref = NULL;
}
return ret;
}
| 1threat
|
What is the logic behind deviding arrays of of double precision matrix to a large number before sending that matrix to a solver? : I am given a code which divides the members of [A] in [A]{X}=[B] to 10^4 when assembling matrix [A].
Then it also divides the results array to this number to calculate correct value.
I cannot understand why this should be done? Does double precision has limitation on numbers of integer it can hold; so the maker of this code wanted to increase number of float digits? Or maybe he misunderstood the conception of double precision?
| 0debug
|
Split 1 column into 3 columns in spark scala : <p>I have a dataframe in Spark using scala that has a column that I need split.</p>
<pre><code>scala> test.show
+-------------+
|columnToSplit|
+-------------+
| a.b.c|
| d.e.f|
+-------------+
</code></pre>
<p>I need this column split out to look like this:</p>
<pre><code>+--------------+
|col1|col2|col3|
| a| b| c|
| d| e| f|
+--------------+
</code></pre>
<p>I'm using Spark 2.0.0</p>
<p>Thanks</p>
| 0debug
|
Heroku auto restart dyno on H12 Request timeout errors : <p>We have a node dyno processing small API requests, ~10/second. All requests complete in under 0.5s</p>
<p>Once every few days, dyno starts giving H12 Request timeout errors on all requests. We couldn't discover the cause. Restarting fixes it.</p>
<p>How to make Heroku automatically restart the dyno on a H12 Request timeout threshold, e.g. more than 5/second?</p>
| 0debug
|
static inline CopyRet copy_frame(AVCodecContext *avctx,
BC_DTS_PROC_OUT *output,
void *data, int *data_size)
{
BC_STATUS ret;
BC_DTS_STATUS decoder_status = { 0, };
uint8_t trust_interlaced;
uint8_t interlaced;
CHDContext *priv = avctx->priv_data;
int64_t pkt_pts = AV_NOPTS_VALUE;
uint8_t pic_type = 0;
uint8_t bottom_field = (output->PicInfo.flags & VDEC_FLAG_BOTTOMFIELD) ==
VDEC_FLAG_BOTTOMFIELD;
uint8_t bottom_first = !!(output->PicInfo.flags & VDEC_FLAG_BOTTOM_FIRST);
int width = output->PicInfo.width;
int height = output->PicInfo.height;
int bwidth;
uint8_t *src = output->Ybuff;
int sStride;
uint8_t *dst;
int dStride;
if (output->PicInfo.timeStamp != 0) {
OpaqueList *node = opaque_list_pop(priv, output->PicInfo.timeStamp);
if (node) {
pkt_pts = node->reordered_opaque;
pic_type = node->pic_type;
av_free(node);
} else {
pic_type = PICT_BOTTOM_FIELD;
}
av_log(avctx, AV_LOG_VERBOSE, "output \"pts\": %"PRIu64"\n",
output->PicInfo.timeStamp);
av_log(avctx, AV_LOG_VERBOSE, "output picture type %d\n",
pic_type);
}
ret = DtsGetDriverStatus(priv->dev, &decoder_status);
if (ret != BC_STS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR,
"CrystalHD: GetDriverStatus failed: %u\n", ret);
return RET_ERROR;
}
trust_interlaced = avctx->codec->id != CODEC_ID_H264 ||
!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) ||
priv->need_second_field ||
(decoder_status.picNumFlags & ~0x40000000) ==
output->PicInfo.picture_number;
if (output->PicInfo.picture_number == priv->last_picture && !priv->need_second_field) {
av_log(avctx, AV_LOG_WARNING,
"Incorrectly guessed progressive frame. Discarding second field\n");
return RET_OK;
}
interlaced = (output->PicInfo.flags & VDEC_FLAG_INTERLACED_SRC) &&
trust_interlaced;
if (!trust_interlaced && (decoder_status.picNumFlags & ~0x40000000) == 0) {
av_log(avctx, AV_LOG_VERBOSE,
"Next picture number unknown. Assuming progressive frame.\n");
}
av_log(avctx, AV_LOG_VERBOSE, "Interlaced state: %d | trust_interlaced %d\n",
interlaced, trust_interlaced);
if (priv->pic.data[0] && !priv->need_second_field)
avctx->release_buffer(avctx, &priv->pic);
priv->need_second_field = interlaced && !priv->need_second_field;
priv->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
FF_BUFFER_HINTS_REUSABLE;
if (!priv->pic.data[0]) {
if (avctx->get_buffer(avctx, &priv->pic) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return RET_ERROR;
}
}
bwidth = av_image_get_linesize(avctx->pix_fmt, width, 0);
if (priv->is_70012) {
int pStride;
if (width <= 720)
pStride = 720;
else if (width <= 1280)
pStride = 1280;
else pStride = 1920;
sStride = av_image_get_linesize(avctx->pix_fmt, pStride, 0);
} else {
sStride = bwidth;
}
dStride = priv->pic.linesize[0];
dst = priv->pic.data[0];
av_log(priv->avctx, AV_LOG_VERBOSE, "CrystalHD: Copying out frame\n");
if (interlaced) {
int dY = 0;
int sY = 0;
height /= 2;
if (bottom_field) {
av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: bottom field\n");
dY = 1;
} else {
av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: top field\n");
dY = 0;
}
for (sY = 0; sY < height; dY++, sY++) {
memcpy(&(dst[dY * dStride]), &(src[sY * sStride]), bwidth);
dY++;
}
} else {
av_image_copy_plane(dst, dStride, src, sStride, bwidth, height);
}
priv->pic.interlaced_frame = interlaced;
if (interlaced)
priv->pic.top_field_first = !bottom_first;
priv->pic.pkt_pts = pkt_pts;
if (!priv->need_second_field) {
*data_size = sizeof(AVFrame);
*(AVFrame *)data = priv->pic;
}
if (!interlaced && (output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) &&
(pic_type == PICT_TOP_FIELD || pic_type == PICT_BOTTOM_FIELD)) {
av_log(priv->avctx, AV_LOG_VERBOSE, "Fieldpair from two packets.\n");
return RET_SKIP_NEXT_COPY;
}
return priv->need_second_field &&
!(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) ?
RET_COPY_NEXT_FIELD : RET_OK;
}
| 1threat
|
Destructuring array of objects in es6 : <p>In es6, how can i simplify the following lines using destructuring?:</p>
<pre><code>const array0 = someArray[0].data;
const array1 = someArray[1].data;
const array2 = someArray[2].data;
</code></pre>
| 0debug
|
How to make an arraylist that stores infomration from 3 different classes : <p>I have an assignment where I need to make a program that stores student information. I need to apply concepts of inheritance and interfaces.
I need to create an Arraylist that stores info from 3 different classes. Attached is the program description and features. I want a general idea of what I need to do to implement this program.<a href="https://i.stack.imgur.com/kVT27.png" rel="nofollow noreferrer">cord</a></p>
| 0debug
|
How to tackle different Image dimensions : I am working on a problem where I have to classify image into different groups . I am a beginner and working with Keras with simple sequence model . How should i tackle the problem of images with different dimension in below code e.g. some images have dimension 2101583 while some have 210603 etc . Please suggest .
model.add(Dense(100,input_dim = ?,activation= "sigmoid"))
model.add(Dense(100,input_dim = ?,activation= "sigmoid"))
| 0debug
|
Best way to setup a webhook for dialogflow? : I'm using the inline code editor with dialogflow. But i want to use an external webhook I just wasn't sure the best way to do this. I've got some experience with firebase and firebase functions - so if I wanted to create a firebase project i'd just run firebase init, etc. Can the url for the webhook be the firebase functions url?
In addition there are is the action on google github page https://github.com/actions-on-google/actions-on-google-nodejs where there are examples of writing conversational code for dialogflow using a dialogflow instance but the syntax for this is different to the syntax used in fulfilment. Just wondering the differences between writing code for actions on google versus dialogflow.
| 0debug
|
MongoDB select via java : MongoClient mongo = new MongoClient();
DB db = mongo.getDB("mytest");
DBCollection col = db.getCollection("testt");
//read example
DBObject query = BasicDBObjectBuilder.start("$gte", "06/01/2016 00:00:00").add("$lte", "10/01/2016 00:00;00").get();
DBCursor cursor = col.find(query);
while(cursor.hasNext()){
System.out.println("docc:");
System.out.println(cursor.next());
}
**I am getting below exception while selecting data from MongoDB in java**
com.mongodb.MongoQueryException: Query failed with error code 2 and error message 'unknown top level operator: $gte' on server 127.0.0.1:27017
at com.mongodb.operation.FindOperation$1.call(FindOperation.java:493)
at com.mongodb.operation.FindOperation$1.call(FindOperation.java:483)
at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:241)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:214)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:483)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:80)
at com.mongodb.Mongo.execute(Mongo.java:818)
at com.mongodb.Mongo$2.execute(Mongo.java:805)
at com.mongodb.DBCursor.initializeCursor(DBCursor.java:851)
at com.mongodb.DBCursor.hasNext(DBCursor.java:152)
at MongoFetch.main(MongoFetch.java:55)
| 0debug
|
Constructor Function is not working properly : <p>I wrote a constructor function for a class RandomGame which inherits from a different class, SGGame. However, the constructor is not functioning properly. </p>
<p>It is supposed to create a stochastic game with random payoffs and transition probabilities given interger inputs of number of players, actions, and states. Right now, it is always creating a game with two players, one state, and one action, regardless of inputs. </p>
<p>Here is the constructor function: </p>
<pre><code>class RandomGame : public SGGame
{
private:
int numactions;
public:
RandomGame(int numPlayers,
int numStates,
int numactions)
{
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::default_random_engine generator (seed);
std::uniform_real_distribution<double> distribution(1e-6,1-(1e-6));
double delta = distribution(generator);
vector<bool> unconstrained(numPlayers,false);
vector< vector< int > > numActions(numStates,vector<int>(numPlayers,numactions));
vector<int> numActions_total(numStates,pow(numactions, numPlayers));
// Payoffs
vector< vector< vector<double> > >
payoffs(numStates,vector< vector<double> >(pow(numactions, numPla
yers),vector<double>(numPlayers,0.0)));
unsigned int i,j,k,l;
for(i=0;i<numStates;i++)
{
for(j=0;j<numActions_total[i];j++)
{
for(k=0;k<numPlayers;k++)
{
std::uniform_real_distribution<double> distribution(0,10);
payoffs[i][j][k] = distribution(generator);
}
}
}
// Transition probabilities
vector < vector< vector<double> > >
probabilities(numStates,vector< vector<double> >(pow(numactions,
numPlayers), vector<double>(numStates,1.0))); // 1.0 as initial value, but then ran
domize
// randomize transition probabilities
double prob_sum;
for(i=0;i<numStates;i++)
{
for(j=0;j<numActions_total[i];j++)
{
prob_sum = 0.0;
for(k=0;k<numStates;k++)
{
std::uniform_real_distribution<double> distribution(0,1.0);
probabilities[i][j][k] = distribution(generator);
// normalize probabilities
prob_sum += probabilities[i][j][k];
}
for(k=0;k<numStates;k++)
{
probabilities[i][j][k] = probabilities[i][j][k]/prob_sum;
}
}
}
SGGame game(delta,
numStates,
numActions,
payoffs,
probabilities,
unconstrained);
}
}; ```
// decleration of the class SGGame: the constructor I call at the bottom of that code uses an SGGame constructor which creates an SGGame with the given inputs.
``` ```
class SGGame
{
private:
double delta; /*!< The discount factor. */
int numPlayers; /*!< The number of players. */
int numStates; /*!< The number of states, must be at least 1. */
vector< vector<int> > numActions; /*!< Gives the number of each
player's actions in each
state. In particular, player i
has numActions[s][i] actions in
state s. Should note that a
pair (a1,a2) is mapped into an
action profile using the
formula
a=a1+a2*numActions[s][a1], and
generalized to n>2. */
vector<int> numActions_total; /*!< Total number of action profiles
for each state. */
vector< vector<SGPoint> > payoffs; /*!< Gives the payoffs of the
players as a function of the
action profile. In particular,
payoffs[s][a][i] are player
i's payoffs in state s when
action profile a is played. */
vector< vector< vector<double> > > probabilities; /*!< State
transition
probabilities:
probabilities[s][a][s']
is the
probability of
transitioning
to state s'
when action
profile a is
played in state
s. */
vector< vector<bool> > eqActions; /*!< Indicates which action profiles
are allowed to be played on path in
each state. By default, initialized
to true for all action
profiles. Allows one to, for
example, look at strongly symmetric
equilibria (by first excluding
asymmetric action profiles from the
lists). Players can always deviate
to action profiles which are not
allowed on path. */
vector<bool> unconstrained; /*!< If unconstrained[i]=true, the
algorithm will not impose incentive
compatibility as a constraint for
player i. */ ```
// call to the constructor which is not working properly:
``` ```
RandomGame game(2,3,4); ```
</code></pre>
| 0debug
|
Can't connect to MySql database using PHP : <p>I created a login screen for my website but I can't seem to reach my MySql database via PHP. I'm using XAMPP 1.7.7., Codelobster PHP Edition and MySql Workbench. I know this is a really old version of XAMPP but I have to use this because at school this version is installed on every PC.
So I wrote the PHP file which establishes the connection with the database (called metaler) and another PHP file which gets the value of the input fields on the login screen via POST method, and all I want to do is insert these values to one of my tables (called user_data). There is no password set for the database.</p>
<p>Here goes the code:</p>
<pre><code><?php
$connect = mysql_connect("localhost", "root", "")
or exit("Nem sikerült kapcsolódni a szerverhez.");
mysql_select_db("metaler",$connect)
or exit("Nem sikerült megnyitni az adatbázist.");
mysql_query("SET NAMES 'utf8'");
?>
</code></pre>
<p>Above is the connection PHP.</p>
<pre><code><?php
include("connecttodb.php");
$ema=$_POST['ema'];
$pass=$_POST['pass'];
$insert=("INSERT INTO metaler.user_data (email, password)
VALUES ($ema, $pass)");
$result=mysql_query($insert);
if($result){
print "Sikeres bejelentkezés!";
}
else{
print "Nem sikerült kapcsolódni.";
}
mysql_close($connect);
?>
</code></pre>
<p>And this is the one that should perform the INSERT command, but all it does is display the error message "Nem sikerült kapcsolódni." which is in the ELSE clause so the mistake must be in the second one.
Since there is no other error message given I couldn't find the answer yet. If you would take a look at my code you'll see I'm a total beginner and maybe the answer is obvious but I need some help.
If you have any suggestions everything is more than welcome.
Thank you in advance! </p>
| 0debug
|
java.util.Arrays.asList when used with removeIf throws UnsupportedOperationException : <p>I am preparing for an OCPJP 8 exam for the next 2 months
and currently I this one got my attention as I dont understand why</p>
<pre><code>public class BiPredicateTest {
public static void main(String[] args) {
BiPredicate<List<Integer>, Integer> containsInt = List::contains;
List<Integer> ints = java.util.Arrays.asList(1,20,20);
ints.add(1);
ints.add(20);
ints.add(20);
System.out.println(containsInt.test(ints, 20));
BiConsumer<List<Integer>, Integer> listInt = BiPredicateTest::consumeMe;
listInt.accept(ints, 15);
}
public static void consumeMe(List<Integer> ints, int num) {
ints.removeIf(i -> i>num);
ints.forEach(System.out::println);
}
}
</code></pre>
<p>this clearly is going to compile OK! but when you run it you will see the exception like this</p>
<pre><code>C:\Users\user\Documents>javac BiPredicateTest.java
C:\Users\user\Documents>java BiPredicateTest
true
Exception in thread "main" java.lang.UnsupportedOperationException
at java.util.AbstractList.remove(AbstractList.java:161)
at java.util.AbstractList$Itr.remove(AbstractList.java:374)
at java.util.Collection.removeIf(Collection.java:415)
at BiPredicateTest.consumeMe(BiPredicateTest.java:22)
at BiPredicateTest.main(BiPredicateTest.java:17)
</code></pre>
<p>I need some help here to understand why the asList method is not working with removeIf? i assume it will return an instance of ArrayList which implements removeIf method!. </p>
<p>Any answer will be appreciated.</p>
<p>cheers! </p>
| 0debug
|
static void assign_storage(SCLPDevice *sclp, SCCB *sccb)
{
MemoryRegion *mr = NULL;
uint64_t this_subregion_size;
AssignStorage *assign_info = (AssignStorage *) sccb;
sclpMemoryHotplugDev *mhd = get_sclp_memory_hotplug_dev();
ram_addr_t assign_addr;
MemoryRegion *sysmem = get_system_memory();
if (!mhd) {
sccb->h.response_code = cpu_to_be16(SCLP_RC_INVALID_SCLP_COMMAND);
return;
}
assign_addr = (assign_info->rn - 1) * mhd->rzm;
if ((assign_addr % MEM_SECTION_SIZE == 0) &&
(assign_addr >= mhd->padded_ram_size)) {
mr = memory_region_find(sysmem, assign_addr, 1).mr;
memory_region_unref(mr);
if (!mr) {
MemoryRegion *standby_ram = g_new(MemoryRegion, 1);
ram_addr_t offset = assign_addr -
(assign_addr - mhd->padded_ram_size)
% mhd->standby_subregion_size;
char id[16];
snprintf(id, 16, "standby.ram%d",
(int)((offset - mhd->padded_ram_size) /
mhd->standby_subregion_size) + 1);
if (offset + mhd->standby_subregion_size >
mhd->padded_ram_size + mhd->standby_mem_size) {
this_subregion_size = mhd->padded_ram_size +
mhd->standby_mem_size - offset;
} else {
this_subregion_size = mhd->standby_subregion_size;
}
memory_region_init_ram(standby_ram, NULL, id, this_subregion_size, &error_abort);
object_ref(OBJECT(standby_ram));
object_unparent(OBJECT(standby_ram));
vmstate_register_ram_global(standby_ram);
memory_region_add_subregion(sysmem, offset, standby_ram);
}
mhd->standby_state_map[(assign_addr - mhd->padded_ram_size)
/ MEM_SECTION_SIZE] = 1;
}
sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_COMPLETION);
}
| 1threat
|
ERROR Error: Uncaught (in promise), Cannot match any routes. URL Segment : <p>I have simple navigation in angular 6 app, </p>
<p>Here is HTML</p>
<pre><code><nav class="main-nav>
<ul class="main-nav__list " ng-sticky [addClass]="'main-sticky-link'" [ngClass]="ref.click === true? 'Navbar__ToggleShow' :''">
<li class="main-nav__item">
<a class="main-nav__link" routerLink="['/']" routerLinkActive="active">Home</a>
</li>
<li class="main-nav__item">
<a class="main-nav__link" routerLink="['/about']" routerLinkActive="active">About us</a>
</li>
</ul>
</nav>
</code></pre>
<p>here is app.routing module</p>
<pre><code>import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { MainLayoutComponent } from './layout/main-layout/main-layout.component';
import { AboutComponent } from './components/about/about.component';
import { WhatwedoComponent } from './components/whatwedo/whatwedo.component';
import { FooterComponent } from './components/footer/footer.component';
import { ProjectsComponent } from './components/projects/projects.component';
const routes: Routes = [
{ path: 'about', component: AboutComponent },
{ path: 'what', component: WhatwedoComponent },
{ path: 'contacts', component: FooterComponent },
{ path: 'projects', component: ProjectsComponent},
];
@NgModule({
imports: [
CommonModule,
RouterModule.forRoot(routes),
],
declarations: []
})
export class AppRoutingModule { }
</code></pre>
<p>Here is app module</p>
<pre><code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgStickyDirective } from 'ng-sticky';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { MainLayoutComponent } from './layout/main-layout/main-layout.component';
import { AppRoutingModule } from './/app-routing.module';
import { MainNavDirective } from './layout/main-nav.directive';
import { AboutComponent } from './components/about/about.component';
import { WhatwedoComponent } from './components/whatwedo/whatwedo.component';
import { FooterComponent } from './components/footer/footer.component';
import { WhyChooseUsComponent } from './components/why-choose-us/why-choose-us.component';
import { TeamComponent } from './components/team/team.component';
import { ProjectsComponent } from './components/projects/projects.component';
import { ClientsComponent } from './components/clients/clients.component';
import { HowItWorksComponent } from './components/how-it-works/how-it-works.component';
import { PartnersComponent } from './components/partners/partners.component';
@NgModule({
declarations: [
AppComponent,
NgStickyDirective,
MainLayoutComponent,
MainNavDirective,
AboutComponent,
WhatwedoComponent,
FooterComponent,
WhyChooseUsComponent,
TeamComponent,
ProjectsComponent,
ClientsComponent,
HowItWorksComponent,
PartnersComponent
],
imports: [
BrowserModule,
RouterModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
</code></pre>
<p>when I run my app and click about us i get the following error :</p>
<pre><code>core.js:1673 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: '%5B'/about'%5D'
Error: Cannot match any routes. URL Segment: '%5B'/about'%5D'
at
</code></pre>
<p>I have tried different combination to solve the issue but still not able to get rid of this error, </p>
<p>what am I doing wrong in my code? any help will be helpfull thanks</p>
| 0debug
|
Changing router-outlet with *ngIf in app.component.html in angular2 : <p>I am using angular 2.0 final. I am trying to change the location of the <strong>router-outlet</strong> in the main app.component.html. The template is updating fine display wise except, the first time I use router.navigate the component won't display in the new router-outlet, and there is no error. The second and every time after I use router.navigate it works properly.</p>
<p><strong>example template of app.component.html</strong></p>
<pre><code> <div *ngIf="authenticated() == false">
<h1>not logged in</h1>
<router-outlet>
</router-outlet>
</div>
<div *ngIf="authenticated()">
<h1>logged in</h1>
<router-outlet>
</router-outlet>
</div>
</code></pre>
| 0debug
|
bool cpu_restore_state(CPUState *cpu, uintptr_t retaddr)
{
TranslationBlock *tb;
bool r = false;
tb_lock();
tb = tb_find_pc(retaddr);
if (tb) {
cpu_restore_state_from_tb(cpu, tb, retaddr);
if (tb->cflags & CF_NOCACHE) {
tb_phys_invalidate(tb, -1);
tb_free(tb);
r = true;
tb_unlock();
| 1threat
|
def remove_Char(s,c) :
counts = s.count(c)
s = list(s)
while counts :
s.remove(c)
counts -= 1
s = '' . join(s)
return (s)
| 0debug
|
static int qemu_rdma_write(QEMUFile *f, RDMAContext *rdma,
uint64_t block_offset, uint64_t offset,
uint64_t len)
{
uint64_t current_addr = block_offset + offset;
uint64_t index = rdma->current_index;
uint64_t chunk = rdma->current_chunk;
int ret;
if (!qemu_rdma_buffer_mergable(rdma, current_addr, len)) {
ret = qemu_rdma_write_flush(f, rdma);
if (ret) {
return ret;
}
rdma->current_length = 0;
rdma->current_addr = current_addr;
ret = qemu_rdma_search_ram_block(rdma, block_offset,
offset, len, &index, &chunk);
if (ret) {
fprintf(stderr, "ram block search failed\n");
return ret;
}
rdma->current_index = index;
rdma->current_chunk = chunk;
}
rdma->current_length += len;
if (rdma->current_length >= RDMA_MERGE_MAX) {
return qemu_rdma_write_flush(f, rdma);
}
return 0;
}
| 1threat
|
static int h261_decode_gob_header(H261Context *h){
unsigned int val;
MpegEncContext * const s = &h->s;
val = show_bits(&s->gb, 15);
if(val)
return -1;
skip_bits(&s->gb, 16);
h->gob_number = get_bits(&s->gb, 4);
s->qscale = get_bits(&s->gb, 5);
while (get_bits1(&s->gb) != 0) {
skip_bits(&s->gb, 8);
}
if(s->qscale==0)
return -1;
h->current_mba = 0;
h->mba_diff = 0;
return 0;
}
| 1threat
|
VB.net Picture Box Dispose Picture so that I can delete it : My vb.net application downloads Pictures from the internet and displays it as a PictureBox. When exiting the program, I want it to delete the shown files that have been downloaded, however Im not able to do so. The Debugger throws an error saying the spicified file cannot be accessed as its still used in the picture box.
I already tried using the Dispose() Method which didnt work.
| 0debug
|
How to exit spark-submit after the submission : <p>When submitting spark streaming program using spark-submit(YARN mode)
it keep polling the status and never exit</p>
<p>Is there any option in spark-submit to exit after the submission?</p>
<p>===why this trouble me===</p>
<p>The streaming program will run forever and i don't need the status update</p>
<p>I can ctrl+c to stop it if i start it manually
but i have lots of streaming context to start and i need to start them using script</p>
<p>I can put the spark-submit program in background,
but after lots of background java process created, the user corresponding to, will not able to run any other java process because JVM cannot create GC thread</p>
| 0debug
|
React Native: require() with Dynamic String? : <p>I have read several posts about issues that people are having with React Native and the <code>require()</code> function when trying to require a dynamic resource such as:</p>
<p>Dynamic <strong>(fails)</strong>:</p>
<pre><code>urlName = "sampleData.json";
data = require('../' + urlName);
</code></pre>
<p>vs. Static <strong>(succeeds)</strong>:</p>
<pre><code>data = require('../sampleData.json');
</code></pre>
<p>I have read on some threads that this is a bug in React Native and in others that this is a feature.</p>
<p>Is there a new way to require a dynamic resource within a function?</p>
<p>Related Posts (all fairly old in React time):</p>
<ul>
<li><a href="https://stackoverflow.com/questions/33085341/importing-text-from-local-json-file-in-react-native">Importing Text from local json file in React native</a></li>
<li><a href="https://stackoverflow.com/questions/39901584/react-native-dynamically-list-require-files-in-directory">React Native - Dynamically List/Require Files In Directory</a></li>
<li><a href="https://stackoverflow.com/questions/30854232/react-native-image-require-module-using-dynamic-names">React Native - Image Require Module using Dynamic Names</a></li>
<li><a href="https://stackoverflow.com/questions/43516269/react-native-how-to-use-requirepath-with-dynamic-urls">React Native: how to use require(path) with dynamic urls?</a></li>
</ul>
| 0debug
|
Using function with return type Task<T>...c# : ASP.NET MVC 5/ C# .NEt 4.6.1
I had a function that did the following:
public class UserClass
{
public static CurrentUserData GetUserInfo()
{
CurrentUserData ui;
ui = GetUserData();
return ui;
}
}
My CurrentUserData object is as follows:
public class CurrentUserData
{
public bool ReadOnly{get;set;}
}
In my controller, I call my method and can see the ReadOnly property fine:
var user = UserClass.GetUserInfo();
if (user.ReadOnly)
{
////code to execute
}
I had to add an async call to my function, and now it looks likes this (I omitted code for brevity):
public static Task<CurrentUserData > GetUserInfo()
{
Task<CurrentUserData > ui;
ui = GetUserData();
HttpResponseMessage response = await httpClient.SendAsync(request);
return ui;
}
Notice the Task<T> I had to add. But when I call the method in my controller like before, I get the error:
Error CS1061 'Task<CurrentUserData >' does not contain a definition for
'ReadOnly' and no extension method 'ReadOnly' accepting a first argument of
type 'Task<CurrentUserData >' could be found (are you missing a using directive or
an assembly reference?)
What do I need to change so when any class calls my new Task<CurrentUserData > method, it will see all the properties of the object wrapped in Task<CurrentUserData >?
Thanks
| 0debug
|
Changing colors for an image in website : <p>how to partition an image in a website ? like this web site (each image is able to change her colors) : <a href="http://www.zolpan-intensement-couleurs.fr/fr/simulateur/decorateur_virtuel/index.aspx" rel="nofollow">http://www.zolpan-intensement-couleurs.fr/fr/simulateur/decorateur_virtuel/index.aspx</a> , what is the language that can we use ?</p>
| 0debug
|
int rom_add_option(const char *file)
{
if (!rom_enable_driver_roms)
return 0;
return rom_add_file(file, "genroms", file, 0);
}
| 1threat
|
Index was outside the bounds of the array c# so confusing : Hello Ladies And Gentlemen goodevening to all, may i ask ? how can i get error for this ? it is so confusing i get bug like this i try to fix it many hours but not work at all sorry for being noob coding im just newbie
namespace WindowsFormsApp1
{
public partial class Schedule : Form
{
public Schedule()
{
InitializeComponent();
}
MySqlConnection con = new MySqlConnection(@"Data Source=localhost;port=3306;Initial Catalog=Payroll;User Id=root;password=''");
MySqlDataReader dr;
int tc = 0;
private void Schedule_Load(object sender, EventArgs e)
{
datagrid();
fillsched();
}
public void datagrid()
{
con.Open();
MySqlDataAdapter sda = new MySqlDataAdapter("Select * from employee where Pstatus='Active'", con);
DataTable data = new DataTable();
sda.Fill(data);
dataGridView1.DataSource = data;
con.Close();
}
public void fillsched()
{
con.Open();
MySqlDataReader dr;
MySqlCommand cmd = new MySqlCommand("select * from updateschedule ", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
int data = dr.GetInt32("empSched");
comboBox1.Items.Add(data);
}
con.Close();
}
public void getsched()
{
if (Int32.TryParse(comboBox1.SelectedItem.ToString(), out tc))
{
con.Open();
MySqlCommand cmd = new MySqlCommand("select * from updateschedule where empSched=@empSched ", con);
cmd.Parameters.Add("@empSched", MySqlDbType.Int32).Value = tc;
dr = cmd.ExecuteReader();
if (dr.Read())
{
textBox2.Text = dr["TimeIn"].ToString();
textBox3.Text = dr["TimeOut"].ToString();
label5.Text = tc.ToString();//to pass the data in the combobox1
}
con.Close();
}
}
public void view()
{
textBox1.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
getsched();
}
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.RowIndex >= 0)
{
view();
}
}
private void button1_Click(object sender, EventArgs e)
{
insert();
insertempsched();
}
public void insert()
{
MySqlCommand cmd = new MySqlCommand("INSERT INTO schedule (empSchedID,empID,empIN,empOut)VALUES(@empSchedID,@empID,@empIn,@EmpOut)", con);
cmd.Parameters.Add("@empSchedID", MySqlDbType.Int32).Value = label5.Text;
cmd.Parameters.Add("@empID", MySqlDbType.VarChar).Value = textBox1.Text;
cmd.Parameters.Add("@empIn", MySqlDbType.Date).Value = textBox2.Text;
cmd.Parameters.Add("@empOut", MySqlDbType.VarChar).Value = textBox3.Text;
execnonquery(cmd, "Data Inserted");
}
public void insertempsched()
{
con.Open();
MySqlCommand cmd = new MySqlCommand("Update employee set empSched=empSched where empID=@empID", con);
cmd.Parameters.Add("@empSchedID", MySqlDbType.Int32).Value = label5.Text;
cmd.Parameters.Add("@empID", MySqlDbType.VarChar).Value = textBox1.Text;
cmd.ExecuteNonQuery();
con.Close();
}
public void execnonquery(MySqlCommand sqc, string mymsg)
{
con.Open();
if (sqc.ExecuteNonQuery() == 1)
{
MessageBox.Show(mymsg);
}
else
{
MessageBox.Show("Query not Executed");
}
con.Close();
}
}
}
| 0debug
|
Can you use AND in an IF - to check two conditions - python : <p>I am trying to search by two criteria matches or word starts in an input:</p>
<pre><code>sentence=input("What is wrong with your device?\n") # variable arrays
screenissues=["scre","displ","moni","blan"]
wifiissues=["wif","connect","signal","3g","4g"]
waterdamage=["wet","damp","rain","water","soak"]
phone=["phon","samsun","calls","mobi","mob"]
for word in sentence.split(): #splits
if (word.startswith(tuple(screenissues)) and word.startswith(tuple(phone))): #trys to serach for two criteria at once - or works...
print( word)
print("you have an issue with your PHONE screen, please call us")
</code></pre>
| 0debug
|
What is the difference between boto3 list_objects and list_objects_v2? : <p>I'm trying to list objects in an Amazon s3 bucket in python using <code>boto3</code>.</p>
<p>It seems <code>boto3</code> has 2 functions for listing the objects in a bucket: <code>list_objects()</code> and <code>list_objects_v2()</code>. </p>
<p>What is the difference between the 2 and what is the benefit of using one over the other? </p>
| 0debug
|
Preprocessor directive #pragma pack in C : <p>I am trying to understand the use of #pragma, especially #pragma pack() directive. How does it work, when I set pragma pack to 4.5, -5, 6 etc. </p>
| 0debug
|
How can i solve this issue ? is it of tflearn or my python versio. (version 3.7.4) : **PROBLEM REGARDING TFLEARN AND PYTHON 3.7.4**
i believe that my code is fine but i am facing tflearn OR TENSORFLOW issue in my python 3.7.4 how can i solve it?[1st image is here][1]
[2nd image is here][2]
[1]: https://i.stack.imgur.com/1APL6.jpg
[2]: https://i.stack.imgur.com/G4ISZ.jpg
| 0debug
|
static void read_vec_element(DisasContext *s, TCGv_i64 tcg_dest, int srcidx,
int element, TCGMemOp memop)
{
int vect_off = vec_reg_offset(srcidx, element, memop & MO_SIZE);
switch (memop) {
case MO_8:
tcg_gen_ld8u_i64(tcg_dest, cpu_env, vect_off);
break;
case MO_16:
tcg_gen_ld16u_i64(tcg_dest, cpu_env, vect_off);
break;
case MO_32:
tcg_gen_ld32u_i64(tcg_dest, cpu_env, vect_off);
break;
case MO_8|MO_SIGN:
tcg_gen_ld8s_i64(tcg_dest, cpu_env, vect_off);
break;
case MO_16|MO_SIGN:
tcg_gen_ld16s_i64(tcg_dest, cpu_env, vect_off);
break;
case MO_32|MO_SIGN:
tcg_gen_ld32s_i64(tcg_dest, cpu_env, vect_off);
break;
case MO_64:
case MO_64|MO_SIGN:
tcg_gen_ld_i64(tcg_dest, cpu_env, vect_off);
break;
default:
g_assert_not_reached();
}
}
| 1threat
|
static int raw_write(BlockDriverState *bs, int64_t sector_num,
const uint8_t *buf, int nb_sectors)
{
return bdrv_write(bs->file, sector_num, buf, nb_sectors);
}
| 1threat
|
static int fill_psinfo(struct target_elf_prpsinfo *psinfo, const TaskState *ts)
{
char *filename, *base_filename;
unsigned int i, len;
(void) memset(psinfo, 0, sizeof (*psinfo));
len = ts->info->arg_end - ts->info->arg_start;
if (len >= ELF_PRARGSZ)
len = ELF_PRARGSZ - 1;
if (copy_from_user(&psinfo->pr_psargs, ts->info->arg_start, len))
return -EFAULT;
for (i = 0; i < len; i++)
if (psinfo->pr_psargs[i] == 0)
psinfo->pr_psargs[i] = ' ';
psinfo->pr_psargs[len] = 0;
psinfo->pr_pid = getpid();
psinfo->pr_ppid = getppid();
psinfo->pr_pgrp = getpgrp();
psinfo->pr_sid = getsid(0);
psinfo->pr_uid = getuid();
psinfo->pr_gid = getgid();
filename = strdup(ts->bprm->filename);
base_filename = strdup(basename(filename));
(void) strncpy(psinfo->pr_fname, base_filename,
sizeof(psinfo->pr_fname));
free(base_filename);
free(filename);
#ifdef BSWAP_NEEDED
bswap_psinfo(psinfo);
#endif
return (0);
}
| 1threat
|
Display the currency with fractions : <p>I use this code to display amount using the built in currency Pipe:</p>
<pre><code><td>{{transaction.amount | currency: transaction.currency}}</td>
</code></pre>
<p>Is there a way just to display the currency with fractions (.00) with the 3 characters for currency type? I don't need <code>$10,080.00</code> I need <code>10,080.00 USD</code> or <code>10080 JPY</code></p>
<p>Is there a wya to get this visual result?</p>
| 0debug
|
MACRO, difference between a date and today : i have a range of dates from column E3:E, in column F, i want to have the difference in days of today-E3=F3, in F4= Today-E4 and so on until the last value in E. this is the code i have right now:
'Calculate Overdue
For i = 1 To lastrow
If i = 1 Then
Workbooks(Main).Sheets(1).Cells(i + 1, lastcolumn + 1).Value = "Overdue [days]"
Else
Workbooks(Main).Sheets(1).Cells(i + 1, lastcolumn + 1).Value = _
Now - Workbooks(Main).Sheets(1).Cells(i + 1, lastcolumn - 1).Value
End If
Next i
help pleaseee
| 0debug
|
Which packages in Java contain Wrapper Class? : <p>List all the packages in Java which contain the 'Wrapper Class' for example java.lang.
Does java.util contain the Wrapper class?</p>
| 0debug
|
static QObject *qmp_input_get_object(QmpInputVisitor *qiv,
const char *name,
bool consume, Error **errp)
{
StackObject *tos;
QObject *qobj;
QObject *ret;
if (QSLIST_EMPTY(&qiv->stack)) {
assert(qiv->root);
return qiv->root;
}
tos = QSLIST_FIRST(&qiv->stack);
qobj = tos->obj;
assert(qobj);
if (qobject_type(qobj) == QTYPE_QDICT) {
assert(name);
ret = qdict_get(qobject_to_qdict(qobj), name);
if (tos->h && consume && ret) {
bool removed = g_hash_table_remove(tos->h, name);
assert(removed);
}
if (!ret) {
error_setg(errp, QERR_MISSING_PARAMETER, name);
}
} else {
assert(qobject_type(qobj) == QTYPE_QLIST);
assert(!name);
ret = qlist_entry_obj(tos->entry);
assert(ret);
if (consume) {
tos->entry = qlist_next(tos->entry);
}
}
return ret;
}
| 1threat
|
static void cris_evaluate_flags(DisasContext *dc)
{
if (!dc->flags_uptodate) {
cris_flush_cc_state(dc);
switch (dc->cc_op)
{
case CC_OP_MCP:
gen_helper_evaluate_flags_mcp();
break;
case CC_OP_MULS:
gen_helper_evaluate_flags_muls();
break;
case CC_OP_MULU:
gen_helper_evaluate_flags_mulu();
break;
case CC_OP_MOVE:
case CC_OP_AND:
case CC_OP_OR:
case CC_OP_XOR:
case CC_OP_ASR:
case CC_OP_LSR:
case CC_OP_LSL:
switch (dc->cc_size)
{
case 4:
gen_helper_evaluate_flags_move_4();
break;
case 2:
gen_helper_evaluate_flags_move_2();
break;
default:
gen_helper_evaluate_flags();
break;
}
break;
case CC_OP_FLAGS:
break;
default:
{
switch (dc->cc_size)
{
case 4:
gen_helper_evaluate_flags_alu_4();
break;
default:
gen_helper_evaluate_flags();
break;
}
}
break;
}
if (dc->flagx_known) {
if (dc->flags_x)
tcg_gen_ori_tl(cpu_PR[PR_CCS],
cpu_PR[PR_CCS], X_FLAG);
else
tcg_gen_andi_tl(cpu_PR[PR_CCS],
cpu_PR[PR_CCS], ~X_FLAG);
}
dc->flags_uptodate = 1;
}
}
| 1threat
|
static void test_visitor_in_string(TestInputVisitorData *data,
const void *unused)
{
char *res = NULL, *value = (char *) "Q E M U";
Visitor *v;
v = visitor_input_test_init(data, "%s", value);
visit_type_str(v, NULL, &res, &error_abort);
g_assert_cmpstr(res, ==, value);
g_free(res);
}
| 1threat
|
Print a student grade, list, and letter grade : <p>I'm trying to get Python to print a specific set of names, grades, and the letter grade but I'm coming up short for how to do it after asking "the user" to input the number and the name. What I have to do is make sure that it says it with a name, numeric grade, and letter grade in a list so
Name Grade Letter
Joe 98 A
Bob 56 F
and so on...</p>
<p>Here is what I have already...</p>
<pre><code>A_score = 90
B_score = 80
C_score = 70
D_score = 60
F_score = 50
score1 = int(input('Enter score: '))
name1 = input('Enter name: ')
score = int(input('Enter score: '))
name = input('Enter name: ')
score = int(input('Enter score: '))
name = input('Enter name: ')
score = int(input('Enter score: '))
name = input('Enter name: ')
score = float(input('Enter score: '))
name = input('Enter name: ')
# Print the table headings
print('Name\tNumeric grade\tLetter grade')
print('---------------------------------')
#Print the names and grades
for score in range(A_score, B_score, C_score):
print(name1, '\t', score1)
</code></pre>
| 0debug
|
static inline void RET_CHG_FLOW (DisasContext *ctx)
{
ctx->exception = EXCP_MTMSR;
}
| 1threat
|
expected ';' and instead saw '=' : <p>i have many problems</p>
<p>**very long code is that just a part and stackoverflow limiterd 30000 characters ** </p>
<p><em>first problem</em> :</p>
<p><strong>expected ';' and instead saw '='.</strong></p>
<pre><code>var qq = function(a) {
"use strict";
return {
hide: function() {
return a.style.display = "none", this
},
attach: function(b, c) {
return a.addEventListener ? a.addEventListener(b, c, !1) : a.attachEvent && a.attachEvent("on" + b, c),
function() {
qq(a).detach(b, c)
}
}
}
};
</code></pre>
<p><em>other problems</em></p>
<p><strong>unreachable '=' after 'return'.</strong></p>
<p><strong>expected an identifier and instead saw '='.</strong></p>
| 0debug
|
User inputs array size(N). Numbers from 0 until N fill the array : <p>It's supposed to be N={0,1,2...N}
N is entered by the user.
If N is 6 then N={0,1...5}
The numbers from 0 to N should fill the array.
We haven't studied vectors yet so that's not an option.</p>
| 0debug
|
Import two exported classes with the same name : <p>In typescript, using Angular 2, I need to import two classes with the same name, but lying in different paths.</p>
<p>The project is quite too big that I find it hard to change the exported class names.</p>
<p>Is there any way to alias the imported classes,</p>
<pre><code>import {Class1} from '../location1/class1'
import {Class1} from '../location2/class1'
</code></pre>
| 0debug
|
static void qemu_cpu_kick_thread(CPUState *cpu)
{
#ifndef _WIN32
int err;
err = pthread_kill(cpu->thread->thread, SIG_IPI);
if (err) {
fprintf(stderr, "qemu:%s: %s", __func__, strerror(err));
exit(1);
}
#else
if (!qemu_cpu_is_self(cpu)) {
SuspendThread(cpu->hThread);
cpu_signal(0);
ResumeThread(cpu->hThread);
}
#endif
}
| 1threat
|
SQL query group and filter by filed value : for example have this table:
```
ID ProdId Status
1 111 None
2 111 Success
3 222 Process
4 222 Fail
5 333 Process
6 333 Process
7 444 None
```
I need to group by field ```ProdId``` and exclude all rows that contain ```Status``` - "Success" or "Fail"
So, result of this sql query must be :
```
6 333 Process
7 444 None
```
Is it possible?
I use sqlalchemy and postgres.
| 0debug
|
java lang error when using toArray() : <p>Here is my basic setup:</p>
<pre><code>ArrayList<String> myList = new ArrayList<>();
myList.add("test");
String[] arr = myList.toArray(new String[myList.size()]);
System.out.println(arr);
</code></pre>
<p>And i get the classic error: [Ljava.lang.String;@1540e19d</p>
<p>Can anyone explain and help me fix it?</p>
| 0debug
|
static int qcrypto_cipher_init_aes(QCryptoCipher *cipher,
const uint8_t *key, size_t nkey,
Error **errp)
{
QCryptoCipherBuiltin *ctxt;
if (cipher->mode != QCRYPTO_CIPHER_MODE_CBC &&
cipher->mode != QCRYPTO_CIPHER_MODE_ECB) {
error_setg(errp, "Unsupported cipher mode %d", cipher->mode);
return -1;
}
ctxt = g_new0(QCryptoCipherBuiltin, 1);
if (AES_set_encrypt_key(key, nkey * 8, &ctxt->state.aes.encrypt_key) != 0) {
error_setg(errp, "Failed to set encryption key");
goto error;
}
if (AES_set_decrypt_key(key, nkey * 8, &ctxt->state.aes.decrypt_key) != 0) {
error_setg(errp, "Failed to set decryption key");
goto error;
}
ctxt->free = qcrypto_cipher_free_aes;
ctxt->setiv = qcrypto_cipher_setiv_aes;
ctxt->encrypt = qcrypto_cipher_encrypt_aes;
ctxt->decrypt = qcrypto_cipher_decrypt_aes;
cipher->opaque = ctxt;
return 0;
error:
g_free(ctxt);
return -1;
}
| 1threat
|
Automatically convert entered letters into capital : I am using angular 4 for my front end.My project consist of many components and each component consist of forms and inputs.
Is there any way to convert each and every letter user entered to my input fields to capital letters.
Thanks in advance
| 0debug
|
insert substring into first string in ORACLE : **I have this table**
n......n+1.m......m+1.
n......n+1substring.m......m+1.
**How add add string before the point (Add a substring in the first string)**
| 0debug
|
Error: Data source must be a dictionary (dplyr) : <p>Im very new to R and did not find a solution for my problem. I really hope you can help me.</p>
<p>Although there are more columns and observations, my dataframe looks like the following: </p>
<pre><code>dt <- data.frame(hid = c(1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4),
syear = c(2000, 2001, 2003, 2003, 2003, 2000, 2000, 2001, 2001, 2002, 2002),
employlvl = c("Full-time", "Part-time", "Part-time", "Unemployed", "Unemployed",
"Full-time", "Full-time", "Full-time", "Unemployed", "Part-time",
"Full-time"),
relhead = c("Head", "Head", "Head", "Partner", "other", "Head",
"Partner", "Head", "Partner", "Head", "Partner"))
</code></pre>
<hr>
<pre><code>| hid | syear | employlvl | relhead |
|-----|-------|-------------|-----------------------|
| 1 | 2000 | Full-time | Head |
| 2 | 2001 | Part-time | Head |
| 2 | 2003 | Part-time | Head |
| 2 | 2003 | Unemployed | Partner |
| 2 | 2003 | Unemployed | other |
| 4 | 2000 | Full-time | Head |
| 4 | 2000 | Full-time | Partner |
| 4 | 2001 | Full-time | Head |
| 4 | 2001 | Unemployed | Partner |
| 4 | 2002 | Part-time | Head |
| 4 | 2002 | Full-time | Partner |
</code></pre>
<p>I would like to create another column which indicates the employmentlevel of the Partner and hope to get the following output:</p>
<pre><code>| hid | syear | employlvl | relhead | Partner |
|-----|-------|-------------|-----------------------|-------------------|
| 1 | 2000 | Part-time | Head | NA |
| 2 | 2001 | Part-time | Head | NA |
| 2 | 2003 | Part-time | Head | Unemployed |
| 2 | 2003 | Unemployed | Partner | NA |
| 2 | 2003 | Unemployed | other | NA |
| 4 | 2000 | Full-time | Head | Full-time |
| 4 | 2000 | Full-time | Partner | NA |
| 4 | 2001 | Full-time | Head | Unemployed |
| 4 | 2001 | Unemployed | Partner | NA |
| 4 | 2002 | Part-time | Head | Full-time |
| 4 | 2002 | Full-time | Partner | NA |
</code></pre>
<p>Currently I am using the following code. (Thanks again user ycw)</p>
<pre><code>library(dplyr)
library(tidyr)
dt2 <- dt %>%
group_by(hid, syear) %>%
filter(n() > 1) %>%
filter(`relhead` != "Child") %>%
spread(relhead, employlvl) %>%
mutate(Relation = "Head") %>%
rename(`Employment Partner` = Partner) %>%
select(-Head)
dt3 <- dt %>%
left_join(dt2, by = c("hid", "syear", "relhead" = "Relation"))
</code></pre>
<p>The code works absolutely fine for this small data set. But as soon as I try for my whole data I get the following:</p>
<pre><code>Error: Data source must be a dictionary
</code></pre>
<p>Thank you so much for your help.</p>
| 0debug
|
static void fcse_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
{
ARMCPU *cpu = arm_env_get_cpu(env);
if (env->cp15.c13_fcse != value) {
tlb_flush(CPU(cpu), 1);
env->cp15.c13_fcse = value;
}
}
| 1threat
|
function taking diffrent value than passed in c++ : I wrote a simple code for dfs using c++ , but the value that I am passing and the value that the function is accepting is diffrent .printing the values accepted by the function explains . Can you please help me out ?
#include<bits/stdc++.h>
using namespace std;
void dfs(int i,int j);
char graph[51][51];
int n,m,loop=0,inx,iny,completed=0;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int i,j,k,a,b,c;
cin>>n>>m;
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
cin>>graph[i][j];
}
}
for(i=1;i<=n,completed==0;i++){
for(j=1;j<=m,completed==0;j++){
inx=i;
iny=j;
dfs(i,j);
}
}
if(completed==1)
cout<<"YES\n";
else cout<<"NO\n";
return 0;
}
void dfs(int i,int j){
cout<<i<<" "<<j<<"\n"; //for checking values taken by the function
if(completed)
return;
if(i==inx && j==iny){
if(loop>=4)
completed=1;
return ;
}
// loop will increase exponentially !!!!!!
int k=loop;
if(j<m && graph[i][j]==graph[i][j+1]){
loop++;
dfs(i,j+1);
}
loop=k;
if(j>1 && graph[i][j]==graph[i][j-1]){
loop++;
dfs(i,j-1);
}
loop=k;
if(i>1 && graph[i][j]==graph[i-1][j]){
loop++;
dfs(i-1,j);
}
loop=k;
if(i<n && graph[i][j]==graph[i+1][j]){
loop++;
dfs(i+1,j);
}
}
p.s.In case anyone is interested , I was trying [this question .][1]
[1]: https://codeforces.com/problemset/problem/510/B
| 0debug
|
static uint64_t get_cluster_offset(BlockDriverState *bs,
uint64_t offset, int allocate,
int compressed_size,
int n_start, int n_end)
{
BDRVQcowState *s = bs->opaque;
int min_index, i, j, l1_index, l2_index;
uint64_t l2_offset, *l2_table, cluster_offset, tmp;
uint32_t min_count;
int new_l2_table;
l1_index = offset >> (s->l2_bits + s->cluster_bits);
l2_offset = s->l1_table[l1_index];
new_l2_table = 0;
if (!l2_offset) {
if (!allocate)
return 0;
l2_offset = bdrv_getlength(bs->file);
l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);
s->l1_table[l1_index] = l2_offset;
tmp = cpu_to_be64(l2_offset);
if (bdrv_pwrite(bs->file, s->l1_table_offset + l1_index * sizeof(tmp),
&tmp, sizeof(tmp)) != sizeof(tmp))
return 0;
new_l2_table = 1;
}
for(i = 0; i < L2_CACHE_SIZE; i++) {
if (l2_offset == s->l2_cache_offsets[i]) {
if (++s->l2_cache_counts[i] == 0xffffffff) {
for(j = 0; j < L2_CACHE_SIZE; j++) {
s->l2_cache_counts[j] >>= 1;
}
}
l2_table = s->l2_cache + (i << s->l2_bits);
goto found;
}
}
min_index = 0;
min_count = 0xffffffff;
for(i = 0; i < L2_CACHE_SIZE; i++) {
if (s->l2_cache_counts[i] < min_count) {
min_count = s->l2_cache_counts[i];
min_index = i;
}
}
l2_table = s->l2_cache + (min_index << s->l2_bits);
if (new_l2_table) {
memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
if (bdrv_pwrite(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=
s->l2_size * sizeof(uint64_t))
return 0;
} else {
if (bdrv_pread(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=
s->l2_size * sizeof(uint64_t))
return 0;
}
s->l2_cache_offsets[min_index] = l2_offset;
s->l2_cache_counts[min_index] = 1;
found:
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[l2_index]);
if (!cluster_offset ||
((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) {
if (!allocate)
return 0;
if ((cluster_offset & QCOW_OFLAG_COMPRESSED) &&
(n_end - n_start) < s->cluster_sectors) {
if (decompress_cluster(bs, cluster_offset) < 0)
return 0;
cluster_offset = bdrv_getlength(bs->file);
cluster_offset = (cluster_offset + s->cluster_size - 1) &
~(s->cluster_size - 1);
if (bdrv_pwrite(bs->file, cluster_offset, s->cluster_cache, s->cluster_size) !=
s->cluster_size)
return -1;
} else {
cluster_offset = bdrv_getlength(bs->file);
if (allocate == 1) {
cluster_offset = (cluster_offset + s->cluster_size - 1) &
~(s->cluster_size - 1);
bdrv_truncate(bs->file, cluster_offset + s->cluster_size);
if (s->crypt_method &&
(n_end - n_start) < s->cluster_sectors) {
uint64_t start_sect;
start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
memset(s->cluster_data + 512, 0x00, 512);
for(i = 0; i < s->cluster_sectors; i++) {
if (i < n_start || i >= n_end) {
encrypt_sectors(s, start_sect + i,
s->cluster_data,
s->cluster_data + 512, 1, 1,
&s->aes_encrypt_key);
if (bdrv_pwrite(bs->file, cluster_offset + i * 512,
s->cluster_data, 512) != 512)
return -1;
}
}
}
} else if (allocate == 2) {
cluster_offset |= QCOW_OFLAG_COMPRESSED |
(uint64_t)compressed_size << (63 - s->cluster_bits);
}
}
tmp = cpu_to_be64(cluster_offset);
l2_table[l2_index] = tmp;
if (bdrv_pwrite(bs->file,
l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp))
return 0;
}
return cluster_offset;
}
| 1threat
|
What is the moral of this? : <p>One great personality said once:</p>
<p><strong>"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."</strong></p>
<p>Is it true? What do you think the moral of this? </p>
| 0debug
|
What is difference between Log4j and Log4 net : <p>What is difference between Log4j and Log4 net
In each scenario which these two should be used</p>
| 0debug
|
static int vhost_user_reset_device(struct vhost_dev *dev)
{
VhostUserMsg msg = {
.request = VHOST_USER_RESET_OWNER,
.flags = VHOST_USER_VERSION,
};
vhost_user_write(dev, &msg, NULL, 0);
return 0;
}
| 1threat
|
SVM Plot does not show any result IN R : I use the following code
svm.model<-svm(default.payment.next.month~PAY_AMT6,data=creditdata,cost=5,gamma=1)
plot(svm.model,data=creditdata,fill=TRUE)
| 0debug
|
CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
void (*init)(struct CharDriverState *s),
Error **errp)
{
Error *local_err = NULL;
CharDriver *cd;
CharDriverState *chr;
GSList *i;
ChardevReturn *ret = NULL;
ChardevBackend *backend;
const char *id = qemu_opts_id(opts);
char *bid = NULL;
if (id == NULL) {
error_setg(errp, "chardev: no id specified");
goto err;
}
if (qemu_opt_get(opts, "backend") == NULL) {
error_setg(errp, "chardev: \"%s\" missing backend",
qemu_opts_id(opts));
goto err;
}
for (i = backends; i; i = i->next) {
cd = i->data;
if (strcmp(cd->name, qemu_opt_get(opts, "backend")) == 0) {
break;
}
}
if (i == NULL) {
error_setg(errp, "chardev: backend \"%s\" not found",
qemu_opt_get(opts, "backend"));
goto err;
}
backend = g_new0(ChardevBackend, 1);
if (qemu_opt_get_bool(opts, "mux", 0)) {
bid = g_strdup_printf("%s-base", id);
}
chr = NULL;
backend->kind = cd->kind;
if (cd->parse) {
cd->parse(opts, backend, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto qapi_out;
}
}
ret = qmp_chardev_add(bid ? bid : id, backend, errp);
if (!ret) {
goto qapi_out;
}
if (bid) {
qapi_free_ChardevBackend(backend);
qapi_free_ChardevReturn(ret);
backend = g_new0(ChardevBackend, 1);
backend->mux = g_new0(ChardevMux, 1);
backend->kind = CHARDEV_BACKEND_KIND_MUX;
backend->mux->chardev = g_strdup(bid);
ret = qmp_chardev_add(id, backend, errp);
if (!ret) {
chr = qemu_chr_find(bid);
qemu_chr_delete(chr);
chr = NULL;
goto qapi_out;
}
}
chr = qemu_chr_find(id);
chr->opts = opts;
qapi_out:
qapi_free_ChardevBackend(backend);
qapi_free_ChardevReturn(ret);
g_free(bid);
return chr;
err:
qemu_opts_del(opts);
return NULL;
}
| 1threat
|
void ff_vp3_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block){
idct(dest, line_size, block, 2);
}
| 1threat
|
static int try_decode_frame(AVStream *st, AVPacket *avpkt)
{
int16_t *samples;
AVCodec *codec;
int got_picture, data_size, ret=0;
AVFrame picture;
if(!st->codec->codec){
codec = avcodec_find_decoder(st->codec->codec_id);
if (!codec)
return -1;
ret = avcodec_open(st->codec, codec);
if (ret < 0)
return ret;
}
if(!has_codec_parameters(st->codec)){
switch(st->codec->codec_type) {
case CODEC_TYPE_VIDEO:
ret = avcodec_decode_video2(st->codec, &picture,
&got_picture, avpkt);
break;
case CODEC_TYPE_AUDIO:
data_size = FFMAX(avpkt->size, AVCODEC_MAX_AUDIO_FRAME_SIZE);
samples = av_malloc(data_size);
if (!samples)
goto fail;
ret = avcodec_decode_audio3(st->codec, samples,
&data_size, avpkt);
av_free(samples);
break;
default:
break;
}
}
fail:
return ret;
}
| 1threat
|
bootstrap 4 get div under buttons centred : I'm bussy with a navbar that collapses in mobile, so far so good. In desktop it looks like i want, but in mobile view i want the div with id plaatsen under the menu buttons and both in width 100%.
So like this
Logo
________________________________
Button 1 Button 2 button 3
________________________________
plaatsen
_________________________________
Code:
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark justify-content-center">
<div class="container" style="padding: 0px;">
<a class="navbar-brand d-flex mr-auto" href="<?php echo $this->url('home'); ?>" target="_self" style="background-color: red;width:350px;">
<img src="<?= $this->basePath('img/logo.png') ?>"/>
</a>
<div id="buttons">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#button1" aria-controls="button1" aria-expanded="false" aria-label="Toggle navigation" style="margin-top: 12px;">
<span class="navbar-toggler-icon"></span>
</button>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#button2" aria-controls="button2" aria-expanded="false" aria-label="Toggle navigation" style="margin-top: 12px;">
<span class="navbar-toggler-icon"></span>
</button>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#button3" aria-controls="button3" aria-expanded="false" aria-label="Toggle navigation" style="margin-top: 12px;">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="button2">
<ul class="navbar-nav mx-auto w-100 justify-content-center" style="background-color: green;">
<li class="nav-item active">
<form class="navbar-form mx-auto" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search">
<span class="input-group-btn">
<button type="submit" class="btn btn-default" style="border-color: white;">Submit</button>
</span>
</div>
</form>
</li>
</ul>
</div>
<div class="flex-md-column ml-auto w-30 justify-content-end">
<div style="text-align: right;" id="plaatsen">
plaatsen
</div>
<div class="collapse navbar-collapse " id="button1">
<ul class="nav navbar-nav ">
<li class="nav-item active">
<a class="nav-link" href="#">Bedrijfsvermelding<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="<?= $this->basePath('inloggen') ?>">Inloggen<span class="sr-only">(current)</span></a>
</li>
</ul>
</div>
</div>
</div>
</nav>
| 0debug
|
static void option_rom_setup_reset(target_phys_addr_t addr, unsigned size)
{
RomResetData *rrd = qemu_malloc(sizeof *rrd);
rrd->data = qemu_malloc(size);
cpu_physical_memory_read(addr, rrd->data, size);
rrd->addr = addr;
rrd->size = size;
qemu_register_reset(option_rom_reset, rrd);
}
| 1threat
|
VSCode: clear integrated terminal when debug starts : <p>when using <code>"console": "integratedTerminal"</code> in a launch.json the program output is redirected to the integrated terminal. However, after terminating a debug session and starting another one, the terminal is re-used which can be pretty annoying.</p>
<p>I have not found a way to make VSCode clear the terminal -- it is possible to <a href="https://code.visualstudio.com/Docs/editor/tasks#_output-behavior" rel="noreferrer">clear the panel in tasks.json</a> with the <code>clear: true</code> property, this however only works for tasks such as the build task but has no effect on the debug panel.</p>
<p>Help is greatly appreciated.</p>
<p>Thanks in advance<br>
-Simon</p>
| 0debug
|
i want to load my main code every 5 seconds? c# (winform) : i have a windows form app that display restaurant orders. i want to load the code every 5 seconds to check if there is a new order to display
i have a timer created in the form designer :
public void timer1_Tick(object sender, EventArgs e)
{
}
| 0debug
|
js stopwatch is not accurate : helloo im very new to js & jquery. i wrote a stopwatch(accuracy 0.1 second) code very quickly in js that seems it works correctly but the problem is after it reaches 10min it keeps being a couple of seconds behind (i compared it to a digital stopwatch) can anyone see the problem pls?
"im writing this part bcause stack told me that your post contains too much code blah blah blah..."
var i = 0,
desi_s = 0,
s2 = 0,
s1 = 0,
m2 = 0,
m1 = 0;
$("#start").click(function () { //calling the start button
$("#reset").click(function () { //calling the reset button
clearInterval(myInt);
$("#reset").each(function(){
$(this).html('');
this.style.backgroundColor = "transparent";
this.style.borderColor = "transparent";
});
i = 0;
desi_s = 0;
s2 = 0;
s1 = 0;
m2 = 0;
m1 = 0;
$("#min2 ,#min1 ,#sec2 ,#sec1 ,#desi_sec").html(0);
})
i++;
clearInterval(myInt);
var myInt = setInterval(function () {
if (i % 2 !== 0) {
$("#start").html('stop');
if (desi_s < 9) {
desi_s++;
$("#desi_sec").html(desi_s);
} else {
desi_s = 0;
if (s2 < 9) {
s2++;
$("#sec2").html(s2);
} else {
s2 = 0;
$("#sec2").html(s2);
if (s1 < 5) {
s1++;
$("#sec1").html(s1);
} else {
s1 = 0;
$("#sec1").html(s1);
if (m2 < 9) {
m2++;
$("#min2").html(m2);
} else {
m2 = 0;
$("#min2").html(m2);
if (m1 < 5) {
m1++;
$("#min1").html(m1);
} else {
m1 = 0;
clearInterval(myInt);
}
}
}
}
}
} else {
clearInterval(myInt);
$("#start").html('start');
$("#reset").each(function(){
$(this).html('reset');
this.style.backgroundColor = "black";
this.style.color = "white";
});
}
}, 100);
})
| 0debug
|
Can I restrict the type that a function throws in Swift? : <p>When calling a function in Swift 3 that <code>throws</code>, you have to be exhaustive in catching all possible errors, which often means you have an unnecessary extra <code>catch {}</code> at the end to handle errors that won't happen.</p>
<p>Is it possible to say <code>throws MyErrorType</code> so that the compiler can know you have indeed been exhaustive when you handle all cases from that enumeration?</p>
| 0debug
|
Java Runnable Interface Solution : <p>Can some one please explain the below Code</p>
<pre><code>public class TestThread implements Runnable {
public static void main(String[] args) {
Thread thread = new Thread(new TestThread());
thread.start();
System.out.println("1");
thread.run();
System.out.println("2");
}
@Override
public void run() {
System.out.println("3");
}
}
</code></pre>
<p>The output results in 1 3 3 2.Can some one please explain.</p>
<p>Thanks in Advance</p>
| 0debug
|
Kotlin iterator to list? : <p>I have an iterator of strings from <a href="http://fasterxml.github.io/jackson-databind/javadoc/2.7/com/fasterxml/jackson/databind/JsonNode.html#fieldNames%28%29" rel="noreferrer">fieldNames</a> of <code>JsonNode</code>:</p>
<pre><code>val mm = ... //JsonNode
val xs = mm.fieldNames()
</code></pre>
<p>I want to loop over the fields while keeping count, something like:</p>
<pre><code>when mm.size() {
1 -> myFunction1(xs[0])
2 -> myFunction2(xs[0], xs[1])
3 -> myFunction3(xs[0], xs[1], xs[2])
else -> print("invalid")
}
</code></pre>
<p>Obviously the above code does not work as <code>xs</code> the Iterator cannot be indexed like so. I tried to see if I can convert the iterator to list by <code>mm.toList()</code> but that does not exist.</p>
<p>How can I achieve this? </p>
| 0debug
|
in php this error show when i am inserting the data by form : <p>Error: insert into products (product_cat, product_name, product_pric, product_desc, product_image, product_keyword, product_ingrid) values ('5','','', '','','','')
Incorrect integer value: '' for column 'product_pric' at row 1
what is this error and how to resolve</p>
| 0debug
|
Как выполнить обработку некоторых строк совпадающих с регулярным выражением? : У меня есть таблица вида:
id, name(text), characteristics(text),
1, 'ivan', 'lier, tall'
2, 'michailmichail', 'gnorts, wol, rtams'
3, 'sergei', 'smart'
Как выполнить функцию обработки строк совпадающие с регулярным выражением, так чтобы в результирующей таблице оставались все значения?
Переворачивать значения колонки characteristics если в name имя повторяется несколько раз!
Результирующая таблица должна быть:
id, name(text), characteristics(text),
1, 'ivan', 'lier, tall'
2, 'michailmichail', 'smart, low, strong'
3, 'sergei', 'smart'
Это регулярное выражение проходит проверку но не работает после WHERE '\b(\w+)+\1\b'. И я не знаю как обработать строки совпадающие с re и вывести все значения столбца.
Буду благодарен за любую помощь!
SELECT
name, reverse(characteristics) as characteristics
FROM
table
WHERE name ~* 'regexp'
| 0debug
|
In tensorflow what is the difference between tf.add and operator (+)? : <p>In tensorflow tutorials, I see both codes like <code>tf.add(tf.matmul(X, W), b)</code> and <code>tf.matmul(X, W) + b</code>, what is the difference between using the math function <code>tf.add()</code>, <code>tf.assign()</code>, etc and the operators <code>+</code> and <code>=</code>, etc, in precision or other aspects? </p>
| 0debug
|
static void pc_compat_1_5(QEMUMachineInitArgs *args)
{
pc_compat_1_6(args);
has_pvpanic = true;
}
| 1threat
|
Converting ajax Post query to XHR results on 415 http code : <p>I had an issue with ajax to download files, I was told that using XhmlHttpRequest (XHR) will help resolve the issue, so I m trying to convert my old ajax rest request to a new xhr rest request</p>
<p>Unfortunatly I m not yet successfull, I m getting 415 http error code which indicates an unsuported media type <code>req.send(JSON.stringify(printData));</code> and chrome is highlihgting this par of my code which will be presented below. </p>
<p>Here is My ajax call</p>
<pre><code>var jsonData = JSON.parse(JSON.stringify(printData));
var settings = {
"async": true,
"crossDomain": true,
"url": "http://" + document.location.host + "/facturation/print/client",
"method": "POST",
"headers": {
"cache-control": "no-cache",
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
"processData": false,
"contentType": "application/json",
xhrFields: {
responseType: 'blob'
},
"dataType": "text",
"data": JSON.stringify(printData)
}
$.ajax(settings).done(function(response, status, xhr) {
console.log(response);
var filename = "";
var disposition = xhr.getResponseHeader('Content-Disposition');
if (disposition) {
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
var matches = filenameRegex.exec(disposition);
if (matches !== null && matches[1]) filename = matches[1].replace(/['"]/g, '');
}
var linkelem = document.createElement('a');
try {
var blob = new Blob([response], {
type: 'application/octet-stream'
});
if (typeof window.navigator.msSaveBlob !== 'undefined') {
// IE workaround for "HTML7007: One or more blob URLs were revoked by closing the blob for which they were created. These URLs will no longer resolve as the data backing the URL has been freed."
window.navigator.msSaveBlob(blob, filename);
} else {
var URL = window.URL || window.webkitURL;
var downloadUrl = URL.createObjectURL(blob);
if (filename) {
// use HTML5 a[download] attribute to specify filename
var a = document.createElement("a");
// safari doesn't support this yet
if (typeof a.download === 'undefined') {
window.location = downloadUrl;
} else {
a.href = downloadUrl;
a.download = filename;
document.body.appendChild(a);
a.target = "_blank";
a.click();
}
} else {
window.location = downloadUrl;
}
}
} catch (ex) {
console.log(ex);
}
})
</code></pre>
<p>What I tried using XHR is a s below</p>
<pre><code> var req = new XMLHttpRequest();
req.open("POST", "http://" + document.location.host + "/facturation/print/client", true);
req.responseType = "blob";
req.setRequestHeader("cache-control", "no-cache");
req.setRequestHeader("contentType", "application/json");
req.setRequestHeader("dataType", "text");
req.setRequestHeader("X-CSRF-TOKEN", $('meta[name="csrf-token"]').attr('content'));
req.onload = function(event) {
var blob = req.response;
console.log(blob.size);
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = "Dossier_" + new Date() + ".pdf";
link.click();
};
req.send(JSON.stringify(printData));
</code></pre>
<p>What should I do to make this work ?</p>
| 0debug
|
Dynamically change locale for DatePipe in Angular 2 : <p>I'm making an Angular project where the user has the ability to switch languages. Is it possible to make the locale dynamic?</p>
<p>I have seen that you can add it in the NgModule but i'm guessing it's not dynamic when i put it there? Or can i change it somehow through a service or something?</p>
| 0debug
|
Why doesn't span display height? : <p>In the following code, why doesn't span adhere to the height rule:</p>
<pre><code><div style="border:1px black solid">
inside div
<span style="height:300px">inside span</span>
</div>
</code></pre>
<p><a href="http://scratchpad.io/hilarious-shirt-8130" rel="nofollow noreferrer">http://scratchpad.io/hilarious-shirt-8130</a></p>
| 0debug
|
static int net_socket_listen_init(NetClientState *peer,
const char *model,
const char *name,
const char *host_str)
{
NetClientState *nc;
NetSocketState *s;
struct sockaddr_in saddr;
int fd, ret;
Error *err = NULL;
if (parse_host_port(&saddr, host_str, &err) < 0) {
error_report_err(err);
return -1;
}
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
return -1;
}
qemu_set_nonblock(fd);
socket_set_fast_reuse(fd);
ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));
if (ret < 0) {
perror("bind");
closesocket(fd);
return -1;
}
ret = listen(fd, 0);
if (ret < 0) {
perror("listen");
closesocket(fd);
return -1;
}
nc = qemu_new_net_client(&net_socket_info, peer, model, name);
s = DO_UPCAST(NetSocketState, nc, nc);
s->fd = -1;
s->listen_fd = fd;
s->nc.link_down = true;
net_socket_rs_init(&s->rs, net_socket_rs_finalize, false);
qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s);
return 0;
}
| 1threat
|
Getting wrong answer : <p>So I am trying to solve a question on HackerEarth and I just don't get what is going wrong.. 11 out of 12 test cases are passed but one is failing..
Here is the question:</p>
<blockquote>
<p>Stephen wants to explore the space, let's say which is of N rows and N
columns. Each cell consist of a planet or black hole denoted with a
character '.' or '#' respectively. Stephen can only visit planets and
he can't move outside the grid.</p>
<p>Stephen wants to explore the unexplored space. So He follows the
instructions of Dr. Hawking to explore the space. Dr. Hawking sends
him a sequence of moves described by a string S of length L. Each
character is one of 'U', 'D', 'R', 'L', denoting directions: up, down,
right and left, respectively.</p>
<p>Depending on the starting cell, making all L moves might be
impossible. Stephen considers each planet as a starting one and
wonders how many moves in the sequence he can make, before being
forced to stop. For example, if S starts with 'R' but a cell on the
right from the starting cell is a black hole (or is outside the grid),
Stephen would do 0 moves.</p>
<p>Your task is to find the number of moves Stephen would do from each
starting cell, and print the bitwise XOR of those numbers.</p>
<p>Input The first line of the input contains an integer T denoting the
number of test cases. The description of T test cases follows.</p>
<p>The first line of each test case contains two integers L and N
denoting the length of the sequence of moves and the size of the grid.</p>
<p>The second line of a test case contains a string S denoting the
sequence of moves.</p>
<p>Next N lines describe the grid. The i-th line contains a string of
length N denoting the i-th row of the grid.</p>
<p>Output For each test case, output a single line containing one integer
— the bitwise XOR of the number of moves made by Limak from each
possible starting cell.</p>
<p>Constraints 1 ≤ T ≤ 100,1 ≤ L ≤ 1000,1 ≤ N ≤ 1000</p>
</blockquote>
<p>Sample Input:</p>
<pre><code>2
3 4
DDU
#..#
#...
...#
..#.
10 4
RLLRDDLUUL
....
.#..
..#.
.#.#
</code></pre>
<p>Sample Output:</p>
<pre><code>2
3
</code></pre>
<p>Explanation:</p>
<pre><code>Test case 1. We are given the grid of size N = 4, and a sequence of L = 3 moves. For each empty cell of the grid, below you can see the number of moves Limak would make:
# 3 3 #
# 3 1 0
1 1 0 #
0 0 # 0
The answer is 3 xor 3 xor 3 xor 1 xor 1 xor 1 = 2.
Test case 2. Again, below you can see the number of moves Limak would make from each cell:
2 4 5 0
0 # 2 0
2 0 # 0
0 # 0 #
</code></pre>
<p>Here is my solution:</p>
<pre><code>#include<iostream>
using namespace std;
char **a;
int l,n;
bool pos(int& x,int& y,char m)
{
if(m=='D')x++;
if(m=='U')x--;
if(m=='L')y--;
if(m=='R')y++;
if(x<0 || x>=n || y<0 || y>=n)return false;
if(a[x][y]=='#')return false;
return true;
}
int val(int x,int y,string s)
{
int t=0;
for(int i=0;i<s.length();i++)
{
if(pos(x,y,s[i]))t++;
else break;
}
return t;
}
int main()
{
int t;cin>>t;
while(t--)
{
int ans=0;
cin>>l>>n;
a=new char*[n];
for(int i=0;i<n;i++)a[i]=new char[n];
string s;cin>>s;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cin>>a[i][j];
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i][j]=='.')
{
ans=ans^val(i,j,s);
}
}
}
cout<<ans<<endl;
}
}
</code></pre>
<p>Can anyone spot any error in my logic? The solution works for 11 out of 12 cases but fails for 1 and I just cant spot the issue.. Any help would be appreciated.</p>
| 0debug
|
Validate a email field with jquery : <p>I need to validate a email field with jquery but the program doesn't work.</p>
<pre><code> var email_form=$('#email');
if(email_form!=null){
console.log("HI");
$('#email').on('input', function(){
console.log("show ");
});
}
</code></pre>
<p>The program prints "HI" but it doesn't print in "show".My purpose is to every time that an user writes a character in a email field I must validate this text. Anyone can help me?</p>
| 0debug
|
static float voice_factor(float *p_vector, float p_gain,
float *f_vector, float f_gain,
CELPMContext *ctx)
{
double p_ener = (double) ctx->dot_productf(p_vector, p_vector,
AMRWB_SFR_SIZE) *
p_gain * p_gain;
double f_ener = (double) ctx->dot_productf(f_vector, f_vector,
AMRWB_SFR_SIZE) *
f_gain * f_gain;
return (p_ener - f_ener) / (p_ener + f_ener);
}
| 1threat
|
what is the last parameter in getInt() method in SharedPerference Android : <p>What is meant by "-1" in last line of this SharedPreference program ?</p>
<pre><code>SharedPreferences sp = getSharedPreferences("your_prefs", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putInt("your_int_key", yourIntValue);
editor.commit();
SharedPreferences sp = getSharedPreferences("your_prefs", Activity.MODE_PRIVATE);
int myIntValue = sp.getInt("your_int_key", -1);
</code></pre>
| 0debug
|
I want to figure out what should "?" is in the code below : **Declare a class Zoo with a property weeklyHot which means the most popular one inthe zoo this week. The codes below can’t work correctly, please find what data typeshould A be and solve the problem**
class Animal{
let animal :String
enum Gender{
case male
case female
case undefined
}
init(animal : String) {
self.animal = animal
}
func eat(){
print("I eat everyyhing")
}
}
class Elephant : Animal{
override func eat() {
print("I eat grass")
}
}
class Tiger : Animal{
override func eat() {
print("I eat meat")
}
}
class Horse : Animal{
override func eat() {
print("I eat grass, too")
}
}
class Zoo {
var weekHot : ?
init(weeklyHot : ?){}
}
let zoo = Zoo(weeklyHot:Tiger())
zoo.weeklyHot = tiger
| 0debug
|
static EHCIQueue *ehci_state_fetchqh(EHCIState *ehci, int async)
{
EHCIPacket *p;
uint32_t entry, devaddr;
EHCIQueue *q;
entry = ehci_get_fetch_addr(ehci, async);
q = ehci_find_queue_by_qh(ehci, entry, async);
if (NULL == q) {
q = ehci_alloc_queue(ehci, entry, async);
}
p = QTAILQ_FIRST(&q->packets);
q->seen++;
if (q->seen > 1) {
ehci_set_state(ehci, async, EST_ACTIVE);
q = NULL;
goto out;
}
get_dwords(ehci, NLPTR_GET(q->qhaddr),
(uint32_t *) &q->qh, sizeof(EHCIqh) >> 2);
ehci_trace_qh(q, NLPTR_GET(q->qhaddr), &q->qh);
devaddr = get_field(q->qh.epchar, QH_EPCHAR_DEVADDR);
if (q->dev != NULL && q->dev->addr != devaddr) {
if (!QTAILQ_EMPTY(&q->packets)) {
ehci_cancel_queue(q);
}
q->dev = NULL;
}
if (q->dev == NULL) {
q->dev = ehci_find_device(q->ehci, devaddr);
}
if (p && p->async == EHCI_ASYNC_FINISHED) {
trace_usb_ehci_packet_action(p->queue, p, "complete");
ehci_set_state(ehci, async, EST_EXECUTING);
goto out;
}
if (async && (q->qh.epchar & QH_EPCHAR_H)) {
if (ehci->usbsts & USBSTS_REC) {
ehci_clear_usbsts(ehci, USBSTS_REC);
} else {
DPRINTF("FETCHQH: QH 0x%08x. H-bit set, reclamation status reset"
" - done processing\n", q->qhaddr);
ehci_set_state(ehci, async, EST_ACTIVE);
q = NULL;
goto out;
}
}
#if EHCI_DEBUG
if (q->qhaddr != q->qh.next) {
DPRINTF("FETCHQH: QH 0x%08x (h %x halt %x active %x) next 0x%08x\n",
q->qhaddr,
q->qh.epchar & QH_EPCHAR_H,
q->qh.token & QTD_TOKEN_HALT,
q->qh.token & QTD_TOKEN_ACTIVE,
q->qh.next);
}
#endif
if (q->qh.token & QTD_TOKEN_HALT) {
ehci_set_state(ehci, async, EST_HORIZONTALQH);
} else if ((q->qh.token & QTD_TOKEN_ACTIVE) &&
(NLPTR_TBIT(q->qh.current_qtd) == 0)) {
q->qtdaddr = q->qh.current_qtd;
ehci_set_state(ehci, async, EST_FETCHQTD);
} else {
ehci_set_state(ehci, async, EST_ADVANCEQUEUE);
}
out:
return q;
}
| 1threat
|
static void __attribute__((constructor)) init_main_loop(void)
{
init_clocks();
init_timer_alarm();
qemu_clock_enable(vm_clock, false);
}
| 1threat
|
static void bdrv_co_em_bh(void *opaque)
{
BlockAIOCBCoroutine *acb = opaque;
acb->common.cb(acb->common.opaque, acb->req.error);
qemu_bh_delete(acb->bh);
qemu_aio_unref(acb);
}
| 1threat
|
Please help me for this complexity of algorithm : I have 2 questions for algorithm analysis. Can please anyone tell me, what is complexity of:
first:
For(int i=1; i<n; i=i*i*i)
{
//something O(1)
}
Second:
n/1 + n/2 + n/3 +...+ n/n
Please help me with explanation.. Thank you
| 0debug
|
static inline void gen_op_eval_fbe(TCGv dst, TCGv src,
unsigned int fcc_offset)
{
gen_mov_reg_FCC0(dst, src, fcc_offset);
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset);
tcg_gen_or_tl(dst, dst, cpu_tmp0);
tcg_gen_xori_tl(dst, dst, 0x1);
}
| 1threat
|
please can you what does return -1 and return 1 means here and does is work : <p>I want to figure out what return -1 and return 1 did in following code
<a href="https://www.w3schools.com/js/tryit.asp?filename=tryjs_array_sort_object2" rel="nofollow noreferrer">https://www.w3schools.com/js/tryit.asp?filename=tryjs_array_sort_object2</a></p>
| 0debug
|
ioapic_mem_write(void *opaque, target_phys_addr_t addr, uint64_t val,
unsigned int size)
{
IOAPICCommonState *s = opaque;
int index;
switch (addr & 0xff) {
case IOAPIC_IOREGSEL:
s->ioregsel = val;
break;
case IOAPIC_IOWIN:
if (size != 4) {
break;
}
DPRINTF("write: %08x = %08" PRIx64 "\n", s->ioregsel, val);
switch (s->ioregsel) {
case IOAPIC_REG_ID:
s->id = (val >> IOAPIC_ID_SHIFT) & IOAPIC_ID_MASK;
break;
case IOAPIC_REG_VER:
case IOAPIC_REG_ARB:
break;
default:
index = (s->ioregsel - IOAPIC_REG_REDTBL_BASE) >> 1;
if (index >= 0 && index < IOAPIC_NUM_PINS) {
if (s->ioregsel & 1) {
s->ioredtbl[index] &= 0xffffffff;
s->ioredtbl[index] |= (uint64_t)val << 32;
} else {
s->ioredtbl[index] &= ~0xffffffffULL;
s->ioredtbl[index] |= val;
}
ioapic_service(s);
}
}
break;
}
}
| 1threat
|
How do I stop my divs from moving on other computers : <p>On my website template I have divs that look fine on my screen. but if I restore down the browser or look at it on another computer the divs are moved.
Is there some sort of tag I can use to make my div stay in place.</p>
<p>//example of a div </p>
<pre><code>#divtest{
width:450px;
height:75px;
margin:20px;
margin-top: 150px;
display:flex;
border-width: 2px;
border-color: black;
border-style: solid;
margin-left: -7%;
}
</code></pre>
| 0debug
|
C# Windows Picture Box Image Flickering : C# windows.
I have a panel containing multiple picturebox.
I want to give users the option of selecting any part of any picturebox.
The user will select it by mouse.
I want to draw a semi-transparent rectangle on the picturebox while the mouse move as per the selection.
The code is working fine, but the rectangle is flickering. **I want to stop the flickering.**
I tried double buffer using http://stackoverflow.com/questions/8046560/how-to-stop-flickering-c-sharp-winforms
Also, added Invalide using http://stackoverflow.com/questions/19469210/how-to-force-graphic-to-be-redrawn-with-the-invalidate-method
But not working. Please help.
My Code:
private Brush selectionBrush = new SolidBrush(Color.FromArgb(70, 76, 255, 0));
private void Picture_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left) return;
PictureBox pb = (PictureBox)(sender);
Point tempEndPoint = e.Location;
Rect.Location = new Point(
Math.Min(RecStartpoint.X, tempEndPoint.X),
Math.Min(RecStartpoint.Y, tempEndPoint.Y));
Rect.Size = new Size(
Math.Abs(RecStartpoint.X - tempEndPoint.X),
Math.Abs(RecStartpoint.Y - tempEndPoint.Y));
pb.CreateGraphics().FillRectangle(selectionBrush, Rect);
pb.Invalidate(Rect);
}
| 0debug
|
creating jar file for java appication using derby database : <p>I have recently developed a school management system in java netbeans using derby(java built in database).Now i want to make a jar file and proivide it to my client .So can this jar run on client pc without netbeans or java installed? and what about database?</p>
| 0debug
|
static void imx_eth_enable_rx(IMXFECState *s)
{
IMXFECBufDesc bd;
bool rx_ring_full;
imx_fec_read_bd(&bd, s->rx_descriptor);
rx_ring_full = !(bd.flags & ENET_BD_E);
if (rx_ring_full) {
FEC_PRINTF("RX buffer full\n");
} else if (!s->regs[ENET_RDAR]) {
qemu_flush_queued_packets(qemu_get_queue(s->nic));
}
s->regs[ENET_RDAR] = rx_ring_full ? 0 : ENET_RDAR_RDAR;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.