problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
const uint8_t *buf, int buf_size)
{
int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos;
int big_offsets, offset_size, is_8bit = 0;
const uint8_t *yuv_palette = NULL;
uint8_t *colormap = ctx->colormap, *alpha = ctx->alpha;
int date;
int i;
int is_menu = 0;
if (buf_size < 10)
return -1;
if (AV_RB16(buf) == 0) {
big_offsets = 1;
offset_size = 4;
cmd_pos = 6;
} else {
big_offsets = 0;
offset_size = 2;
cmd_pos = 2;
}
cmd_pos = READ_OFFSET(buf + cmd_pos);
if (cmd_pos < 0 || cmd_pos > buf_size - 2 - offset_size)
return AVERROR(EAGAIN);
while (cmd_pos > 0 && cmd_pos < buf_size - 2 - offset_size) {
date = AV_RB16(buf + cmd_pos);
next_cmd_pos = READ_OFFSET(buf + cmd_pos + 2);
av_dlog(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n",
cmd_pos, next_cmd_pos, date);
pos = cmd_pos + 2 + offset_size;
offset1 = -1;
offset2 = -1;
x1 = y1 = x2 = y2 = 0;
while (pos < buf_size) {
cmd = buf[pos++];
av_dlog(NULL, "cmd=%02x\n", cmd);
switch(cmd) {
case 0x00:
is_menu = 1;
break;
case 0x01:
sub_header->start_display_time = (date << 10) / 90;
break;
case 0x02:
sub_header->end_display_time = (date << 10) / 90;
break;
case 0x03:
if ((buf_size - pos) < 2)
goto fail;
colormap[3] = buf[pos] >> 4;
colormap[2] = buf[pos] & 0x0f;
colormap[1] = buf[pos + 1] >> 4;
colormap[0] = buf[pos + 1] & 0x0f;
pos += 2;
break;
case 0x04:
if ((buf_size - pos) < 2)
goto fail;
alpha[3] = buf[pos] >> 4;
alpha[2] = buf[pos] & 0x0f;
alpha[1] = buf[pos + 1] >> 4;
alpha[0] = buf[pos + 1] & 0x0f;
pos += 2;
av_dlog(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
break;
case 0x05:
case 0x85:
if ((buf_size - pos) < 6)
goto fail;
x1 = (buf[pos] << 4) | (buf[pos + 1] >> 4);
x2 = ((buf[pos + 1] & 0x0f) << 8) | buf[pos + 2];
y1 = (buf[pos + 3] << 4) | (buf[pos + 4] >> 4);
y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5];
if (cmd & 0x80)
is_8bit = 1;
av_dlog(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
pos += 6;
break;
case 0x06:
if ((buf_size - pos) < 4)
goto fail;
offset1 = AV_RB16(buf + pos);
offset2 = AV_RB16(buf + pos + 2);
av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 4;
break;
case 0x86:
if ((buf_size - pos) < 8)
goto fail;
offset1 = AV_RB32(buf + pos);
offset2 = AV_RB32(buf + pos + 4);
av_dlog(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
pos += 8;
break;
case 0x83:
if ((buf_size - pos) < 768)
goto fail;
yuv_palette = buf + pos;
pos += 768;
break;
case 0x84:
if ((buf_size - pos) < 256)
goto fail;
for (i = 0; i < 256; i++)
alpha[i] = 0xFF - buf[pos+i];
pos += 256;
break;
case 0xff:
goto the_end;
default:
av_dlog(NULL, "unrecognised subpicture command 0x%x\n", cmd);
goto the_end;
}
}
the_end:
if (offset1 >= 0) {
int w, h;
uint8_t *bitmap;
w = x2 - x1 + 1;
if (w < 0)
w = 0;
h = y2 - y1 + 1;
if (h < 0)
h = 0;
if (w > 0 && h > 0) {
reset_rects(sub_header);
bitmap = av_malloc(w * h);
sub_header->rects = av_mallocz(sizeof(*sub_header->rects));
sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
sub_header->num_rects = 1;
sub_header->rects[0]->pict.data[0] = bitmap;
decode_rle(bitmap, w * 2, w, (h + 1) / 2,
buf, offset1, buf_size, is_8bit);
decode_rle(bitmap + w, w * 2, w, h / 2,
buf, offset2, buf_size, is_8bit);
sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
if (is_8bit) {
if (!yuv_palette)
goto fail;
sub_header->rects[0]->nb_colors = 256;
yuv_a_to_rgba(yuv_palette, alpha, (uint32_t*)sub_header->rects[0]->pict.data[1], 256);
} else {
sub_header->rects[0]->nb_colors = 4;
guess_palette(ctx, (uint32_t*)sub_header->rects[0]->pict.data[1],
0xffff00);
}
sub_header->rects[0]->x = x1;
sub_header->rects[0]->y = y1;
sub_header->rects[0]->w = w;
sub_header->rects[0]->h = h;
sub_header->rects[0]->type = SUBTITLE_BITMAP;
sub_header->rects[0]->pict.linesize[0] = w;
sub_header->rects[0]->flags = is_menu ? AV_SUBTITLE_FLAG_FORCED : 0;
}
}
if (next_cmd_pos < cmd_pos) {
av_log(NULL, AV_LOG_ERROR, "Invalid command offset\n");
break;
}
if (next_cmd_pos == cmd_pos)
break;
cmd_pos = next_cmd_pos;
}
if (sub_header->num_rects > 0)
return is_menu;
fail:
reset_rects(sub_header);
return -1;
}
| 1threat
|
static void unassign_storage(SCCB *sccb)
{
MemoryRegion *mr = NULL;
AssignStorage *assign_info = (AssignStorage *) sccb;
sclpMemoryHotplugDev *mhd = get_sclp_memory_hotplug_dev();
assert(mhd);
ram_addr_t unassign_addr = (assign_info->rn - 1) * mhd->rzm;
MemoryRegion *sysmem = get_system_memory();
if ((unassign_addr % MEM_SECTION_SIZE == 0) &&
(unassign_addr >= mhd->padded_ram_size)) {
mhd->standby_state_map[(unassign_addr -
mhd->padded_ram_size) / MEM_SECTION_SIZE] = 0;
mr = memory_region_find(sysmem, unassign_addr, 1).mr;
if (mr) {
int i;
int is_removable = 1;
ram_addr_t map_offset = (unassign_addr - mhd->padded_ram_size -
(unassign_addr - mhd->padded_ram_size)
% mhd->standby_subregion_size);
for (i = 0;
i < (mhd->standby_subregion_size / MEM_SECTION_SIZE);
i++) {
if (mhd->standby_state_map[i + map_offset / MEM_SECTION_SIZE]) {
is_removable = 0;
break;
}
}
if (is_removable) {
memory_region_del_subregion(sysmem, mr);
object_unparent(OBJECT(mr));
g_free(mr);
}
}
}
sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_COMPLETION);
}
| 1threat
|
uint16_t css_build_subchannel_id(SubchDev *sch)
{
if (channel_subsys.max_cssid > 0) {
return (sch->cssid << 8) | (1 << 3) | (sch->ssid << 1) | 1;
}
return (sch->ssid << 1) | 1;
}
| 1threat
|
void css_adapter_interrupt(uint8_t isc)
{
S390CPU *cpu = s390_cpu_addr2state(0);
uint32_t io_int_word = (isc << 27) | IO_INT_WORD_AI;
trace_css_adapter_interrupt(isc);
s390_io_interrupt(cpu, 0, 0, 0, io_int_word);
}
| 1threat
|
I have two questions about Hyperledger Fabric,can somebody help me?Thank you : I'm a novice fabric, hope someone can answer my two questions:
1:When I call the "Invoke" method, how is the data passed to my Chaincode?Can you post some primary functions?
{
"jsonrpc": "2.0",
"method": "invoke",
"params": {
"type": 1,
"chaincodeID":{
"name":"mycc"
},
"ctorMsg": {
"args":["invoke", "a", "b", "10"]
}
},
"id": 3
}
2:How and when the consensus service put data to database?
| 0debug
|
How Do I Make Li Boxes Line Up If They Contain Variable Length Text? : <p>I am using an unordered list with li items to display multiple boxes across the page, and onto multiple lines. Each box contains variable text length which pushes up the height of some of the boxes. <a href="http://webref.eu/test-uniform-box-size.htm" rel="nofollow noreferrer">Here's the example</a>.</p>
<p>How do I get all rows of boxes to line up across the page nicely? </p>
<p>Thanks</p>
| 0debug
|
Bulk saving complex objects SQLAlchemy : <pre><code>association_table = Table("association_table",
Base.metadata,
Column("show_id", Integer(), ForeignKey("show_times.id"), primary_key=True),
Column("theater_id", Integer(), ForeignKey("theaters.id")))
association_table2 = Table("association_table2",
Base.metadata,
Column("show_id", Integer(), ForeignKey("show_times.id"), primary_key=True),
Column("movie_id", Integer(), ForeignKey("movies.id")))
class Movie(Base):
__tablename__ = "movies"
id = Column(Integer, primary_key=True)
title = Column(String(), unique=True)
plot = Column(String())
duration = Column(String())
rating = Column(String())
trailer = Column(String())
imdb = Column(String())
poster = Column(String())
summary = Column(String())
class Theater(Base):
__tablename__ = "theaters"
id = Column(Integer, primary_key=True)
zip_code = Column(String())
city = Column(String())
state = Column(String())
address = Column(String())
phone_number = Column(String())
class Showtime(Base):
__tablename__ = "show_times"
id = Column(Integer, primary_key=True)
date = Column(Date())
theaterz = relationship("Theater", secondary=association_table)
moviez = relationship("Movie", secondary=association_table2)
showtimes = Column(String())
</code></pre>
<p>supposing we have movie objects:</p>
<pre><code>movie_1 = Movie(title="Cap Murica",
plot="Cap punches his way to freedom",
duration="2 hours")
movie_2 = Movie(title="Cap Murica 22222",
plot="Cap punches his way to freedom again",
duration="2 hours")
</code></pre>
<p>and a theater object:</p>
<pre><code>theater = Theater(name="Regal Cinemas",
zip_code="00000",
city="Houston",
state="TX")
</code></pre>
<p>how do we bulk save this into the <code>show_times</code> Model?</p>
<p>I've tried doing this:</p>
<pre><code>movies = [movie_1, movie_2] # these movie objects are from the code snippet above
show_times = Showtime(date="5/19/2016",
theaterz=[theater],
moviez=movies)
session.add(show_times)
session.commit()
</code></pre>
<p>hurray the above works. but when i do it in bulk like this:</p>
<pre><code>showtime_lists = [show_time1, show_time2, showtime3] # these are basically just the same show time objects as above
session.bulk_save_objects(showtime_lists)
session.commit()
</code></pre>
<p>it doesn't fail but the data also doesn't get persisted to the database.</p>
<p>I mean is there an alternative to adding each <code>show_time</code> to the session individually? A bulk insert would be better but I don't get why the data doesn't get persisted if done that way.</p>
| 0debug
|
How to convert "hh:mm AM/PM" string to formatted time? : <p>I have string inputs as "03:00 PM" or "09:00 AM", which i want to convert it to formatted time or even to integer. So that I can compare them by the order of time.
Anyone can help me with that?</p>
<p>Thank you in advance.</p>
| 0debug
|
static int xan_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int ret, buf_size = avpkt->size;
XanContext *s = avctx->priv_data;
if (avctx->codec->id == CODEC_ID_XAN_WC3) {
const uint8_t *buf_end = buf + buf_size;
int tag = 0;
while (buf_end - buf > 8 && tag != VGA__TAG) {
unsigned *tmpptr;
uint32_t new_pal;
int size;
int i;
tag = bytestream_get_le32(&buf);
size = bytestream_get_be32(&buf);
size = FFMIN(size, buf_end - buf);
switch (tag) {
case PALT_TAG:
if (size < PALETTE_SIZE)
return AVERROR_INVALIDDATA;
if (s->palettes_count >= PALETTES_MAX)
return AVERROR_INVALIDDATA;
tmpptr = av_realloc(s->palettes, (s->palettes_count + 1) * AVPALETTE_SIZE);
if (!tmpptr)
return AVERROR(ENOMEM);
s->palettes = tmpptr;
tmpptr += s->palettes_count * AVPALETTE_COUNT;
for (i = 0; i < PALETTE_COUNT; i++) {
#if RUNTIME_GAMMA
int r = gamma_corr(*buf++);
int g = gamma_corr(*buf++);
int b = gamma_corr(*buf++);
#else
int r = gamma_lookup[*buf++];
int g = gamma_lookup[*buf++];
int b = gamma_lookup[*buf++];
#endif
*tmpptr++ = (r << 16) | (g << 8) | b;
}
s->palettes_count++;
break;
case SHOT_TAG:
if (size < 4)
return AVERROR_INVALIDDATA;
new_pal = bytestream_get_le32(&buf);
if (new_pal < s->palettes_count) {
s->cur_palette = new_pal;
} else
av_log(avctx, AV_LOG_ERROR, "Invalid palette selected\n");
break;
case VGA__TAG:
break;
default:
buf += size;
break;
}
}
buf_size = buf_end - buf;
}
if ((ret = avctx->get_buffer(avctx, &s->current_frame))) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
s->current_frame.reference = 3;
if (!s->frame_size)
s->frame_size = s->current_frame.linesize[0] * s->avctx->height;
memcpy(s->current_frame.data[1], s->palettes + s->cur_palette * AVPALETTE_COUNT, AVPALETTE_SIZE);
s->buf = buf;
s->size = buf_size;
xan_wc3_decode_frame(s);
if (s->last_frame.data[0])
avctx->release_buffer(avctx, &s->last_frame);
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->current_frame;
FFSWAP(AVFrame, s->current_frame, s->last_frame);
return buf_size;
}
| 1threat
|
Trying to hash a password using bcrypt inside an async function : <p>Following on from <a href="https://stackoverflow.com/questions/48799479/async-function-in-mongoose-pre-save-hook-not-working?noredirect=1#comment84602023_48799479">this question</a>.</p>
<p>I feel like I'm almost there, but my incomplete understanding of async is preventing me from solving this. I'm basically trying to just hash a password using bcrypt and have decided to seperate out the hashPassword function so that I can potentially use it in other parts of the app. </p>
<p><code>hashedPassword</code> keeps returning undefined though...</p>
<pre><code>userSchema.pre('save', async function (next) {
let user = this
const password = user.password;
const hashedPassword = await hashPassword(user);
user.password = hashedPassword
next()
})
async function hashPassword (user) {
const password = user.password
const saltRounds = 10;
const hashedPassword = await bcrypt.hash(password, saltRounds, function(err, hash) {
if (err) {
return err;
}
return hash
});
return hashedPassword
}
</code></pre>
| 0debug
|
static void qmp_monitor_complete(void *opaque, QObject *ret_data)
{
monitor_protocol_emitter(opaque, ret_data);
}
| 1threat
|
static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
vorbis_residue *vr,
unsigned ch,
uint8_t *do_not_decode,
float *vec,
unsigned vlen,
unsigned ch_left,
int vr_type)
{
GetBitContext *gb = &vc->gb;
unsigned c_p_c = vc->codebooks[vr->classbook].dimensions;
uint8_t *classifs = vr->classifs;
unsigned pass, ch_used, i, j, k, l;
unsigned max_output = (ch - 1) * vlen;
int ptns_to_read = vr->ptns_to_read;
if (vr_type == 2) {
for (j = 1; j < ch; ++j)
do_not_decode[0] &= do_not_decode[j];
if (do_not_decode[0])
return 0;
ch_used = 1;
max_output += vr->end / ch;
} else {
ch_used = ch;
max_output += vr->end;
}
if (max_output > ch_left * vlen) {
av_log(vc->avctx, AV_LOG_ERROR, "Insufficient output buffer\n");
return AVERROR_INVALIDDATA;
}
av_dlog(NULL, " residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c);
for (pass = 0; pass <= vr->maxpass; ++pass) {
int voffset, partition_count, j_times_ptns_to_read;
voffset = vr->begin;
for (partition_count = 0; partition_count < ptns_to_read;) {
if (!pass) {
setup_classifs(vc, vr, do_not_decode, ch_used, partition_count);
}
for (i = 0; (i < c_p_c) && (partition_count < ptns_to_read); ++i) {
for (j_times_ptns_to_read = 0, j = 0; j < ch_used; ++j) {
unsigned voffs;
if (!do_not_decode[j]) {
unsigned vqclass = classifs[j_times_ptns_to_read + partition_count];
int vqbook = vr->books[vqclass][pass];
if (vqbook >= 0 && vc->codebooks[vqbook].codevectors) {
unsigned coffs;
unsigned dim = vc->codebooks[vqbook].dimensions;
unsigned step = FASTDIV(vr->partition_size << 1, dim << 1);
vorbis_codebook codebook = vc->codebooks[vqbook];
if (vr_type == 0) {
voffs = voffset+j*vlen;
for (k = 0; k < step; ++k) {
coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
for (l = 0; l < dim; ++l)
vec[voffs + k + l * step] += codebook.codevectors[coffs + l];
}
} else if (vr_type == 1) {
voffs = voffset + j * vlen;
for (k = 0; k < step; ++k) {
coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
for (l = 0; l < dim; ++l, ++voffs) {
vec[voffs]+=codebook.codevectors[coffs+l];
av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d \n",
pass, voffs, vec[voffs], codebook.codevectors[coffs+l], coffs);
}
}
} else if (vr_type == 2 && ch == 2 && (voffset & 1) == 0 && (dim & 1) == 0) {
voffs = voffset >> 1;
if (dim == 2) {
for (k = 0; k < step; ++k) {
coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * 2;
vec[voffs + k ] += codebook.codevectors[coffs ];
vec[voffs + k + vlen] += codebook.codevectors[coffs + 1];
}
} else if (dim == 4) {
for (k = 0; k < step; ++k, voffs += 2) {
coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * 4;
vec[voffs ] += codebook.codevectors[coffs ];
vec[voffs + 1 ] += codebook.codevectors[coffs + 2];
vec[voffs + vlen ] += codebook.codevectors[coffs + 1];
vec[voffs + vlen + 1] += codebook.codevectors[coffs + 3];
}
} else
for (k = 0; k < step; ++k) {
coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
for (l = 0; l < dim; l += 2, voffs++) {
vec[voffs ] += codebook.codevectors[coffs + l ];
vec[voffs + vlen] += codebook.codevectors[coffs + l + 1];
av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n",
pass, voffset / ch + (voffs % ch) * vlen,
vec[voffset / ch + (voffs % ch) * vlen],
codebook.codevectors[coffs + l], coffs, l);
}
}
} else if (vr_type == 2) {
unsigned voffs_div = FASTDIV(voffset << 1, ch <<1);
unsigned voffs_mod = voffset - voffs_div * ch;
for (k = 0; k < step; ++k) {
coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
for (l = 0; l < dim; ++l) {
vec[voffs_div + voffs_mod * vlen] +=
codebook.codevectors[coffs + l];
av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n",
pass, voffs_div + voffs_mod * vlen,
vec[voffs_div + voffs_mod * vlen],
codebook.codevectors[coffs + l], coffs, l);
if (++voffs_mod == ch) {
voffs_div++;
voffs_mod = 0;
}
}
}
}
}
}
j_times_ptns_to_read += ptns_to_read;
}
++partition_count;
voffset += vr->partition_size;
}
}
}
return 0;
}
| 1threat
|
How to get the zoom level from the leaflet map in R/shiny? : <p>I create a map using leaflet package in Shiny which have a <code>selectInput</code> to allow user to select from a site list. The site list also adds into leaflet as markers.</p>
<p>When user selects a new site, I want to recenter map into the selected site without change the zoom level. The <code>setView</code> function can be called to set center points, but has to specify the zoom level. </p>
<p>Is it possible to get the zoom level of leaflet map which can be used in the <code>setView</code> function?</p>
<p>This is a minimum example to play with my question with reset zoom level.</p>
<pre><code>library(shiny)
library(leaflet)
df <- data.frame(
site = c('S1', 'S2'),
lng = c(140, 120),
lat = c(-20, -30),
stringsAsFactors = FALSE)
# Define UI for application that draws a histogram
ui <- shinyUI(fluidPage(
selectInput('site', 'Site', df$site),
leafletOutput('map')
))
server <- shinyServer(function(input, output, session) {
output$map <- renderLeaflet({
leaflet() %>%
addTiles() %>%
setView(lng = 133, lat = -25, zoom = 4) %>%
addMarkers(lng = df$lng, lat = df$lat)
})
observe({
req(input$site)
sel_site <- df[df$site == input$site,]
isolate({
leafletProxy('map') %>%
setView(lng = sel_site$lng, lat = sel_site$lat, zoom = 4)
})
})
})
shinyApp(ui = ui, server = server)
</code></pre>
<p>PS: when you play with these codes, please adjust zoom level before selecting a new site.</p>
<p>Thanks of any suggestions.</p>
| 0debug
|
Stuck on Rosalind Python Village - Variables and Some Arithmetics : http://rosalind.info/problems/ini2/
Given: Two positive integers a and b, each less than 1000.
Return: The integer corresponding to the square of the hypotenuse of the right triangle whose legs have lengths a and b
ex)for dataset 3,4 return 25
the dataset is always different for every trial.
a=859
b=938
print( a**2 + b**2 )
I've tried this code on my computer, and it worked. But Rosalind won't take it. What might be wrong in this code?
| 0debug
|
static BlockDriverAIOCB *raw_aio_writev(BlockDriverState *bs,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque)
{
const uint8_t *first_buf;
int first_buf_index = 0, i;
for (i = 0; i < qiov->niov; i++) {
if (qiov->iov[i].iov_len) {
assert(qiov->iov[i].iov_len >= 512);
first_buf_index = i;
break;
}
}
first_buf = qiov->iov[first_buf_index].iov_base;
if (check_write_unsafe(bs, sector_num, first_buf, nb_sectors)) {
RawScrubberBounce *b;
int ret;
ret = raw_write_scrubbed_bootsect(bs, first_buf);
if (ret < 0) {
return NULL;
}
b = qemu_malloc(sizeof(*b));
b->cb = cb;
b->opaque = opaque;
qemu_iovec_init(&b->qiov, qiov->nalloc);
qemu_iovec_concat(&b->qiov, qiov, qiov->size);
b->qiov.size -= 512;
b->qiov.iov[first_buf_index].iov_base += 512;
b->qiov.iov[first_buf_index].iov_len -= 512;
return bdrv_aio_writev(bs->file, sector_num + 1, &b->qiov,
nb_sectors - 1, raw_aio_writev_scrubbed, b);
}
return bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, cb, opaque);
}
| 1threat
|
How to get data from html form and save in database(with button) using angular? : I want to get data from input boxes and save it in a database with a click on the button . I'm using angular.How i can get this data from my from? Please help me.
I have this HTML code:
<form ng-submit="createUser(userForm.$valid)" name="userForm1">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="database_address">User</label>
<input type="text" class="form-control1" ng-model="usernamee" placeholder="Потребителско Име..." />
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="text" class="form-control1" ng-model="passwordd"required id="password" />
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="username">Operator</label>
<input type="text" class="form-control1" ng-model="namee" required id="username" />
</div>
</div>
</div>
<button class="btn btn-primary" ng-click="createUser();" type="submit">Add user</button>
<!--<button class="btn btn-primary" ng-disabled="userForm.$invalid" type="submit">Добавяне на нов</button>-->
</form>
And Angular code:
$scope.createUser=function()
{
//console.log($scope.activeItem);
//delete $scope.activeItem.hash_method
var objectToSave = {
username: console.log($scope.usernamee),
password: console.log($scope.passwordd),
name: console.log($scope.namee),
id: $scope.id
};
{
defaultAdapter.query('INSERT INTO users(username,password,name,id) VALUES(username = :usernamee, password = :passwordd,name = :namee WHERE id =:id)',
{ replacements: objectToSave, type: Sequelize.QueryTypes.UPDATE }
).then(projects => {
console.log(projects);
$scope.editMode = false;
$scope.activeItem = false;
$scope.refresh();
});
}
}
| 0debug
|
why is the garbage value for an integer so un-integerly huge : <p>Today while experimenting with a C++ program i tried to get a random variable from a garbage value with code that read</p>
<pre><code>int main(){
int x,r;
r = x%7
cout << r;
}
</code></pre>
<p>needless to say this method didn't work since x was being used without initialization however when I looked at he variable watch I saw that the garbage value of x was -846.... and the same value for r. This confused me as to how could an integer hold such insanely huge garbage values. Normally C++ integers are ±32676 however the insane 7+ digit value I saw was never in this range. What could be the reason for this very large value if integers can hold only small values</p>
| 0debug
|
Xcode 9 Wireless debugging not working : <p>For some reason the wireless debugging does not work here. Here is what I've done:</p>
<ul>
<li>Using newest Xcode 9</li>
<li>Using newest iOS 11 on my iPhone 7+</li>
<li>Both devices are in the same network</li>
<li>Connected the iPhone via Lightning, selected "Connect via Network" in the Devices & Simulator menu</li>
<li>Run an app on the iPhone while still connected via Lightning - everything works</li>
</ul>
<p>But as soon as I unplug the phone, Xcode is no longer able to connect with the phone. I can ping the phone with the Mac, but even the "connect via ip" option in Xcode does not work.</p>
<p>Anybody got tips on how to get this working?</p>
| 0debug
|
Some sort of error in android studio in .java : Something is wrong with my java file, but I don't know what it is. Can someone please tell me.
BTW, I'm new to this
Thank You
[Screenshot][1]
[1]: https://i.stack.imgur.com/xgrzV.png
| 0debug
|
void do_device_add(Monitor *mon, const QDict *qdict)
{
QemuOpts *opts;
opts = qemu_opts_parse(&qemu_device_opts,
qdict_get_str(qdict, "config"), "driver");
if (opts && !qdev_device_help(opts))
qdev_device_add(opts);
}
| 1threat
|
"non-static variable cannot be initialized from a static context" java error : <p>i'm researching on how to make a parameter that accepts any object, i found an answer and i tried recreating the code. but the problem is whenever i initialize Bee,Horse and Apple it always shows the error "non-static variable cannot be initialized from a static context". so how is this wrong?</p>
<pre><code>public class Testing{
public static void main(String[]args){
Bee a= new Bee();
Horse b= new Horse();
Apple c= new Apple():
}
private interface holder{
public int getX();
}
private class Bee implements holder{
int a=52;
public int getX(){
return a;
}
}
private class Horse implements holder{
int a=62;
public int getX(){
return a;
}
}
</code></pre>
| 0debug
|
Can QML caching in Qt 5.8 be disabled for a particular project? : <p>Qt 5.8 was supposed to come with the optional use ahead of time qtquick compiler, instead it arrived with a sort-of-a-jit-compiler, a feature that's enabled by default and caches compiled QML files on disk in order to improve startup performance and reduce memory usage.</p>
<p>The feature however arrives with <a href="https://bugreports.qt.io/browse/QTBUG-56935">serious</a> <a href="https://bugreports.qt.io/browse/QTBUG-58486">bugs</a> which greatly diminish, or in my case even completely negate its benefits, as I didn't have a problem with startup times to begin with, and testing didn't reveal any memory usage improvements whatsoever.</p>
<p>So what I would like to do is opt out of that feature in my project, but I don't seem to find how to do that. Going back to Qt 5.7.1 is not an option since my project relies on other new features, introduced with 5.8.</p>
| 0debug
|
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
| 1threat
|
vba excel code...i want to know why it can't read duplicates?...need your help guys...TIA :) : r = 11
Do While Not tgtWSheet.Cells(r, 2) = "0"
If tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 1, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 2, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 3, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 4, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 5, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 6, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 7, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 8, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 9, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 10, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 11, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 12, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 13, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 14, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 15, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 16, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 17, 2) Or tgtWSheet.Cells(r, 2) = tgtWSheet.Cells(r + 18, 2) Then
MsgBox "Duplicate Record Found!"
Exit Sub
Else
r = r + 1
End If
Loop
| 0debug
|
How to add text temporarly for contains using ArrayList? Java : ##Summary##
I am developing a programming language in Java (using Eclipse). For my compiler, I split the text the user inputs in using the character ";", then converts the list to an ArrayList. It then goes through each line in the ArrayList, and checks what it is doing.
##The Problem?##
When it breaks it down into multiple lines, there is a "\n" at the beginning of the line because each line of code is on it's own line.
I am doing somethings with calling functions using variables, for example,
container.callFunction();
So I have to figure out is "container" is a variable. I have an ArrayList of all the variables created while running the code. So in the ArrayList containing variables, called "variables", is the string "container". But when my compiler breaks the lines down, it ends up with "\ncontainer", then I use the ArrayList.contains() method to confirm the item is a variable. But in variables, there is "container", but no "\ncontainer".
I know a solution to this, but I just don't exactly know how to do it. I could add the "\n" to the beginning of the variables array temporarily for the .contains() method. Does any one know how to do that, or have a better solution to this?
| 0debug
|
How to run react-native run-ios with specific target : <p>Is there a way to run a specific target with command</p>
<pre><code>react-native run-ios
</code></pre>
<p>for Android I'm using following</p>
<pre><code>react-native run-android --variant=targetRelease
</code></pre>
| 0debug
|
static void fsl_imx6_realize(DeviceState *dev, Error **errp)
{
FslIMX6State *s = FSL_IMX6(dev);
uint16_t i;
Error *err = NULL;
for (i = 0; i < smp_cpus; i++) {
if (smp_cpus > 1) {
object_property_set_int(OBJECT(&s->cpu[i]), FSL_IMX6_A9MPCORE_ADDR,
"reset-cbar", &error_abort);
}
if (i) {
object_property_set_bool(OBJECT(&s->cpu[i]), true,
"start-powered-off", &error_abort);
}
object_property_set_bool(OBJECT(&s->cpu[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
}
object_property_set_int(OBJECT(&s->a9mpcore), smp_cpus, "num-cpu",
&error_abort);
object_property_set_int(OBJECT(&s->a9mpcore),
FSL_IMX6_MAX_IRQ + GIC_INTERNAL, "num-irq",
&error_abort);
object_property_set_bool(OBJECT(&s->a9mpcore), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->a9mpcore), 0, FSL_IMX6_A9MPCORE_ADDR);
for (i = 0; i < smp_cpus; i++) {
sysbus_connect_irq(SYS_BUS_DEVICE(&s->a9mpcore), i,
qdev_get_gpio_in(DEVICE(&s->cpu[i]), ARM_CPU_IRQ));
sysbus_connect_irq(SYS_BUS_DEVICE(&s->a9mpcore), i + smp_cpus,
qdev_get_gpio_in(DEVICE(&s->cpu[i]), ARM_CPU_FIQ));
}
object_property_set_bool(OBJECT(&s->ccm), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX6_CCM_ADDR);
object_property_set_bool(OBJECT(&s->src), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->src), 0, FSL_IMX6_SRC_ADDR);
for (i = 0; i < FSL_IMX6_NUM_UARTS; i++) {
static const struct {
hwaddr addr;
unsigned int irq;
} serial_table[FSL_IMX6_NUM_UARTS] = {
{ FSL_IMX6_UART1_ADDR, FSL_IMX6_UART1_IRQ },
{ FSL_IMX6_UART2_ADDR, FSL_IMX6_UART2_IRQ },
{ FSL_IMX6_UART3_ADDR, FSL_IMX6_UART3_IRQ },
{ FSL_IMX6_UART4_ADDR, FSL_IMX6_UART4_IRQ },
{ FSL_IMX6_UART5_ADDR, FSL_IMX6_UART5_IRQ },
};
if (i < MAX_SERIAL_PORTS) {
Chardev *chr;
chr = serial_hds[i];
if (!chr) {
char *label = g_strdup_printf("imx6.uart%d", i + 1);
chr = qemu_chr_new(label, "null");
g_free(label);
serial_hds[i] = chr;
}
qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
}
object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
qdev_get_gpio_in(DEVICE(&s->a9mpcore),
serial_table[i].irq));
}
s->gpt.ccm = IMX_CCM(&s->ccm);
object_property_set_bool(OBJECT(&s->gpt), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt), 0, FSL_IMX6_GPT_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt), 0,
qdev_get_gpio_in(DEVICE(&s->a9mpcore),
FSL_IMX6_GPT_IRQ));
for (i = 0; i < FSL_IMX6_NUM_EPITS; i++) {
static const struct {
hwaddr addr;
unsigned int irq;
} epit_table[FSL_IMX6_NUM_EPITS] = {
{ FSL_IMX6_EPIT1_ADDR, FSL_IMX6_EPIT1_IRQ },
{ FSL_IMX6_EPIT2_ADDR, FSL_IMX6_EPIT2_IRQ },
};
s->epit[i].ccm = IMX_CCM(&s->ccm);
object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0,
qdev_get_gpio_in(DEVICE(&s->a9mpcore),
epit_table[i].irq));
}
for (i = 0; i < FSL_IMX6_NUM_I2CS; i++) {
static const struct {
hwaddr addr;
unsigned int irq;
} i2c_table[FSL_IMX6_NUM_I2CS] = {
{ FSL_IMX6_I2C1_ADDR, FSL_IMX6_I2C1_IRQ },
{ FSL_IMX6_I2C2_ADDR, FSL_IMX6_I2C2_IRQ },
{ FSL_IMX6_I2C3_ADDR, FSL_IMX6_I2C3_IRQ }
};
object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0,
qdev_get_gpio_in(DEVICE(&s->a9mpcore),
i2c_table[i].irq));
}
for (i = 0; i < FSL_IMX6_NUM_GPIOS; i++) {
static const struct {
hwaddr addr;
unsigned int irq_low;
unsigned int irq_high;
} gpio_table[FSL_IMX6_NUM_GPIOS] = {
{
FSL_IMX6_GPIO1_ADDR,
FSL_IMX6_GPIO1_LOW_IRQ,
FSL_IMX6_GPIO1_HIGH_IRQ
},
{
FSL_IMX6_GPIO2_ADDR,
FSL_IMX6_GPIO2_LOW_IRQ,
FSL_IMX6_GPIO2_HIGH_IRQ
},
{
FSL_IMX6_GPIO3_ADDR,
FSL_IMX6_GPIO3_LOW_IRQ,
FSL_IMX6_GPIO3_HIGH_IRQ
},
{
FSL_IMX6_GPIO4_ADDR,
FSL_IMX6_GPIO4_LOW_IRQ,
FSL_IMX6_GPIO4_HIGH_IRQ
},
{
FSL_IMX6_GPIO5_ADDR,
FSL_IMX6_GPIO5_LOW_IRQ,
FSL_IMX6_GPIO5_HIGH_IRQ
},
{
FSL_IMX6_GPIO6_ADDR,
FSL_IMX6_GPIO6_LOW_IRQ,
FSL_IMX6_GPIO6_HIGH_IRQ
},
{
FSL_IMX6_GPIO7_ADDR,
FSL_IMX6_GPIO7_LOW_IRQ,
FSL_IMX6_GPIO7_HIGH_IRQ
},
};
object_property_set_bool(OBJECT(&s->gpio[i]), true, "has-edge-sel",
&error_abort);
object_property_set_bool(OBJECT(&s->gpio[i]), true, "has-upper-pin-irq",
&error_abort);
object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,
qdev_get_gpio_in(DEVICE(&s->a9mpcore),
gpio_table[i].irq_low));
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 1,
qdev_get_gpio_in(DEVICE(&s->a9mpcore),
gpio_table[i].irq_high));
}
for (i = 0; i < FSL_IMX6_NUM_ESDHCS; i++) {
static const struct {
hwaddr addr;
unsigned int irq;
} esdhc_table[FSL_IMX6_NUM_ESDHCS] = {
{ FSL_IMX6_uSDHC1_ADDR, FSL_IMX6_uSDHC1_IRQ },
{ FSL_IMX6_uSDHC2_ADDR, FSL_IMX6_uSDHC2_IRQ },
{ FSL_IMX6_uSDHC3_ADDR, FSL_IMX6_uSDHC3_IRQ },
{ FSL_IMX6_uSDHC4_ADDR, FSL_IMX6_uSDHC4_IRQ },
};
object_property_set_bool(OBJECT(&s->esdhc[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->esdhc[i]), 0, esdhc_table[i].addr);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->esdhc[i]), 0,
qdev_get_gpio_in(DEVICE(&s->a9mpcore),
esdhc_table[i].irq));
}
for (i = 0; i < FSL_IMX6_NUM_ECSPIS; i++) {
static const struct {
hwaddr addr;
unsigned int irq;
} spi_table[FSL_IMX6_NUM_ECSPIS] = {
{ FSL_IMX6_eCSPI1_ADDR, FSL_IMX6_ECSPI1_IRQ },
{ FSL_IMX6_eCSPI2_ADDR, FSL_IMX6_ECSPI2_IRQ },
{ FSL_IMX6_eCSPI3_ADDR, FSL_IMX6_ECSPI3_IRQ },
{ FSL_IMX6_eCSPI4_ADDR, FSL_IMX6_ECSPI4_IRQ },
{ FSL_IMX6_eCSPI5_ADDR, FSL_IMX6_ECSPI5_IRQ },
};
object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_table[i].addr);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
qdev_get_gpio_in(DEVICE(&s->a9mpcore),
spi_table[i].irq));
}
object_property_set_bool(OBJECT(&s->eth), true, "realized", &err);
if (err) {
error_propagate(errp, err);
return;
}
sysbus_mmio_map(SYS_BUS_DEVICE(&s->eth), 0, FSL_IMX6_ENET_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth), 0,
qdev_get_gpio_in(DEVICE(&s->a9mpcore),
FSL_IMX6_ENET_MAC_IRQ));
sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth), 1,
qdev_get_gpio_in(DEVICE(&s->a9mpcore),
FSL_IMX6_ENET_MAC_1588_IRQ));
memory_region_init_rom_nomigrate(&s->rom, NULL, "imx6.rom",
FSL_IMX6_ROM_SIZE, &err);
if (err) {
error_propagate(errp, err);
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX6_ROM_ADDR,
&s->rom);
memory_region_init_rom_nomigrate(&s->caam, NULL, "imx6.caam",
FSL_IMX6_CAAM_MEM_SIZE, &err);
if (err) {
error_propagate(errp, err);
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX6_CAAM_MEM_ADDR,
&s->caam);
memory_region_init_ram(&s->ocram, NULL, "imx6.ocram", FSL_IMX6_OCRAM_SIZE,
&err);
if (err) {
error_propagate(errp, err);
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX6_OCRAM_ADDR,
&s->ocram);
memory_region_init_alias(&s->ocram_alias, NULL, "imx6.ocram_alias",
&s->ocram, 0, FSL_IMX6_OCRAM_ALIAS_SIZE);
memory_region_add_subregion(get_system_memory(), FSL_IMX6_OCRAM_ALIAS_ADDR,
&s->ocram_alias);
}
| 1threat
|
static int64_t coroutine_fn qcow_co_get_block_status(BlockDriverState *bs,
int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file)
{
BDRVQcowState *s = bs->opaque;
int index_in_cluster, n;
uint64_t cluster_offset;
qemu_co_mutex_lock(&s->lock);
cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
qemu_co_mutex_unlock(&s->lock);
index_in_cluster = sector_num & (s->cluster_sectors - 1);
n = s->cluster_sectors - index_in_cluster;
if (n > nb_sectors)
n = nb_sectors;
*pnum = n;
if (!cluster_offset) {
return 0;
}
if ((cluster_offset & QCOW_OFLAG_COMPRESSED) || s->cipher) {
return BDRV_BLOCK_DATA;
}
cluster_offset |= (index_in_cluster << BDRV_SECTOR_BITS);
*file = bs->file->bs;
return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | cluster_offset;
}
| 1threat
|
Access SQS from EC2 - Instance Profile vs Role : <p>I am trying to access SQS from spring boot app running on EC2 instance. Both the consumer and SQS queue will be on the same AWS account. I was told that I should add an instance profile to EC2 instance to access SQS. What is the difference between role and instance profile in this case? Wouldn't a role with appropriate policy be sufficient?</p>
| 0debug
|
Cannot call a method within a class it defined it in ES6 in Node.js : <p>I am making an app using Node.js, Express.js and MongoDB.
I am using a MVC pattern and also have separate file for routes.
I am trying me make a Controller class, in which a method calls another method declared within it. But I cannot seem to be able to do this. I get "Cannot read property '' of undefined".</p>
<p>index.js file</p>
<pre><code>let express = require('express');
let app = express();
let productController = require('../controllers/ProductController');
app.post('/product', productController.create);
http.createServer(app).listen('3000');
</code></pre>
<p>ProductController.js file</p>
<pre><code>class ProductController {
constructor(){}
create(){
console.log('Checking if the following logs:');
this.callme();
}
callme(){
console.log('yes');
}
}
module.exports = new ProductController();
</code></pre>
<p>When I run this I get following error message:</p>
<pre><code>Cannot read property 'callme' of undefined
</code></pre>
<p>I have ran this code by itself with little modification as following and it works.</p>
<pre><code>class ProductController {
constructor(){}
create(){
console.log('Checking if the following logs:');
this.callme();
}
callme(){
console.log('yes');
}
}
let product = new ProductController();
product.create();
</code></pre>
<p>Why does one work and not the other?
HELP!</p>
| 0debug
|
akka http throws EntityStreamException: Entity stream truncation : <p>I'm writing a client for a rest API using the akka http library. The library seems very powerful, but it works very unstable for me. Quite often (not always) it throws the following exception when I try to consume an HttpResponse.entity:</p>
<blockquote>
<p>EntityStreamException: Entity stream truncation</p>
</blockquote>
<p>and after this it stops processing subsequent requests at all. Maybe it tries to deal with some back-pressure or actors just die, I don't know.</p>
<p>It doesn't matter how I send a request, using the Request-Level Client-Side API:</p>
<pre><code>def pollSearchResult(searchId: String): FutureActionResult[String, SearchResult] = {
val request = HttpRequest(GET, s"http://***/Search/$searchId")
for {
response <- Http().singleRequest(request)
entity <- Unmarshal(response.entity).to[String]
result = entity.decodeEither[SearchResult]
} yield result
}
</code></pre>
<p>or using the Connection-Level Client-Side API:</p>
<pre><code>val client = Http(actorSystem).outgoingConnection("***")
def pollSearchResult(searchId: String): FutureActionResult[String, SearchResult] = {
val request = HttpRequest(GET, s"Search/$searchId")
for {
response <- Source.single(request).via(client).runWith(Sink.head)
entity <- Unmarshal(response.entity).to[String]
result = entity.decodeEither[SearchResult]
} yield result
}
</code></pre>
<p>It doesn't metter whether I consume the entity using unmarshaller or manually using the getDataBytes, the result is the same - the above exception.</p>
<p>The http status of the response is 200 OK, headers are ok, it is a "Default" entity (so, no chunking), content length is about 500-2000 Kb (increasing akka.http.parsing.max-content-length doesn't help, although the default value should be enough). The server is also ok - other http libraries on other platforms work with this API just fine.</p>
<p>Is it a bug or I am doing something wrong? What is the best non blocking, asycnhonous http library for scala?</p>
| 0debug
|
PHP MYSQL update / redirect : <p>Updating mysql db. This page get an id via page post. The Textfield "Links" could be changed and submitted. After the submit, there's a mysql update on the ID and after the update the page should redirect to dbedit.php. but i get a: </p>
<p>Cannot modify header information - headers already sent on line 13.</p>
<p>I have no idea why? and can't find any output before the "header()" to the user. Where's my mistake? </p>
<pre><code><html>
<body>
<?php
include('config.php');
if(isset($_GET['id']))
{
$id=$_GET['id'];
if(isset($_POST['submit']))
{
$Links=$_POST['Links'];
$query3=mysqli_query($link, "update posts set Links='$Links' where id='$id'");
if($query3){
header('location:dbedit.php');
}
}
$query1=mysqli_query($link, "select * from posts where ID='$id'");
$query2=mysqli_fetch_array($query1);
?>
<form method="post" action="">
Name:<input type="text" name="Links" value="<?php echo $query2['Links'];?>"/>
<input type="submit" name="submit" value="update" />
</form>
<?php
mysqli_close($link);
};
?>
</body>
</html>
</code></pre>
| 0debug
|
static int encode_slice(AVCodecContext *c, void *arg)
{
FFV1Context *fs = *(void **)arg;
FFV1Context *f = fs->avctx->priv_data;
int width = fs->slice_width;
int height = fs->slice_height;
int x = fs->slice_x;
int y = fs->slice_y;
const AVFrame *const p = f->frame;
const int ps = (av_pix_fmt_desc_get(c->pix_fmt)->flags & AV_PIX_FMT_FLAG_PLANAR)
? (f->bits_per_raw_sample > 8) + 1
: 4;
if (f->key_frame)
ffv1_clear_slice_state(f, fs);
if (f->version > 2) {
encode_slice_header(f, fs);
}
if (!fs->ac) {
if (f->version > 2)
put_rac(&fs->c, (uint8_t[]) { 129 }, 0);
fs->ac_byte_count = f->version > 2 || (!x && !y) ? ff_rac_terminate( &fs->c) : 0;
init_put_bits(&fs->pb, fs->c.bytestream_start + fs->ac_byte_count,
fs->c.bytestream_end - fs->c.bytestream_start - fs->ac_byte_count);
}
if (f->colorspace == 0) {
const int chroma_width = -((-width) >> f->chroma_h_shift);
const int chroma_height = -((-height) >> f->chroma_v_shift);
const int cx = x >> f->chroma_h_shift;
const int cy = y >> f->chroma_v_shift;
encode_plane(fs, p->data[0] + ps * x + y * p->linesize[0],
width, height, p->linesize[0], 0);
if (f->chroma_planes) {
encode_plane(fs, p->data[1] + ps * cx + cy * p->linesize[1],
chroma_width, chroma_height, p->linesize[1], 1);
encode_plane(fs, p->data[2] + ps * cx + cy * p->linesize[2],
chroma_width, chroma_height, p->linesize[2], 1);
}
if (fs->transparency)
encode_plane(fs, p->data[3] + ps * x + y * p->linesize[3], width,
height, p->linesize[3], 2);
} else {
const uint8_t *planes[3] = { p->data[0] + ps * x + y * p->linesize[0],
p->data[1] + ps * x + y * p->linesize[1],
p->data[2] + ps * x + y * p->linesize[2] };
encode_rgb_frame(fs, planes, width, height, p->linesize);
}
emms_c();
return 0;
}
| 1threat
|
for loop doesn't work for image selector : i'm trying to make a picture selector but the loop doesn't work.
It should make the selected div orange, and turn the other divs white
function ClickPic(id)
{
document.getElementById("pic"+id).style.backgroundColor='orange';
for(var i = 0; i < 310; i++)
{
if(!i == id)
{
document.getElementById("pic"+i).style.backgroundColor='white';
}
}
}
| 0debug
|
Remove duplicates untill is not possible : I have an sring like this
> anxxnbddc
I need a c# algorithm to remove duplicates untill is not possible
I think i need an while and a for but i have no idea how to put the condition .
Results from the while should look like this order
anxxnbddc>annbc>abc
and final string returned should be :
abc
Help , thanks
| 0debug
|
How to generate swagger.json using gradle? : <p>I want to use swagger-codegen to generate REST clients and possibly static HTML documentation.</p>
<p>However, swagger-codegen needs swagger.json for input.</p>
<p>I am aware, that I can get this from a running REST server equipped with Swagger.</p>
<p>But is there a way to obtain swagger.json directly from my Java code - i.e. to generate it with gradle from the source code - without the need to run the application in a web container, and pointing <code>curl</code> or a browser to it?</p>
| 0debug
|
Group multiple views into one view in Android : For example, if I have:
EditText A;
TextView B;
ImageView C;
And I want to set all their visibilities to `View.GONE`, how can I do it in a way that instead of this:
A.setVisibility(View.GONE);
B.setVisibility(View.GONE);
C.setVisibility(View.GONE);
I do this:
groupD.setVisibility(View.GONE);
without having to put all of them in one `RelativeLayout` and then setting the `RL` to `View.GONE`?
| 0debug
|
struct omap_mmc_s *omap_mmc_init(hwaddr base,
MemoryRegion *sysmem,
BlockDriverState *bd,
qemu_irq irq, qemu_irq dma[], omap_clk clk)
{
struct omap_mmc_s *s = (struct omap_mmc_s *)
g_malloc0(sizeof(struct omap_mmc_s));
s->irq = irq;
s->dma = dma;
s->clk = clk;
s->lines = 1;
s->rev = 1;
omap_mmc_reset(s);
memory_region_init_io(&s->iomem, NULL, &omap_mmc_ops, s, "omap.mmc", 0x800);
memory_region_add_subregion(sysmem, base, &s->iomem);
s->card = sd_init(bd, false);
if (s->card == NULL) {
exit(1);
}
return s;
}
| 1threat
|
static void *sparc32_dma_init(target_phys_addr_t daddr, qemu_irq parent_irq,
void *iommu, qemu_irq *dev_irq)
{
DeviceState *dev;
SysBusDevice *s;
dev = qdev_create(NULL, "sparc32_dma");
qdev_prop_set_ptr(dev, "iommu_opaque", iommu);
qdev_init(dev);
s = sysbus_from_qdev(dev);
sysbus_connect_irq(s, 0, parent_irq);
*dev_irq = qdev_get_gpio_in(dev, 0);
sysbus_mmio_map(s, 0, daddr);
return s;
}
| 1threat
|
How to take backup of a Bigquery view script using BQ? : I need to take backup of a view while testing the new bug fixes in the same bq view script. can i use a script to do so?
Also how to I pass table name as a argument in the BQ script?
| 0debug
|
grouing array elements with given number in php : grouing array elements with given number in php.<br>
How to group array elements using php ?
i have the following array
array (size=10)
0 => int 1
1 => int 2
2 => int 3
3 => int 4
4 => int 5
5 => int 6
6 => int 7
7 => int 8
8 => int 9
9 => int 10
i need group this array following model
0 =>
array (size=3)
0 => int 1
1 => int 2
2 => int 3
1 =>
array (size=3)
0 => int 4
1 => int 5
2 => int 6
2 =>
array (size=3)
0 => int 7
1 => int 8
2 => int 9
3 =>
array (size=3)
0 => int 10
How can i do this?<br>
i tried following code.
$arr = array(1,2,3,4,5,6,7,8,9,10);
$result = array();
for ($i = 0; $i < count($arr); $i++) {
for ($j = 0; $j < 3; $j++) {
$result[$i][] = $arr[$j];
}
}
the result to this code given below
array (size=10)
0 =>
array (size=3)
0 => int 1
1 => int 2
2 => int 3
1 =>
array (size=3)
0 => int 1
1 => int 2
2 => int 3
2 =>
array (size=3)
0 => int 1
1 => int 2
2 => int 3
3 =>
array (size=3)
0 => int 1
1 => int 2
2 => int 3
4 =>
array (size=3)
0 => int 1
1 => int 2
2 => int 3
5 =>
array (size=3)
0 => int 1
1 => int 2
2 => int 3
6 =>
array (size=3)
0 => int 1
1 => int 2
2 => int 3
7 =>
array (size=3)
0 => int 1
1 => int 2
2 => int 3
8 =>
array (size=3)
0 => int 1
1 => int 2
2 => int 3
9 =>
array (size=3)
0 => int 1
1 => int 2
2 => int 3
| 0debug
|
Find "inverse" in array : a[n] is an array with n element, If i <j and a[i]>a[j] then (a[i], a[j]) called "inverse". For example, array a[5]={2, 3, 8, 6, 1} have 5 "inverse"
(8,6) (2,1) (3,1) (8,1) (6,1)
write code in c++ to find "inverse" in array. but running time must be O(nlogn)
Any idea?
| 0debug
|
Flutter-Web: Mouse hover -> Change cursor to pointer : <p>How can the cursor appearance be changed within Flutter?
I know that with the <a href="https://api.flutter.dev/flutter/widgets/Listener-class.html" rel="noreferrer">Listener()</a> Widget we can listen for Mouse-Events,
but I haven't found any information regarding hovering events for flutter web.</p>
<p>Has someone found a soulution yet?</p>
| 0debug
|
static av_cold int encode_init(AVCodecContext *avctx)
{
NellyMoserEncodeContext *s = avctx->priv_data;
int i, ret;
if (avctx->channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Nellymoser supports only 1 channel\n");
return AVERROR(EINVAL);
}
if (avctx->sample_rate != 8000 && avctx->sample_rate != 16000 &&
avctx->sample_rate != 11025 &&
avctx->sample_rate != 22050 && avctx->sample_rate != 44100 &&
avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
av_log(avctx, AV_LOG_ERROR, "Nellymoser works only with 8000, 16000, 11025, 22050 and 44100 sample rate\n");
return AVERROR(EINVAL);
}
avctx->frame_size = NELLY_SAMPLES;
avctx->delay = NELLY_BUF_LEN;
ff_af_queue_init(avctx, &s->afq);
s->avctx = avctx;
if ((ret = ff_mdct_init(&s->mdct_ctx, 8, 0, 32768.0)) < 0)
goto error;
ff_dsputil_init(&s->dsp, avctx);
ff_sine_window_init(ff_sine_128, 128);
for (i = 0; i < POW_TABLE_SIZE; i++)
pow_table[i] = -pow(2, -i / 2048.0 - 3.0 + POW_TABLE_OFFSET);
if (s->avctx->trellis) {
s->opt = av_malloc(NELLY_BANDS * OPT_SIZE * sizeof(float ));
s->path = av_malloc(NELLY_BANDS * OPT_SIZE * sizeof(uint8_t));
if (!s->opt || !s->path) {
ret = AVERROR(ENOMEM);
goto error;
}
}
#if FF_API_OLD_ENCODE_AUDIO
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame) {
ret = AVERROR(ENOMEM);
goto error;
}
#endif
return 0;
error:
encode_end(avctx);
return ret;
}
| 1threat
|
App to launch the Google Map : <p>I have implemented the cordova app using angular frame work.please guide me to launch the google map or map application by passing the longitude and langtitude.</p>
| 0debug
|
How can I connect my autoscaling group to my ecs cluster? : <p>In all tutorials for ECS you need to create a cluster and after that an autoscaling group, that will spawn instances. Somehow in all these tutorials the instances magically show up in the cluster, but noone gives a hint what's connecting the autoscaling group and the cluster.</p>
<p>my autoscaling group spawns instances as expected, but they just dont show up on my ecs cluster, who holds my docker definitions.</p>
<p>Where is the connection I'm missing?</p>
| 0debug
|
Counting vowel and consonant in C# : int total = 0;
int wordCount = 0, index = 0;
var vowels = new HashSet<char> { 'a', 'e', 'i', 'o', 'u' };
var consonants = new HashSet<char> { 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'x' };
for (int i = 0; i < sentence.Length; i++)
if (vowels.Contains(sentence[i]))
{
total++;
}
else if (consonants.Contains(sentence[i]))
{
total++;
}
}
Console.WriteLine("Your total number of vowels is: {0}", total);
Console.WriteLine("Number of consonants: {0}", total);
Console.ReadLine();
`
This is my code. When I run my code, it accurately tells me how many vowels there are, but it does not tell me the number of consonants. It just copied the number of vowels.
| 0debug
|
Best Practice to have same View across all Activities? : <p>I have a view on top that will be always displayed almost across all Activities in my App.</p>
<p>What is the best practice to do that?</p>
<p>I believe to create the view on each Activities and it's layout is not the best practice.</p>
| 0debug
|
Python Numpy TypeError: ufunc 'isfinite' not supported for the input types : <p>Here's my code:</p>
<pre><code>def topK(dataMat,sensitivity):
meanVals = np.mean(dataMat, axis=0)
meanRemoved = dataMat - meanVals
covMat = np.cov(meanRemoved, rowvar=0)
eigVals,eigVects = np.linalg.eig(np.mat(covMat))
</code></pre>
<p>I get the error in the title on the last line above. I suspect has something to do with the datatype, so, here's an image of the variable and datatype from the Variable Explorer in Spyder:</p>
<p><a href="https://i.stack.imgur.com/i1cCj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/i1cCj.png" alt="enter image description here"></a></p>
<p>I've tried changing <strong>np.linalg.eig(np.mat(covMat))</strong> to <strong>np.linalg.eig(np.array(np.mat(covMat)))</strong> and to <strong>np.linalg.eig(np.array(covMat))</strong>, nothing works. Any ideas? (an example would be great!)</p>
| 0debug
|
static char *sysbus_get_fw_dev_path(DeviceState *dev)
{
SysBusDevice *s = SYS_BUS_DEVICE(dev);
char path[40];
int off;
off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev));
if (s->num_mmio) {
snprintf(path + off, sizeof(path) - off, "@"TARGET_FMT_plx,
s->mmio[0].addr);
} else if (s->num_pio) {
snprintf(path + off, sizeof(path) - off, "@i%04x", s->pio[0]);
}
return g_strdup(path);
}
| 1threat
|
SQL transaction rollback and commit : <p>I have the below 3 inserts wrapped in a transaction. If any of the inserts fail for any reason I would like the entire transaction rolled back. and if all 3 are successful I would like it commited.</p>
<pre><code>BEGIN TRANSACTION
INSERT INTO myTable (myColumns ...) VALUES (myValues ...);
INSERT INTO myTable (myColumns ...) VALUES (myValues ...);
INSERT INTO myTable (myColumns ...) VALUES (myValues ...);
COMMIT TRAN
</code></pre>
| 0debug
|
search and replace charecters in the SQL server query : I have a long sql query and have to modify the query by doing a search and replace for the below strings found. Can you pls. let me know the easiest way to achieve it.
1) Search and replace the
input string - "ch.[No_] AS [Contract No.]"
as
output string - "ch.[No] AS [ContractNo.]"
2)
input string - [Status Reason Code Description]
output string - [StatusReasonCodeDescription]
This search and replace has to scan the whole query and replace only if the above string is found, so that this modified query could be runned in an other DB
| 0debug
|
Row to column for frequency in R : <p>I have a data frame which looks like this</p>
<pre><code>> initial
Name Status
1 a Win
2 b Win
3 c Loss
</code></pre>
<p>From here I want a data frame which looks like this</p>
<pre><code>> final
Name Win Loss
1 a 1 0
2 b 1 0
3 c 0 1
</code></pre>
<p>How can I achieve this</p>
| 0debug
|
Visual Studio Node: debug into Worker Threads (node 11) : <p>Can VS Code's Javascript debugger be made to debug node 11's new "Worker Threads"? Worker threads are modelled after web workers with a small number of extra capabilities on top and are available from the new worker_threads package (see <a href="https://nodejs.org/api/worker_threads.html" rel="noreferrer">https://nodejs.org/api/worker_threads.html</a>). Other than with node's sub processes, one can share memory with worker threads in the form of <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer" rel="noreferrer">SharedArrayBuffers</a>.</p>
<p>My VS Code launch configuration looks like that:</p>
<pre><code> {
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"runtimeArgs": [
"--experimental-wasm-threads",
"--experimental-worker"
],
"args": [
"-u", "tdd",
"--timeout", "100000",
"--colors", "${workspaceFolder}/test"
],
"internalConsoleOptions": "openOnSessionStart",
"autoAttachChildProcesses": true
}
</code></pre>
<p>I can debug into the main node script, but the "autoAttachChildProcesses" flag is not effective in attaching to the spawned off worker threads and neither is adding a "debugger" statement within the code that runs inside the worker thread. </p>
<p>They mention that the "inspector" package is not yet supported for worker threads in their reference documentation, so I guess this may explain why that is.</p>
<p>Against all these odds, has anyone still succeeded in debugging into worker threads inside VS Code? </p>
| 0debug
|
yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2],
const int16_t *ubuf[2], const int16_t *vbuf[2],
const int16_t *abuf[2], uint8_t *dest, int dstW,
int yalpha, int uvalpha, int y,
enum PixelFormat target)
{
const int16_t *buf0 = buf[0], *buf1 = buf[1],
*ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
*vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
int yalpha1 = 4095 - yalpha;
int uvalpha1 = 4095 - uvalpha;
int i;
for (i = 0; i < (dstW >> 1); i++) {
int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
output_pixels(i * 4, Y1, U, Y2, V);
}
}
| 1threat
|
void av_dump_format(AVFormatContext *ic,
int index,
const char *url,
int is_output)
{
int i;
uint8_t *printed = av_mallocz(ic->nb_streams);
if (ic->nb_streams && !printed)
return;
av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n",
is_output ? "Output" : "Input",
index,
is_output ? ic->oformat->name : ic->iformat->name,
is_output ? "to" : "from", url);
dump_metadata(NULL, ic->metadata, " ");
if (!is_output) {
av_log(NULL, AV_LOG_INFO, " Duration: ");
if (ic->duration != AV_NOPTS_VALUE) {
int hours, mins, secs, us;
secs = ic->duration / AV_TIME_BASE;
us = ic->duration % AV_TIME_BASE;
mins = secs / 60;
secs %= 60;
hours = mins / 60;
mins %= 60;
av_log(NULL, AV_LOG_INFO, "%02d:%02d:%02d.%02d", hours, mins, secs,
(100 * us) / AV_TIME_BASE);
} else {
av_log(NULL, AV_LOG_INFO, "N/A");
}
if (ic->start_time != AV_NOPTS_VALUE) {
int secs, us;
av_log(NULL, AV_LOG_INFO, ", start: ");
secs = ic->start_time / AV_TIME_BASE;
us = abs(ic->start_time % AV_TIME_BASE);
av_log(NULL, AV_LOG_INFO, "%d.%06d",
secs, (int)av_rescale(us, 1000000, AV_TIME_BASE));
}
av_log(NULL, AV_LOG_INFO, ", bitrate: ");
if (ic->bit_rate) {
av_log(NULL, AV_LOG_INFO,"%d kb/s", ic->bit_rate / 1000);
} else {
av_log(NULL, AV_LOG_INFO, "N/A");
}
av_log(NULL, AV_LOG_INFO, "\n");
}
for (i = 0; i < ic->nb_chapters; i++) {
AVChapter *ch = ic->chapters[i];
av_log(NULL, AV_LOG_INFO, " Chapter #%d.%d: ", index, i);
av_log(NULL, AV_LOG_INFO, "start %f, ", ch->start * av_q2d(ch->time_base));
av_log(NULL, AV_LOG_INFO, "end %f\n", ch->end * av_q2d(ch->time_base));
dump_metadata(NULL, ch->metadata, " ");
}
if(ic->nb_programs) {
int j, k, total = 0;
for(j=0; j<ic->nb_programs; j++) {
AVDictionaryEntry *name = av_dict_get(ic->programs[j]->metadata,
"name", NULL, 0);
av_log(NULL, AV_LOG_INFO, " Program %d %s\n", ic->programs[j]->id,
name ? name->value : "");
dump_metadata(NULL, ic->programs[j]->metadata, " ");
for(k=0; k<ic->programs[j]->nb_stream_indexes; k++) {
dump_stream_format(ic, ic->programs[j]->stream_index[k], index, is_output);
printed[ic->programs[j]->stream_index[k]] = 1;
}
total += ic->programs[j]->nb_stream_indexes;
}
if (total < ic->nb_streams)
av_log(NULL, AV_LOG_INFO, " No Program\n");
}
for(i=0;i<ic->nb_streams;i++)
if (!printed[i])
dump_stream_format(ic, i, index, is_output);
av_free(printed);
}
| 1threat
|
def unique_sublists(list1):
result ={}
for l in list1:
result.setdefault(tuple(l), list()).append(1)
for a, b in result.items():
result[a] = sum(b)
return result
| 0debug
|
How to reference CSS from libraries installed via npm? : <p>So for example say I installed something:</p>
<pre><code>npm install --save something
</code></pre>
<p>and it downloads into</p>
<pre><code>./node_modules/something/
</code></pre>
<p>and it has a folder in there perhaps called <code>styles</code> and <em>in</em> that folder you have <code>something.css</code>. How would I include that css file in my html document (if my html document was along-side the <code>node-modules</code> folder?</p>
<p>I mean I <em>could</em> do this in my html head:</p>
<pre><code><link rel="stylesheet" href="./node_modules/something/styles/something.css" type="text/css" media="screen" />
</code></pre>
<p>But it feels wrong to go dig in your <code>node_modules</code> directory for stuff. Especially if the html document perhaps needs to get minified and then thrown into some <code>./dist/</code> directory. Because then the path to <code>something.css</code> is off.. </p>
<p>Isn't there a way to simply just go:</p>
<pre><code><link rel="stylesheet" href="something.css" type="text/css" media="screen" />
</code></pre>
<p>in your html document - regardless of where it's sitting in your project structure - and it'll just know where to go find that css file?</p>
| 0debug
|
build_header(GArray *linker, GArray *table_data,
AcpiTableHeader *h, const char *sig, int len, uint8_t rev,
const char *oem_id, const char *oem_table_id)
{
memcpy(&h->signature, sig, 4);
h->length = cpu_to_le32(len);
h->revision = rev;
if (oem_id) {
strncpy((char *)h->oem_id, oem_id, sizeof h->oem_id);
} else {
memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6);
}
if (oem_table_id) {
strncpy((char *)h->oem_table_id, oem_table_id, sizeof(h->oem_table_id));
} else {
memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4);
memcpy(h->oem_table_id + 4, sig, 4);
}
h->oem_revision = cpu_to_le32(1);
memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4);
h->asl_compiler_revision = cpu_to_le32(1);
h->checksum = 0;
bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
table_data, h, len, &h->checksum);
}
| 1threat
|
int qemu_acl_party_is_allowed(qemu_acl *acl,
const char *party)
{
qemu_acl_entry *entry;
TAILQ_FOREACH(entry, &acl->entries, next) {
#ifdef CONFIG_FNMATCH
if (fnmatch(entry->match, party, 0) == 0)
return entry->deny ? 0 : 1;
#else
if (strcmp(entry->match, party) == 0)
return entry->deny ? 0 : 1;
#endif
}
return acl->defaultDeny ? 0 : 1;
}
| 1threat
|
Is it possible to print on both sides, like printing ID card or driving license, in c#? This is not a simple double sided printing : I have two images front.jpg and back.jpg. I want to print them front and back on a same page to make one 'card'. I came across 'duplex' property but not sure how it can help me in this regard.
I tried using Duplex
| 0debug
|
static int matroska_parse_frame(MatroskaDemuxContext *matroska,
MatroskaTrack *track, AVStream *st,
uint8_t *data, int pkt_size,
uint64_t timecode, uint64_t duration,
int64_t pos, int is_keyframe)
{
MatroskaTrackEncoding *encodings = track->encodings.elem;
uint8_t *pkt_data = data;
int offset = 0, res;
AVPacket *pkt;
if (encodings && encodings->scope & 1) {
res = matroska_decode_buffer(&pkt_data, &pkt_size, track);
if (res < 0)
return res;
}
if (st->codec->codec_id == AV_CODEC_ID_WAVPACK) {
uint8_t *wv_data;
res = matroska_parse_wavpack(track, pkt_data, &wv_data, &pkt_size);
if (res < 0) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Error parsing a wavpack block.\n");
goto fail;
}
if (pkt_data != data)
pkt_data = wv_data;
}
if (st->codec->codec_id == AV_CODEC_ID_PRORES)
offset = 8;
pkt = av_mallocz(sizeof(AVPacket));
if (av_new_packet(pkt, pkt_size + offset) < 0) {
av_free(pkt);
return AVERROR(ENOMEM);
}
if (st->codec->codec_id == AV_CODEC_ID_PRORES) {
uint8_t *buf = pkt->data;
bytestream_put_be32(&buf, pkt_size);
bytestream_put_be32(&buf, MKBETAG('i', 'c', 'p', 'f'));
}
memcpy(pkt->data + offset, pkt_data, pkt_size);
if (pkt_data != data)
av_free(pkt_data);
pkt->flags = is_keyframe;
pkt->stream_index = st->index;
if (track->ms_compat)
pkt->dts = timecode;
else
pkt->pts = timecode;
pkt->pos = pos;
if (st->codec->codec_id == AV_CODEC_ID_TEXT)
pkt->convergence_duration = duration;
else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE)
pkt->duration = duration;
if (st->codec->codec_id == AV_CODEC_ID_SSA)
matroska_fix_ass_packet(matroska, pkt, duration);
if (matroska->prev_pkt &&
timecode != AV_NOPTS_VALUE &&
matroska->prev_pkt->pts == timecode &&
matroska->prev_pkt->stream_index == st->index &&
st->codec->codec_id == AV_CODEC_ID_SSA)
matroska_merge_packets(matroska->prev_pkt, pkt);
else {
dynarray_add(&matroska->packets, &matroska->num_packets, pkt);
matroska->prev_pkt = pkt;
}
return 0;
fail:
if (pkt_data != data)
return res;
}
| 1threat
|
av_cold void ff_lpc_init_x86(LPCContext *c)
{
#if HAVE_SSE2_INLINE
int cpu_flags = av_get_cpu_flags();
if (INLINE_SSE2(cpu_flags) && (cpu_flags & AV_CPU_FLAG_SSE2SLOW)) {
c->lpc_apply_welch_window = lpc_apply_welch_window_sse2;
c->lpc_compute_autocorr = lpc_compute_autocorr_sse2;
}
#endif
}
| 1threat
|
static AVFrame *get_palette_frame(AVFilterContext *ctx)
{
AVFrame *out;
PaletteGenContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
double ratio;
int box_id = 0;
struct range_box *box;
s->refs = load_color_refs(s->histogram, s->nb_refs);
if (!s->refs) {
av_log(ctx, AV_LOG_ERROR, "Unable to allocate references for %d different colors\n", s->nb_refs);
return NULL;
}
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out)
return NULL;
out->pts = 0;
box = &s->boxes[box_id];
box->len = s->nb_refs;
box->sorted_by = -1;
box->color = get_avg_color(s->refs, box);
box->variance = -1;
s->nb_boxes = 1;
while (box && box->len > 1) {
int i, rr, gr, br, longest;
uint64_t median, box_weight = 0;
uint8_t min[3] = {0xff, 0xff, 0xff};
uint8_t max[3] = {0x00, 0x00, 0x00};
for (i = box->start; i < box->start + box->len; i++) {
const struct color_ref *ref = s->refs[i];
const uint32_t rgb = ref->color;
const uint8_t r = rgb >> 16 & 0xff, g = rgb >> 8 & 0xff, b = rgb & 0xff;
min[0] = FFMIN(r, min[0]), max[0] = FFMAX(r, max[0]);
min[1] = FFMIN(g, min[1]), max[1] = FFMAX(g, max[1]);
min[2] = FFMIN(b, min[2]), max[2] = FFMAX(b, max[2]);
box_weight += ref->count;
}
rr = max[0] - min[0];
gr = max[1] - min[1];
br = max[2] - min[2];
longest = 1;
if (br >= rr && br >= gr) longest = 2;
if (rr >= gr && rr >= br) longest = 0;
if (gr >= rr && gr >= br) longest = 1;
av_dlog(ctx, "box #%02X [%6d..%-6d] (%6d) w:%-6"PRIu64" ranges:[%2x %2x %2x] sort by %c (already sorted:%c) ",
box_id, box->start, box->start + box->len - 1, box->len, box_weight,
rr, gr, br, "rgb"[longest], box->sorted_by == longest ? 'y':'n');
if (box->sorted_by != longest) {
cmp_func cmpf = cmp_funcs[longest];
AV_QSORT(&s->refs[box->start], box->len, const struct color_ref *, cmpf);
box->sorted_by = longest;
}
median = (box_weight + 1) >> 1;
box_weight = 0;
for (i = box->start; i < box->start + box->len - 2; i++) {
box_weight += s->refs[i]->count;
if (box_weight > median)
break;
}
av_dlog(ctx, "split @ i=%-6d with w=%-6"PRIu64" (target=%6"PRIu64")\n", i, box_weight, median);
split_box(s, box, i);
box_id = get_next_box_id_to_split(s);
box = box_id >= 0 ? &s->boxes[box_id] : NULL;
}
ratio = set_colorquant_ratio_meta(out, s->nb_boxes, s->nb_refs);
av_log(ctx, AV_LOG_INFO, "%d%s colors generated out of %d colors; ratio=%f\n",
s->nb_boxes, s->reserve_transparent ? "(+1)" : "", s->nb_refs, ratio);
qsort(s->boxes, s->nb_boxes, sizeof(*s->boxes), cmp_color);
write_palette(ctx, out);
return out;
}
| 1threat
|
Most efficient way to search in list of dicts : <p>I have the following list of dicts.</p>
<pre><code>people = [
{'name': "Tom", 'age': 10},
{'name': "Mark", 'age': 5},
{'name': "Pam", 'age': 7}
]
</code></pre>
<p>Which would be the most optimized way in terms of performance to search in list of dicts. Following are different some methods:</p>
<pre><code>next((item for item in dicts if item["name"] == "Pam"), None)
</code></pre>
<p>OR</p>
<pre><code>filter(lambda person: person['name'] == 'Pam', people)
</code></pre>
<p>OR</p>
<pre><code>def search(name):
for p in people:
if p['name'] == name:
return p
</code></pre>
<p>OR</p>
<pre><code>def search_dictionaries(key, value, list_of_dictionaries):
return [element for element in list_of_dictionaries if element[key] == value]
</code></pre>
<p>Any other method is also welcome. Thanks.</p>
| 0debug
|
static int vm_can_run(void)
{
if (powerdown_requested)
return 0;
if (reset_requested)
return 0;
if (shutdown_requested)
return 0;
if (debug_requested)
return 0;
return 1;
}
| 1threat
|
Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted : <p>I recently encountered a SwiftMail error while trying to send a mail through gmail.</p>
<pre><code> Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted.
</code></pre>
<p>I was trying to send mail through my gmail and google thought that I was a spam(maybe because I was requesting too fast) I received a mail from them saying my account was access and I told them it was me. I was able to send mail without problem and it just occured now.</p>
<p>This is the contents of my env file.</p>
<pre><code>MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=talentscoutphil@gmail.com
MAIL_PASSWORD=mypasswordhere
MAIL_FROM=talentscoutphil@gmail.com
MAIL_NAME=talentscout
</code></pre>
| 0debug
|
static int mjpeg_probe(AVProbeData *p)
{
int i;
int state = -1;
int nb_invalid = 0;
int nb_frames = 0;
for (i=0; i<p->buf_size-2; i++) {
int c;
if (p->buf[i] != 0xFF)
continue;
c = p->buf[i+1];
switch (c) {
case 0xD8:
state = 0xD8;
break;
case 0xC0:
case 0xC1:
case 0xC2:
case 0xC3:
case 0xC5:
case 0xC6:
case 0xC7:
case 0xF7:
if (state == 0xD8) {
state = 0xC0;
} else
nb_invalid++;
break;
case 0xDA:
if (state == 0xC0) {
state = 0xDA;
} else
nb_invalid++;
break;
case 0xD9:
if (state == 0xDA) {
state = 0xD9;
nb_frames++;
} else
nb_invalid++;
break;
default:
if ( (c >= 0x02 && c <= 0xBF)
|| c == 0xC8) {
nb_invalid++;
}
}
}
if (nb_invalid*4 + 1 < nb_frames) {
static const char ct_jpeg[] = "\r\nContent-Type: image/jpeg\r\n\r\n";
int i;
for (i=0; i<FFMIN(p->buf_size - sizeof(ct_jpeg), 100); i++)
if (!memcmp(p->buf + i, ct_jpeg, sizeof(ct_jpeg) - 1))
return AVPROBE_SCORE_EXTENSION;
if (nb_invalid == 0 && nb_frames > 2)
return AVPROBE_SCORE_EXTENSION / 2;
return AVPROBE_SCORE_EXTENSION / 4;
}
return 0;
}
| 1threat
|
How to specify different readme files for github and npm : <p>Both use the <code>README.md</code> as the description when you publish. A common practice is to use a single shared file. </p>
<p>But what if I need to have the different Readme and still publish it from a single local repo with no manual editing/replacement</p>
<p>PS</p>
<p>I tried to use <code>"readme": "npm-readme.md"</code> in package.json but it displays a value of this field, not the content of а file</p>
| 0debug
|
Split string with square bracket : <p>I'm trying to use preg_split to split this text</p>
<pre><code>Yes, it was great. [I have no ideas how great it was.]
</code></pre>
<p>into this array:</p>
<pre><code>['Yes', 'it', 'was', great', '[I have no ideas how great it was.]'
</code></pre>
<p>But I don't know how...</p>
| 0debug
|
Client characteristics [JAVA] : <p>I am trying to write my first client-server program in java but as I am new there are a few things that got me really confused.
Is there any way to give specific characteristics to the client? For example I want each client who connects to have an id and a sum of money that will be changed by the server. Is something like this possible? If so how?<br>
Also, I want to put some commands from the clients in a queue in order to make sure they are served in the correct order. How can I do that if each client has its own thread? In what part of the code should I initialise the queue?</p>
| 0debug
|
int nbd_receive_negotiate(QIOChannel *ioc, const char *name,
QCryptoTLSCreds *tlscreds, const char *hostname,
QIOChannel **outioc, NBDExportInfo *info,
Error **errp)
{
char buf[256];
uint64_t magic;
int rc;
bool zeroes = true;
bool structured_reply = info->structured_reply;
trace_nbd_receive_negotiate(tlscreds, hostname ? hostname : "<null>");
info->structured_reply = false;
rc = -EINVAL;
if (outioc) {
*outioc = NULL;
if (tlscreds && !outioc) {
error_setg(errp, "Output I/O channel required for TLS");
if (nbd_read(ioc, buf, 8, errp) < 0) {
error_prepend(errp, "Failed to read data");
buf[8] = '\0';
if (strlen(buf) == 0) {
error_setg(errp, "Server connection closed unexpectedly");
magic = ldq_be_p(buf);
trace_nbd_receive_negotiate_magic(magic);
if (memcmp(buf, "NBDMAGIC", 8) != 0) {
error_setg(errp, "Invalid magic received");
if (nbd_read(ioc, &magic, sizeof(magic), errp) < 0) {
error_prepend(errp, "Failed to read magic");
magic = be64_to_cpu(magic);
trace_nbd_receive_negotiate_magic(magic);
if (magic == NBD_OPTS_MAGIC) {
uint32_t clientflags = 0;
uint16_t globalflags;
bool fixedNewStyle = false;
if (nbd_read(ioc, &globalflags, sizeof(globalflags), errp) < 0) {
error_prepend(errp, "Failed to read server flags");
globalflags = be16_to_cpu(globalflags);
trace_nbd_receive_negotiate_server_flags(globalflags);
if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) {
fixedNewStyle = true;
clientflags |= NBD_FLAG_C_FIXED_NEWSTYLE;
if (globalflags & NBD_FLAG_NO_ZEROES) {
zeroes = false;
clientflags |= NBD_FLAG_C_NO_ZEROES;
clientflags = cpu_to_be32(clientflags);
if (nbd_write(ioc, &clientflags, sizeof(clientflags), errp) < 0) {
error_prepend(errp, "Failed to send clientflags field");
if (tlscreds) {
if (fixedNewStyle) {
*outioc = nbd_receive_starttls(ioc, tlscreds, hostname, errp);
if (!*outioc) {
ioc = *outioc;
} else {
error_setg(errp, "Server does not support STARTTLS");
if (!name) {
trace_nbd_receive_negotiate_default_name();
name = "";
if (fixedNewStyle) {
int result;
result = nbd_opt_go(ioc, name, info, errp);
if (result > 0) {
return 0;
if (nbd_receive_query_exports(ioc, name, errp) < 0) {
if (nbd_send_option_request(ioc, NBD_OPT_EXPORT_NAME, -1, name,
errp) < 0) {
if (nbd_read(ioc, &info->size, sizeof(info->size), errp) < 0) {
error_prepend(errp, "Failed to read export length");
be64_to_cpus(&info->size);
if (nbd_read(ioc, &info->flags, sizeof(info->flags), errp) < 0) {
error_prepend(errp, "Failed to read export flags");
be16_to_cpus(&info->flags);
} else if (magic == NBD_CLIENT_MAGIC) {
uint32_t oldflags;
if (name) {
error_setg(errp, "Server does not support export names");
if (tlscreds) {
error_setg(errp, "Server does not support STARTTLS");
if (nbd_read(ioc, &info->size, sizeof(info->size), errp) < 0) {
error_prepend(errp, "Failed to read export length");
be64_to_cpus(&info->size);
if (nbd_read(ioc, &oldflags, sizeof(oldflags), errp) < 0) {
error_prepend(errp, "Failed to read export flags");
be32_to_cpus(&oldflags);
if (oldflags & ~0xffff) {
error_setg(errp, "Unexpected export flags %0x" PRIx32, oldflags);
info->flags = oldflags;
} else {
error_setg(errp, "Bad magic received");
trace_nbd_receive_negotiate_size_flags(info->size, info->flags);
if (zeroes && nbd_drop(ioc, 124, errp) < 0) {
error_prepend(errp, "Failed to read reserved block");
rc = 0;
fail:
return rc;
| 1threat
|
import math
def sumofFactors(n) :
if (n % 2 != 0) :
return 0
res = 1
for i in range(2, (int)(math.sqrt(n)) + 1) :
count = 0
curr_sum = 1
curr_term = 1
while (n % i == 0) :
count= count + 1
n = n // i
if (i == 2 and count == 1) :
curr_sum = 0
curr_term = curr_term * i
curr_sum = curr_sum + curr_term
res = res * curr_sum
if (n >= 2) :
res = res * (1 + n)
return res
| 0debug
|
error in executing sql via PERL : I am trying to execute the opensource code which find the list of tables involved in sql. Link of the code am working on http://www.theunixschool.com/2012/03/retrieve-table-names-from-oracle.html
I understood the expressions/commands to some extent(new to PERL), and tried it.
Details of my execution :
1) GetTable.pl file : (same as in the link)
2) test.sql file : didn't use the one in link, instead had only single sql for testing.
SELECT EMP_NAME FROM LOAD_TABLES.TEMP;
3) executed in StrawberryPerl
perl GetTable.pl
Usage : GetTable < sql query file>
perl test.sql
Error : **Can't locate object method "FROM" via package "LOAD_TABLES" (perhaps you forgot to load "LOAD_TABLES"?) at test.sql line 1**
Can someone help me in executing it? Not sure if there is problem with code , As I could see two people have executed successfully (mentioned in same link). Thanks
| 0debug
|
static AVFilterContext *create_filter_with_args(const char *filt, void *opaque)
{
AVFilterContext *ret;
char *filter = av_strdup(filt);
char *name, *args;
name = filter;
if((args = strchr(filter, '='))) {
if(args == filter)
goto fail;
*args ++ = 0;
}
av_log(NULL, AV_LOG_INFO, "creating filter \"%s\" with args \"%s\"\n",
name, args ? args : "(none)");
if((ret = avfilter_create_by_name(name, NULL))) {
if(avfilter_init_filter(ret, args, opaque)) {
av_log(NULL, AV_LOG_ERROR, "error initializing filter!\n");
avfilter_destroy(ret);
goto fail;
}
} else av_log(NULL, AV_LOG_ERROR, "error creating filter!\n");
return ret;
fail:
return NULL;
}
| 1threat
|
static void aarch64_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu)
{
DisasContext *dc = container_of(dcbase, DisasContext, base);
dc->insn_start_idx = tcg_op_buf_count();
tcg_gen_insn_start(dc->pc, 0, 0);
}
| 1threat
|
"Error loading documents" on Cloud Firestore when console left open for a while : <p>I noticed a quite new phenomenon which is that when I leave the console open for over a couple of minutes I get an "Error loading documents" error on all my collections until I refresh the page. This never happened before regardless of how long I left it open.</p>
<p>The only thing that has changed was that I was experimenting with the rules, but at the end went back to the default setup.</p>
<p>My question is whether this might have repercussions on how my users access their information. Please see below the current rules (commented are the ones that I published for about 10 minutes to test).</p>
<pre><code>service cloud.firestore {
match /databases/{database}/documents {
// match /users/{user}/{document=**} {
// allow read;
// allow write: if request.auth.uid == user;
// }
// match /items/{document=**} {
// allow read;
// allow write: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.admin == true;
// }
// match /completedItems/{document=**} {
// allow read;
// allow write: if get(/databases/$(database)/documents/users/$(request.auth.uid)).data.admin == true;
// }
match /{document=**} {
allow read, write: if request.auth.uid != null;
}
}
}
</code></pre>
<p>Thanks!</p>
| 0debug
|
Starting on hyperledger fabroc : so I was following a tutorial on medium
[Tutorial Link][1]
and his transaction structure and mine were different , his was :
[![Submit Transaction][2]][2]
and mine was:
[![my trasaction][3]][3]
[1]: https://medium.freecodecamp.org/how-to-build-a-blockchain-network-using-hyperledger-fabric-and-composer-e06644ff801d?_branch_match_id=582194111361612536
[2]: https://i.stack.imgur.com/2v6qt.png
[3]: https://i.stack.imgur.com/JVreh.png
| 0debug
|
Conversion to Typescript : <p>Please refer the below link</p>
<p>Please visit <a href="https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-directions" rel="nofollow noreferrer">https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-directions</a></p>
<p>I am trying to convert the same application to Angular 6</p>
<p>But not been able to do so.</p>
<p>1) The HTML part i copied in test.component.html
2) the javascript part am trying to convert to typescript. This is where am not good.</p>
<p>Sorry i could not paste the code here since its all messed up with errors.</p>
<p>Suggest how to do or any ideas to convert the code, the place where am stuck is creation of events.</p>
<p>Regards,
Amit</p>
<p>Same code to be in angular 6</p>
| 0debug
|
Firebase Cloud Functions https.onCall finished with status code: 204 : <p><strong>Firebase Function</strong></p>
<pre><code>const functions = require('firebase-functions');
const admin = require('firebase-admin');
const cors = require('cors')({ origin: true });
exports.addMessage = functions.https.onCall((data, context) => {
return { text: "Test" };
});
</code></pre>
<p><strong>Issue</strong></p>
<p>The problem is when i call this function from the app i first get <strong>finished with status code: 204</strong> and after that <strong>finished with status code: 200</strong></p>
<p><a href="https://i.stack.imgur.com/J8brI.png" rel="noreferrer">204</a></p>
<p>How can i prevent this?</p>
| 0debug
|
ValueError: cannot index with vector containing NA / NaN values : <p>I do not understand why I am receiving the error listed in the title, the value that I am intending to return is the number 30</p>
<pre><code>import csv
import os
import pandas as pd
os.chdir('C:\\Users\\khalha\\Desktop\\RealExcel')
filename = 'sales.csv'
Sales = pd.read_csv('sales.csv')
iFlowStatus = Sales[Sales['Product'].str.contains('iFlow')]['Status']
print(iFlowStatus)
</code></pre>
| 0debug
|
>How end-user know whether the page is developed using semantic elements in html5? : >How end-user know whether the page is developed using semantic elements in
HTML5? What differences end-user can get if we use HTML5 semantic tags?
| 0debug
|
static int vfio_msix_setup(VFIOPCIDevice *vdev, int pos, Error **errp)
{
int ret;
vdev->msix->pending = g_malloc0(BITS_TO_LONGS(vdev->msix->entries) *
sizeof(unsigned long));
ret = msix_init(&vdev->pdev, vdev->msix->entries,
vdev->bars[vdev->msix->table_bar].region.mem,
vdev->msix->table_bar, vdev->msix->table_offset,
vdev->bars[vdev->msix->pba_bar].region.mem,
vdev->msix->pba_bar, vdev->msix->pba_offset, pos);
if (ret < 0) {
if (ret == -ENOTSUP) {
return 0;
}
error_setg(errp, "msix_init failed");
return ret;
}
memory_region_set_enabled(&vdev->pdev.msix_pba_mmio, false);
return 0;
}
| 1threat
|
How to get Last latest value from recyclerview : I am making Garage Application just like Calculator..Taking 2 values from Edittext and print in third Edittext.and then it will store all values in recyclerview.**Now issue is I am trying to get the latest Total Gross value ie last row Total Value** I had done all possibly Solution still I am not getting.
Here is my code in Custom Adapter:
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
Employee employee = bank_details.get(position);
holder.total.setText(employee.getTotal());
holder.accept.setText(employee.getAcceptmoney());
holder.given.setText(employee.getGivemoney());
holder.note.setText(employee.getNote());
holder.date.setText(employee.getTime());
int selectedItem = 0;
if(selectedItem == position)
holder.itemView.setSelected(true);
}
@Override
public int getItemCount() {
return bank_details.size();
}
public void setSelectedItem(int last_pos) {
}
public class MyViewHolder extends RecyclerView.ViewHolder {
CardView cv;
TextView total;
TextView accept;
TextView given;
TextView note;
TextView date;
Button edit;
Button delete;
public MyViewHolder(View itemView) {
super(itemView);
cv= (CardView) itemView.findViewById(R.id.cv);
total = (TextView) itemView.findViewById(R.id.grossIncome);
accept = (TextView) itemView.findViewById(R.id.acceptmoney);
given = (TextView) itemView.findViewById(R.id.givenmoney);
note = (TextView) itemView.findViewById(R.id.note);
date= (TextView) itemView.findViewById(R.id.date);
}
}
public Employee getItem(int position) {
return bank_details.get(position);
}
Here is the code of recyclerview:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recyclerview);
final RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
rv.setHasFixedSize(true);
final ArrayList<Employee> arr = InitializeData();
final LinearLayoutManager llm = new LinearLayoutManager(this);
rv.setLayoutManager(llm);
rv.setHasFixedSize(true);
cu = new CustomAdapter(arr);
rv.setAdapter(cu);
int last_pos = cu.getItemCount() - 1;
cu.notifyDataSetChanged();
cu.setSelectedItem(last_pos);
rv.scrollToPosition(last_pos);
}
public ArrayList<Employee> InitializeData() {
ArrayList<Employee> arr_emp = new ArrayList<>();
ArrayList<Employee> arr_emp_2 = new ArrayList<>();
DAL dal = new DAL(this);
dal.OpenDB();
arr_emp = dal.AllSelectQryForTabEmpData();
dal.CloseDB();
return arr_emp;
}
public void setSelectedItem(int position)
{
selectedItem = position;
}
Problem is I want total value and that total value can be used as giving and receiving value ie-**Total+receving Money**,**Total-giving Money**
| 0debug
|
c++ vector isn't showing any values i inserted : <p>So I am trying to convert string to int and then store the int into vector. But when I do that and i create a for loop to display what I have stored in the vector, all i get is 0000. here is my code:</p>
<pre><code>#include<iostream>
#include<sstream>
#include<vector>
using namespace std;
int main() {
std::string str = "<4: 3 2 1>";
vector<int> vect;
char c;
int found;
size_t i = 0;
for ( ; i < str.length(); i++ )
{
if ( isdigit(str[i]) )
{
c=str[i];
found = c-'0';
cout<<found<<endl;
vect.push_back(found);
}
}
for(int j=0;j<vect.size();j++)
{
cout<<vect[i];
}
return 0;
}
</code></pre>
| 0debug
|
How to call external css and JS in AMp using asp.net(aspx) c# : How to call external css and JS in AMp using asp.net(aspx) c#
<link href="/css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
please help me for finding the both the tag js and css to call externally
i have done the Internal style sheet its say long term
| 0debug
|
Xcode 10.1 textField secureTextEntry : <p>StoryBoard textField checked secureTextEntry, other textField all textFields are asking faceRecognition in iphone X, other lower version of iphones are working fine. Is that iphone x, bug or xcode bug ? </p>
| 0debug
|
struct MUSBState *musb_init(qemu_irq *irqs)
{
MUSBState *s = g_malloc0(sizeof(*s));
int i;
s->irqs = irqs;
s->faddr = 0x00;
s->power = MGC_M_POWER_HSENAB;
s->tx_intr = 0x0000;
s->rx_intr = 0x0000;
s->tx_mask = 0xffff;
s->rx_mask = 0xffff;
s->intr = 0x00;
s->mask = 0x06;
s->idx = 0;
s->ep[0].config = MGC_M_CONFIGDATA_SOFTCONE | MGC_M_CONFIGDATA_DYNFIFO;
for (i = 0; i < 16; i ++) {
s->ep[i].fifosize = 64;
s->ep[i].maxp[0] = 0x40;
s->ep[i].maxp[1] = 0x40;
s->ep[i].musb = s;
s->ep[i].epnum = i;
usb_packet_init(&s->ep[i].packey[0].p);
usb_packet_init(&s->ep[i].packey[1].p);
}
usb_bus_new(&s->bus, &musb_bus_ops, NULL );
usb_register_port(&s->bus, &s->port, s, 0, &musb_port_ops,
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
return s;
}
| 1threat
|
Best practices to use await-async, where to start the task? : <p>I started to use the await/async mechanism in our .Net WPF application.</p>
<p>In my ViewModel, I'm calling an async method on a service.</p>
<p>My question is:
Is it better to </p>
<ol>
<li>Directly inside this service, make one big <code>return await Task.Run(()=>{...});</code></li>
<li>Have all the submethods on this service being also async and then inside this have the <code>Task.Run</code>?</li>
</ol>
<p>By example:</p>
<p>1)</p>
<pre><code>public class Service:IService{
public async Task<SomeResult>(SomeParameter parameter){
return await Task.Run(()=>{
CopyStuff(parameter.A);
UpgradeStuff(parameter.B);
return ReloadStuff(parameter.C)
});
}
private void CopyStuff(ParamA parameter){
...//Some long operation that will mainly wait on the disk
}
private void UpgradeStuff(ParamB parameter){
...//Some long operation that should not block the GUI thread
}
public SomeResult ReloadStuff(ParamC parameter){
return ...;//Some long operation that relaunch some services and return their successs
}
}
</code></pre>
<p>2)</p>
<pre><code>public class Service:IService{
public async Task<SomeResult>(SomeParameter parameter){
await CopyStuff(parameter.A);
await UpgradeStuff(parameter.B);
return await ReloadStuff(parameter.C)
}
private async Task CopyStuff(ParamA parameter){
return await Task.Run(()=>{...});//Some long operation that will mainly wait on the disk
}
private async Task UpgradeStuff(ParamB parameter){
return await Task.Run(()=>{...});//Some long operation that should not block the GUI thread
}
public async Task<SomeResult> ReloadStuff(ParamC parameter){
return await Task.Run(()=>{return ...});//Some long operation that relaunch some services and return their successs
}
}
</code></pre>
<p>I can see advantages in both approaches:</p>
<ul>
<li>In 1) we will use less task, this is probably most efficient(???)</li>
<li>In 2) This feel more "compliant" with the async-await approach, this would allow to change the visibility of some methods and still being async, this would allow the methods to run in parallel if required one day.</li>
</ul>
| 0debug
|
static void arm_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
{
j_rev_dct_ARM (block);
add_pixels_clamped(block, dest, line_size);
}
| 1threat
|
Tell if a C# method runs : <p>Is it possible, somehow, to trace if a C# method has been run by adding some code in it? <strong>I do not want to be in debug mode</strong>, so something like <code>Trace.WriteLine</code> is not acceptable. I just want to run my project normally and tell if some methods have been called or not. I am new to C# and I have a Javascript background, so what actually I want is something similar to <code>console.log()</code>.</p>
| 0debug
|
How to view logs to see when someone downloaded the images and html of my site? : Background: a competitor decided to steal pixel for pixel the entirety of my one page website. I was tipped off to this by seeing 25,000+ clicks in my google analytics going to pages I’ve never created.
I’m familiar with tools like website ripper copier/httools/etc and also of course know they can just right click and save all images and copy paste the code but I’m hoping these people were careless and left tracks in the log.
I use bluehost vps and have a cpanel. It’s a basic html css website.
Question: is it possible to see this in the logs?
Perhaps if it’s from a specific copier tool I can see that?
Or maybe I can see a difference between images being loaded on page view and images being downloaded by right clicking?
Thanks for reading this!
| 0debug
|
static void test_machine(gconstpointer data)
{
const char *machine = data;
char *args;
QDict *response;
args = g_strdup_printf("-machine %s", machine);
qtest_start(args);
test_properties("/machine");
response = qmp("{ 'execute': 'quit' }");
g_assert(qdict_haskey(response, "return"));
qtest_end();
g_free(args);
}
| 1threat
|
What's the difference between 'window' and 'screen' in the Dimensions API : <p>On my iOS emulator they both return the same values.</p>
<p>I understand the difference on a normal browser,
but what is the difference on React Native?
Are there scenarios where they return differente values?</p>
| 0debug
|
Woocommerce - coustemize checkout fields : I hope you quys can help me with a woocommerce problem.
I used [this guide][1] to delete the entire checkout and replace it with my own. I use this code to delete the standard fields.
My problem is:
when I fill out the form, I keep getting this fail (*translated from danish to english ;-)* ): please fill out the address field to continue .
// Hook in
add_filter( 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' );
// Our hooked in function - $address_fields is passed via the filter!
function custom_override_default_address_fields( $address_fields ) {
$address_fields['address_1']['required'] = false;
return $address_fields;
}
[1]: https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/
| 0debug
|
The SDK platform-tools version (24.0.4) is too old to check APIs compiled with API 25; please update : <p>I am getting this error on the latest version of Android Studio and while I have installed both Android SDK Platform API 25 and Android SDK Build-Tools 25.</p>
| 0debug
|
Is it possible to convert this curl command to PHP? : <p>Is it possible to convert this curl command to PHP? </p>
<pre><code>curl -F file=@filename https://any.website.com/
</code></pre>
| 0debug
|
How to turn off autoscaling in Kubernetes with the kubectl command? : <p>If I set to autoscale a deployment using the kubectl autoscale command (<a href="http://kubernetes.io/docs/user-guide/kubectl/kubectl_autoscale/" rel="noreferrer">http://kubernetes.io/docs/user-guide/kubectl/kubectl_autoscale/</a>), how can I turn it off an go back to manual scaling?</p>
| 0debug
|
static av_cold int pnm_encode_init(AVCodecContext *avctx)
{
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
avctx->coded_frame->key_frame = 1;
return 0;
}
| 1threat
|
How to use forward slash in website : <p>I have a website that runs on a URL, for example www.mywebsite.com. I want to be able to host different users profiles at URLs like www.mywebsite.com/userID . How can I use the same page for all possible userID s, so the website can show the same page, but it pulls specific data from my database just for that userID?
Sorry that this is probably a very basic question.</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.