problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
{
const int isRgb = isBGR(c->dstFormat);
const int bpp = fmt_depth(c->dstFormat);
int i;
uint8_t table_Y[1024];
uint32_t *table_32 = 0;
uint16_t *table_16 = 0;
uint8_t *table_8 = 0;
uint8_t *table_332 = 0;
uint8_t *table_121 = 0;
uint8_t *table_1 = 0;
int entry_size = 0;
void *table_r = 0, *table_g = 0, *table_b = 0;
void *table_start;
int64_t crv = inv_table[0];
int64_t cbu = inv_table[1];
int64_t cgu = -inv_table[2];
int64_t cgv = -inv_table[3];
int64_t cy = 1<<16;
int64_t oy = 0;
if(!fullRange){
cy= (cy*255) / 219;
oy= 16<<16;
}else{
crv= (crv*224) / 255;
cbu= (cbu*224) / 255;
cgu= (cgu*224) / 255;
cgv= (cgv*224) / 255;
}
cy = (cy *contrast )>>16;
crv= (crv*contrast * saturation)>>32;
cbu= (cbu*contrast * saturation)>>32;
cgu= (cgu*contrast * saturation)>>32;
cgv= (cgv*contrast * saturation)>>32;
oy -= 256*brightness;
for (i = 0; i < 1024; i++) {
int j;
j= (cy*(((i - 384)<<16) - oy) + (1<<31))>>32;
j = (j < 0) ? 0 : ((j > 255) ? 255 : j);
table_Y[i] = j;
}
switch (bpp) {
case 32:
table_start= table_32 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t));
entry_size = sizeof (uint32_t);
table_r = table_32 + 197;
table_b = table_32 + 197 + 685;
table_g = table_32 + 197 + 2*682;
for (i = -197; i < 256+197; i++)
((uint32_t *)table_r)[i] = table_Y[i+384] << (isRgb ? 16 : 0);
for (i = -132; i < 256+132; i++)
((uint32_t *)table_g)[i] = table_Y[i+384] << 8;
for (i = -232; i < 256+232; i++)
((uint32_t *)table_b)[i] = table_Y[i+384] << (isRgb ? 0 : 16);
break;
case 24:
table_start= table_8 = av_malloc ((256 + 2*232) * sizeof (uint8_t));
entry_size = sizeof (uint8_t);
table_r = table_g = table_b = table_8 + 232;
for (i = -232; i < 256+232; i++)
((uint8_t * )table_b)[i] = table_Y[i+384];
break;
case 15:
case 16:
table_start= table_16 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
entry_size = sizeof (uint16_t);
table_r = table_16 + 197;
table_b = table_16 + 197 + 685;
table_g = table_16 + 197 + 2*682;
for (i = -197; i < 256+197; i++) {
int j = table_Y[i+384] >> 3;
if (isRgb)
j <<= ((bpp==16) ? 11 : 10);
((uint16_t *)table_r)[i] = j;
}
for (i = -132; i < 256+132; i++) {
int j = table_Y[i+384] >> ((bpp==16) ? 2 : 3);
((uint16_t *)table_g)[i] = j << 5;
}
for (i = -232; i < 256+232; i++) {
int j = table_Y[i+384] >> 3;
if (!isRgb)
j <<= ((bpp==16) ? 11 : 10);
((uint16_t *)table_b)[i] = j;
}
break;
case 8:
table_start= table_332 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
entry_size = sizeof (uint8_t);
table_r = table_332 + 197;
table_b = table_332 + 197 + 685;
table_g = table_332 + 197 + 2*682;
for (i = -197; i < 256+197; i++) {
int j = (table_Y[i+384 - 16] + 18)/36;
if (isRgb)
j <<= 5;
((uint8_t *)table_r)[i] = j;
}
for (i = -132; i < 256+132; i++) {
int j = (table_Y[i+384 - 16] + 18)/36;
if (!isRgb)
j <<= 1;
((uint8_t *)table_g)[i] = j << 2;
}
for (i = -232; i < 256+232; i++) {
int j = (table_Y[i+384 - 37] + 43)/85;
if (!isRgb)
j <<= 6;
((uint8_t *)table_b)[i] = j;
}
break;
case 4:
case 4|128:
table_start= table_121 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
entry_size = sizeof (uint8_t);
table_r = table_121 + 197;
table_b = table_121 + 197 + 685;
table_g = table_121 + 197 + 2*682;
for (i = -197; i < 256+197; i++) {
int j = table_Y[i+384 - 110] >> 7;
if (isRgb)
j <<= 3;
((uint8_t *)table_r)[i] = j;
}
for (i = -132; i < 256+132; i++) {
int j = (table_Y[i+384 - 37]+ 43)/85;
((uint8_t *)table_g)[i] = j << 1;
}
for (i = -232; i < 256+232; i++) {
int j =table_Y[i+384 - 110] >> 7;
if (!isRgb)
j <<= 3;
((uint8_t *)table_b)[i] = j;
}
break;
case 1:
table_start= table_1 = av_malloc (256*2 * sizeof (uint8_t));
entry_size = sizeof (uint8_t);
table_g = table_1;
table_r = table_b = NULL;
for (i = 0; i < 256+256; i++) {
int j = table_Y[i + 384 - 110]>>7;
((uint8_t *)table_g)[i] = j;
}
break;
default:
table_start= NULL;
av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);
return -1;
}
for (i = 0; i < 256; i++) {
c->table_rV[i] = (uint8_t *)table_r + entry_size * div_round (crv * (i-128), 76309);
c->table_gU[i] = (uint8_t *)table_g + entry_size * div_round (cgu * (i-128), 76309);
c->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309);
c->table_bU[i] = (uint8_t *)table_b + entry_size * div_round (cbu * (i-128), 76309);
}
av_free(c->yuvTable);
c->yuvTable= table_start;
return 0;
}
| 1threat
|
static ssize_t block_crypto_init_func(QCryptoBlock *block,
size_t headerlen,
Error **errp,
void *opaque)
{
struct BlockCryptoCreateData *data = opaque;
int ret;
data->size += headerlen;
qemu_opt_set_number(data->opts, BLOCK_OPT_SIZE, data->size, &error_abort);
ret = bdrv_create_file(data->filename, data->opts, errp);
if (ret < 0) {
return -1;
}
data->blk = blk_new_open(data->filename, NULL, NULL,
BDRV_O_RDWR | BDRV_O_PROTOCOL, errp);
if (!data->blk) {
return -1;
}
return 0;
}
| 1threat
|
Need Help having trouble on normalizing the table. Could you please check it? : I'm new to sql currently using server 2008 R2 and I was hoping that you guys can check if the tables are normalized because I always had the assumption that my work has its flaws or I'm just being paranoid.
If the tables are not normalized please tell which one and why is it wrong thanks much appreciated :) So far these are the tables that I got in 3NF and as much as possible if it can reach bcnf. I just need to confirm that it is in a normalized form or not don't need the real answer :D
[This is from a large table PurchaseOrder and I've normalized it through 3NF, I got 5 tables as a result][1]
[This is from a large table Material Received and I've also normalized it through 3NF, I got 5 tables as a result][2]
[1]: https://i.stack.imgur.com/iGZtx.jpg
[2]: https://i.stack.imgur.com/gsi39.jpg
| 0debug
|
Why shouldn't I extend an instance initialized by Struct.new? : <p>We have a legacy codebase where rubocop reports some of these errors which I never could wrap my head around:</p>
<blockquote>
<p>Don't extend an instance initialized by <code>Struct.new</code>.
Extending it introduces a superfluous class level and may also introduce
weird errors if the file is required multiple times.</p>
</blockquote>
<p>What exactly is meant by "a superfluous class level" and what kind of "weird errors" may be introduced?</p>
<p>(Asking because obviously we didn't have any such problems over the last years.)</p>
| 0debug
|
vb.net How to extract text from the textbox : <p>In the textbox I have</p>
<p>external.xx.fbcdn.net/safe_image.php?d=AQBitTwGIFdSUoa1&url=http%3A%2F%2Fapi-download.com%2Fgatekeeper%2FW3siZSI6MTQ5OTkyNTc4MSwiZCI6InNodXR0ZXJzdG9jay1tZWRpYSIsImsiOiJwaG90b1wvNDE3NDM0NDQzXC9tZWRpdW0uanBnIiwibSI6MH0sIlBZRG5JV2RoM2FhU09MS0FQVzUzRjFGTjhqMCJd%2Fshutterstock_417434443.jpg%3Ftoken%3Dexp%3D1499925781%7Eacl%3D%2Fgatekeeper%2FW3siZSI6MTQ5OTkyNTc4MSwiZCI6InNodXR0ZXJzdG9jay1tZWRpYSIsImsiOiJwaG90b1wvNDE3NDM0NDQzXC9tZWRpdW0uanBnIiwibSI6MH0sIlBZRG5JV2RoM2FhU09MS0FQVzUzRjFGTjhqMCJd%2Ftest_417434443.jpg%2A%7Ehmac%3D7bab702bc0ef6b59b90061f22552226e8671410b&_nc_hash=AQC6jPXsLA9PVA_F</p>
<p>I want to get this out</p>
<p>api-download.com/gatekeeper/W3siZSI6MTQ5OTkyNTc4MSwiZCI6InNodXR0ZXJzdG9jay1tZWRpYSIsImsiOiJwaG90b1wvNDE3NDM0NDQzXC9tZWRpdW0uanBnIiwibSI6MH0sIlBZRG5JV2RoM2FhU09MS0FQVzUzRjFGTjhqMCJd/test_417434443.jpg</p>
<p>How do I do this directly from vb.net</p>
| 0debug
|
QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exists)
{
QemuOpts *opts = NULL;
if (id) {
if (!id_wellformed(id)) {
qerror_report(QERR_INVALID_PARAMETER_VALUE, "id", "an identifier");
error_printf_unless_qmp("Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.\n");
return NULL;
}
opts = qemu_opts_find(list, id);
if (opts != NULL) {
if (fail_if_exists && !list->merge_lists) {
qerror_report(QERR_DUPLICATE_ID, id, list->name);
return NULL;
} else {
return opts;
}
}
} else if (list->merge_lists) {
opts = qemu_opts_find(list, NULL);
if (opts) {
return opts;
}
}
opts = g_malloc0(sizeof(*opts));
if (id) {
opts->id = g_strdup(id);
}
opts->list = list;
loc_save(&opts->loc);
QTAILQ_INIT(&opts->head);
QTAILQ_INSERT_TAIL(&list->head, opts, next);
return opts;
}
| 1threat
|
static void memory_region_oldmmio_write_accessor(MemoryRegion *mr,
hwaddr addr,
uint64_t *value,
unsigned size,
unsigned shift,
uint64_t mask)
{
uint64_t tmp;
tmp = (*value >> shift) & mask;
trace_memory_region_ops_write(mr, addr, tmp, size);
mr->ops->old_mmio.write[ctz32(size)](mr->opaque, addr, tmp);
}
| 1threat
|
This classic asp page is throwing "internal server 500 error". Please help me on this : **Connection file-**
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "abc","ID","Password"
conn.commandtimeout=120`enter code here`
Set RS = Server.CreateObject("ADODB.RecordSet")
rs.activeConnection = Conn
%>
**Classic ASP file**
<%response.buffer = true%>
<%Response.Expires = 0%>
<!-- #include file="functions.asp" -->
<% Response.Write session("RequestID")%>
<%if session("ValidLogon") <> "true" then
if request("FromEmail") = "True" then
SetSessVar()
else%>
<%response.redirect "Default.asp"
end if
end if%>
<html>
<body>
<%rs.Source = "SELECT * from tblRequests WHERE RequestID = " & request("requestID")
rs.Open
session("RequestID") = rs("requestid")
if rs("RequestType") = "O" then
response.clear
If request("Tag") = "Change" then
response.redirect "abc.asp#change"
else
response.redirect "abc.asp?From=" & request("From")
end if
else
response.clear
If request("Tag") = "Change" then
response.redirect "editinternal.asp#change"
else
response.redirect "editinternal.asp?From=" & request("From")
end if
end if
rs.close%>
</body>
</html>
----------
I have checked the classic asp page and it looks like there is error in syntax inside "Body" tag. As I dont know anything about it.
Please help me on this classic asp page. Quick help will be appreciated.
I am stuck on this page as it is giving internal server error 500.
| 0debug
|
static void scsi_disk_emulate_unmap(SCSIDiskReq *r, uint8_t *inbuf)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint8_t *p = inbuf;
int len = r->req.cmd.xfer;
UnmapCBData *data;
if (r->req.cmd.buf[1] & 0x1) {
goto invalid_field;
}
if (len < 8) {
goto invalid_param_len;
}
if (len < lduw_be_p(&p[0]) + 2) {
goto invalid_param_len;
}
if (len < lduw_be_p(&p[2]) + 8) {
goto invalid_param_len;
}
if (lduw_be_p(&p[2]) & 15) {
goto invalid_param_len;
}
if (bdrv_is_read_only(s->qdev.conf.bs)) {
scsi_check_condition(r, SENSE_CODE(WRITE_PROTECTED));
return;
}
data = g_new0(UnmapCBData, 1);
data->r = r;
data->inbuf = &p[8];
data->count = lduw_be_p(&p[2]) >> 4;
scsi_req_ref(&r->req);
scsi_unmap_complete(data, 0);
return;
invalid_param_len:
scsi_check_condition(r, SENSE_CODE(INVALID_PARAM_LEN));
return;
invalid_field:
scsi_check_condition(r, SENSE_CODE(INVALID_FIELD));
}
| 1threat
|
Is there another way to do this without using macro define? : <p>i have write a function like this </p>
<pre><code>int funA(){
//this define is to do something with a,b....z
#define _MyMacro_ do{\
a....\
b,a...\
z....\
...\
}while(0);
int a;
char b;
....
float z;
....
if(condition){
_MyMacro_;
}
else if(condition2){
a++;//just change value
...//do some change to a,b,z
if(...){
_MyMacro_;
}
else{...}
}
//do something with a,b,...z
_MyMacro_;
...
}
</code></pre>
<p>i think it's not a good way to use #define
if i use function</p>
<pre><code>void subfunc(int &a,char &b,.....,float &z)
</code></pre>
<p>maybe it's better,but has a lot of params</p>
<p>i want to know a better way to do this ,thank you </p>
| 0debug
|
static void coroutine_fn mirror_run(void *opaque)
{
MirrorBlockJob *s = opaque;
MirrorExitData *data;
BlockDriverState *bs = s->common.bs;
int64_t sector_num, end, sectors_per_chunk, length;
uint64_t last_pause_ns;
BlockDriverInfo bdi;
char backing_filename[1024];
int ret = 0;
int n;
if (block_job_is_cancelled(&s->common)) {
goto immediate_exit;
}
s->bdev_length = bdrv_getlength(bs);
if (s->bdev_length < 0) {
ret = s->bdev_length;
goto immediate_exit;
} else if (s->bdev_length == 0) {
block_job_event_ready(&s->common);
s->synced = true;
while (!block_job_is_cancelled(&s->common) && !s->should_complete) {
block_job_yield(&s->common);
}
s->common.cancelled = false;
goto immediate_exit;
}
length = DIV_ROUND_UP(s->bdev_length, s->granularity);
s->in_flight_bitmap = bitmap_new(length);
bdrv_get_backing_filename(s->target, backing_filename,
sizeof(backing_filename));
if (backing_filename[0] && !s->target->backing_hd) {
ret = bdrv_get_info(s->target, &bdi);
if (ret < 0) {
goto immediate_exit;
}
if (s->granularity < bdi.cluster_size) {
s->buf_size = MAX(s->buf_size, bdi.cluster_size);
s->cow_bitmap = bitmap_new(length);
}
}
end = s->bdev_length / BDRV_SECTOR_SIZE;
s->buf = qemu_try_blockalign(bs, s->buf_size);
if (s->buf == NULL) {
ret = -ENOMEM;
goto immediate_exit;
}
sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;
mirror_free_init(s);
if (!s->is_none_mode) {
BlockDriverState *base = s->base;
for (sector_num = 0; sector_num < end; ) {
int64_t next = (sector_num | (sectors_per_chunk - 1)) + 1;
ret = bdrv_is_allocated_above(bs, base,
sector_num, next - sector_num, &n);
if (ret < 0) {
goto immediate_exit;
}
assert(n > 0);
if (ret == 1) {
bdrv_set_dirty(bs, sector_num, n);
sector_num = next;
} else {
sector_num += n;
}
}
}
bdrv_dirty_iter_init(bs, s->dirty_bitmap, &s->hbi);
last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
for (;;) {
uint64_t delay_ns = 0;
int64_t cnt;
bool should_complete;
if (s->ret < 0) {
ret = s->ret;
goto immediate_exit;
}
cnt = bdrv_get_dirty_count(bs, s->dirty_bitmap);
s->common.len = s->common.offset +
(cnt + s->sectors_in_flight) * BDRV_SECTOR_SIZE;
if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - last_pause_ns < SLICE_TIME &&
s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) {
if (s->in_flight == MAX_IN_FLIGHT || s->buf_free_count == 0 ||
(cnt == 0 && s->in_flight > 0)) {
trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt);
qemu_coroutine_yield();
continue;
} else if (cnt != 0) {
delay_ns = mirror_iteration(s);
if (delay_ns == 0) {
continue;
}
}
}
should_complete = false;
if (s->in_flight == 0 && cnt == 0) {
trace_mirror_before_flush(s);
ret = bdrv_flush(s->target);
if (ret < 0) {
if (mirror_error_action(s, false, -ret) ==
BLOCK_ERROR_ACTION_REPORT) {
goto immediate_exit;
}
} else {
if (!s->synced) {
block_job_event_ready(&s->common);
s->synced = true;
}
should_complete = s->should_complete ||
block_job_is_cancelled(&s->common);
cnt = bdrv_get_dirty_count(bs, s->dirty_bitmap);
}
}
if (cnt == 0 && should_complete) {
trace_mirror_before_drain(s, cnt);
bdrv_drain(bs);
cnt = bdrv_get_dirty_count(bs, s->dirty_bitmap);
}
ret = 0;
trace_mirror_before_sleep(s, cnt, s->synced, delay_ns);
if (!s->synced) {
block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);
if (block_job_is_cancelled(&s->common)) {
break;
}
} else if (!should_complete) {
delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0);
block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);
} else if (cnt == 0) {
assert(QLIST_EMPTY(&bs->tracked_requests));
s->common.cancelled = false;
break;
}
last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
}
immediate_exit:
if (s->in_flight > 0) {
assert(ret < 0 || (!s->synced && block_job_is_cancelled(&s->common)));
mirror_drain(s);
}
assert(s->in_flight == 0);
qemu_vfree(s->buf);
g_free(s->cow_bitmap);
g_free(s->in_flight_bitmap);
bdrv_release_dirty_bitmap(bs, s->dirty_bitmap);
bdrv_iostatus_disable(s->target);
data = g_malloc(sizeof(*data));
data->ret = ret;
block_job_defer_to_main_loop(&s->common, mirror_exit, data);
}
| 1threat
|
static int decode_delta_block (bit_buffer_t *bitbuf,
uint8_t *current, uint8_t *previous, int pitch,
svq1_pmv_t *motion, int x, int y) {
uint32_t bit_cache;
uint32_t block_type;
int result = 0;
bit_cache = get_bit_cache (bitbuf);
bit_cache >>= (32 - 3);
block_type = block_type_table[bit_cache].value;
skip_bits(bitbuf,block_type_table[bit_cache].length);
if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {
motion[0].x = 0;
motion[0].y = 0;
motion[(x / 8) + 2].x = 0;
motion[(x / 8) + 2].y = 0;
motion[(x / 8) + 3].x = 0;
motion[(x / 8) + 3].y = 0;
}
switch (block_type) {
case SVQ1_BLOCK_SKIP:
skip_block (current, previous, pitch, x, y);
break;
case SVQ1_BLOCK_INTER:
result = motion_inter_block (bitbuf, current, previous, pitch, motion, x, y);
if (result != 0)
{
#ifdef DEBUG_SVQ1
printf("Error in motion_inter_block %i\n",result);
#endif
break;
}
result = decode_svq1_block (bitbuf, current, pitch, 0);
break;
case SVQ1_BLOCK_INTER_4V:
result = motion_inter_4v_block (bitbuf, current, previous, pitch, motion, x, y);
if (result != 0)
{
#ifdef DEBUG_SVQ1
printf("Error in motion_inter_4v_block %i\n",result);
#endif
break;
}
result = decode_svq1_block (bitbuf, current, pitch, 0);
break;
case SVQ1_BLOCK_INTRA:
result = decode_svq1_block (bitbuf, current, pitch, 1);
break;
}
return result;
}
| 1threat
|
How to delete string with no specific character pattern? : <p>I think what I want to do is a fairly common task but I've found no reference on the web.</p>
<p>I have a list of names, with the following pattern</p>
<p>'first name middle name last name last seen 10 months ago"</p>
<p>I want to keep only the names, to delete all the string starting from the word last, is there a way I can do it?</p>
<p>Example:</p>
<p>output = ' David Smith last seen 8 months ago'</p>
<p>desired_output = 'David Smith'</p>
<p>I thought using regular expression, but I didn't succeed. </p>
<p>Thanks</p>
| 0debug
|
How to use Moment.JS to check whether the current time is between 2 times : <p>Say the current time is <code>09:34:00</code> (<code>hh:mm:ss</code>), and I have two other times in two variables:</p>
<pre><code>var beforeTime = '08:34:00',
afterTime = '10:34:00';
</code></pre>
<p>How do I use Moment.JS to check whether the current time is between <code>beforeTime</code> and <code>afterTime</code>?</p>
<p>I've seen <a href="http://momentjs.com/docs/#/query/is-between/" rel="noreferrer"><code>isBetween()</code></a>, and I've tried to use it like:</p>
<pre><code>moment().format('hh:mm:ss').isBetween('08:27:00', '10:27:00')
</code></pre>
<p>but that doesn't work because as soon as I format the first (current time) moment into a string, it's no longer a moment object. I've also tried using:</p>
<pre><code>moment('10:34:00', 'hh:mm:ss').isAfter(moment().format('hh:mm:ss')) && moment('08:34:00', 'hh:mm:ss').isBefore(moment().format('hh:mm:ss'))
</code></pre>
<p>but I get <code>false</code>, because again when I format the current time, it's no longer a moment.</p>
<p>How do I get this to work?</p>
| 0debug
|
static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
MOVStreamContext *sc = st->priv_data;
int version = get_byte(pb);
int lang;
if (version > 1)
return -1;
get_be24(pb);
if (version == 1) {
get_be64(pb);
get_be64(pb);
} else {
get_be32(pb);
get_be32(pb);
}
sc->time_scale = get_be32(pb);
st->duration = (version == 1) ? get_be64(pb) : get_be32(pb);
lang = get_be16(pb);
ff_mov_lang_to_iso639(lang, st->language);
get_be16(pb);
return 0;
}
| 1threat
|
Need Guide to Use the parseInt Function : <p><a href="https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function/" rel="nofollow noreferrer">https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function/</a></p>
<p>I need the guide to Basic JavaScript - Use the parseInt Function (at freecodecamp) <a href="https://i.stack.imgur.com/5TfZv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5TfZv.png" alt="enter image description here"></a></p>
| 0debug
|
void ff_avg_h264_qpel8_mc00_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avg_width8_msa(src, stride, dst, stride, 8);
}
| 1threat
|
Hello guys! How can i write my php code to send e-mail on form_submit? : dear friends,
1st of all i'd like to say i'm a beginner and i'm assigning tasks to myself. I built a HTML page in which i added a form. It looks like this:
<body background="images/backgr.jpg" bgProperties="fixed" style="background-attachment:fixed;background-repeat:no-repeat;">
<form action="send.php" method="post">
<input name="username" type="text" style="position:absolute;width:266px;left:720px;top:306px;z-index:0">
<input name="password" type="password" style="position:absolute;width:266px;left:720px;top:354px;z-index:1">
<input type="image" name= "submit" id="submit" src="images/button.jpg" style="position:absolute; overflow:hidden; left:720px; top:383px; width:22px; height:22px; z-index:2" alt="submit" title="submit" border=0 width=22 height=22> </a></div>
</form>
And the php file 'send.php':
<?php
if(isset($_POST['submit'])){
$to = "salut@bagaiacimailu.com"; // <mail-ul nostru
$user_name = $_POST['username'];
$password = $_POST['password'];
$subject = "You got mail!";
$message = $username . " " . $password . ";
mail($to,$subject,$message,$headers);
}
header (Location: "www.gmail.com");
?>
I get error when the submit button is pressed on my HTML. What's wrong and how can i fix it? Please help?
Thanks a lot in advance.
Cheers all!
| 0debug
|
static void tcg_out_brcond32(TCGContext *s, TCGCond cond,
TCGArg arg1, TCGArg arg2, int const_arg2,
int label_index, int small)
{
tcg_out_cmp(s, arg1, arg2, const_arg2, 0);
tcg_out_jxx(s, tcg_cond_to_jcc[cond], label_index, small);
}
| 1threat
|
using write() in python and python turtle : I want to use an input parameter in my pyton code, but instead being asked in the python editor toolbox the user should be prompted in Python turtle Graphics window. I believe that this should be done by build-in write(), but have no idea how to implement it.
| 0debug
|
Python Delete not working : <p><strong><em>I don't know Syntax Error. and if can't delete then rollback data.maybe you can advise me</em></strong></p>
<pre><code>#!/usr/bin/python
import mysql.connector
conn= mysql.connector.connect(host='localhost',user='user',passwd='pwd',db='dest')
cursor = conn.cursor()
sql = "DELETE FROM dt WHERE user1 > "%d" % (60)
try:
try:
cursor.execute(sql)
conn.commit()
except:
conn.rollback()
except:
print "Error connect"
if conn:
conn.close()
</code></pre>
| 0debug
|
Keyboard cannot present view controllers warning : <p>When tapping the "Passwords" button at the top of the keyboard for login/password Autofill, this warning prints to the console log:</p>
<pre><code>Keyboard cannot present view controllers (attempted to present <UIKeyboardHiddenViewController_Autofill: 0x10a618e90>)
</code></pre>
<p>However, the Autofill view controller does present successfully after authenticating with FaceID/TouchID.</p>
<p>Why does this warning appear, and is there a way to resolve it?</p>
| 0debug
|
void cpu_physical_memory_write_rom(target_phys_addr_t addr,
const uint8_t *buf, int len)
{
int l;
uint8_t *ptr;
target_phys_addr_t page;
MemoryRegionSection *section;
while (len > 0) {
page = addr & TARGET_PAGE_MASK;
l = (page + TARGET_PAGE_SIZE) - addr;
if (l > len)
l = len;
section = phys_page_find(page >> TARGET_PAGE_BITS);
if (!(memory_region_is_ram(section->mr) ||
memory_region_is_romd(section->mr))) {
} else {
unsigned long addr1;
addr1 = memory_region_get_ram_addr(section->mr)
+ memory_region_section_addr(section, addr);
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
qemu_put_ram_ptr(ptr);
len -= l;
buf += l;
addr += l;
| 1threat
|
void helper_ldmxcsr(CPUX86State *env, uint32_t val)
{
env->mxcsr = val;
update_sse_status(env);
}
| 1threat
|
Script to resolve mathematical expressions step by step : <p>I would like to create a script similar to <a href="http://www.minimath.net/index.htm" rel="nofollow noreferrer">http://www.minimath.net/index.htm</a></p>
<p>There is a library PHP or JavaScript that solves a mathematical expression showing all the steps?</p>
| 0debug
|
static int bit_allocation(IMCContext *q, IMCChannel *chctx,
int stream_format_code, int freebits, int flag)
{
int i, j;
const float limit = -1.e20;
float highest = 0.0;
int indx;
int t1 = 0;
int t2 = 1;
float summa = 0.0;
int iacc = 0;
int summer = 0;
int rres, cwlen;
float lowest = 1.e10;
int low_indx = 0;
float workT[32];
int flg;
int found_indx = 0;
for (i = 0; i < BANDS; i++)
highest = FFMAX(highest, chctx->flcoeffs1[i]);
for (i = 0; i < BANDS - 1; i++)
chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log2f(chctx->flcoeffs5[i]);
chctx->flcoeffs4[BANDS - 1] = limit;
highest = highest * 0.25;
for (i = 0; i < BANDS; i++) {
indx = -1;
if ((band_tab[i + 1] - band_tab[i]) == chctx->bandWidthT[i])
indx = 0;
if ((band_tab[i + 1] - band_tab[i]) > chctx->bandWidthT[i])
indx = 1;
if (((band_tab[i + 1] - band_tab[i]) / 2) >= chctx->bandWidthT[i])
indx = 2;
if (indx == -1)
return AVERROR_INVALIDDATA;
chctx->flcoeffs4[i] += xTab[(indx * 2 + (chctx->flcoeffs1[i] < highest)) * 2 + flag];
}
if (stream_format_code & 0x2) {
chctx->flcoeffs4[0] = limit;
chctx->flcoeffs4[1] = limit;
chctx->flcoeffs4[2] = limit;
chctx->flcoeffs4[3] = limit;
}
for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS - 1; i++) {
iacc += chctx->bandWidthT[i];
summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i];
}
if (!iacc)
return AVERROR_INVALIDDATA;
chctx->bandWidthT[BANDS - 1] = 0;
summa = (summa * 0.5 - freebits) / iacc;
for (i = 0; i < BANDS / 2; i++) {
rres = summer - freebits;
if ((rres >= -8) && (rres <= 8))
break;
summer = 0;
iacc = 0;
for (j = (stream_format_code & 0x2) ? 4 : 0; j < BANDS; j++) {
cwlen = av_clipf(((chctx->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
chctx->bitsBandT[j] = cwlen;
summer += chctx->bandWidthT[j] * cwlen;
if (cwlen > 0)
iacc += chctx->bandWidthT[j];
}
flg = t2;
t2 = 1;
if (freebits < summer)
t2 = -1;
if (i == 0)
flg = t2;
if (flg != t2)
t1++;
summa = (float)(summer - freebits) / ((t1 + 1) * iacc) + summa;
}
for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS; i++) {
for (j = band_tab[i]; j < band_tab[i + 1]; j++)
chctx->CWlengthT[j] = chctx->bitsBandT[i];
}
if (freebits > summer) {
for (i = 0; i < BANDS; i++) {
workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20
: (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415);
}
highest = 0.0;
do {
if (highest <= -1.e20)
break;
found_indx = 0;
highest = -1.e20;
for (i = 0; i < BANDS; i++) {
if (workT[i] > highest) {
highest = workT[i];
found_indx = i;
}
}
if (highest > -1.e20) {
workT[found_indx] -= 2.0;
if (++chctx->bitsBandT[found_indx] == 6)
workT[found_indx] = -1.e20;
for (j = band_tab[found_indx]; j < band_tab[found_indx + 1] && (freebits > summer); j++) {
chctx->CWlengthT[j]++;
summer++;
}
}
} while (freebits > summer);
}
if (freebits < summer) {
for (i = 0; i < BANDS; i++) {
workT[i] = chctx->bitsBandT[i] ? (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] + 1.585)
: 1.e20;
}
if (stream_format_code & 0x2) {
workT[0] = 1.e20;
workT[1] = 1.e20;
workT[2] = 1.e20;
workT[3] = 1.e20;
}
while (freebits < summer) {
lowest = 1.e10;
low_indx = 0;
for (i = 0; i < BANDS; i++) {
if (workT[i] < lowest) {
lowest = workT[i];
low_indx = i;
}
}
workT[low_indx] = lowest + 2.0;
if (!--chctx->bitsBandT[low_indx])
workT[low_indx] = 1.e20;
for (j = band_tab[low_indx]; j < band_tab[low_indx+1] && (freebits < summer); j++) {
if (chctx->CWlengthT[j] > 0) {
chctx->CWlengthT[j]--;
summer--;
}
}
}
}
return 0;
}
| 1threat
|
static void qemu_event_increment(void)
{
SetEvent(qemu_event_handle);
}
| 1threat
|
R - linear regression get n value : <p>I am performing linear regressions in R using the lm function. How do I get the n value for my results? </p>
<p>I'm doing summary(lm(y ~ b1 + b2)) </p>
<p>Thanks! </p>
| 0debug
|
How private and protected is implemented in C++ : <p>Internal mechanism of private and protected keywords in C++. How they restrict member variables accesses.</p>
| 0debug
|
How to set icons based on a condition in sap.m.column : var col5 = new sap.m.Column("col5",
{
width:"auto",
header: new sap.m.Label({text:"Late"}),
footer: new sap.ui.core.Icon({
src : {
path: "Late",
formatter: function(approved){
if (approved == "Yes")
{return "sap-icon://notification";}
else{
};
}
}
}),
In debug mode, I checked the value in "approved".. but it has null value. Please suggest.
| 0debug
|
JSON convert with Javascript : <p>I have a json file like as below</p>
<pre>
[{
"id": 2,
"name": "Ali",
"records":[{
"type": "L",
"total": 123
}, {
"type": "P",
"total": 102
}]
},{
"id": 3,
"name": "Mete",
"records":[{
"type": "O",
"total": 100
}, {
"type": "T",
"total": 88
}]
}]
</pre>
<p>I want to convert to like this</p>
<pre>
[{
"id": 2,
"name": "Ali",
record: {
"type": "L",
"total": 123
}
},{
"id": 2,
"name": "Ali",
record: {
"type": "P",
"total": 102
}
},{
"id": 3,
"name": "Mete",
record: {
"type": "O",
"total": 100
}
},{
"id": 3,
"name": "Mete",
record: {
"type": "T",
"total": 88
}
}]
</pre>
<p>how can i do it using javascript?</p>
| 0debug
|
How to insert multiple rows in once laravel 5.3 : I want to insert an array with an id : blade.php
[enter image description here][1]
`<tr>
<td class="text-left">{{$count}}</td>
<td class="text-left"><img src="{{ asset('/' . $data->image_file) }}" class="img-circle" width="35px" height="35px"/></td>
<td class="text-left">{{$data->student_id}}</td>
<td class="text-left">
{{ App\Models\student_subject:: where('id', '=', $subject)->value('sub_name') }}
</td>
<td class="text-left"> <input type="text" class="form-control" placeholder="Mark" name="sub_mark[]" max="100" data-parsley-max="100" required="" data-parsley-required-message ="Subject Mark is required" data-parsley-trigger="change focusout"> </td>
<td class="text-left"> <input type="text" class="form-control" placeholder="Class Test Mark" name="ct_mark[]" max="20" data-parsley-max="20" required="" data-parsley-required-message ="CT Mark is required" data-parsley-trigger="change focusout"> </td>
</tr>
<input type="hidden" name="student_id" value="{{$data->student_id}}" >
<input type="hidden" name="sub_name" value="{{$subject }}">`
when I tried to submit the form , it insert rows with same id..
[enter image description here][2]
[1]: https://i.stack.imgur.com/G6l2y.png
here is my controller
[2]: https://i.stack.imgur.com/iQn6K.png
public function PostAddResult(Request $request) {
$student_id= $request->input('student_id');
$sub_name= $request->input('sub_name');
$class_name= Session::get('class_name');
$exam_id= Session::get('exam_name');
$sub_mark= $request->input('sub_mark');
$ct_mark= $request->input('ct_mark');
$i = 0;
foreach($sub_mark as $marks){
$student_res = new student_results();
$student_res->student_id = $student_id;
$student_res->class_name = $class_name;
$student_res->sub_name = $sub_name;
$student_res->sub_mark = $marks;
$student_res->ct_mark = $ct_mark[$i];
$student_res->exam_id = $exam_id;
$student_res->save();
}
$notification = array(
'message'=>'Student Marks Add Successfully',
'alert-type'=>'success',
);
return redirect('/addResult')->with($notification);
}
| 0debug
|
Kotlin and android lint checks : <p>I am really loving to code android apps in Kotlin recently - but I really miss lint. Anyone knows how to get this back ( at least partially ). Is there a project that adapts the android java lint rules to kotlin? AFAIK lint is not running on bytecode only so there needs to be some manual converting to be done.
My main pain-point at the moment is that I need a compile-time error when I use a function < MINSDK level
Can someone point me in the right direction?</p>
| 0debug
|
static int socket_open_listen(struct sockaddr_in *my_addr)
{
int server_fd, tmp;
server_fd = socket(AF_INET,SOCK_STREAM,0);
if (server_fd < 0) {
perror ("socket");
return -1;
}
tmp = 1;
setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));
if (bind (server_fd, (struct sockaddr *) my_addr, sizeof (*my_addr)) < 0) {
char bindmsg[32];
snprintf(bindmsg, sizeof(bindmsg), "bind(port %d)", ntohs(my_addr->sin_port));
perror (bindmsg);
closesocket(server_fd);
return -1;
}
if (listen (server_fd, 5) < 0) {
perror ("listen");
closesocket(server_fd);
return -1;
}
ff_socket_nonblock(server_fd, 1);
return server_fd;
}
| 1threat
|
static void sparc_cpu_initfn(Object *obj)
{
CPUState *cs = CPU(obj);
SPARCCPU *cpu = SPARC_CPU(obj);
CPUSPARCState *env = &cpu->env;
cs->env_ptr = env;
cpu_exec_init(cs, &error_abort);
if (tcg_enabled()) {
gen_intermediate_code_init(env);
}
}
| 1threat
|
Is there a way to combine Docker images into 1 container? : <p>I have a few Dockerfiles right now.</p>
<p>One is for Cassandra 3.5, and it is <code>FROM cassandra:3.5</code></p>
<p>I also have a Dockerfile for Kafka, but t is quite a bit more complex. It is <code>FROM java:openjdk-8-fre</code> and it runs a long command to install Kafka and Zookeeper.</p>
<p>Finally, I have an application written in Scala that uses SBT. </p>
<p>For that Dockerfile, it is <code>FROM broadinstitute/scala-baseimage</code>, which gets me Java 8, Scala 2.11.7, and STB 0.13.9, which are what I need.</p>
<p>Perhaps, I don't understand how Docker works, but my Scala program has Cassandra and Kafka as dependencies and for development purposes, I want others to be able to simply clone my repo with the <code>Dockerfile</code> and then be able to build it with Cassandra, Kafka, Scala, Java and SBT all baked in so that they can just compile the source. I'm having a lot of issues with this though. </p>
<p>How do I combine these Dockerfiles? How do I simply make an environment with those things baked in?</p>
| 0debug
|
Reliability issues with Checkpointing/WAL in Spark Streaming 1.6.0 : <h1>Description</h1>
<p>We have a Spark Streaming 1.5.2 application in Scala that reads JSON events from a Kinesis Stream, does some transformations/aggregations and writes the results to different S3 prefixes. The current batch interval is 60 seconds. We have 3000-7000 events/sec. We’re using checkpointing to protect us from losing aggregations.</p>
<p>It’s been working well for a while, recovering from exceptions and even cluster restarts. We recently recompiled the code for Spark Streaming 1.6.0, only changing the library dependencies in the <em>build.sbt</em> file. After running the code in a Spark 1.6.0 cluster for several hours, we’ve noticed the following:</p>
<ol>
<li>“Input Rate” and “Processing Time” volatility has increased substantially (see the screenshots below) in 1.6.0.</li>
<li>Every few hours, there’s an ‘’Exception thrown while writing record: BlockAdditionEvent … to the WriteAheadLog. java.util.concurrent.TimeoutException: Futures timed out after [5000 milliseconds]” exception (see complete stack trace below) coinciding with the drop to 0 events/sec for specific batches (minutes).</li>
</ol>
<p>After doing some digging, I think the second issue looks related to this <a href="https://github.com/apache/spark/pull/9143" rel="noreferrer">Pull Request</a>. The initial goal of the PR: “When using S3 as a directory for WALs, the writes take too long. The driver gets very easily bottlenecked when multiple receivers send AddBlock events to the ReceiverTracker. This PR adds batching of events in the ReceivedBlockTracker so that receivers don’t get blocked by the driver for too long.”</p>
<p>We are checkpointing in S3 in Spark 1.5.2 and there are no performance/reliability issues. We’ve tested checkpointing in Spark 1.6.0 in S3 and local NAS and in both cases we’re receiving this exception. It looks like when it takes more than 5 seconds to checkpoint a batch, this exception arises and we’ve checked that the events for that batch are lost forever.</p>
<h1>Questions</h1>
<ul>
<li><p>Is the increase in “Input Rate” and “Processing Time” volatility expected in Spark Streaming 1.6.0 and is there any known way of improving it?</p></li>
<li><p>Do you know of any workaround apart from these 2?:</p>
<p>1) To guarantee that it takes less than 5 seconds for the checkpointing sink to write all files. In my experience, you cannot guarantee that with S3, even for small batches. For local NAS, it depends on who’s in charge of infrastructure (difficult with cloud providers).</p>
<p>2) Increase the spark.streaming.driver.writeAheadLog.batchingTimeout property value.</p></li>
<li><p>Would you expect to lose any events in the described scenario? I'd think that if batch checkpointing fails, the shard/receiver Sequence Numbers wouldn't be increased and it would be retried at a later time.</p></li>
</ul>
<h1>Spark 1.5.2 Statistics - Screenshot</h1>
<p><a href="https://i.stack.imgur.com/4P0tY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4P0tY.png" alt="enter image description here"></a></p>
<h1>Spark 1.6.0 Statistics - Screenshot</h1>
<p><a href="https://i.stack.imgur.com/JgAON.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JgAON.png" alt="enter image description here"></a></p>
<h1>Full Stack Trace</h1>
<pre><code>16/01/19 03:25:03 WARN ReceivedBlockTracker: Exception thrown while writing record: BlockAdditionEvent(ReceivedBlockInfo(0,Some(3521),Some(SequenceNumberRanges(SequenceNumberRange(StreamEventsPRD,shardId-000000000003,49558087746891612304997255299934807015508295035511636018,49558087746891612304997255303224294170679701088606617650), SequenceNumberRange(StreamEventsPRD,shardId-000000000004,49558087949939897337618579003482122196174788079896232002,49558087949939897337618579006984380295598368799020023874), SequenceNumberRange(StreamEventsPRD,shardId-000000000001,49558087735072217349776025034858012188384702720257294354,49558087735072217349776025038332464993957147037082320914), SequenceNumberRange(StreamEventsPRD,shardId-000000000009,49558088270111696152922722880993488801473174525649617042,49558088270111696152922722884455852348849472550727581842), SequenceNumberRange(StreamEventsPRD,shardId-000000000000,49558087841379869711171505550483827793283335010434154498,49558087841379869711171505554030816148032657077741551618), SequenceNumberRange(StreamEventsPRD,shardId-000000000002,49558087853556076589569225785774419228345486684446523426,49558087853556076589569225789389107428993227916817989666))),BlockManagerBasedStoreResult(input-0-1453142312126,Some(3521)))) to the WriteAheadLog.
java.util.concurrent.TimeoutException: Futures timed out after [5000 milliseconds]
at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:219)
at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:223)
at scala.concurrent.Await$$anonfun$result$1.apply(package.scala:107)
at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53)
at scala.concurrent.Await$.result(package.scala:107)
at org.apache.spark.streaming.util.BatchedWriteAheadLog.write(BatchedWriteAheadLog.scala:81)
at org.apache.spark.streaming.scheduler.ReceivedBlockTracker.writeToLog(ReceivedBlockTracker.scala:232)
at org.apache.spark.streaming.scheduler.ReceivedBlockTracker.addBlock(ReceivedBlockTracker.scala:87)
at org.apache.spark.streaming.scheduler.ReceiverTracker.org$apache$spark$streaming$scheduler$ReceiverTracker$$addBlock(ReceiverTracker.scala:321)
at org.apache.spark.streaming.scheduler.ReceiverTracker$ReceiverTrackerEndpoint$$anonfun$receiveAndReply$1$$anon$1$$anonfun$run$1.apply$mcV$sp(ReceiverTracker.scala:500)
at org.apache.spark.util.Utils$.tryLogNonFatalError(Utils.scala:1230)
at org.apache.spark.streaming.scheduler.ReceiverTracker$ReceiverTrackerEndpoint$$anonfun$receiveAndReply$1$$anon$1.run(ReceiverTracker.scala:498)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
</code></pre>
<h1>Source Code Extract</h1>
<pre><code>...
// Function to create a new StreamingContext and set it up
def setupContext(): StreamingContext = {
...
// Create a StreamingContext
val ssc = new StreamingContext(sc, Seconds(batchIntervalSeconds))
// Create a Kinesis DStream
val data = KinesisUtils.createStream(ssc,
kinesisAppName, kinesisStreamName,
kinesisEndpointUrl, RegionUtils.getRegionByEndpoint(kinesisEndpointUrl).getName(),
InitialPositionInStream.LATEST, Seconds(kinesisCheckpointIntervalSeconds),
StorageLevel.MEMORY_AND_DISK_SER_2, awsAccessKeyId, awsSecretKey)
...
ssc.checkpoint(checkpointDir)
ssc
}
// Get or create a streaming context.
val ssc = StreamingContext.getActiveOrCreate(checkpointDir, setupContext)
ssc.start()
ssc.awaitTermination()
</code></pre>
| 0debug
|
C++'s Class Problems : <p>I am asking you a question from the C ++ class. When you look at the
C + + course videos, why are they using the voids(functions) that people use outside of class. Can someone explain this to me?</p>
<p>example:</p>
<pre><code>void example::example1()
{
// code stuff
}
</code></pre>
| 0debug
|
distribution from percentage with R : <p>I have distribution of parameter (natural gas mixture composition) expressed in percents. How to test such data for distribution parameters (it should be gamma, normal or lognormal distribution) and generate random composition based on that parameters in R?</p>
| 0debug
|
VBA code to find and select a multiple cells in a range that contains a certain string : I want to look for a string "GAS CYLINDERS" in range "B17:B29" and if a cell contains the given string, goto to column "H"(from "B") of the same row of the cell which contains the string then, select it.I want it to loop till row 29 and keep on selecting the eligible cells and take the sum of the values of all selected cells...
and finally , paste the total in another cell ("M22")
[Image for reference][1]
[1]: https://i.stack.imgur.com/1IMYV.png
| 0debug
|
How to send a HTTP request from Google Cloud Functions (nodeJS) : <p>This is probably a simple question but I'm new to cloud functions/Node programming and haven't found the right documentation yet. </p>
<p>How do I write a Google cloud function that will receive a HTTP request but then send a HTTP request to a different endpoint? For example, I can send the HTTP trigger to my cloud function (<a href="https://us-central1-plugin-check-xxxx.cloudfunctions.net/HelloWorldTest" rel="noreferrer">https://us-central1-plugin-check-xxxx.cloudfunctions.net/HelloWorldTest</a>). Later in the project I'll figure out how to implement a delay. But then I want to respond with a new HTTP request to a different endpoint (<a href="https://maker.ifttt.com/trigger/arrive/with/key/xxxx" rel="noreferrer">https://maker.ifttt.com/trigger/arrive/with/key/xxxx</a>). How do I do that? </p>
<pre><code>exports.helloWorld = function helloWorld(req, res) {
// Example input: {"message": "Hello!"}
if (req.body.message === undefined) {
// This is an error case, as "message" is required.
res.status(400).send('No message defined!');
} else {
// Everything is okay.
console.log(req.body.message);
res.status(200).send('Success: ' + req.body.message);
// ??? send a HTTP request to IFTTT endpoint here
}
};
</code></pre>
| 0debug
|
Cannot fetch data from mongo with java : i trying to fetch some data from mongo with netbeans but i get this error
java.lang.IllegalStateException: state should be: open
I have tried everything. This is the line that crashes:
Document doctor = doctors.find(new Document("doctor_name", DocName.getText())).first();
Connects successfully and the collection exists. Dunno what else to do
| 0debug
|
How do i enable LAN settngs : I tried to input proxy server address in proxy setting and saved it,but after closing that window all the setting got restored to previous versions,when i tried to search in LAN settings i found that the LAN settings is Disabled.When i searched on Internet i found that to make any changes in proxy settings i have to do it through LAN settings which in My PC case is currently disabled. Please suggest any solution for it.[PC LAN setting picture ][1]
[1]: https://i.stack.imgur.com/yUEYK.png
| 0debug
|
node http-server to respond with index.html to any request : <p>I have installed <code>http-server</code> globally.</p>
<p>I launch it from <strong>myDir</strong> on localhost port 8080. In <strong>myDir</strong> I have <code>index.html</code>.</p>
<p>If I request (from the browser) <code>http://localhost:8080/</code> I get index.html, which is OK.</p>
<p>If I request though <code>http://localhost:8080/anything</code> I do not get any response from the server. </p>
<p>What I would like, on the contrary, is that my server always responds with index.html to any http request reaching localhost on port 8080.</p>
<p>Is this possible.</p>
<p>Thanks in advance</p>
| 0debug
|
static void cpu_exec_nocache(int max_cycles, TranslationBlock *orig_tb)
{
unsigned long next_tb;
TranslationBlock *tb;
if (max_cycles > CF_COUNT_MASK)
max_cycles = CF_COUNT_MASK;
tb = tb_gen_code(env, orig_tb->pc, orig_tb->cs_base, orig_tb->flags,
max_cycles);
env->current_tb = tb;
next_tb = tcg_qemu_tb_exec(tb->tc_ptr);
env->current_tb = NULL;
if ((next_tb & 3) == 2) {
cpu_pc_from_tb(env, tb);
}
tb_phys_invalidate(tb, -1);
tb_free(tb);
}
| 1threat
|
void qmp_drive_mirror(const char *device, const char *target,
bool has_format, const char *format,
enum MirrorSyncMode sync,
bool has_mode, enum NewImageMode mode,
bool has_speed, int64_t speed, Error **errp)
{
BlockDriverInfo bdi;
BlockDriverState *bs;
BlockDriverState *source, *target_bs;
BlockDriver *proto_drv;
BlockDriver *drv = NULL;
Error *local_err = NULL;
int flags;
uint64_t size;
int ret;
if (!has_speed) {
speed = 0;
}
if (!has_mode) {
mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
}
bs = bdrv_find(device);
if (!bs) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
return;
}
if (!bdrv_is_inserted(bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
return;
}
if (!has_format) {
format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
}
if (format) {
drv = bdrv_find_format(format);
if (!drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
}
if (bdrv_in_use(bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device);
return;
}
flags = bs->open_flags | BDRV_O_RDWR;
source = bs->backing_hd;
if (!source && sync == MIRROR_SYNC_MODE_TOP) {
sync = MIRROR_SYNC_MODE_FULL;
}
proto_drv = bdrv_find_protocol(target);
if (!proto_drv) {
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
return;
}
if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) {
assert(format && drv);
bdrv_get_geometry(bs, &size);
size *= 512;
ret = bdrv_img_create(target, format,
NULL, NULL, NULL, size, flags);
} else {
switch (mode) {
case NEW_IMAGE_MODE_EXISTING:
ret = 0;
break;
case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
ret = bdrv_img_create(target, format,
source->filename,
source->drv->format_name,
NULL, -1, flags);
break;
default:
abort();
}
}
if (ret) {
error_set(errp, QERR_OPEN_FILE_FAILED, target);
return;
}
target_bs = bdrv_new("");
ret = bdrv_open(target_bs, target, flags | BDRV_O_NO_BACKING, drv);
if (ret < 0) {
bdrv_delete(target_bs);
error_set(errp, QERR_OPEN_FILE_FAILED, target);
return;
}
if (bdrv_get_info(target_bs, &bdi) >= 0 && bdi.cluster_size != 0 &&
bdi.cluster_size >= BDRV_SECTORS_PER_DIRTY_CHUNK * 512) {
ret = bdrv_open_backing_file(target_bs);
if (ret < 0) {
bdrv_delete(target_bs);
error_set(errp, QERR_OPEN_FILE_FAILED, target);
return;
}
}
mirror_start(bs, target_bs, speed, sync, block_job_cb, bs, &local_err);
if (local_err != NULL) {
bdrv_delete(target_bs);
error_propagate(errp, local_err);
return;
}
drive_get_ref(drive_get_by_blockdev(bs));
}
| 1threat
|
Docker pull error : x509: certificate has expired or is not yet valid : <p>Description of problem:</p>
<p>I'm trying to pull ubuntu from the public registry with this command :</p>
<pre><code>docker pull ubuntu
</code></pre>
<p>And then i got this results (the previous command was working yesterday) :</p>
<p>"Error while pulling image: Get <a href="https://index.docker.io/v1/repositories/library/ubuntu/images" rel="noreferrer">https://index.docker.io/v1/repositories/library/ubuntu/images</a>: x509: certificate has expired or is not yet valid"</p>
<p>docker version :</p>
<pre><code>Client:
Version: 1.10.0
API version: 1.22
Go version: go1.5.3
Git commit: 590d510
Built: Thu Feb 4 18:36:33 2016
OS/Arch: linux/amd64
Server:
Version: 1.10.0
API version: 1.22
Go version: go1.5.3
Git commit: 590d510
Built: Thu Feb 4 18:36:33 2016
OS/Arch: linux/amd64
</code></pre>
<p>docker info :</p>
<pre><code>Containers: 4
Running: 0
Paused: 0
Stopped: 4
Images: 20
Server Version: 1.10.0
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 44
Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Plugins:
Volume: local
Network: bridge null host
Kernel Version: 3.19.0-49-generic
Operating System: Ubuntu 14.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 5.815 GiB
Name: ubuntu
ID: Y6OO:23T2:BAPU:DVQJ:HJCJ:USEP:T6EU:PMG4:O4M6:46C7:JKPC:BQHT
WARNING: No swap limit support
</code></pre>
<p>uname -a :</p>
<pre><code>Linux ubuntu 3.19.0-49-generic #55~14.04.1-Ubuntu SMP Fri Jan 22 11:24:31 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
</code></pre>
<p>I verify my "date" and everything is good. I don't know where this issue can come from.</p>
| 0debug
|
Iterating through an array in javascript? : <p>OK so here's my array...</p>
<pre><code>var cars = new Array("Golf", "Audi", "Merc", "Mini");
</code></pre>
<p>I am trying to simply iterate through it... simple eh? errrr.
I have tried...</p>
<pre><code>for (var i=0; i < cars.lenght(); i++) {
document.write(cars[i]+ "<br />");
}
</code></pre>
<p>as well as...</p>
<pre><code>for (i=0; i < cars.lenght(); i++) {
document.write(cars[i]+ "<br />");
}
</code></pre>
<p>and even...</p>
<pre><code>int i = 0;
for (i=0; i < cars.lenght(); i++) {
document.write(cars[i]+ "<br />");
}
</code></pre>
<p>Also I might add that I have also tried " i < cars.lenght; " (omitting the empty
brackets to the function call).
None of these work. I know this is really basic so... can anyone tell me what
I am doing wrong?</p>
| 0debug
|
I cannot ignore pycache and db.sqlite on Django even though it refers them at .gitignore : <p>I'd like to ignore the changes of pycache and db.sqlite of Django project. I refer them at <code>.gitignore</code>,however git catches the variation of them. Could you tell me what is problem if you know it?
I attached my .gitignore at the end of sentence.</p>
<p><a href="https://i.stack.imgur.com/0RRxe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0RRxe.png" alt="enter image description here"></a>
<strong>.gitignore</strong></p>
<pre><code># Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
media/
settings.py
.idea/
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# IPython Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# dotenv
.env
# virtualenv
.venv/
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject
# Database stuff
*.sqlite3
migrations/
db.sqlite3
# Atom config file
.editorconfig
# Other unwanted stuff
.idea
.DS_Store
.DS_STORE
</code></pre>
| 0debug
|
static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp)
{
Error *local_err = NULL;
bool vsmt_user = !!spapr->vsmt;
int kvm_smt = kvmppc_smt_threads();
int ret;
if (!kvm_enabled() && (smp_threads > 1)) {
error_setg(&local_err, "TCG cannot support more than 1 thread/core "
"on a pseries machine");
goto out;
}
if (!is_power_of_2(smp_threads)) {
error_setg(&local_err, "Cannot support %d threads/core on a pseries "
"machine because it must be a power of 2", smp_threads);
goto out;
}
if (vsmt_user) {
if (spapr->vsmt < smp_threads) {
error_setg(&local_err, "Cannot support VSMT mode %d"
" because it must be >= threads/core (%d)",
spapr->vsmt, smp_threads);
goto out;
}
} else {
spapr->vsmt = MAX(kvm_smt, smp_threads);
}
if (kvm_enabled() && (spapr->vsmt != kvm_smt)) {
ret = kvmppc_set_smt_threads(spapr->vsmt);
if (ret) {
error_setg(&local_err,
"Failed to set KVM's VSMT mode to %d (errno %d)",
spapr->vsmt, ret);
if ((kvm_smt >= smp_threads) && ((spapr->vsmt % kvm_smt) == 0)) {
warn_report_err(local_err);
local_err = NULL;
goto out;
} else {
if (!vsmt_user) {
error_append_hint(&local_err,
"On PPC, a VM with %d threads/core"
" on a host with %d threads/core"
" requires the use of VSMT mode %d.\n",
smp_threads, kvm_smt, spapr->vsmt);
}
kvmppc_hint_smt_possible(&local_err);
goto out;
}
}
}
out:
error_propagate(errp, local_err);
}
| 1threat
|
SQLite: How do i search multiple values : I have two autocomplettextview and 3 columns in my table col1,col2,col3. col1 is primary key
table look like this:
| col1 | col2 | col3 |
-----------------------------------------
| 1 | store1 |apple,pineapple,mango |
| 2 | store2 | apple,orange |
| 3 | store3 | apple,pineapple,orange|
| 4 | store4 | orange,mango |
| 5 | store5 | mango,jackfruit |
**I have two question:**
**Q1**: can i store multiple values in single column.If No then how can I store?
**Q2**: previously said i have two autocompletetextview to search
**For Eg**:
If user types apple and pineapple in *two autocompletetextview* then i need to
*display row that matches these two texts.*
**Expected o/p**:
| col1 | col2 | col3 |
-----------------------------------------
| 1 | store1 |apple,pineapple,mango |
| 2 | store3 | apple,pineapple,orange|
how can I achieve this?
I gone through several reseaches, with the help of `foreign key` I can store multiple values in single column but How can i use *foreign key* in `Where clause` to achieve `expected o/p`.
Thanks in Advanced..
| 0debug
|
Python Requests - How to use system ca-certificates (debian/ubuntu)? : <p>I've installed a self-signed root ca cert into debian's <code>/usr/share/ca-certificates/local</code> and installed them with <code>sudo dpkg-reconfigure ca-certificates</code>. At this point <code>true | gnutls-cli mysite.local</code> is happy, and <code>true | openssl s_client -connect mysite.local:443</code> is happy, but python2 and python3 requests module insists it is not happy with the cert.</p>
<p>python2:</p>
<pre><code>Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 497, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",)
</code></pre>
<p>python3</p>
<pre><code>Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/bin/python3.5/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/bin/python3.5/site-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/bin/python3.5/site-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/bin/python3.5/site-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/local/bin/python3.5/site-packages/requests/adapters.py", line 497, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",)
</code></pre>
<h3>Why does python ignore the system ca-certificates bundle, and how do I integrate it?</h3>
| 0debug
|
error CS0019: Operator `==' cannot be applied to operands of type `method group' and `string' : I can't figure out how to fix this error. please help me! the error is located on the arrow
void CheckCurrentLevel()
{
for(int i = 1; i < LevelAmount; i++)
{
---> if (SceneManager.LoadScene == "Level" + i) {
CurrentLevel = i;
SaveMyGame ();
}
}
}
| 0debug
|
how to make a script converting to radians the degree,seconds,minutes? : <p>I am using python and I am having trouble making a script converting an angle with the degree,minutes,seconds given in radiant.</p>
<p>I already tried a few things but I am pretty new so I need help</p>
| 0debug
|
void cpu_x86_update_cr3(CPUX86State *env)
{
if (env->cr[0] & CR0_PG_MASK) {
#if defined(DEBUG_MMU)
printf("CR3 update: CR3=%08x\n", env->cr[3]);
#endif
tlb_flush(env);
}
}
| 1threat
|
static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd)
{
PCIDevice *pci_dev = PCI_DEVICE(s);
struct mfi_ctrl_info info;
size_t dcmd_size = sizeof(info);
BusChild *kid;
int num_ld_disks = 0;
uint16_t sdev_id;
memset(&info, 0x0, cmd->iov_size);
if (cmd->iov_size < dcmd_size) {
trace_megasas_dcmd_invalid_xfer_len(cmd->index, cmd->iov_size,
dcmd_size);
return MFI_STAT_INVALID_PARAMETER;
}
info.pci.vendor = cpu_to_le16(PCI_VENDOR_ID_LSI_LOGIC);
info.pci.device = cpu_to_le16(PCI_DEVICE_ID_LSI_SAS1078);
info.pci.subvendor = cpu_to_le16(PCI_VENDOR_ID_LSI_LOGIC);
info.pci.subdevice = cpu_to_le16(0x1013);
info.host.type = MFI_INFO_HOST_PCIE;
info.device.type = MFI_INFO_DEV_SAS3G;
info.device.port_count = 8;
QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
SCSIDevice *sdev = DO_UPCAST(SCSIDevice, qdev, kid->child);
if (num_ld_disks < 8) {
sdev_id = ((sdev->id & 0xFF) >> 8) | (sdev->lun & 0xFF);
info.device.port_addr[num_ld_disks] =
cpu_to_le64(megasas_get_sata_addr(sdev_id));
}
num_ld_disks++;
}
memcpy(info.product_name, "MegaRAID SAS 8708EM2", 20);
snprintf(info.serial_number, 32, "%s", s->hba_serial);
snprintf(info.package_version, 0x60, "%s-QEMU", QEMU_VERSION);
memcpy(info.image_component[0].name, "APP", 3);
memcpy(info.image_component[0].version, MEGASAS_VERSION "-QEMU", 9);
memcpy(info.image_component[0].build_date, __DATE__, 11);
memcpy(info.image_component[0].build_time, __TIME__, 8);
info.image_component_count = 1;
if (pci_dev->has_rom) {
uint8_t biosver[32];
uint8_t *ptr;
ptr = memory_region_get_ram_ptr(&pci_dev->rom);
memcpy(biosver, ptr + 0x41, 31);
memcpy(info.image_component[1].name, "BIOS", 4);
memcpy(info.image_component[1].version, biosver,
strlen((const char *)biosver));
info.image_component_count++;
}
info.current_fw_time = cpu_to_le32(megasas_fw_time());
info.max_arms = 32;
info.max_spans = 8;
info.max_arrays = MEGASAS_MAX_ARRAYS;
info.max_lds = s->fw_luns;
info.max_cmds = cpu_to_le16(s->fw_cmds);
info.max_sg_elements = cpu_to_le16(s->fw_sge);
info.max_request_size = cpu_to_le32(MEGASAS_MAX_SECTORS);
info.lds_present = cpu_to_le16(num_ld_disks);
info.pd_present = cpu_to_le16(num_ld_disks);
info.pd_disks_present = cpu_to_le16(num_ld_disks);
info.hw_present = cpu_to_le32(MFI_INFO_HW_NVRAM |
MFI_INFO_HW_MEM |
MFI_INFO_HW_FLASH);
info.memory_size = cpu_to_le16(512);
info.nvram_size = cpu_to_le16(32);
info.flash_size = cpu_to_le16(16);
info.raid_levels = cpu_to_le32(MFI_INFO_RAID_0);
info.adapter_ops = cpu_to_le32(MFI_INFO_AOPS_RBLD_RATE |
MFI_INFO_AOPS_SELF_DIAGNOSTIC |
MFI_INFO_AOPS_MIXED_ARRAY);
info.ld_ops = cpu_to_le32(MFI_INFO_LDOPS_DISK_CACHE_POLICY |
MFI_INFO_LDOPS_ACCESS_POLICY |
MFI_INFO_LDOPS_IO_POLICY |
MFI_INFO_LDOPS_WRITE_POLICY |
MFI_INFO_LDOPS_READ_POLICY);
info.max_strips_per_io = cpu_to_le16(s->fw_sge);
info.stripe_sz_ops.min = 3;
info.stripe_sz_ops.max = ffs(MEGASAS_MAX_SECTORS + 1) - 1;
info.properties.pred_fail_poll_interval = cpu_to_le16(300);
info.properties.intr_throttle_cnt = cpu_to_le16(16);
info.properties.intr_throttle_timeout = cpu_to_le16(50);
info.properties.rebuild_rate = 30;
info.properties.patrol_read_rate = 30;
info.properties.bgi_rate = 30;
info.properties.cc_rate = 30;
info.properties.recon_rate = 30;
info.properties.cache_flush_interval = 4;
info.properties.spinup_drv_cnt = 2;
info.properties.spinup_delay = 6;
info.properties.ecc_bucket_size = 15;
info.properties.ecc_bucket_leak_rate = cpu_to_le16(1440);
info.properties.expose_encl_devices = 1;
info.properties.OnOffProperties = cpu_to_le32(MFI_CTRL_PROP_EnableJBOD);
info.pd_ops = cpu_to_le32(MFI_INFO_PDOPS_FORCE_ONLINE |
MFI_INFO_PDOPS_FORCE_OFFLINE);
info.pd_mix_support = cpu_to_le32(MFI_INFO_PDMIX_SAS |
MFI_INFO_PDMIX_SATA |
MFI_INFO_PDMIX_LD);
cmd->iov_size -= dma_buf_read((uint8_t *)&info, dcmd_size, &cmd->qsg);
return MFI_STAT_OK;
}
| 1threat
|
In Xcode/SWIFT - how to store various types of data each day? : I want to store in CoreData various information each day as following:
day1: string, integer, integer, double, Boolean
day2: string, integer, integer, double, Boolean
day3: ....
up to several months.
I plan to do save it in CoreData due to the amount and type of information but I cannot find the best way to do it. I was thinking to use an Array but as it cannot contain various types what is the best way to do it?
Typically the user will enter such information every day, selecting the actual day on the interface and entering all his inputs.
| 0debug
|
How I redirect dynamic url with query string in php? : <p>I need to redirect dynamic URL like this "<a href="https://test.com?user=abc@gmail.com" rel="nofollow">https://test.com?user=abc@gmail.com</a>" to "<a href="https://test.com" rel="nofollow">https://test.com</a>" </p>
| 0debug
|
Issue regarding designing UI : I am having problem designing below UI.
[text1] [inputBox1]
[text2] [inputBox2]
[text3] [inputBox3]
text1, text2, text3 can be variable length. So if length of text increases, there width should increases and input box moves towards right. If text is much longer, than text wrapping should happen. Someone suggested me I should use flexbox. But I have no idea how to start with it. Can somebody please help me with it ?
Basic structure
<div>
<div>text1</div>
<div>inputBox1</div>
<div>text2</div>
<div>inputBox2</div>
<div>text3</div>
<div>inputBox3</div>
.
.
.
.
</div>
| 0debug
|
static void vhost_virtqueue_stop(struct vhost_dev *dev,
struct VirtIODevice *vdev,
struct vhost_virtqueue *vq,
unsigned idx)
{
int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx);
struct vhost_vring_state state = {
.index = vhost_vq_index,
};
int r;
r = dev->vhost_ops->vhost_get_vring_base(dev, &state);
if (r < 0) {
fprintf(stderr, "vhost VQ %d ring restore failed: %d\n", idx, r);
fflush(stderr);
}
virtio_queue_set_last_avail_idx(vdev, idx, state.num);
virtio_queue_invalidate_signalled_used(vdev, idx);
if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) &&
vhost_needs_vring_endian(vdev)) {
r = vhost_virtqueue_set_vring_endian_legacy(dev,
!virtio_is_big_endian(vdev),
vhost_vq_index);
if (r < 0) {
error_report("failed to reset vring endianness");
}
}
assert (r >= 0);
cpu_physical_memory_unmap(vq->ring, virtio_queue_get_ring_size(vdev, idx),
0, virtio_queue_get_ring_size(vdev, idx));
cpu_physical_memory_unmap(vq->used, virtio_queue_get_used_size(vdev, idx),
1, virtio_queue_get_used_size(vdev, idx));
cpu_physical_memory_unmap(vq->avail, virtio_queue_get_avail_size(vdev, idx),
0, virtio_queue_get_avail_size(vdev, idx));
cpu_physical_memory_unmap(vq->desc, virtio_queue_get_desc_size(vdev, idx),
0, virtio_queue_get_desc_size(vdev, idx));
}
| 1threat
|
START_TEST(vararg_number)
{
QObject *obj;
QInt *qint;
QFloat *qfloat;
int value = 0x2342;
int64_t value64 = 0x2342342343LL;
double valuef = 2.323423423;
obj = qobject_from_jsonf("%d", value);
fail_unless(obj != NULL);
fail_unless(qobject_type(obj) == QTYPE_QINT);
qint = qobject_to_qint(obj);
fail_unless(qint_get_int(qint) == value);
QDECREF(qint);
obj = qobject_from_jsonf("%" PRId64, value64);
fail_unless(obj != NULL);
fail_unless(qobject_type(obj) == QTYPE_QINT);
qint = qobject_to_qint(obj);
fail_unless(qint_get_int(qint) == value64);
QDECREF(qint);
obj = qobject_from_jsonf("%f", valuef);
fail_unless(obj != NULL);
fail_unless(qobject_type(obj) == QTYPE_QFLOAT);
qfloat = qobject_to_qfloat(obj);
fail_unless(qfloat_get_double(qfloat) == valuef);
QDECREF(qfloat);
}
| 1threat
|
PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq *pic)
{
DeviceState *dev;
PCIBus *b;
PCIDevice *d;
I440FXState *s;
PIIX3State *piix3;
dev = qdev_create(NULL, "i440FX-pcihost");
s = FROM_SYSBUS(I440FXState, sysbus_from_qdev(dev));
b = pci_bus_new(&s->busdev.qdev, NULL, 0);
s->bus = b;
qdev_init(dev);
d = pci_create_simple(b, 0, "i440FX");
*pi440fx_state = DO_UPCAST(PCII440FXState, dev, d);
piix3 = DO_UPCAST(PIIX3State, dev,
pci_create_simple(b, -1, "PIIX3"));
piix3->pic = pic;
pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3, 4);
(*pi440fx_state)->piix3 = piix3;
*piix3_devfn = piix3->dev.devfn;
return b;
}
| 1threat
|
static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
struct in_addr my_ip)
{
AVFormatContext *avc;
AVStream avs[MAX_STREAMS];
int i;
avc = avformat_alloc_context();
if (avc == NULL) {
return -1;
}
av_metadata_set2(&avc->metadata, "title",
stream->title[0] ? stream->title : "No Title", 0);
avc->nb_streams = stream->nb_streams;
if (stream->is_multicast) {
snprintf(avc->filename, 1024, "rtp:
inet_ntoa(stream->multicast_ip),
stream->multicast_port, stream->multicast_ttl);
} else {
snprintf(avc->filename, 1024, "rtp:
}
for(i = 0; i < stream->nb_streams; i++) {
avc->streams[i] = &avs[i];
avc->streams[i]->codec = stream->streams[i]->codec;
}
*pbuffer = av_mallocz(2048);
avf_sdp_create(&avc, 1, *pbuffer, 2048);
av_free(avc);
return strlen(*pbuffer);
}
| 1threat
|
void bdrv_set_read_only(BlockDriverState *bs, bool read_only)
{
bs->read_only = read_only;
}
| 1threat
|
Changing assigned user in sql using SelectOneMenu primeface : I have been searching for similar issue but I could not find any.
so here is the thing
I am trying to create a web application that deals with HR stuff, like employee requests (Resign, loan, vacation, etc..)
I am using primeface and I have the following problem that I cant figure out.
The thing is I am trying to do is :
1- When user first creates the request and assigns the user and submit the form
the next step is
2- the manager would sees the request and then change the "Person responsible for the request" to a new one using the drop menu in the datatable and I have been trying to solve this problem with no luck.
Here is the dialog script
<h:form id='resignf'>
<p:dialog id='res' header="Resign Request" widgetVar="resign" minHeight="40">
<p:outputLabel value="Employee name" />
<p:inputText value="#{controller.resignName}" required="true" requiredMessage="This field is required" />
<p:outputLabel value="Employee Number" />
<p:inputText value="#{controller.resignEmployeNum}" required="true" />
<p:inputText value{controller.resignNationalIDNum}" required="true" />
<p:inputText value="#{controller.resignNotes}" required="true" />
<p:outputLabel for="AssignUser" value="User" />
<p:selectOneMenu id="AssignUser" value="#{controller.assignUser}" style="width:150px" converter="UConverter">
<f:selectItems value="#{controller.usersList}" var="user" itemLabel="#{user.username}"/>
</p:selectOneMenu >
<p:commandButton action="#{controller.createResignRequest()}" onclick="PF('resign').hide();" update="@all"/>
</p:panelGrid>
</p:dialog>
And the code is my `controller.java` file below to create the request in the table
/* Request to resign*/
private List<ResignationRequest> resignList;
private ResignationRequestController rController = new ResignationRequestController();
private String resignName;
private String resignEmployeNum;
private String resignNationalIDNum;
private String ResignNotes;
private int AutoAssignToIDNUM;
/* end of request to resign*/
public void createResignRequest() {
System.out.println("createResignRequest");
ResignationRequest newResign = new ResignationRequest();
newResign.setName(resignName);
newResign.setEmployeeNum(resignEmployeNum);
newResign.setNationalID(resignNationalIDNum);
newResign.setNotes(ResignNotes);
newResign.setUserID(AssignUser);
rController.create(newResign);
resignList = rController.findResignationRequestEntities(); //retrieves all the resigns from the database
}
Now all that is working perfectly, but when I try to change the old user with the new one here I get confused! so far what I have been thinking is I need to find the old user and then switch him, but I could not figure a way to do it using the select list. The script for for changing the "User responsible for the request" below
<p:dataTable id="resignTable1" cellSeparator="true" editMode="cell" editable="true" var="resign" value="#{controller.resignList}" paginator="true" rows="10" rowIndexVar="index1">
<p:ajax id="aj" event="cellEdit" listener="#{controller.editUser(user)}" update="resignTable1"/>
<p:column headerText="Employee number">
<p:cellEditor>
<f:facet name="output"> <h:outputText value="#{resign.employeeNum}" /></f:facet>
<f:facet name="input"> <h:inputText value="#{resign.employeeNum}" /></f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="name">
<p:cellEditor>
<f:facet name="output"> <h:outputText value="#{resign.name}" /></f:facet>
<f:facet name="input"> <h:inputText value="#{resign.name}" /></f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Request Number">
<p:cellEditor>
<f:facet name="output"> <h:outputText value="#{resign.id}" /></f:facet>
<f:facet name="input"> <h:inputText value="#{resign.id}" /></f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="User responsible for the request">
<p:cellEditor>
<f:facet name="output"> <h:outputText value="#{resign.userID}" /></f:facet>
<f:facet name="input"> <h:inputText value="#{resign.userID}" /></f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Comments">
<p:cellEditor>
<f:facet name="output"> <h:outputText value="#{resign.notes}" /></f:facet>
<f:facet name="input"> <h:inputText value="#{resign.notes}" /></f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Send the request to the next employee">
<p:selectOneMenu id="AssignUser" value="#{controller.assignUser}" style="width:150px" converter="UConverter" onchange="submit();">
<f:selectItems value="#{controller.usersList}" var="user" itemLabel="#{user.username}" actionListener="#{controller.editRequestStep(resign)}" >
</f:selectItems>
</p:selectOneMenu >
In my controller file
public void editRequestStep(ResignationRequest r) {
System.out.println("Edit resign");
try {
System.out.println("Edit resign");
rController.edit(r);
} catch (Exception ex) {
Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
}
}
I tried to get as much as I could from the code but I have a lot of stuff that I am not sure if I should submit. I tried ajax
NOTE: I am using mySQL, apache tomcat in case if it matters.
| 0debug
|
static av_cold int vp8_init(AVCodecContext *avctx)
{
VP8Context *ctx = avctx->priv_data;
const struct vpx_codec_iface *iface = &vpx_codec_vp8_cx_algo;
struct vpx_codec_enc_cfg enccfg;
int res;
av_log(avctx, AV_LOG_INFO, "%s\n", vpx_codec_version_str());
av_log(avctx, AV_LOG_VERBOSE, "%s\n", vpx_codec_build_config());
if ((res = vpx_codec_enc_config_default(iface, &enccfg, 0)) != VPX_CODEC_OK) {
av_log(avctx, AV_LOG_ERROR, "Failed to get config: %s\n",
vpx_codec_err_to_string(res));
return AVERROR(EINVAL);
}
dump_enc_cfg(avctx, &enccfg);
enccfg.g_w = avctx->width;
enccfg.g_h = avctx->height;
enccfg.g_timebase.num = avctx->time_base.num;
enccfg.g_timebase.den = avctx->time_base.den;
enccfg.g_threads = avctx->thread_count;
enccfg.g_lag_in_frames= ctx->lag_in_frames;
if (avctx->flags & CODEC_FLAG_PASS1)
enccfg.g_pass = VPX_RC_FIRST_PASS;
else if (avctx->flags & CODEC_FLAG_PASS2)
enccfg.g_pass = VPX_RC_LAST_PASS;
else
enccfg.g_pass = VPX_RC_ONE_PASS;
if (avctx->rc_min_rate == avctx->rc_max_rate &&
avctx->rc_min_rate == avctx->bit_rate)
enccfg.rc_end_usage = VPX_CBR;
else if (ctx->crf)
enccfg.rc_end_usage = VPX_CQ;
enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
AV_ROUND_NEAR_INF);
if (avctx->qmin > 0)
enccfg.rc_min_quantizer = avctx->qmin;
if (avctx->qmax > 0)
enccfg.rc_max_quantizer = avctx->qmax;
enccfg.rc_dropframe_thresh = avctx->frame_skip_threshold;
enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100);
enccfg.rc_2pass_vbr_minsection_pct =
avctx->rc_min_rate * 100LL / avctx->bit_rate;
if (avctx->rc_max_rate)
enccfg.rc_2pass_vbr_maxsection_pct =
avctx->rc_max_rate * 100LL / avctx->bit_rate;
if (avctx->rc_buffer_size)
enccfg.rc_buf_sz =
avctx->rc_buffer_size * 1000LL / avctx->bit_rate;
if (avctx->rc_initial_buffer_occupancy)
enccfg.rc_buf_initial_sz =
avctx->rc_initial_buffer_occupancy * 1000LL / avctx->bit_rate;
enccfg.rc_buf_optimal_sz = enccfg.rc_buf_sz * 5 / 6;
enccfg.rc_undershoot_pct = round(avctx->rc_buffer_aggressivity * 100);
if (avctx->keyint_min >= 0 && avctx->keyint_min == avctx->gop_size)
enccfg.kf_min_dist = avctx->keyint_min;
if (avctx->gop_size >= 0)
enccfg.kf_max_dist = avctx->gop_size;
if (enccfg.g_pass == VPX_RC_FIRST_PASS)
enccfg.g_lag_in_frames = 0;
else if (enccfg.g_pass == VPX_RC_LAST_PASS) {
int decode_size;
if (!avctx->stats_in) {
av_log(avctx, AV_LOG_ERROR, "No stats file for second pass\n");
return AVERROR_INVALIDDATA;
}
ctx->twopass_stats.sz = strlen(avctx->stats_in) * 3 / 4;
ctx->twopass_stats.buf = av_malloc(ctx->twopass_stats.sz);
if (!ctx->twopass_stats.buf) {
av_log(avctx, AV_LOG_ERROR,
"Stat buffer alloc (%zu bytes) failed\n",
ctx->twopass_stats.sz);
return AVERROR(ENOMEM);
}
decode_size = av_base64_decode(ctx->twopass_stats.buf, avctx->stats_in,
ctx->twopass_stats.sz);
if (decode_size < 0) {
av_log(avctx, AV_LOG_ERROR, "Stat buffer decode failed\n");
return AVERROR_INVALIDDATA;
}
ctx->twopass_stats.sz = decode_size;
enccfg.rc_twopass_stats_in = ctx->twopass_stats;
}
if (avctx->profile != FF_PROFILE_UNKNOWN)
enccfg.g_profile = avctx->profile;
enccfg.g_error_resilient = ctx->error_resilient || ctx->flags & VP8F_ERROR_RESILIENT;
dump_enc_cfg(avctx, &enccfg);
res = vpx_codec_enc_init(&ctx->encoder, iface, &enccfg, 0);
if (res != VPX_CODEC_OK) {
log_encoder_error(avctx, "Failed to initialize encoder");
return AVERROR(EINVAL);
}
av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n");
if (ctx->cpu_used != INT_MIN)
codecctl_int(avctx, VP8E_SET_CPUUSED, ctx->cpu_used);
if (ctx->flags & VP8F_AUTO_ALT_REF)
ctx->auto_alt_ref = 1;
if (ctx->auto_alt_ref >= 0)
codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
if (ctx->arnr_max_frames >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames);
if (ctx->arnr_strength >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_STRENGTH, ctx->arnr_strength);
if (ctx->arnr_type >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_TYPE, ctx->arnr_type);
codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices));
codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx->mb_threshold);
codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx->crf);
if (ctx->max_intra_rate >= 0)
codecctl_int(avctx, VP8E_SET_MAX_INTRA_BITRATE_PCT, ctx->max_intra_rate);
av_log(avctx, AV_LOG_DEBUG, "Using deadline: %d\n", ctx->deadline);
vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1,
(unsigned char*)1);
avctx->coded_frame = avcodec_alloc_frame();
if (!avctx->coded_frame) {
av_log(avctx, AV_LOG_ERROR, "Error allocating coded frame\n");
vp8_free(avctx);
return AVERROR(ENOMEM);
}
return 0;
}
| 1threat
|
How to switch class for div using js? : <p>I've done this using jquery, but can't do it with js.</p>
<p>Look at my code: </p>
<p>https:// jsfiddle. net/88pd6zj0/</p>
<p>It's working only with first class = "html", but not working with another.
I've tried change "querySelector" on "querySelectorAll" - and it's working no one class.</p>
<p>How to fix this problem?
Thank you.</p>
| 0debug
|
static void encode_quant_matrix(VC2EncContext *s)
{
int level, custom_quant_matrix = 0;
if (s->wavelet_depth > 4 || s->quant_matrix != VC2_QM_DEF)
custom_quant_matrix = 1;
put_bits(&s->pb, 1, custom_quant_matrix);
if (custom_quant_matrix) {
init_custom_qm(s);
put_vc2_ue_uint(&s->pb, s->quant[0][0]);
for (level = 0; level < s->wavelet_depth; level++) {
put_vc2_ue_uint(&s->pb, s->quant[level][1]);
put_vc2_ue_uint(&s->pb, s->quant[level][2]);
put_vc2_ue_uint(&s->pb, s->quant[level][3]);
}
} else {
for (level = 0; level < s->wavelet_depth; level++) {
s->quant[level][0] = ff_dirac_default_qmat[s->wavelet_idx][level][0];
s->quant[level][1] = ff_dirac_default_qmat[s->wavelet_idx][level][1];
s->quant[level][2] = ff_dirac_default_qmat[s->wavelet_idx][level][2];
s->quant[level][3] = ff_dirac_default_qmat[s->wavelet_idx][level][3];
}
}
}
| 1threat
|
How to detect if App has gone in or out of App Standyby Mode ( Android M+) : <p>If the device is in DOZE IDLE or IDLE_MAINTENANCE mode, these events can be received if we register a broadcast receiver for "<strong>android.os.action.DEVICE_IDLE_MODE_CHANGED</strong>". But this receiver is not working when making App to go into <strong>App Standby</strong> using adb commands. Is is possible that we can programmatically check whether the app has gone in or exited from the App Standby mode for devices running on Marshmallow and above?</p>
<p>adb commands used to make App go into App Standby</p>
<pre><code>adb shell dumpsys battery unplug
adb shell am set-inactive {Package name} true
</code></pre>
<p>and to exit</p>
<pre><code>adb shell am set-inactive {Package name} false
</code></pre>
| 0debug
|
static int quantize(CinepakEncContext *s, int h, AVPicture *pict, int v1mode, int size, int v4, strip_info *info)
{
int x, y, i, j, k, x2, y2, x3, y3, plane, shift;
int entry_size = s->pix_fmt == AV_PIX_FMT_YUV420P ? 6 : 4;
int *codebook = v1mode ? info->v1_codebook : info->v4_codebook;
int64_t total_error = 0;
uint8_t vq_pict_buf[(MB_AREA*3)/2];
AVPicture sub_pict, vq_pict;
for(i = y = 0; y < h; y += MB_SIZE) {
for(x = 0; x < s->w; x += MB_SIZE, i += v1mode ? 1 : 4) {
int *base = s->codebook_input + i*entry_size;
if(v1mode) {
for(j = y2 = 0; y2 < entry_size; y2 += 2) {
for(x2 = 0; x2 < 4; x2 += 2, j++) {
plane = y2 < 4 ? 0 : 1 + (x2 >> 1);
shift = y2 < 4 ? 0 : 1;
x3 = shift ? 0 : x2;
y3 = shift ? 0 : y2;
base[j] = (pict->data[plane][((x+x3) >> shift) + ((y+y3) >> shift) * pict->linesize[plane]] +
pict->data[plane][((x+x3) >> shift) + 1 + ((y+y3) >> shift) * pict->linesize[plane]] +
pict->data[plane][((x+x3) >> shift) + (((y+y3) >> shift) + 1) * pict->linesize[plane]] +
pict->data[plane][((x+x3) >> shift) + 1 + (((y+y3) >> shift) + 1) * pict->linesize[plane]]) >> 2;
}
}
} else {
for(j = y2 = 0; y2 < MB_SIZE; y2 += 2) {
for(x2 = 0; x2 < MB_SIZE; x2 += 2) {
for(k = 0; k < entry_size; k++, j++) {
plane = k >= 4 ? k - 3 : 0;
if(k >= 4) {
x3 = (x+x2) >> 1;
y3 = (y+y2) >> 1;
} else {
x3 = x + x2 + (k & 1);
y3 = y + y2 + (k >> 1);
}
base[j] = pict->data[plane][x3 + y3*pict->linesize[plane]];
}
}
}
}
}
}
ff_init_elbg(s->codebook_input, entry_size, i, codebook, size, 1, s->codebook_closest, &s->randctx);
ff_do_elbg(s->codebook_input, entry_size, i, codebook, size, 1, s->codebook_closest, &s->randctx);
vq_pict.data[0] = vq_pict_buf;
vq_pict.linesize[0] = MB_SIZE;
vq_pict.data[1] = &vq_pict_buf[MB_AREA];
vq_pict.data[2] = vq_pict.data[1] + (MB_AREA >> 2);
vq_pict.linesize[1] = vq_pict.linesize[2] = MB_SIZE >> 1;
indices
for(i = j = y = 0; y < h; y += MB_SIZE) {
for(x = 0; x < s->w; x += MB_SIZE, j++, i += v1mode ? 1 : 4) {
mb_info *mb = &s->mb[j];
get_sub_picture(s, x, y, pict, &sub_pict);
if(v1mode) {
mb->v1_vector = s->codebook_closest[i];
decode_v1_vector(s, &vq_pict, mb, info);
mb->v1_error = compute_mb_distortion(s, &sub_pict, &vq_pict);
total_error += mb->v1_error;
} else {
for(k = 0; k < 4; k++)
mb->v4_vector[v4][k] = s->codebook_closest[i+k];
decode_v4_vector(s, &vq_pict, mb->v4_vector[v4], info);
mb->v4_error[v4] = compute_mb_distortion(s, &sub_pict, &vq_pict);
total_error += mb->v4_error[v4];
}
}
}
return 0;
}
| 1threat
|
static int mmap_init(AVFormatContext *ctx)
{
int i, res;
struct video_data *s = ctx->priv_data;
struct v4l2_requestbuffers req = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.count = desired_video_buffers,
.memory = V4L2_MEMORY_MMAP
};
res = ioctl(s->fd, VIDIOC_REQBUFS, &req);
if (res < 0) {
if (errno == EINVAL) {
av_log(ctx, AV_LOG_ERROR, "Device does not support mmap\n");
} else {
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_REQBUFS)\n");
}
return AVERROR(errno);
}
if (req.count < 2) {
av_log(ctx, AV_LOG_ERROR, "Insufficient buffer memory\n");
return AVERROR(ENOMEM);
}
s->buffers = req.count;
s->buf_start = av_malloc(sizeof(void *) * s->buffers);
if (s->buf_start == NULL) {
av_log(ctx, AV_LOG_ERROR, "Cannot allocate buffer pointers\n");
return AVERROR(ENOMEM);
}
s->buf_len = av_malloc(sizeof(unsigned int) * s->buffers);
if (s->buf_len == NULL) {
av_log(ctx, AV_LOG_ERROR, "Cannot allocate buffer sizes\n");
av_free(s->buf_start);
return AVERROR(ENOMEM);
}
for (i = 0; i < req.count; i++) {
struct v4l2_buffer buf = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.index = i,
.memory = V4L2_MEMORY_MMAP
};
res = ioctl(s->fd, VIDIOC_QUERYBUF, &buf);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYBUF)\n");
return AVERROR(errno);
}
s->buf_len[i] = buf.length;
if (s->frame_size > 0 && s->buf_len[i] < s->frame_size) {
av_log(ctx, AV_LOG_ERROR,
"Buffer len [%d] = %d != %d\n",
i, s->buf_len[i], s->frame_size);
return -1;
}
s->buf_start[i] = mmap(NULL, buf.length,
PROT_READ | PROT_WRITE, MAP_SHARED,
s->fd, buf.m.offset);
if (s->buf_start[i] == MAP_FAILED) {
av_log(ctx, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
return AVERROR(errno);
}
}
return 0;
}
| 1threat
|
NodeJs Express send 403 and render : <p>How can I send a error 403 and render a page with 'you have no rights to visited this page' message?</p>
<p>I have now this: </p>
<pre><code>res.send(403,"You do not have rights to visit this page");
</code></pre>
<p>but I want to render a HTML page instead a basic text</p>
<pre><code>res.render('no-rights', {title: 'You have no rights to visit this page', text: 'You are not allowed to visited this page. Maybe you are not logged in?'});
</code></pre>
<p>with a 403 status. </p>
| 0debug
|
In Java How to convert a numeric string to a Char : I have to convert a numeric string into an asc ii char. The charAt method does not work here.
I have a string string c =4;
How do i convert it to its sac ii char.
| 0debug
|
How can i replace an empty line with a specific text using bash script? : <p>Hi I am having a text file . the file has some lines without text . I would like to replace these lines with some specific text .</p>
<p>log.txt </p>
<pre><code>{"id":0,"manufacturer":"cheverlot","model":"AC 3000ME 1002","description":"Culpa exercitation nulla amet excepteur amet sint voluptate elit consectetur. Sit eiusmod velit occaecat consequat pariatur mollit cupidatat ad velit ipsum reprehenderit ea labore aliquip. Nostrud ullamco minim nulla in ea nulla nisi Lorem laboris aute.\r\n","date":"3202-07-20T12:29:26 -01:00"}
{"id":1,"manufacturer":"Bugati","model":"AC 3000ME 1003","description":"Eiusmod magna laborum nulla labore esse. Qui velit nulla eiusmod excepteur anim veniam cupidatat proident incididunt proident non laborum irure aliqua. Magna exercitation eiusmod ad mollit pariatur commodo. Deserunt mollit Lorem do laboris pariatur reprehenderit consequat consectetur excepteur nostrud.\r\n","date":"11925-03-15T05:54:00 -00:00"}
{"id":2,"manufacturer":"Bugati","model":"AC 3000ME 1001","description":"Commodo cupidatat laborum aliquip mollit irure reprehenderit ipsum cillum officia labore Lorem aliqua reprehenderit. Lorem ad consectetur anim aute non tempor magna aliquip elit minim. Et laboris tempor velit non. Commodo amet laborum pariatur id et Lorem consectetur elit cupidatat aute eu proident quis nostrud. Do laboris ipsum officia pariatur deserunt ullamco qui. Eu tempor irure consectetur officia adipisicing cupidatat laboris non consectetur ad laboris commodo deserunt tempor.\r\n","date":"7679-11-22T08:16:34 -00:00"}
{"id":3,"manufacturer":"cheverlot","model":"AC 3000ME 1001","description":"Deserunt occaecat laboris laborum cupidatat nisi reprehenderit aute aute culpa. Sunt consequat fugiat dolor dolore dolor sint. Exercitation sunt adipisicing nostrud culpa non consequat anim est excepteur deserunt et excepteur. Minim eu cupidatat adipisicing quis occaecat deserunt magna ea.\r\n","date":"3959-09-20T09:24:42 -01:00"}
{"id":4,"manufacturer":"Audi","model":"AC 3000ME 1003","description":"Magna commodo fugiat ea consequat incididunt. Adipisicing commodo duis consequat officia esse et ea excepteur exercitation anim laboris dolor ad. Officia magna incididunt irure sit et minim adipisicing aliquip officia magna Lorem qui veniam quis. Lorem elit et deserunt exercitation nisi sit non aliqua officia veniam consequat. Non ut fugiat nisi nulla exercitation nostrud. Ut culpa reprehenderit mollit commodo officia irure labore fugiat cillum tempor esse aliqua est ipsum.\r\n","date":"8024-05-26T04:22:34 -01:00"}
</code></pre>
<p>Expected result</p>
<pre><code>{"index":{}}
{"id":0,"manufacturer":"cheverlot","model":"AC 3000ME 1002","description":"Culpa exercitation nulla amet excepteur amet sint voluptate elit consectetur. Sit eiusmod velit occaecat consequat pariatur mollit cupidatat ad velit ipsum reprehenderit ea labore aliquip. Nostrud ullamco minim nulla in ea nulla nisi Lorem laboris aute.\r\n","date":"3202-07-20T12:29:26 -01:00"}
{"index":{}}
{"id":1,"manufacturer":"Bugati","model":"AC 3000ME 1003","description":"Eiusmod magna laborum nulla labore esse. Qui velit nulla eiusmod excepteur anim veniam cupidatat proident incididunt proident non laborum irure aliqua. Magna exercitation eiusmod ad mollit pariatur commodo. Deserunt mollit Lorem do laboris pariatur reprehenderit consequat consectetur excepteur nostrud.\r\n","date":"11925-03-15T05:54:00 -00:00"}
{"index":{}}
{"id":2,"manufacturer":"Bugati","model":"AC 3000ME 1001","description":"Commodo cupidatat laborum aliquip mollit irure reprehenderit ipsum cillum officia labore Lorem aliqua reprehenderit. Lorem ad consectetur anim aute non tempor magna aliquip elit minim. Et laboris tempor velit non. Commodo amet laborum pariatur id et Lorem consectetur elit cupidatat aute eu proident quis nostrud. Do laboris ipsum officia pariatur deserunt ullamco qui. Eu tempor irure consectetur officia adipisicing cupidatat laboris non consectetur ad laboris commodo deserunt tempor.\r\n","date":"7679-11-22T08:16:34 -00:00"}
{"index":{}}
{"id":3,"manufacturer":"cheverlot","model":"AC 3000ME 1001","description":"Deserunt occaecat laboris laborum cupidatat nisi reprehenderit aute aute culpa. Sunt consequat fugiat dolor dolore dolor sint. Exercitation sunt adipisicing nostrud culpa non consequat anim est excepteur deserunt et excepteur. Minim eu cupidatat adipisicing quis occaecat deserunt magna ea.\r\n","date":"3959-09-20T09:24:42 -01:00"}
{"index":{}}
{"id":4,"manufacturer":"Audi","model":"AC 3000ME 1003","description":"Magna commodo fugiat ea consequat incididunt. Adipisicing commodo duis consequat officia esse et ea excepteur exercitation anim laboris dolor ad. Officia magna incididunt irure sit et minim adipisicing aliquip officia magna Lorem qui veniam quis. Lorem elit et deserunt exercitation nisi sit non aliqua officia veniam consequat. Non ut fugiat nisi nulla exercitation nostrud. Ut culpa reprehenderit mollit commodo officia irure labore fugiat cillum tempor esse aliqua est ipsum.\r\n","date":"8024-05-26T04:22:34 -01:00"}
</code></pre>
<p>so in short i want to replace those blank lines with this text {"index":{}}</p>
<p>any idea how can i do it in shell script .
thank you </p>
| 0debug
|
Hi i have my code which gives me an out out but it will not graph ,here is the code (Matlab) : Hey i have written this code and it will not plot , I run it with a 0:.5:100 and get a blank graph in matlab. as well this is a inclined plane friction problem. I need to create an animation in matlab that shows the blocks sliding based on inputs . i don't even know how to bigin
Thanks as always you guys rock
%Numerical Project Code 1
%mass ratio input
mratio = input('Enter the Mass Ratio(m/M): ');
%angle input
theta = input('Enter Angle in Degrees Between 0 and 90: ');
%static coeff input
mus = input('Enter Coefficient of Static Friction: ');
%kinetic coeff input
muk = input('Enter Coefficient of Kinetic Friction: ');
%constants
g = 9.81;
%interface formating
disp('--------------------------------------------');
disp('All Friction Forces are given in terms of the mass on the slope (M)');
%Loops
%NETUP
if mratio > sind(theta)
%static only
if mratio <= (sind(theta) + (mus*cosd(theta)))
ff = g*(mratio - sind(theta));
fprintf("Friction Force = %f M Newtons\n",ff);
fprintf("The Direction of the Friction Force is down the slope and the block not moving.\n")
%kinetic only
else
ff = muk * g * cosd(theta);
fprintf("Friction Force = %f M Newtons\n",ff);
fprintf("The Direction of the Friction Force is down the slope and the block is sliding up the slope.\n");
end
%NETDOWN
elseif mratio < sind(theta)
%static only
if sind(theta) <= (mratio + (mus*cosd(theta)))
ff = g*(sind(theta) - mratio);
fprintf("Friciton Force = %f M Newtons\n",ff);
fprintf("The Direction of the Friction Force is up the slope and the block is not moving.\n")
%kinetic only
else
ff = muk * g * cosd(theta);
fprintf("Friction Force = %f M Newtons\n",ff);
fprintf("The Direction of the Friction Force is up the slope and the block is sliding down the slope.\n");
end
%NETZERO
else
fprintf("Friction Force = 0 Newtons\n");
end
%graph
for i = 0:0.01:1
mratiog = i;
if mratiog > sind(theta)
if mratiog <= (sind(theta) + (mus*cosd(theta)))
ffg = g*(mratiog - sind(theta));
else
ffg = muk * g * cosd(theta);
end
elseif mratiog < sind(theta)
if sind(theta) <= (mratiog + (mus*cosd(theta)))
ffg = g*(sind(theta) - mratiog);
else
ffg = muk * g * cosd(theta);
end
else
ffg = 0;
end
plot (ffg,mratio, 'r:')
end
| 0debug
|
is there any package to extract particular keyword in python : I have comments like "the product name with ch12345 and tp12345 " there are so many comments like this. my query is to extract keywords starts with ch and tp followed by two or three-digit number.
| 0debug
|
React, why use super(props) inside of ES6 class constructor? : <p>I realize the super keyword can be used to call functions in a parent component. However, I'm not totally clear why you would use the super keyword in the example below - just passing it whatever props are being passed to the constructor. </p>
<p>Can someone please shed some light on the various reasons for using the super keyword in an ES6 class constructor, in react?</p>
<pre><code> constructor(props) {
super(props);
this.state = {
course: Object.assign({}, this.props.course),
errors: { }
};
this.updateCourseState = this.updateCourseState.bind(this);
}
</code></pre>
| 0debug
|
Remove a named volume with docker-compose? : <p>If I have a docker-compose file like:</p>
<pre><code>version: "3"
services:
postgres:
image: postgres:9.4
volumes:
- db-data:/var/lib/db
volumes:
db-data:
</code></pre>
<p>... then doing <code>docker-compose up</code> creates a named volume for <code>db-data</code>. Is there a way to remove this volume via <code>docker-compose</code>? If it were an anonymous volume, then <code>docker-compose rm -v postgres</code> would do the trick. But as it stands, I don't know how to remove the <code>db-data</code> volume without reverting to <code>docker</code> commands. It feels like this should be possible from within the <code>docker-compose</code> CLI. Am I missing something?</p>
| 0debug
|
static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pic_arg, int *got_packet)
{
MpegEncContext *s = avctx->priv_data;
AVFrame *pic;
int i, ret;
int chroma_h_shift, chroma_v_shift;
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);
if(s->avctx->flags & CODEC_FLAG_EMU_EDGE)
return AVERROR(EINVAL);
pic = av_frame_alloc();
if (!pic)
return AVERROR(ENOMEM);
av_frame_ref(pic, pic_arg);
for(i=0; i < 3; i++) {
int vsample = i ? 2 >> chroma_v_shift : 2;
pic->data[i] += (pic->linesize[i] * (vsample * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));
pic->linesize[i] *= -1;
}
ret = ff_MPV_encode_picture(avctx, pkt, pic, got_packet);
av_frame_free(&pic);
return ret;
}
| 1threat
|
Xcode 11: Canvas does not show up : <p>I´m trying to get the new Canvas feature from Xcode 11 running, but the Canvas won´t show up. What am I doing wrong?</p>
<p>I just created a new default project (single view app), compiled it and activated 'Editor > Editor and Canvas'. I can navigate to each file in the project, nothing shows up.</p>
<p>What else does need to be done?</p>
| 0debug
|
static void vtd_handle_gcmd_qie(IntelIOMMUState *s, bool en)
{
uint64_t iqa_val = vtd_get_quad_raw(s, DMAR_IQA_REG);
trace_vtd_inv_qi_enable(en);
if (en) {
if (vtd_queued_inv_enable_check(s)) {
s->iq = iqa_val & VTD_IQA_IQA_MASK;
s->iq_size = 1UL << ((iqa_val & VTD_IQA_QS) + 8);
s->qi_enabled = true;
trace_vtd_inv_qi_setup(s->iq, s->iq_size);
vtd_set_clear_mask_long(s, DMAR_GSTS_REG, 0, VTD_GSTS_QIES);
} else {
trace_vtd_err_qi_enable(s->iq_tail);
}
} else {
if (vtd_queued_inv_disable_check(s)) {
vtd_set_quad_raw(s, DMAR_IQH_REG, 0);
s->iq_head = 0;
s->qi_enabled = false;
vtd_set_clear_mask_long(s, DMAR_GSTS_REG, VTD_GSTS_QIES, 0);
} else {
trace_vtd_err_qi_disable(s->iq_head, s->iq_tail, s->iq_last_desc_type);
}
}
}
| 1threat
|
How to make a regex? : I need to make a regex which matches with pattern like:-
1.data1,data2
2.data1
but not with data1&data2 or any other special character apart from ','.
I have tried few like flag_regex = new RegExp("[a-zA-Z0-9].*,.*[a-zA-Z0-9]*");
but its only matches with first pattern not the second one.
I am doing this in javascript.
| 0debug
|
Pyspark Joining dataframes with multiple rows on the second dataframe : I want to join a dataframe "df_1" with "df_2" on a column named "TrackID".
df_1: cluster TrackID
1 a_1
2 a_1
3 a_2
1 a_3
df_2: TrackID Value
a_1 5
a_1 6
a_2 7
a_2 8
a_3 9
Output:
cluster TrackID Value
1 a_1 Vector(5,6)
2 a_1 Vector(5,6)
3 a_2 Vector(6,7)
1 a_3 Vetor(8)
I want the output of the join to look like this. is there a way I can do this?
| 0debug
|
static int coroutine_fn blkreplay_co_pwrite_zeroes(BlockDriverState *bs,
int64_t offset, int count, BdrvRequestFlags flags)
{
uint64_t reqid = request_id++;
int ret = bdrv_co_pwrite_zeroes(bs->file->bs, offset, count, flags);
block_request_create(reqid, bs, qemu_coroutine_self());
qemu_coroutine_yield();
return ret;
}
| 1threat
|
static int mkv_write_chapters(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *pb = s->pb;
ebml_master chapters, editionentry;
AVRational scale = {1, 1E9};
int i, ret;
if (!s->nb_chapters || mkv->wrote_chapters)
return 0;
ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CHAPTERS, avio_tell(pb));
if (ret < 0) return ret;
chapters = start_ebml_master(pb, MATROSKA_ID_CHAPTERS , 0);
editionentry = start_ebml_master(pb, MATROSKA_ID_EDITIONENTRY, 0);
put_ebml_uint(pb, MATROSKA_ID_EDITIONFLAGDEFAULT, 1);
put_ebml_uint(pb, MATROSKA_ID_EDITIONFLAGHIDDEN , 0);
for (i = 0; i < s->nb_chapters; i++) {
ebml_master chapteratom, chapterdisplay;
AVChapter *c = s->chapters[i];
int chapterstart = av_rescale_q(c->start, c->time_base, scale);
int chapterend = av_rescale_q(c->end, c->time_base, scale);
AVDictionaryEntry *t = NULL;
if (chapterstart < 0 || chapterstart > chapterend)
return AVERROR_INVALIDDATA;
chapteratom = start_ebml_master(pb, MATROSKA_ID_CHAPTERATOM, 0);
put_ebml_uint(pb, MATROSKA_ID_CHAPTERUID, c->id + mkv->chapter_id_offset);
put_ebml_uint(pb, MATROSKA_ID_CHAPTERTIMESTART, chapterstart);
put_ebml_uint(pb, MATROSKA_ID_CHAPTERTIMEEND, chapterend);
put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGHIDDEN , 0);
put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGENABLED, 1);
if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
chapterdisplay = start_ebml_master(pb, MATROSKA_ID_CHAPTERDISPLAY, 0);
put_ebml_string(pb, MATROSKA_ID_CHAPSTRING, t->value);
put_ebml_string(pb, MATROSKA_ID_CHAPLANG , "und");
end_ebml_master(pb, chapterdisplay);
}
end_ebml_master(pb, chapteratom);
}
end_ebml_master(pb, editionentry);
end_ebml_master(pb, chapters);
mkv->wrote_chapters = 1;
return 0;
}
| 1threat
|
static int send_solid_rect(VncState *vs)
{
size_t bytes;
vnc_write_u8(vs, VNC_TIGHT_FILL << 4);
if (vs->tight_pixel24) {
tight_pack24(vs, vs->tight.buffer, 1, &vs->tight.offset);
bytes = 3;
} else {
bytes = vs->clientds.pf.bytes_per_pixel;
}
vnc_write(vs, vs->tight.buffer, bytes);
return 1;
}
| 1threat
|
save all the effect of a webpage forever : <p>Suppose i have a webpage having a button, and when i press the button it will create another button bellow that.Now i want to save the effect, that means when i will open the webpage again it will direct show the button bellow the button.
How can i store this effect in data base or in some other way?</p>
| 0debug
|
static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
AVIContext *avi = s->priv_data;
ByteIOContext *pb = &s->pb;
uint32_t tag, tag1, handler;
int codec_type, stream_index, frame_period, bit_rate, scale, rate;
unsigned int size, nb_frames;
int i, n;
AVStream *st;
AVIStream *ast;
int xan_video = 0;
if (get_riff(avi, pb) < 0)
return -1;
stream_index = -1;
codec_type = -1;
frame_period = 0;
for(;;) {
if (url_feof(pb))
goto fail;
tag = get_le32(pb);
size = get_le32(pb);
#ifdef DEBUG
print_tag("tag", tag, size);
#endif
switch(tag) {
case MKTAG('L', 'I', 'S', 'T'):
tag1 = get_le32(pb);
#ifdef DEBUG
print_tag("list", tag1, 0);
#endif
if (tag1 == MKTAG('m', 'o', 'v', 'i')) {
avi->movi_list = url_ftell(pb) - 4;
if(size) avi->movi_end = avi->movi_list + size;
else avi->movi_end = url_filesize(url_fileno(pb));
#ifdef DEBUG
printf("movi end=%Lx\n", avi->movi_end);
#endif
goto end_of_header;
}
break;
case MKTAG('d', 'm', 'l', 'h'):
avi->is_odml = 1;
url_fskip(pb, size + (size & 1));
break;
case MKTAG('a', 'v', 'i', 'h'):
frame_period = get_le32(pb);
bit_rate = get_le32(pb) * 8;
url_fskip(pb, 4 * 4);
n = get_le32(pb);
for(i=0;i<n;i++) {
AVIStream *ast;
st = av_new_stream(s, i);
if (!st)
goto fail;
ast = av_mallocz(sizeof(AVIStream));
if (!ast)
goto fail;
st->priv_data = ast;
}
url_fskip(pb, size - 7 * 4);
break;
case MKTAG('s', 't', 'r', 'h'):
stream_index++;
tag1 = get_le32(pb);
handler = get_le32(pb);
#ifdef DEBUG
print_tag("strh", tag1, -1);
#endif
switch(tag1) {
case MKTAG('i', 'a', 'v', 's'):
case MKTAG('i', 'v', 'a', 's'):
if (s->nb_streams != 1)
goto fail;
if (handler != MKTAG('d', 'v', 's', 'd') &&
handler != MKTAG('d', 'v', 'h', 'd') &&
handler != MKTAG('d', 'v', 's', 'l'))
goto fail;
ast = s->streams[0]->priv_data;
av_freep(&s->streams[0]->codec.extradata);
av_freep(&s->streams[0]);
s->nb_streams = 0;
avi->dv_demux = dv_init_demux(s);
if (!avi->dv_demux)
goto fail;
s->streams[0]->priv_data = ast;
url_fskip(pb, 3 * 4);
ast->scale = get_le32(pb);
ast->rate = get_le32(pb);
stream_index = s->nb_streams - 1;
url_fskip(pb, size - 7*4);
break;
case MKTAG('v', 'i', 'd', 's'):
codec_type = CODEC_TYPE_VIDEO;
if (stream_index >= s->nb_streams) {
url_fskip(pb, size - 8);
break;
}
st = s->streams[stream_index];
ast = st->priv_data;
st->codec.stream_codec_tag= handler;
get_le32(pb);
get_le16(pb);
get_le16(pb);
get_le32(pb);
scale = get_le32(pb);
rate = get_le32(pb);
if(scale && rate){
}else if(frame_period){
rate = 1000000;
scale = frame_period;
}else{
rate = 25;
scale = 1;
}
ast->rate = rate;
ast->scale = scale;
av_set_pts_info(st, 64, scale, rate);
st->codec.frame_rate = rate;
st->codec.frame_rate_base = scale;
get_le32(pb);
nb_frames = get_le32(pb);
st->start_time = 0;
st->duration = av_rescale(nb_frames,
st->codec.frame_rate_base * AV_TIME_BASE,
st->codec.frame_rate);
url_fskip(pb, size - 9 * 4);
break;
case MKTAG('a', 'u', 'd', 's'):
{
unsigned int length;
codec_type = CODEC_TYPE_AUDIO;
if (stream_index >= s->nb_streams) {
url_fskip(pb, size - 8);
break;
}
st = s->streams[stream_index];
ast = st->priv_data;
get_le32(pb);
get_le16(pb);
get_le16(pb);
get_le32(pb);
ast->scale = get_le32(pb);
ast->rate = get_le32(pb);
if(!ast->rate)
ast->rate= 1;
if(!ast->scale)
ast->scale= 1;
av_set_pts_info(st, 64, ast->scale, ast->rate);
ast->start= get_le32(pb);
length = get_le32(pb);
get_le32(pb);
get_le32(pb);
ast->sample_size = get_le32(pb);
st->start_time = 0;
if (ast->rate != 0)
st->duration = (int64_t)length * AV_TIME_BASE / ast->rate;
url_fskip(pb, size - 12 * 4);
}
break;
case MKTAG('t', 'x', 't', 's'):
codec_type = CODEC_TYPE_DATA;
url_fskip(pb, size - 8);
break;
case MKTAG('p', 'a', 'd', 's'):
codec_type = CODEC_TYPE_UNKNOWN;
url_fskip(pb, size - 8);
stream_index--;
break;
default:
av_log(s, AV_LOG_ERROR, "unknown stream type %X\n", tag1);
goto fail;
}
break;
case MKTAG('s', 't', 'r', 'f'):
if (stream_index >= s->nb_streams || avi->dv_demux) {
url_fskip(pb, size);
} else {
st = s->streams[stream_index];
switch(codec_type) {
case CODEC_TYPE_VIDEO:
get_le32(pb);
st->codec.width = get_le32(pb);
st->codec.height = get_le32(pb);
get_le16(pb);
st->codec.bits_per_sample= get_le16(pb);
tag1 = get_le32(pb);
get_le32(pb);
get_le32(pb);
get_le32(pb);
get_le32(pb);
get_le32(pb);
if(size > 10*4 && size<(1<<30)){
st->codec.extradata_size= size - 10*4;
st->codec.extradata= av_malloc(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
get_buffer(pb, st->codec.extradata, st->codec.extradata_size);
}
if(st->codec.extradata_size & 1) check if the encoder really did this correctly
get_byte(pb);
if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) {
st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl));
#ifdef WORDS_BIGENDIAN
for (i = 0; i < FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)/4; i++)
st->codec.palctrl->palette[i] = bswap_32(((uint32_t*)st->codec.extradata)[i]);
#else
memcpy(st->codec.palctrl->palette, st->codec.extradata,
FFMIN(st->codec.extradata_size, AVPALETTE_SIZE));
#endif
st->codec.palctrl->palette_changed = 1;
}
#ifdef DEBUG
print_tag("video", tag1, 0);
#endif
st->codec.codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_tag = tag1;
st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1);
if (st->codec.codec_id == CODEC_ID_XAN_WC4)
xan_video = 1;
break;
case CODEC_TYPE_AUDIO:
get_wav_header(pb, &st->codec, size);
if (size%2)
url_fskip(pb, 1);
st->need_parsing = 1;
if (xan_video)
st->codec.codec_id = CODEC_ID_XAN_DPCM;
break;
default:
st->codec.codec_type = CODEC_TYPE_DATA;
st->codec.codec_id= CODEC_ID_NONE;
st->codec.codec_tag= 0;
url_fskip(pb, size);
break;
}
}
break;
default:
size += (size & 1);
url_fskip(pb, size);
break;
}
}
end_of_header:
if (stream_index != s->nb_streams - 1) {
fail:
for(i=0;i<s->nb_streams;i++) {
av_freep(&s->streams[i]->codec.extradata);
av_freep(&s->streams[i]);
}
return -1;
}
assert(!avi->index_loaded);
avi_load_index(s);
avi->index_loaded = 1;
return 0;
}
| 1threat
|
Mainactivity appears to exist twice or more after restarting app : I have an app with an activity sending a broadcast to another activity.
Everything appears to be fine. But if I close my app and open it again,
this broadcasts seems to get send more than once. In fact it gets send
as often I reopened the app. If I print out "this" right before sending the broadcast I get different instances.
Why could this happen? Why is the activity not dying? I checked, onDestroy get's called. BUT I have a background-service, which I dont stop, when the app is closed. Is it therefore? Can I reopen the old activity, when starting the app instead of opening a new one?
Setting launchmode in the Manifest to singleTask or singleInstance didn't work either.
Thanks!
| 0debug
|
static int ioh3420_initfn(PCIDevice *d)
{
PCIBridge* br = DO_UPCAST(PCIBridge, dev, d);
PCIEPort *p = DO_UPCAST(PCIEPort, br, br);
PCIESlot *s = DO_UPCAST(PCIESlot, port, p);
int rc;
int tmp;
rc = pci_bridge_initfn(d);
if (rc < 0) {
return rc;
}
d->config[PCI_REVISION_ID] = PCI_DEVICE_ID_IOH_REV;
pcie_port_init_reg(d);
pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_INTEL);
pci_config_set_device_id(d->config, PCI_DEVICE_ID_IOH_EPORT);
rc = pci_bridge_ssvid_init(d, IOH_EP_SSVID_OFFSET,
IOH_EP_SSVID_SVID, IOH_EP_SSVID_SSID);
if (rc < 0) {
goto err_bridge;
}
rc = msi_init(d, IOH_EP_MSI_OFFSET, IOH_EP_MSI_NR_VECTOR,
IOH_EP_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_64BIT,
IOH_EP_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT);
if (rc < 0) {
goto err_bridge;
}
rc = pcie_cap_init(d, IOH_EP_EXP_OFFSET, PCI_EXP_TYPE_ROOT_PORT, p->port);
if (rc < 0) {
goto err_msi;
}
pcie_cap_deverr_init(d);
pcie_cap_slot_init(d, s->slot);
pcie_chassis_create(s->chassis);
rc = pcie_chassis_add_slot(s);
if (rc < 0) {
goto err_pcie_cap;
return rc;
}
pcie_cap_root_init(d);
rc = pcie_aer_init(d, IOH_EP_AER_OFFSET);
if (rc < 0) {
goto err;
}
pcie_aer_root_init(d);
ioh3420_aer_vector_update(d);
return 0;
err:
pcie_chassis_del_slot(s);
err_pcie_cap:
pcie_cap_exit(d);
err_msi:
msi_uninit(d);
err_bridge:
tmp = pci_bridge_exitfn(d);
assert(!tmp);
return rc;
}
| 1threat
|
void css_queue_crw(uint8_t rsc, uint8_t erc, int chain, uint16_t rsid)
{
CrwContainer *crw_cont;
trace_css_crw(rsc, erc, rsid, chain ? "(chained)" : "");
crw_cont = g_try_malloc0(sizeof(CrwContainer));
if (!crw_cont) {
channel_subsys.crws_lost = true;
return;
}
crw_cont->crw.flags = (rsc << 8) | erc;
if (chain) {
crw_cont->crw.flags |= CRW_FLAGS_MASK_C;
}
crw_cont->crw.rsid = rsid;
if (channel_subsys.crws_lost) {
crw_cont->crw.flags |= CRW_FLAGS_MASK_R;
channel_subsys.crws_lost = false;
}
QTAILQ_INSERT_TAIL(&channel_subsys.pending_crws, crw_cont, sibling);
if (channel_subsys.do_crw_mchk) {
channel_subsys.do_crw_mchk = false;
s390_crw_mchk();
}
}
| 1threat
|
Appending bullet point sentences to main sentence using python : <p>I have a paragraph which is like in the following format, </p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry;
(a) It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages; and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
(b) Contrary to popular belief; Lorem Ipsum is not simply random text.</p>
<p>so for this I need to collect the bullet point (a) and (b) and append it to the main section like bellow,
Lorem Ipsum is simply dummy text of the printing and typesetting industry. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages; and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>and </p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry Contrary to popular belief; Lorem Ipsum is not simply random text.</p>
<p>Note: ; can be :, :- and (a) can be (i) or any type of bullet point.</p>
| 0debug
|
Java swing: cannot open popup frame from JTable : <p>My current project is simple email client. Now im done main window with list of messages from inbox. Next step is open new window with message from click on Jtable with list of messages.
But Im getting this exception when click on row in table: </p>
<pre><code>22
Test problem
"Alb." <test@gmail.com>
Hello
My PC is not working
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException:4 >= 4
at java.util.Vector.elementAt(Vector.java:470)
at javax.swing.table.DefaultTableColumnModel.getColumn(DefaultTableColumnModel.java:294)
at sun.swing.SwingUtilities2.convertColumnIndexToModel(SwingUtilities2.java:1896)
at javax.swing.JTable.convertColumnIndexToModel(JTable.java:2582)
at javax.swing.JTable.getValueAt(JTable.java:2717)
at CheckEmail$1.mouseClicked(CheckEmail.java:129)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
at java.awt.Component.processMouseEvent(Component.java:6519)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3312)
at java.awt.Component.processEvent(Component.java:6281)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4872)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4698)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4501)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4698)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:747)
at java.awt.EventQueue.access$300(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:706)
at java.awt.EventQueue$3.run(EventQueue.java:704)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:77)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:720)
at java.awt.EventQueue$4.run(EventQueue.java:718)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:77)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:717)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
</code></pre>
<p>here is my code: </p>
<pre><code>import java.awt.BorderLayout;
import org.apache.commons.codec.binary.Base64;
import java.awt.Dimension;
import java.util.*;
import javax.mail.*;
import javax.swing.*;
import javax.swing.table.*;
import org.apache.commons.codec.binary.Base64;
import java.awt.*;
import java.awt.event.*;
public class CheckEmail {
static Object[][] mess = new Object[][]{};
JTextField textMessage = null;
String text = null;
static Object messi = null;
public static void check(String host, String storeType, String user,
String password)
{
try {
Properties properties = new Properties();
properties.put("mail.pop3.host", host);
properties.put("mail.pop3.port", "995");
properties.put("mail.pop3.starttls.enable", "true");
Session emailSession = Session.getDefaultInstance(properties);
Store store = emailSession.getStore("pop3s");
store.connect(host, user, password);
Folder emailFolder = store.getFolder("INBOX");
emailFolder.open(Folder.READ_ONLY);
Message[] messages = emailFolder.getMessages();
JFrame frame = new JFrame("Main");
JPanel panel = new JPanel();
final String data[][] = null;
String [] col = {"num","Subject","From", "Text"};
DefaultTableModel model = new DefaultTableModel(data, col);
final JTable table = new JTable(model);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.getColumnModel().getColumn(0).setPreferredWidth(30);
table.getColumnModel().getColumn(1).setPreferredWidth(400);
table.getColumnModel().getColumn(2).setPreferredWidth(400);
table.getColumnModel().getColumn(3).setPreferredWidth(1);
table.setSize(830, 600);
for (int i = 0, n = messages.length; i < n; i++) {
Message message = messages[i];
int num = i + 1;
String subject = message.getSubject();
String from = message.getFrom()[0].toString();
String text = message.getContent().toString();
Object[] mess = new Object[]{num, subject, from, text};
model.insertRow(i, mess);
}
panel.add(table);
JScrollPane scrollPane = new JScrollPane(table);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(830, 600);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
emailFolder.close(false);
store.close();
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 1) {
final JTable target = (JTable)e.getSource();
int row = target.getSelectedRow();
int column = target.getSelectedRow();
for(int i = 0; i < column; i++) {
Object mess = (Object)target.getValueAt(row, i);
System.out.println(target.getValueAt(row, i));
}
StringBuffer sb = new StringBuffer();
sb.append(mess);
TextFrame textFrame = new TextFrame(sb.toString());
textFrame.setVisible(true);
}
}
});
} catch (NoSuchProviderException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
String host = "pop3.gmail.com";// change accordingly
String mailStoreType = "pop3";
String username = "test@gmail.com";// change accordingly
String password = "pass";// change accordingly
check(host, mailStoreType, username, password);
}
}
</code></pre>
<p>and the second class:</p>
<pre><code>import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JTextArea;
class TextFrame extends JFrame
{
public TextFrame(String content) {
super("TextFrame");
JTextArea ta = new JTextArea();
ta.setText(content);
getContentPane().add(ta);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
dispose();
}
});
setSize(600, 400);
}
}
</code></pre>
| 0debug
|
How to change the colour of the 'Cancel' button on the UISearchBar in Swift : <p>I have added a <code>UISearchBar</code> to the top of my <code>PFQueryTableViewController</code>. I have changed the colour of the searchBar to be the colour of my app, but in doing this, it seems to have also changed the colour of the 'Cancel' button to the right of it to the same colour. Ideally, I want the colour to be White. </p>
<p>This image shows how it currently looks:</p>
<p><a href="https://i.stack.imgur.com/Xppcm.png"><img src="https://i.stack.imgur.com/Xppcm.png" alt=""></a></p>
<p>It looks like there is no 'Cancel' button, but there is, its just the same colour as the searchBar (You can still press it etc)</p>
<p>Is there a way for me to change the colour of this 'Cancel button to white? Everything i've tried seems to make no difference. </p>
<p>Code i've used to make the <code>UISearchBar</code> this colour is:</p>
<pre><code>UISearchBar.appearance().barTintColor = UIColor(hue: 359/360, saturation: 67/100, brightness: 71/100, alpha: 1)
UISearchBar.appearance().tintColor = UIColor(hue: 359/360, saturation: 67/100, brightness: 71/100, alpha: 1)
</code></pre>
<p>And in the storyboard i've set these:</p>
<p><a href="https://i.stack.imgur.com/ZfTy2.png"><img src="https://i.stack.imgur.com/ZfTy2.png" alt="enter image description here"></a></p>
<p>And finally, to make the placeholder, and text white inside the SearchBar, i've used:</p>
<pre><code>for subView in self.filmSearchBar.subviews {
for subsubView in subView.subviews {
if let searchBarTextField = subsubView as? UITextField {
searchBarTextField.attributedPlaceholder = NSAttributedString(string: NSLocalizedString("Search Cinevu film reviews", comment: ""), attributes: [NSForegroundColorAttributeName: UIColor.whiteColor()])
searchBarTextField.textColor = UIColor.whiteColor()
}
}
}
</code></pre>
<p>Thanks for any help! :)</p>
| 0debug
|
def check_identical(test_list1, test_list2):
res = test_list1 == test_list2
return (res)
| 0debug
|
void pp_postprocess(const uint8_t * src[3], const int srcStride[3],
uint8_t * dst[3], const int dstStride[3],
int width, int height,
const QP_STORE_T *QP_store, int QPStride,
pp_mode *vm, void *vc, int pict_type)
{
int mbWidth = (width+15)>>4;
int mbHeight= (height+15)>>4;
PPMode *mode = vm;
PPContext *c = vc;
int minStride= FFMAX(FFABS(srcStride[0]), FFABS(dstStride[0]));
int absQPStride = FFABS(QPStride);
if(c->stride < minStride || c->qpStride < absQPStride)
reallocBuffers(c, width, height,
FFMAX(minStride, c->stride),
FFMAX(c->qpStride, absQPStride));
if(!QP_store || (mode->lumMode & FORCE_QUANT)){
int i;
QP_store= c->forcedQPTable;
absQPStride = QPStride = 0;
if(mode->lumMode & FORCE_QUANT)
for(i=0; i<mbWidth; i++) c->forcedQPTable[i]= mode->forcedQuant;
else
for(i=0; i<mbWidth; i++) c->forcedQPTable[i]= 1;
}
if(pict_type & PP_PICT_TYPE_QP2){
int i;
const int count= FFMAX(mbHeight * absQPStride, mbWidth);
for(i=0; i<(count>>2); i++){
((uint32_t*)c->stdQPTable)[i] = (((const uint32_t*)QP_store)[i]>>1) & 0x7F7F7F7F;
}
for(i<<=2; i<count; i++){
c->stdQPTable[i] = QP_store[i]>>1;
}
QP_store= c->stdQPTable;
QPStride= absQPStride;
}
if(0){
int x,y;
for(y=0; y<mbHeight; y++){
for(x=0; x<mbWidth; x++){
av_log(c, AV_LOG_INFO, "%2d ", QP_store[x + y*QPStride]);
}
av_log(c, AV_LOG_INFO, "\n");
}
av_log(c, AV_LOG_INFO, "\n");
}
if((pict_type&7)!=3){
if (QPStride >= 0){
int i;
const int count= FFMAX(mbHeight * QPStride, mbWidth);
for(i=0; i<(count>>2); i++){
((uint32_t*)c->nonBQPTable)[i] = ((const uint32_t*)QP_store)[i] & 0x3F3F3F3F;
}
for(i<<=2; i<count; i++){
c->nonBQPTable[i] = QP_store[i] & 0x3F;
}
} else {
int i,j;
for(i=0; i<mbHeight; i++) {
for(j=0; j<absQPStride; j++) {
c->nonBQPTable[i*absQPStride+j] = QP_store[i*QPStride+j] & 0x3F;
}
}
}
}
av_log(c, AV_LOG_DEBUG, "using npp filters 0x%X/0x%X\n",
mode->lumMode, mode->chromMode);
postProcess(src[0], srcStride[0], dst[0], dstStride[0],
width, height, QP_store, QPStride, 0, mode, c);
if (!(src[1] && src[2] && dst[1] && dst[2]))
return;
width = (width )>>c->hChromaSubSample;
height = (height)>>c->vChromaSubSample;
if(mode->chromMode){
postProcess(src[1], srcStride[1], dst[1], dstStride[1],
width, height, QP_store, QPStride, 1, mode, c);
postProcess(src[2], srcStride[2], dst[2], dstStride[2],
width, height, QP_store, QPStride, 2, mode, c);
}
else if(srcStride[1] == dstStride[1] && srcStride[2] == dstStride[2]){
linecpy(dst[1], src[1], height, srcStride[1]);
linecpy(dst[2], src[2], height, srcStride[2]);
}else{
int y;
for(y=0; y<height; y++){
memcpy(&(dst[1][y*dstStride[1]]), &(src[1][y*srcStride[1]]), width);
memcpy(&(dst[2][y*dstStride[2]]), &(src[2][y*srcStride[2]]), width);
}
}
}
| 1threat
|
Issue with Garbage Collection : <p>I have code some what like</p>
<pre><code>class HappyGarbage01
{
public static void main(String args[])
{
HappyGarbage01 h = new HappyGarbage01();
h.methodA(); /* Line 6 */
}
Object methodA()
{
Object obj1 = new Object();
Object [] obj2 = new Object[1];
obj2[0] = obj1;
obj1 = null;
return obj2[0];
}
}
</code></pre>
<p>Will the most chance of the garbage collector being invoked be after line 9 or 10?</p>
| 0debug
|
why doesn't input = charArray.ToString() return a string? : <p>I'm writing a program that takes a string as input and reverses it. In doing so I came across a behavior that I'm not understanding. </p>
<p>Why doesn't this return a string? Instead it returns System.Char[].</p>
<pre><code>using System;
public static class ReverseString
{
public static string Reverse(string input)
{
if (input.Length == 0)
{
return input;
}
char[] charArray = input.ToCharArray();
Array.Reverse(charArray);
input = charArray.ToString();
return input;
}
}
</code></pre>
<p>Working Code:</p>
<pre><code>using System;
public static class ReverseString
{
public static string Reverse(string input)
{
if (input.Length == 0)
{
return input;
}
char[] charArray = input.ToCharArray();
Array.Reverse(charArray);
return new string(charArray);
}
}
</code></pre>
| 0debug
|
I want to load(play) the video only when the Marker(HIRO Pattern) is hovered in-front of my webcam : I am using A-Frame. I am trying to augment a Video(mp4) when the pattern or marker(HIRO) is hovered in front of my webcam, the video should be loaded or played on the marker. Now The issue with this code is when the page gets loaded the video gets played automatically without any marker or pattern(HIRO). The video is displayed on the marker.
I just want to load the video whenever the pattern or marker is shown. Without patter, it should not load. Please help me with this
[Video Augmentation on Marker][1]
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- <script src="vendor/aframe/build/aframe.min.js"></script> -->
<script src="https://aframe.io/releases/0.8.0/aframe.min.js"></script>
<!-- <script src="vendor/aframe/build/aframe.js"></script> -->
<!-- include for artoolkit trackingBackend -->
<script src='aframe_lib/artoolkit.min.js'></script>
<script src='aframe_lib/artoolkit.api.js'></script>
<!-- include for aruco trackingBackend -->
<script src='aframe_lib/svd.js'></script>
<script src='aframe_lib/posit1.js'></script>
<script src='aframe_lib/cv.js'></script>
<script src='aframe_lib/aruco.js'></script>
<script src='aframe_lib/threex-arucocontext.js'></script>
<script src='aframe_lib/threex-arucodebug.js'></script>
<!-- include for tango trackingBackend -->
<script src='aframe_lib/THREE.WebAR.js'></script>
<!-- include ar.js -->
<script src='aframe_lib/signals.min.js'></script>
<script src='aframe_lib/threex-artoolkitprofile.js'></script>
<script src='aframe_lib/threex-artoolkitsource.js'></script>
<script src='aframe_lib/threex-artoolkitcontext.js'></script>
<script src='aframe_lib/threex-arbasecontrols.js'></script>
<script src='aframe_lib/threex-armarkercontrols.js'></script>
<script src='aframe_lib/threex-arsmoothedcontrols.js'></script>
<script src='aframe_lib/threex-hittesting-plane.js'></script>
<script src='aframe_lib/threex-hittesting-tango.js'></script>
<script src='aframe_lib/threex-armarkerhelper.js'></script>
<script src='aframe_lib/arjs-utils.js'></script>
<script src='aframe_lib/arjs-session.js'></script>
<script src='aframe_lib/arjs-anchor.js'></script>
<script src='aframe_lib/arjs-hittesting.js'></script>
<script src='aframe_lib/arjs-tangovideomesh.js'></script>
<script src='aframe_lib/arjs-tangopointcloud.js'></script>
<script src='aframe_lib/arjs-debugui.js'></script>
<script src='aframe_lib/threex-armultimarkerutils.js'></script>
<script src='aframe_lib/threex-armultimarkercontrols.js'></script>
<script src='aframe_lib/threex-armultimarkerlearning.js'></script>
<!-- include aframe-ar.js -->
<script src="aframe_lib/system-arjs.js"></script>
<script src="aframe_lib/component-anchor.js"></script>
<script src="aframe_lib/component-hit-testing.js"></script>
<!-- start the body of your page -->
<body style='margin : 0px; overflow: hidden;'>
<a-scene embedded arjs='trackingMethod: best;'>
<a-anchor hit-testing-enabled='true'>
<a-entity>
<video type="video/mp4" id="penguin-sledding" autoplay="true" loop="false" src="resources/video.mp4" webkit-playsinline>
</a-entity>
<a-video position="0 0.2 0" src="#penguin-sledding" rotation="90 180 0"></a-video>
</a-anchor>
<a-camera-static preset='hiro'/>
<a-entity light="color: #ccccff; intensity: 1; type: ambient;" visible="">
</a-entity>
</a-scene>
</body>
<!-- end snippet -->
strong text
[1]: https://i.stack.imgur.com/Nlefh.jpg
| 0debug
|
string not compared in the second activity : i need the string from editText from mainactivity so that i can compare the value and show the desired image in the next..but only the else part is working in the second activity. i tried this code but it didnt work..
private Button b1;
static EditText et;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et = (EditText)findViewById(R.id.pass);
b1 = (Button)findViewById(R.id.clickhere);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(et.getText().toString().equals(getString(R.string.Ronnie)))
{
Intent myIntent = new Intent(MainActivity.this, Thought.class);
startActivity(myIntent);
}
else if(et.getText().toString().equals(getString(R.string.Ankita)))
{
Intent myIntent = new Intent(MainActivity.this, Thought.class);
startActivity(myIntent);
}
else
{
Toast.makeText(getApplicationContext(),"Not for you",Toast.LENGTH_SHORT);
}
}
});
}
and second activity code
public class Thought extends MainActivity {
public ImageView iv;
static String s1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent=getIntent();
setContentView(R.layout.activity_thought);
s1 = MainActivity.et.getText().toString();
iv = (ImageView)findViewById(R.id.imageView);
if(s1.equals(getString(R.string.Ronnie)))
{
iv.setImageResource(R.drawable.ronniel);
}
else if(s1.equals(getString(R.string.Ankita)))
{
iv.setImageResource(R.drawable.ankitat);
}
else
{
iv.setImageResource(R.drawable.subha);
}
}
}
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.