problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
javascript array assign to multiple variable : i got a bit logic problem. i wan't to assign array to several variable. but it's doesn't work. appreciate for your help.
function Case(values){
var x = values;
var A = [];
var B = [];
var C = [];
var temp = 0;
A.push(values[i]);
B.push(values[i]);
C.push(values[i]);
}
var values = [5, 4, 3, 6, 7 , 8];
Case(values);
Output expect:
A = [5, 6];
B = [4, 7];
A = [3, 8]; | 0debug |
int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
int max_size)
{
uint32_t mrk;
int i, tmp;
const uint16_t *ssrc = (const uint16_t *) src;
uint16_t *sdst = (uint16_t *) dst;
PutBitContext pb;
if ((unsigned) src_size > (unsigned) max_size)
src_size = max_size;
mrk = AV_RB32(src);
switch (mrk) {
case DCA_SYNCWORD_CORE_BE:
memcpy(dst, src, src_size);
return src_size;
case DCA_SYNCWORD_CORE_LE:
for (i = 0; i < (src_size + 1) >> 1; i++)
*sdst++ = av_bswap16(*ssrc++);
return src_size;
case DCA_SYNCWORD_CORE_14B_BE:
case DCA_SYNCWORD_CORE_14B_LE:
init_put_bits(&pb, dst, max_size);
for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) {
tmp = ((mrk == DCA_SYNCWORD_CORE_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF;
put_bits(&pb, 14, tmp);
}
flush_put_bits(&pb);
return (put_bits_count(&pb) + 7) >> 3;
default:
return AVERROR_INVALIDDATA;
}
}
| 1threat |
import re
def words_ae(text):
list = re.findall("[ae]\w+", text)
return list | 0debug |
print_with_operands (const struct cris_opcode *opcodep,
unsigned int insn,
unsigned char *buffer,
bfd_vma addr,
disassemble_info *info,
const struct cris_opcode *prefix_opcodep,
unsigned int prefix_insn,
unsigned char *prefix_buffer,
bfd_boolean with_reg_prefix)
{
char temp[sizeof (".d [$r13=$r12-2147483648],$r10") * 2];
char *tp = temp;
static const char mode_char[] = "bwd?";
const char *s;
const char *cs;
struct cris_disasm_data *disdata
= (struct cris_disasm_data *) info->private_data;
(*info->fprintf_func) (info->stream, "%s", opcodep->name);
cs = opcodep->args;
s = cs;
if (*s == 'p')
s++;
if (*s == 'm' || *s == 'M' || *s == 'z')
{
*tp++ = '.';
*tp++ = *s == 'M'
? (insn & 0x8000 ? 'd'
: insn & 0x4000 ? 'w' : 'b')
: mode_char[(insn >> 4) & (*s == 'z' ? 1 : 3)];
s += 2;
}
if (opcodep->match != (BRANCH_PC_LOW + BRANCH_INCR_HIGH * 256))
*tp++ = ' ';
if (opcodep->name[0] == 'j')
{
if (CONST_STRNEQ (opcodep->name, "jsr"))
info->insn_type = dis_jsr;
else
info->insn_type = dis_branch;
}
info->branch_delay_insns = opcodep->delayed;
for (; *s; s++)
{
switch (*s)
{
case 'T':
tp = format_sup_reg ((insn >> 12) & 15, tp, with_reg_prefix);
break;
case 'A':
if (with_reg_prefix)
*tp++ = REGISTER_PREFIX_CHAR;
*tp++ = 'a';
*tp++ = 'c';
*tp++ = 'r';
break;
case '[':
case ']':
case ',':
*tp++ = *s;
break;
case '!':
break;
case 'd':
break;
case 'B':
prefix_opcodep = NULL;
break;
case 'D':
case 'r':
tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
break;
case 'R':
tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
break;
case 'n':
{
unsigned long number
= (buffer[2] + buffer[3] * 256 + buffer[4] * 65536
+ buffer[5] * 0x1000000 + addr);
*tp = 0;
if (temp[0])
(*info->fprintf_func) (info->stream, "%s", temp);
tp = temp;
(*info->print_address_func) ((bfd_vma) number, info);
}
break;
case 'u':
{
unsigned long number = (buffer[0] & 0xf) * 2 + addr;
*tp = 0;
if (temp[0])
(*info->fprintf_func) (info->stream, "%s", temp);
tp = temp;
(*info->print_address_func) ((bfd_vma) number, info);
}
break;
case 'N':
case 'y':
case 'Y':
case 'S':
case 's':
if ((insn & 0x400) && (insn & 15) == 15 && prefix_opcodep == NULL)
{
long number;
int signedp
= ((*cs == 'z' && (insn & 0x20))
|| opcodep->match == BDAP_QUICK_OPCODE);
int nbytes;
if (opcodep->imm_oprnd_size == SIZE_FIX_32)
nbytes = 4;
else if (opcodep->imm_oprnd_size == SIZE_SPEC_REG)
{
const struct cris_spec_reg *sregp
= spec_reg_info ((insn >> 12) & 15, disdata->distype);
if (sregp == NULL)
nbytes = 42;
else
nbytes = disdata->distype == cris_dis_v32
? 4 : (sregp->reg_size + 1) & ~1;
}
else
{
int mode_size = 1 << ((insn >> 4) & (*cs == 'z' ? 1 : 3));
if (mode_size == 1)
nbytes = 2;
else
nbytes = mode_size;
}
switch (nbytes)
{
case 1:
number = buffer[2];
if (signedp && number > 127)
number -= 256;
break;
case 2:
number = buffer[2] + buffer[3] * 256;
if (signedp && number > 32767)
number -= 65536;
break;
case 4:
number
= buffer[2] + buffer[3] * 256 + buffer[4] * 65536
+ buffer[5] * 0x1000000;
break;
default:
strcpy (tp, "bug");
tp += 3;
number = 42;
}
if ((*cs == 'z' && (insn & 0x20))
|| (opcodep->match == BDAP_QUICK_OPCODE
&& (nbytes <= 2 || buffer[1 + nbytes] == 0)))
tp = format_dec (number, tp, signedp);
else
{
unsigned int highbyte = (number >> 24) & 0xff;
if (nbytes == 4
&& (highbyte == ((addr >> 24) & 0xff)
|| (highbyte != 0 && highbyte != 0xff)
|| info->insn_type == dis_branch
|| info->insn_type == dis_jsr))
{
*tp = 0;
tp = temp;
if (temp[0])
(*info->fprintf_func) (info->stream, "%s", temp);
(*info->print_address_func) ((bfd_vma) number, info);
info->target = number;
}
else
tp = format_hex (number, tp, disdata);
}
}
else
{
if (info->insn_type != dis_nonbranch)
{
int mode_size
= 1 << ((insn >> 4)
& (opcodep->args[0] == 'z' ? 1 : 3));
int size;
info->insn_type = dis_dref;
info->flags |= CRIS_DIS_FLAG_MEMREF;
if (opcodep->imm_oprnd_size == SIZE_FIX_32)
size = 4;
else if (opcodep->imm_oprnd_size == SIZE_SPEC_REG)
{
const struct cris_spec_reg *sregp
= spec_reg_info ((insn >> 12) & 15, disdata->distype);
if (sregp == NULL)
size = 4;
else
size = sregp->reg_size;
}
else
size = mode_size;
info->data_size = size;
}
*tp++ = '[';
if (prefix_opcodep
&& ((insn & 0x400) == 0
|| prefix_opcodep->match != DIP_OPCODE))
{
if (insn & 0x400)
{
tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
*tp++ = '=';
}
switch (prefix_opcodep->match)
{
case DIP_OPCODE:
if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
{
unsigned long number
= prefix_buffer[2] + prefix_buffer[3] * 256
+ prefix_buffer[4] * 65536
+ prefix_buffer[5] * 0x1000000;
info->target = (bfd_vma) number;
*tp = 0;
tp = temp;
if (temp[0])
(*info->fprintf_func) (info->stream, "%s", temp);
(*info->print_address_func) ((bfd_vma) number, info);
}
else
{
info->flags
|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
| CRIS_DIS_FLAG_MEM_TARGET2_MEM);
info->target2 = prefix_insn & 15;
*tp++ = '[';
tp = format_reg (disdata, prefix_insn & 15, tp,
with_reg_prefix);
if (prefix_insn & 0x400)
*tp++ = '+';
*tp++ = ']';
}
break;
case BDAP_QUICK_OPCODE:
{
int number;
number = prefix_buffer[0];
if (number > 127)
number -= 256;
tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
with_reg_prefix);
if (number >= 0)
*tp++ = '+';
tp = format_dec (number, tp, 1);
info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
info->target = (prefix_insn >> 12) & 15;
info->target2 = (bfd_vma) number;
break;
}
case BIAP_OPCODE:
tp = format_reg (disdata, prefix_insn & 15, tp,
with_reg_prefix);
*tp++ = '+';
tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
with_reg_prefix);
*tp++ = '.';
*tp++ = mode_char[(prefix_insn >> 4) & 3];
info->flags
|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
| CRIS_DIS_FLAG_MEM_TARGET_IS_REG
| ((prefix_insn & 0x8000)
? CRIS_DIS_FLAG_MEM_TARGET2_MULT4
: ((prefix_insn & 0x8000)
? CRIS_DIS_FLAG_MEM_TARGET2_MULT2 : 0)));
if (insn == 0xf83f && (prefix_insn & ~0xf000) == 0x55f)
case_offset_counter = no_of_case_offsets;
break;
case BDAP_INDIR_OPCODE:
tp = format_reg (disdata, (prefix_insn >> 12) & 15, tp,
with_reg_prefix);
if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
{
long number;
unsigned int nbytes;
int mode_size = 1 << ((prefix_insn >> 4) & 3);
if (mode_size == 1)
nbytes = 2;
else
nbytes = mode_size;
switch (nbytes)
{
case 1:
number = prefix_buffer[2];
if (number > 127)
number -= 256;
break;
case 2:
number = prefix_buffer[2] + prefix_buffer[3] * 256;
if (number > 32767)
number -= 65536;
break;
case 4:
number
= prefix_buffer[2] + prefix_buffer[3] * 256
+ prefix_buffer[4] * 65536
+ prefix_buffer[5] * 0x1000000;
break;
default:
strcpy (tp, "bug");
tp += 3;
number = 42;
}
info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
info->target2 = (bfd_vma) number;
if (nbytes == 4)
{
*tp++ = '+';
*tp = 0;
tp = temp;
(*info->fprintf_func) (info->stream, "%s", temp);
(*info->print_address_func) ((bfd_vma) number, info);
}
else
{
if (number >= 0)
*tp++ = '+';
tp = format_dec (number, tp, 1);
}
}
else
{
*tp++ = '+';
*tp++ = '[';
tp = format_reg (disdata, prefix_insn & 15, tp,
with_reg_prefix);
if (prefix_insn & 0x400)
*tp++ = '+';
*tp++ = ']';
*tp++ = '.';
*tp++ = mode_char[(prefix_insn >> 4) & 3];
info->flags
|= (CRIS_DIS_FLAG_MEM_TARGET2_IS_REG
| CRIS_DIS_FLAG_MEM_TARGET2_MEM
| CRIS_DIS_FLAG_MEM_TARGET_IS_REG
| (((prefix_insn >> 4) == 2)
? 0
: (((prefix_insn >> 4) & 3) == 1
? CRIS_DIS_FLAG_MEM_TARGET2_MEM_WORD
: CRIS_DIS_FLAG_MEM_TARGET2_MEM_BYTE)));
}
break;
default:
(*info->fprintf_func) (info->stream, "?prefix-bug");
}
prefix_opcodep = NULL;
}
else
{
tp = format_reg (disdata, insn & 15, tp, with_reg_prefix);
info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
info->target = insn & 15;
if (insn & 0x400)
*tp++ = '+';
}
*tp++ = ']';
}
break;
case 'x':
tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
*tp++ = '.';
*tp++ = mode_char[(insn >> 4) & 3];
break;
case 'I':
tp = format_dec (insn & 63, tp, 0);
break;
case 'b':
{
int where = buffer[2] + buffer[3] * 256;
if (where > 32767)
where -= 65536;
where += addr + ((disdata->distype == cris_dis_v32) ? 0 : 4);
if (insn == BA_PC_INCR_OPCODE)
info->insn_type = dis_branch;
else
info->insn_type = dis_condbranch;
info->target = (bfd_vma) where;
*tp = 0;
tp = temp;
(*info->fprintf_func) (info->stream, "%s%s ",
temp, cris_cc_strings[insn >> 12]);
(*info->print_address_func) ((bfd_vma) where, info);
}
break;
case 'c':
tp = format_dec (insn & 31, tp, 0);
break;
case 'C':
tp = format_dec (insn & 15, tp, 0);
break;
case 'o':
{
long offset = insn & 0xfe;
bfd_vma target;
if (insn & 1)
offset |= ~0xff;
if (opcodep->match == BA_QUICK_OPCODE)
info->insn_type = dis_branch;
else
info->insn_type = dis_condbranch;
target = addr + ((disdata->distype == cris_dis_v32) ? 0 : 2) + offset;
info->target = target;
*tp = 0;
tp = temp;
(*info->fprintf_func) (info->stream, "%s", temp);
(*info->print_address_func) (target, info);
}
break;
case 'Q':
case 'O':
{
long number = buffer[0];
if (number > 127)
number = number - 256;
tp = format_dec (number, tp, 1);
*tp++ = ',';
tp = format_reg (disdata, (insn >> 12) & 15, tp, with_reg_prefix);
}
break;
case 'f':
tp = print_flags (disdata, insn, tp);
break;
case 'i':
tp = format_dec ((insn & 32) ? (insn & 31) | ~31L : insn & 31, tp, 1);
break;
case 'P':
{
const struct cris_spec_reg *sregp
= spec_reg_info ((insn >> 12) & 15, disdata->distype);
if (sregp->name == NULL)
*tp++ = '?';
else
{
if (with_reg_prefix)
*tp++ = REGISTER_PREFIX_CHAR;
strcpy (tp, sregp->name);
tp += strlen (tp);
}
}
break;
default:
strcpy (tp, "???");
tp += 3;
}
}
*tp = 0;
if (prefix_opcodep)
(*info->fprintf_func) (info->stream, " (OOPS unused prefix \"%s: %s\")",
prefix_opcodep->name, prefix_opcodep->args);
(*info->fprintf_func) (info->stream, "%s", temp);
if (TRACE_CASE && case_offset_counter == 0)
{
if (CONST_STRNEQ (opcodep->name, "sub"))
case_offset = last_immediate;
else if (CONST_STRNEQ (opcodep->name, "add"))
case_offset = -last_immediate;
else if (CONST_STRNEQ (opcodep->name, "bound"))
no_of_case_offsets = last_immediate + 1;
else if (info->insn_type == dis_jsr
|| info->insn_type == dis_branch
|| info->insn_type == dis_condbranch)
case_offset = 0;
}
}
| 1threat |
Pulling values from an array of objects with key pairs inside : I am new to programming so apologies if this is incredibly basic! As part of my application I would like to extract the values for monthlyIncome, savePercent and years and save them as $scope. values so they can be set as default values when a user logs in!
[{"$value":1457178818625,"$id":"date","$priority":null},{"$value":"a@b.com","$id":"email","$priority":null},{"$value":"test","$id":"firstname","$priority":null},{"$value":"Isaacs","$id":"lastname","$priority":null},{"$value":328947,"$id":"monthly","$priority":null},{"$value":123,"$id":"monthlyIncome","$priority":null},{"$value":10,"$id":"percent","$priority":null},{"$value":"4157e8b1-efa2-4feb-bf75-e907c0e200e0","$id":"regUser","$priority":null},{"$value":10,"$id":"savePercent","$priority":null},{"$value":40,"$id":"years","$priority":null}]
Any help would be greatly appreciated. | 0debug |
Why DateTime diff wrong result : I have the following code that is returning the wrong answer. Please let me know what's wrong.
$start_date = new DateTime('31-03-2019');
$end_date = new DateTime('01-05-2019');
$d = $start_date->diff($end_date);
echo "day: " . $d->d . " month: " . $d->m . "\n";
It is returning the wrong answer.
day: 0 month: 1
I expect the answer to be
day: 1 month: 1
| 0debug |
Simplest way to ganerate graphs using javascript and json : What's the simplest way to generate graphs from values coming from an api using javscript and boostrap? My endpoint output is like this:
`
[
{
"battery": "22.7",
"temperature": "80",
"speed": "77",
"time": "2016-02-12 14:09:04"
},
{
"battery": "22.8",
"temperature": "82",
"speed": "99",
"time": "2016-02-12 14:09:04"
},
{
"battery": "22.7",
"temperature": "80",
"speed": "77",
"time": "2016-02-12 14:08:22"
}
]` | 0debug |
e1000e_write_ps_rx_descr(E1000ECore *core, uint8_t *desc,
struct NetRxPkt *pkt,
const E1000E_RSSInfo *rss_info,
size_t ps_hdr_len,
uint16_t(*written)[MAX_PS_BUFFERS])
{
int i;
union e1000_rx_desc_packet_split *d =
(union e1000_rx_desc_packet_split *) desc;
memset(d, 0, sizeof(*d));
d->wb.middle.length0 = cpu_to_le16((*written)[0]);
for (i = 0; i < PS_PAGE_BUFFERS; i++) {
d->wb.upper.length[i] = cpu_to_le16((*written)[i + 1]);
}
e1000e_build_rx_metadata(core, pkt, pkt != NULL,
rss_info,
&d->wb.lower.hi_dword.rss,
&d->wb.lower.mrq,
&d->wb.middle.status_error,
&d->wb.lower.hi_dword.csum_ip.ip_id,
&d->wb.middle.vlan);
d->wb.upper.header_status =
cpu_to_le16(ps_hdr_len | (ps_hdr_len ? E1000_RXDPS_HDRSTAT_HDRSP : 0));
trace_e1000e_rx_desc_ps_write((*written)[0], (*written)[1],
(*written)[2], (*written)[3]);
}
| 1threat |
static void scsi_device_unrealize(SCSIDevice *s, Error **errp)
{
SCSIDeviceClass *sc = SCSI_DEVICE_GET_CLASS(s);
if (sc->unrealize) {
sc->unrealize(s, errp);
}
}
| 1threat |
static double get_scene_score(AVFilterContext *ctx, AVFilterBufferRef *picref)
{
double ret = 0;
SelectContext *select = ctx->priv;
AVFilterBufferRef *prev_picref = select->prev_picref;
if (prev_picref &&
picref->video->h == prev_picref->video->h &&
picref->video->w == prev_picref->video->w &&
picref->linesize[0] == prev_picref->linesize[0]) {
int x, y;
int64_t sad = 0;
double mafd, diff;
uint8_t *p1 = picref->data[0];
uint8_t *p2 = prev_picref->data[0];
const int linesize = picref->linesize[0];
for (y = 0; y < picref->video->h; y += 8)
for (x = 0; x < linesize; x += 8)
sad += select->c.sad[1](select,
p1 + y * linesize + x,
p2 + y * linesize + x,
linesize, 8);
emms_c();
mafd = sad / (picref->video->h * picref->video->w * 3);
diff = fabs(mafd - select->prev_mafd);
ret = av_clipf(FFMIN(mafd, diff) / 100., 0, 1);
select->prev_mafd = mafd;
avfilter_unref_buffer(prev_picref);
}
select->prev_picref = avfilter_ref_buffer(picref, ~0);
return ret;
}
| 1threat |
Is it possible to rename _id field after mongo's group aggregation? : <p>I have a query like this (simplified):</p>
<pre><code>db.report.aggregate([{
$match: {
main_id: ObjectId("58f0f67f50c6af16709fd2c7")
}
}, {
$group: {
_id: "$name",
count: {
$sum: 1
},
sum: {
$sum: {
$add: ["$P31", "$P32"]
}
}
}
}
])
</code></pre>
<p>I do this query from java, and I want to map it on my class, but I don't want '_id' to be mapped on 'name' field. Because if I do something like this:</p>
<pre><code>@JsonProperty("_id")
private String name;
</code></pre>
<p>then when I save this data back to mongo (after some modification) the data is saved with name as '_id' while I want a real Id to be generated.</p>
<p>So, how can I rename '_id' after $group operation?</p>
| 0debug |
static av_cold int XAVS_close(AVCodecContext *avctx)
{
XavsContext *x4 = avctx->priv_data;
av_freep(&avctx->extradata);
av_free(x4->sei);
av_freep(&x4->pts_buffer);
if (x4->enc)
xavs_encoder_close(x4->enc);
av_frame_free(&avctx->coded_frame);
return 0;
}
| 1threat |
static void FUNCC(pred8x8_vertical_add)(uint8_t *pix, const int *block_offset,
const int16_t *block, ptrdiff_t stride)
{
int i;
for(i=0; i<4; i++)
FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
}
| 1threat |
Output a UMD module from dynamic sources with webpack : <p>I have a project structure that contains a folder that I want to dynamically import into a UMD module when I build my webpack config and have each file be a submodule in the outputted build.</p>
<p>For example, let's say my sources look like:</p>
<pre><code>/src/snippets/red.js
/src/snippets/green.js
/src/snippets/blue.js
</code></pre>
<p>I want webpack to build these sources into a single module that allows me to access each one as submodules, like so;</p>
<pre><code>const red = require('snippets').red
</code></pre>
<p>I tried iterating over the snippets directory and creating an object with filenames and paths, but I can't figure out what configuration property will instruct webpack to bundle them into a single file and export each. Here's what I have so far:</p>
<pre><code>const glob = require('glob')
module.exports = {
entry: glob.sync('./src/snippets/*.js').reduce((files, file) => {
files[path.basename(file,'.js')] = file
return files
}, {}),
output: {
path: __dirname + '/lib',
filename: 'snippets.js',
libraryTarget: 'umd'
}
}
</code></pre>
<p>This errors out with: <code>Conflict: Multiple assets emit to the same filename ./lib/snippets.js</code></p>
<p>Any idea on how I can accomplish what I'm looking for?</p>
| 0debug |
Adding cancel button in my Javascript : Is it possible to add a cancel button in this javascript so the form will not be submitted?
This Javascript is currently working in validating these form fields but if for some reason I entered a wrong information there is no way for me to cancel and prevent the form being submitted.
<script language="JavaScript">
function validate(form)
{
if (form.Institution.selectedIndex == 0)
{
alert("You must select an institution for any necessary future correspondence.");
return false;
}
if (form.Requestors_name.value == "")
{
alert("You must enter your name for any necessary future correspondence.");
return false;
}
if (form.EntityFirstName.value == "")
{
alert("You must enter the Entity's first name.");
return false;
}
alert("Your form has been successfully submitted!");
// form.reset();
return true;
}
</script> | 0debug |
Powershell Array to comma separated string with Quotes : <p>I have an array that I need to output to a comma separated string but I also need quotes "". Here is what I have.</p>
<pre><code>$myArray = "file1.csv","file2.csv"
$a = ($myArray -join ",")
$a
</code></pre>
<p>The output for
<code>$a</code>
ends up </p>
<pre><code>file1.csv,file2.csv
</code></pre>
<p>My desired output is </p>
<pre><code>"file1.csv","file2.csv"
</code></pre>
<p>How can I accomplish this?</p>
| 0debug |
static void hpet_reset(void *opaque)
{
HPETState *s = opaque;
int i;
static int count = 0;
for (i = 0; i < HPET_NUM_TIMERS; i++) {
HPETTimer *timer = &s->timer[i];
hpet_del_timer(timer);
timer->tn = i;
timer->cmp = ~0ULL;
timer->config = HPET_TN_PERIODIC_CAP | HPET_TN_SIZE_CAP;
timer->config |= 0x00000004ULL << 32;
timer->state = s;
timer->period = 0ULL;
timer->wrap_flag = 0;
}
s->hpet_counter = 0ULL;
s->hpet_offset = 0ULL;
s->capability = 0x8086a201ULL;
s->capability |= ((HPET_CLK_PERIOD) << 32);
s->config = 0ULL;
if (count > 0) {
hpet_pit_enable();
}
count = 1;
}
| 1threat |
How to delete a pointer for an object? : <p>I've searched for this but didn't find a similar topic.</p>
<p>If I have an object class, for example <code>class Object { ... };</code> , and I have this pointer for it: <code>Object* p = new Object();</code></p>
<p>I was wondering what is the correct way to delete this pointer, is it this:</p>
<p><code>delete (Object*) p;</code></p>
<p>Or this:</p>
<p><code>delete[] p;</code></p>
<p>I can't tell which one is the correct, I would be happy if someone could tell me what's right.
Thank you <3</p>
| 0debug |
Need help creating a relevancy calculator in JavaScript : <p>folks,</p>
<p>I admit that I'm not super strong with JS when it comes to math, so I'm reaching out here for some help. What I need to do is come up with a relevancy calculator that does the following:</p>
<p>Users have two number fields, the first is labeled '# of people', and the second is labeled '# irrelevant stories'. When the user enters a value for each field, the output on submit is calculated with the following: (# of people value x 0.20$) x (# irrelevant stories value x 30 seconds).</p>
<p>Any guidance or direction would be greatly appreciated!</p>
| 0debug |
Java Lambdas Interfaces : <p>As you all know we engineers works best at nights :)
I was studying lambdas at yesterday night and I saw a piece of code like that,</p>
<pre><code> BirdCompare tester = new BirdCompare();
MathOperation addition = (a, b) -> (a + b);
MathOperation subtraction = (int a, int b) -> (a - b);
MathOperation multiplication = (int a, int b) -> {
return a * b;
};
MathOperation division = (a, b) -> a / b;
interface MathOperation {
int operation(int a, int b);
}
</code></pre>
<p>The sample simply assigned lambda expression to MathOperation interface's variable but how ?
It makes a implementation of method named <strong>operation</strong> which is in the interface and the point I was confused is assignment of that implementation to the variable of interface. I really wonder the idea based on this approach.
Thank you in advance to all.</p>
| 0debug |
vcard_emul_find_vreader_from_slot(PK11SlotInfo *slot)
{
VReaderList *reader_list = vreader_get_reader_list();
VReaderListEntry *current_entry = NULL;
if (reader_list == NULL) {
return NULL;
}
for (current_entry = vreader_list_get_first(reader_list); current_entry;
current_entry = vreader_list_get_next(current_entry)) {
VReader *reader = vreader_list_get_reader(current_entry);
VReaderEmul *reader_emul = vreader_get_private(reader);
if (reader_emul->slot == slot) {
vreader_list_delete(reader_list);
return reader;
}
vreader_free(reader);
}
vreader_list_delete(reader_list);
return NULL;
}
| 1threat |
Localization in external class libraries in ASP.NET Core : <p>I have two projects:</p>
<ul>
<li><strong>MyWebApp</strong> - ASP.NET Core Web API </li>
<li><strong>MyServices</strong> - .NET Core class library,
which contains helpful services for project above</li>
</ul>
<p>How can I add localization with <code>IStringLocalizer</code> to <strong>MyServices</strong>? Where must be <code>.resx</code> files located?</p>
| 0debug |
Your project.json doesn't list 'win10' as a targeted runtime : <p>I hate reposting, but I thought posting to the <a href="https://social.msdn.microsoft.com/Forums/en-US/efb7e560-e2e4-4385-8287-a6ada4e3622b/uwphtml-problem-with-uap-app-running-with-references-to-a-pcl?forum=wpdevelop" rel="noreferrer">MSDN forum</a> was the right thing to do since it looks there are not many people working on UWP apps with HTML/JavaScript, but, since I had no answers at all, I'm turning to the great SO community for help.</p>
<p><em>Problem:</em><br>
I have a very simple UAP app in HTML/JavaScript that has a reference to a Windows Runtime Component which has a reference to a Class Library.</p>
<p>I need to project to run in either PCs and/or mobiles so I need to compile it with Any CPU. The problem is that whenever I want to compile my app I get the following error:</p>
<p><code>Your project.json doesn't list 'win10' as a targeted runtime. You should add '"win10": { }' inside your "runtimes" section in your project.json, and then re-run NuGet restore.</code></p>
<p>And If I do add the plain win10 entry under runtimes, I get many other errors. This is what my project.json looks like:</p>
<pre><code>{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
},
"frameworks": {
"uap10.0": { }
},
"runtimes": {
"win10-arm": { },
"win10-arm-aot": { },
"win10-x86": { },
"win10-x86-aot": { },
"win10-x64": { },
"win10-x64-aot": { }
}
}
</code></pre>
<p>Also, there's a minimal repro <a href="http://1drv.ms/1SOmXSW" rel="noreferrer">here</a> if anybody is interested in checking it out.</p>
| 0debug |
How to address 'OSError: libc not found' raised on Gunicorn exec of Flask app inside Alpine docker container : <p>I'm working on a Flask application based on the Microblog app from Miguel Grinberg's mega-tutorial. Code lives here: <a href="https://github.com/dnilasor/quickgig" rel="noreferrer">https://github.com/dnilasor/quickgig</a> . I have a working docker implementation with a linked MySQL 5.7 container. Today I added an Admin View function using the Flask-Admin module. It works beautifully served locally (OSX) on Flask server via 'flask run' but when I build and run the new docker image (based on python:3.8-alpine), it crashes on boot with a <code>OSError: libc not found</code> error, the code for which seems to indicate <a href="https://github.com/benoitc/gunicorn/blob/438371ee90b9676336a44c7abaeb30ee7fc57a5c/gunicorn/socketfromfd.py#L26" rel="noreferrer">an unknown library</a></p>
<p>It looks to me like Gunicorn is unable to serve the app following my additions. My classmate and I are stumped!</p>
<p>I originally got the error using the python:3.6-alpine base image and so tried with 3.7 and 3.8 to no avail. I also noticed that I was redundantly adding PyMySQL, once in requirements.txt specifying version no. and again explicitly in the dockerfile with no spec. Removed the requirements.txt entry. Also tried incrementing the Flask-Admin version no. up and down. Also tried cleaning up my database migrations as I have seen multiple migration files causing the container to fail to boot (admittedly this was when using SQLite). Now there is only a single migration file and based on the stack trace it seems like the <code>flask db upgrade</code> works just fine.</p>
<p>One thing I have yet to try is a different base image (less minimal?), can try soon and update this. But the issue is so mysterious to me that I thought it time to ask if anyone else has seen it : )</p>
<p>I did find <a href="https://bugs.python.org/issue28134" rel="noreferrer">this socket bug</a> which seemed potentially relevant but it was supposed to be fully fixed in python 3.8.</p>
<p>Also FYI I followed some of the advice <a href="https://github.com/miguelgrinberg/microblog/issues/49" rel="noreferrer">here</a> on circular imports and imported my admin controller function inside <code>create_app</code>.</p>
<p>Dockerfile:</p>
<pre><code>FROM python:3.8-alpine
RUN adduser -D quickgig
WORKDIR /home/quickgig
COPY requirements.txt requirements.txt
RUN python -m venv venv
RUN venv/bin/pip install -r requirements.txt
RUN venv/bin/pip install gunicorn pymysql
COPY app app
COPY migrations migrations
COPY quickgig.py config.py boot.sh ./
RUN chmod +x boot.sh
ENV FLASK_APP quickgig.py
RUN chown -R quickgig:quickgig ./
USER quickgig
EXPOSE 5000
ENTRYPOINT ["./boot.sh"]
</code></pre>
<p>boot.sh:</p>
<pre><code>#!/bin/sh
source venv/bin/activate
while true; do
flask db upgrade
if [[ "$?" == "0" ]]; then
break
fi
echo Upgrade command failed, retrying in 5 secs...
sleep 5
done
# flask translate compile
exec gunicorn -b :5000 --access-logfile - --error-logfile - quickgig:app
</code></pre>
<p>Implementation in <strong>init</strong>.py:</p>
<pre><code>from flask_admin import Admin
app_admin = Admin(name='Dashboard')
def create_app(config_class=Config):
app = Flask(__name__)
app.config.from_object(config_class)
...
app_admin.init_app(app)
...
from app.admin import add_admin_views
add_admin_views()
...
return app
from app import models
</code></pre>
<p>admin.py:</p>
<pre><code>from flask_admin.contrib.sqla import ModelView
from app.models import User, Gig, Neighborhood
from app import db
# Add views to app_admin
def add_admin_views():
from . import app_admin
app_admin.add_view(ModelView(User, db.session))
app_admin.add_view(ModelView(Neighborhood, db.session))
app_admin.add_view(ModelView(Gig, db.session))
</code></pre>
<p>requirements.txt:</p>
<pre><code>alembic==0.9.6
Babel==2.5.1
blinker==1.4
certifi==2017.7.27.1
chardet==3.0.4
click==6.7
dominate==2.3.1
elasticsearch==6.1.1
Flask==1.0.2
Flask-Admin==1.5.4
Flask-Babel==0.11.2
Flask-Bootstrap==3.3.7.1
Flask-Login==0.4.0
Flask-Mail==0.9.1
Flask-Migrate==2.1.1
Flask-Moment==0.5.2
Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2
guess-language-spirit==0.5.3
idna==2.6
itsdangerous==0.24
Jinja2==2.10
Mako==1.0.7
MarkupSafe==1.0
PyJWT==1.5.3
python-dateutil==2.6.1
python-dotenv==0.7.1
python-editor==1.0.3
pytz==2017.2
requests==2.18.4
six==1.11.0
SQLAlchemy==1.1.14
urllib3==1.22
visitor==0.1.3
Werkzeug==0.14.1
WTForms==2.1
</code></pre>
<p>When I run the container in interactive terminal I see the following stack trace:</p>
<pre><code>(venv) ****s-MacBook-Pro:quickgig ****$ docker run -ti quickgig:v7
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> 1f5feeca29ac, test
Traceback (most recent call last):
File "/home/quickgig/venv/bin/gunicorn", line 6, in <module>
from gunicorn.app.wsgiapp import run
File "/home/quickgig/venv/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 9, in <module>
from gunicorn.app.base import Application
File "/home/quickgig/venv/lib/python3.8/site-packages/gunicorn/app/base.py", line 12, in <module>
from gunicorn.arbiter import Arbiter
File "/home/quickgig/venv/lib/python3.8/site-packages/gunicorn/arbiter.py", line 16, in <module>
from gunicorn import sock, systemd, util
File "/home/quickgig/venv/lib/python3.8/site-packages/gunicorn/sock.py", line 14, in <module>
from gunicorn.socketfromfd import fromfd
File "/home/quickgig/venv/lib/python3.8/site-packages/gunicorn/socketfromfd.py", line 26, in <module>
raise OSError('libc not found')
OSError: libc not found
</code></pre>
<p>I'd like the app to boot/be served by gunicorn inside the container so I can continue developing with my team using the docker implementation and leveraging dockerized MySQL vs the pain of local MySQL for development. Can you advise?</p>
| 0debug |
VS Code - Connect to remote GIT repository and PUSH local files to new remote repository : <p>I have created a <strong>local project</strong> with Visual Studio Code that implements a <strong>local GIT repository</strong>.</p>
<p>Then I have create a GIT repository on <strong>Visual Studio Online</strong> and I want to PUSH all my project files to the remote repository...</p>
<p>What is the correct procedure to do it ?</p>
<p>My <strong>.git\config</strong> files in this moment look like this:</p>
<pre><code>[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
</code></pre>
<p>Thanks to support</p>
| 0debug |
Change decimal to integer in SQL : <p>I need to round off decimal value to integer in SQL
<strong>Eg : 748.444645 to 749</strong> </p>
| 0debug |
Java byte array of 1 MB or more takes up twice the RAM : <p>Running the code below on Windows 10 / OpenJDK 11.0.4_x64 produces as output <code>used: 197</code> and <code>expected usage: 200</code>. This means that 200 byte arrays of one million elements take up approx. 200MB RAM. Everything fine.</p>
<p>When I change the byte array allocation in the code from <code>new byte[1000000]</code> to <code>new byte[1048576]</code> (that is, to 1024*1024 elements), it produces as output <code>used: 417</code> and <code>expected usage: 200</code>. What the heck?</p>
<pre><code>import java.io.IOException;
import java.util.ArrayList;
public class Mem {
private static Runtime rt = Runtime.getRuntime();
private static long free() { return rt.maxMemory() - rt.totalMemory() + rt.freeMemory(); }
public static void main(String[] args) throws InterruptedException, IOException {
int blocks = 200;
long initiallyFree = free();
System.out.println("initially free: " + initiallyFree / 1000000);
ArrayList<byte[]> data = new ArrayList<>();
for (int n = 0; n < blocks; n++) { data.add(new byte[1000000]); }
System.gc();
Thread.sleep(2000);
long remainingFree = free();
System.out.println("remaining free: " + remainingFree / 1000000);
System.out.println("used: " + (initiallyFree - remainingFree) / 1000000);
System.out.println("expected usage: " + blocks);
System.in.read();
}
}
</code></pre>
<p>Looking a bit deeper with visualvm, I see in the first case everything as expected:</p>
<p><a href="https://i.stack.imgur.com/Z7lPo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Z7lPo.png" alt="byte arrays take up 200mb"></a></p>
<p>In the second case, in addition to the byte arrays, I see the same number of int arrays taking up the same amount of RAM as the byte arrays:</p>
<p><a href="https://i.stack.imgur.com/W0TnR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/W0TnR.png" alt="int arrays take up additional 200mb"></a></p>
<p>These int arrays, by the way, do not show that they are referenced, but I can't garbage collect them... (The byte arrays show just fine where they are referenced.)</p>
<p>Any ideas what is happening here?</p>
| 0debug |
How to type a text in input box in puppeteer : <p>I need to know how can we type a string in input box using puppeteer. I know it can be done like this:</p>
<pre><code>await page.type('input[name=pickup]', 'test comment', {delay: 200})
</code></pre>
<p>But what if the input box does not have a name or id, and instead it has a value name or title id? Like this:</p>
<pre><code>await page.type('[title id^="pickupAgingComment"]', 'test comment', {delay: 200})
</code></pre>
<p>OR</p>
<pre><code>await page.type('[value name^="pickupAgingComment"]', 'test comment', {delay: 200})
</code></pre>
<p>The last two does not work actually.</p>
| 0debug |
"android: can't find sdkmanager.jar" : <p>I downloaded the Android SDK tools from <a href="https://developer.android.com/studio/index.html" rel="noreferrer">https://developer.android.com/studio/index.html</a> which gave me a zip file called <code>tools_r25.2.3-linux.zip</code>. Unziped, it produced a folder called <code>tools</code>, containing the sdkmanager, <code>android</code>. When I tried to run it, it failed with the error message above.</p>
<p>I set <code>ANDROID_HOME</code> to the <code>tools</code> directory, but it still failed.</p>
| 0debug |
static void init_proc_601 (CPUPPCState *env)
{
gen_spr_ne_601(env);
gen_spr_601(env);
spr_register(env, SPR_HID0, "HID0",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_hid0_601,
0x80010080);
spr_register(env, SPR_HID1, "HID1",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_601_HID2, "HID2",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_601_HID5, "HID5",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
spr_register(env, SPR_601_HID15, "HID15",
SPR_NOACCESS, SPR_NOACCESS,
&spr_read_generic, &spr_write_generic,
0x00000000);
#if !defined(CONFIG_USER_ONLY)
env->nb_tlb = 64;
env->nb_ways = 2;
env->id_tlbs = 0;
#endif
init_excp_601(env);
env->dcache_line_size = 64;
env->icache_line_size = 64;
ppc6xx_irq_init(env);
}
| 1threat |
static void gen_stx(DisasContext *dc, uint32_t code, uint32_t flags)
{
I_TYPE(instr, code);
TCGv val = load_gpr(dc, instr.b);
TCGv addr = tcg_temp_new();
tcg_gen_addi_tl(addr, load_gpr(dc, instr.a), instr.imm16s);
tcg_gen_qemu_st_tl(val, addr, dc->mem_idx, flags);
tcg_temp_free(addr);
}
| 1threat |
document.getElementById('input').innerHTML = user_input; | 1threat |
How to create dynamic link when share button is clicked in android with Firebase? : <p>I want to share user posts with dynamic link so that when anyone clicks the link it opens the app with that post's detail. But I am unable to find any good tutorial. Can anyone help me to create this? </p>
| 0debug |
static void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){
int i;
memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int));
d->mb_incr= s->mb_incr;
for(i=0; i<3; i++)
d->last_dc[i]= s->last_dc[i];
d->mv_bits= s->mv_bits;
d->i_tex_bits= s->i_tex_bits;
d->p_tex_bits= s->p_tex_bits;
d->i_count= s->i_count;
d->p_count= s->p_count;
d->skip_count= s->skip_count;
d->misc_bits= s->misc_bits;
d->last_bits= 0;
d->mb_skiped= s->mb_skiped;
}
| 1threat |
static float quantize_band_cost(struct AACEncContext *s, const float *in,
const float *scaled, int size, int scale_idx,
int cb, const float lambda, const float uplim,
int *bits)
{
const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512];
const float CLIPPED_ESCAPE = 165140.0f*IQ;
int i, j, k;
float cost = 0;
const int dim = cb < FIRST_PAIR_BT ? 4 : 2;
int resbits = 0;
#ifndef USE_REALLY_FULL_SEARCH
const float Q34 = sqrtf(Q * sqrtf(Q));
const int range = aac_cb_range[cb];
const int maxval = aac_cb_maxval[cb];
int offs[4];
#endif
if (!cb) {
for (i = 0; i < size; i++)
cost += in[i]*in[i];
if (bits)
*bits = 0;
return cost * lambda;
}
#ifndef USE_REALLY_FULL_SEARCH
offs[0] = 1;
for (i = 1; i < dim; i++)
offs[i] = offs[i-1]*range;
quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval);
#endif
for (i = 0; i < size; i += dim) {
float mincost;
int minidx = 0;
int minbits = 0;
const float *vec;
#ifndef USE_REALLY_FULL_SEARCH
int (*quants)[2] = &s->qcoefs[i];
mincost = 0.0f;
for (j = 0; j < dim; j++)
mincost += in[i+j]*in[i+j];
minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
minbits = ff_aac_spectral_bits[cb-1][minidx];
mincost = mincost * lambda + minbits;
for (j = 0; j < (1<<dim); j++) {
float rd = 0.0f;
int curbits;
int curidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
int same = 0;
for (k = 0; k < dim; k++) {
if ((j & (1 << k)) && quants[k][0] == quants[k][1]) {
same = 1;
break;
}
}
if (same)
continue;
for (k = 0; k < dim; k++)
curidx += quants[k][!!(j & (1 << k))] * offs[dim - 1 - k];
curbits = ff_aac_spectral_bits[cb-1][curidx];
vec = &ff_aac_codebook_vectors[cb-1][curidx*dim];
#else
mincost = INFINITY;
vec = ff_aac_codebook_vectors[cb-1];
for (j = 0; j < ff_aac_spectral_sizes[cb-1]; j++, vec += dim) {
float rd = 0.0f;
int curbits = ff_aac_spectral_bits[cb-1][j];
#endif
if (IS_CODEBOOK_UNSIGNED(cb)) {
for (k = 0; k < dim; k++) {
float t = fabsf(in[i+k]);
float di;
if (vec[k] == 64.0f) {
if (t < 39.0f*IQ) {
rd = INFINITY;
break;
}
if (t >= CLIPPED_ESCAPE) {
di = t - CLIPPED_ESCAPE;
curbits += 21;
} else {
int c = av_clip(quant(t, Q), 0, 8191);
di = t - c*cbrtf(c)*IQ;
curbits += av_log2(c)*2 - 4 + 1;
}
} else {
di = t - vec[k]*IQ;
}
if (vec[k] != 0.0f)
curbits++;
rd += di*di;
}
} else {
for (k = 0; k < dim; k++) {
float di = in[i+k] - vec[k]*IQ;
rd += di*di;
}
}
rd = rd * lambda + curbits;
if (rd < mincost) {
mincost = rd;
minidx = j;
minbits = curbits;
}
}
cost += mincost;
resbits += minbits;
if (cost >= uplim)
return uplim;
}
if (bits)
*bits = resbits;
return cost;
}
| 1threat |
void disas(FILE *out, void *code, unsigned long size)
{
unsigned long pc;
int count;
struct disassemble_info disasm_info;
int (*print_insn)(bfd_vma pc, disassemble_info *info);
INIT_DISASSEMBLE_INFO(disasm_info, out, fprintf);
disasm_info.buffer = code;
disasm_info.buffer_vma = (unsigned long)code;
disasm_info.buffer_length = size;
#ifdef HOST_WORDS_BIGENDIAN
disasm_info.endian = BFD_ENDIAN_BIG;
#else
disasm_info.endian = BFD_ENDIAN_LITTLE;
#endif
#if defined(__i386__)
disasm_info.mach = bfd_mach_i386_i386;
print_insn = print_insn_i386;
#elif defined(__x86_64__)
disasm_info.mach = bfd_mach_x86_64;
print_insn = print_insn_i386;
#elif defined(_ARCH_PPC)
print_insn = print_insn_ppc;
#elif defined(__alpha__)
print_insn = print_insn_alpha;
#elif defined(__sparc__)
print_insn = print_insn_sparc;
#if defined(__sparc_v8plus__) || defined(__sparc_v8plusa__) || defined(__sparc_v9__)
disasm_info.mach = bfd_mach_sparc_v9b;
#endif
#elif defined(__arm__)
print_insn = print_insn_arm;
#elif defined(__MIPSEB__)
print_insn = print_insn_big_mips;
#elif defined(__MIPSEL__)
print_insn = print_insn_little_mips;
#elif defined(__m68k__)
print_insn = print_insn_m68k;
#elif defined(__s390__)
print_insn = print_insn_s390;
#elif defined(__hppa__)
print_insn = print_insn_hppa;
#elif defined(__ia64__)
print_insn = print_insn_ia64;
#else
fprintf(out, "0x%lx: Asm output not supported on this arch\n",
(long) code);
return;
#endif
for (pc = (unsigned long)code; size > 0; pc += count, size -= count) {
fprintf(out, "0x%08lx: ", pc);
#ifdef __arm__
fprintf(out, "%08x ", (int)bfd_getl32((const bfd_byte *)pc));
#endif
count = print_insn(pc, &disasm_info);
fprintf(out, "\n");
if (count < 0)
break;
}
}
| 1threat |
how change user account inactive as default (codeigniter) ? : i have code codeigniter
i want help with problem ,
**" i want set account as inactive by default "** it's active when user create new account .
<?php // status ?>
<div class="form-group col-sm-3<?php echo form_error('status') ? ' has-error' : ''; ?>">
<?php echo form_label(lang('users input status'), '', array('class'=>'control-label')); ?>
<span class="required">*</span>
<div>
<label style="font-weight:500">
<?php echo form_radio(array('class'=>'radio', 'type'=>'radio', 'name'=>'status', 'id'=>'radio-status-1', 'value'=>'1', 'checked'=>(( ! isset($user['status']) OR (isset($user['status']) && (int)$user['status'] == 1) OR $user['id'] == 1) ? 'checked' : FALSE))); ?>
<span><?php echo lang('admin input active'); ?></span>
</label>
</div>
<?php if ( ! $user['id'] OR $user['id'] > 1) : ?>
<div>
<label style="font-weight:500">
<?php echo form_radio(array('class'=>'radio', 'type'=>'radio', 'name'=>'status', 'id'=>'radio-status-2', 'value'=>'0', 'checked'=>((isset($user['status']) && (int)$user['status'] == 0) ? 'checked' : FALSE))); ?>
<span><?php echo lang('admin input inactive'); ?></span>
</label>
</div>
<?php endif; ?>
</div> | 0debug |
Why cast to a pointer then dereference? : <p>I was going through this example which has a function outputting a hex bit pattern to represent an arbitrary float. </p>
<pre><code>void ExamineFloat(float fValue)
{
printf("%08lx\n", *(unsigned long *)&fValue);
}
</code></pre>
<p>Why take the address of fValue, cast to unsigned long pointer, then dereference? Isn't all that work just equivalent to a direct cast to unsigned long?</p>
<pre><code>printf("%08lx\n", (unsigned long)fValue);
</code></pre>
<p>I tried it and the answer isn't the same, so confused. </p>
| 0debug |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
Javscript based nested for loop along with Objects : I'm new to javascript. when I was working with objects and nested loop. [plunker][1] is available
var a = [{b:[{c:null}]}]
for(var x= 0 ; x<10;x++){
for(var y= 0 ; y<10;y++){
console.log(a);
a[x].b[y].c = y;
console.log(a);
}
}
I was getting error like `TypeError: Cannot set property 'c' of undefined` can some one please explain why it is working like this
[1]: https://plnkr.co/edit/EodiL1wo6xqNEPK4StcS?p=preview | 0debug |
Explain Michael & Scott lock-free queue alorigthm : <p>I am studying Michael & Scott's lock-free queue algorithm and trying to implemented it in C++.</p>
<p>But I produced a race in my code and think there may be a race in the algorithm.</p>
<p>I read the paper here:
<a href="https://www.research.ibm.com/people/m/michael/podc-1996.pdf" rel="noreferrer">Simple, Fast, and Practical Non-Blocking and Blocking
Concurrent Queue Algorithms</a>
and the original Dequeue pseudo-code is as following:</p>
<pre><code>dequeue(Q: pointer to queue_t, pvalue: pointer to data type): boolean
D1: loop // Keep trying until Dequeue is done
D2: head = Q->Head // Read Head
D3: tail = Q->Tail // Read Tail
D4: next = head.ptr->next // Read Head.ptr->next
D5: if head == Q->Head // Are head, tail, and next consistent?
D6: if head.ptr == tail.ptr // Is queue empty or Tail falling behind?
D7: if next.ptr == NULL // Is queue empty?
D8: return FALSE // Queue is empty, couldn't dequeue
D9: endif
// Tail is falling behind. Try to advance it
D10: CAS(&Q->Tail, tail, <next.ptr, tail.count+1>)
D11: else // No need to deal with Tail
// Read value before CAS
// Otherwise, another dequeue might free the next node
D12: *pvalue = next.ptr->value
// Try to swing Head to the next node
D13: if CAS(&Q->Head, head, <next.ptr, head.count+1>)
D14: break // Dequeue is done. Exit loop
D15: endif
D16: endif
D17: endif
D18: endloop
D19: free(head.ptr) // It is safe now to free the old node
D20: return TRUE // Queue was not empty, dequeue succeeded
</code></pre>
<p>In my view, the race is like this:</p>
<ol>
<li>Thread 1 advanced to D3 and then stop.</li>
<li>Thread 2 advanced to D3, read the same head as Thread 1.</li>
<li>Thread 2 luckily advanced all the way to D20, at D19 it freed head.ptr</li>
<li>Thread 1 continues and advanced to D4, trying to read <code>head.ptr->next</code>, but as <code>head.ptr</code> is already freed by Thread 1, crash happens.</li>
</ol>
<p>And my C++ code really always crashes at D4 for Thread 1.</p>
<p>Can anyone please point out my mistake and give some explanation ?</p>
| 0debug |
document.getElementById('input').innerHTML = user_input; | 1threat |
What is the difference between List and ForEach in SwiftUI? : <p>I know SwiftUI does not support currently regular for loops but instead provide something called ForEach but what is the difference between that and a List?</p>
| 0debug |
static av_cold int eightsvx_decode_init(AVCodecContext *avctx)
{
EightSvxContext *esc = avctx->priv_data;
if (avctx->channels < 1 || avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "8SVX does not support more than 2 channels\n");
return AVERROR_INVALIDDATA;
}
switch (avctx->codec->id) {
case AV_CODEC_ID_8SVX_FIB: esc->table = fibonacci; break;
case AV_CODEC_ID_8SVX_EXP: esc->table = exponential; break;
case AV_CODEC_ID_PCM_S8_PLANAR:
case AV_CODEC_ID_8SVX_RAW: esc->table = NULL; break;
default:
av_log(avctx, AV_LOG_ERROR, "Invalid codec id %d.\n", avctx->codec->id);
return AVERROR_INVALIDDATA;
}
avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
avcodec_get_frame_defaults(&esc->frame);
avctx->coded_frame = &esc->frame;
return 0;
}
| 1threat |
static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus)
{
uint16_t i;
for (i = 0; i < smp_cpus; i++) {
Aml *dev = aml_device("C%03x", i);
aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007")));
aml_append(dev, aml_name_decl("_UID", aml_int(i)));
aml_append(scope, dev);
}
}
| 1threat |
while loop with two specific conditions : <p>I've got a code something like:</p>
<pre><code>list1 = input()
while list1 != "y" or list1 != "n":
print()
print("INVALID INPUT")
print()
list1 = input()
</code></pre>
<p>and whenever I run it I get stuck in the loop regardless of the input.</p>
<p>I'd like the loop to end if I enter in either "y" or "n".</p>
| 0debug |
How can we override the constructor while still using the `class` keyword? : <p>Two notable ways to create a class are shown below:</p>
<pre><code>class Klass:
pass
Klass = type("Klass", tuple(), dict())
</code></pre>
<p>I would like to override the constructor (<code>__call__</code>) while still using the <code>class</code> keyword instead of doing something else, like directly calling <code>type</code>. I really do want to override (<code>__call__</code>), not <code>__init__</code></p>
<p>My failed attempts are shown below:</p>
<h2>Attempt 1</h2>
<pre><code>class Foo:
@classmethod
def __call__(*args):
print("arr har")
return super(type(args[0]), args[0]).__call__(*args)
instance = Foo()
# did not print "arr har"
</code></pre>
<h2>Attempt 2</h2>
<pre><code>class BarMeta(type):
def __call__(*args):
print("hello world")
return super(type(args[0]), args[0]).__call__(*args[1:])
</code></pre>
<ul>
<li><h2>Attempt 2A</h2>
<pre><code>class Bar:
__metaclass__ = BarMeta
instance = Bar()
# did not print "hello world"
</code></pre></li>
<li><h2>Attempt 2B</h2>
<pre><code>Baz = BarMeta("Baz", tuple(), dict())
instance = Baz()
# Did print "hello world," but we weren't able to use the `class` keyword to create `Baz`
</code></pre></li>
</ul>
| 0debug |
void op_mtc0_status (void)
{
uint32_t val, old;
uint32_t mask = env->Status_rw_bitmask;
val = T0 & mask;
old = env->CP0_Status;
if (!(val & (1 << CP0St_EXL)) &&
!(val & (1 << CP0St_ERL)) &&
!(env->hflags & MIPS_HFLAG_DM) &&
(val & (1 << CP0St_UM)))
env->hflags |= MIPS_HFLAG_UM;
#ifdef TARGET_MIPS64
if ((env->hflags & MIPS_HFLAG_UM) &&
!(val & (1 << CP0St_PX)) &&
!(val & (1 << CP0St_UX)))
env->hflags &= ~MIPS_HFLAG_64;
#endif
env->CP0_Status = (env->CP0_Status & ~mask) | val;
if (loglevel & CPU_LOG_EXEC)
CALL_FROM_TB2(do_mtc0_status_debug, old, val);
CALL_FROM_TB1(cpu_mips_update_irq, env);
RETURN();
}
| 1threat |
Error "request for member 'nombreIntr' in 'jugadorActual'" Help please :v : It simple one class one obj and still don't know why isn't running...
Help
class jugador{
public:
string nombreIntr(string intr);
private:
string nombre;
};
string jugador::nombreIntr(string intr){
nombre = intr;
return nombre;
}
main(){
jugador jugadorActual();
//G
cout << "G: Bienvenido Jugador!\n\nG: Me dirias tu nombre?\n\n";
//Introducir Nombre
cin >> jugadorActual.nombreIntr(intr); | 0debug |
static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
{
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
CcwDevice *ccw_dev = CCW_DEVICE(d);
SubchDev *sch = ccw_dev->sch;
int n = virtio_get_num_queues(vdev);
S390FLICState *flic = s390_get_flic();
if (!virtio_has_feature(vdev->host_features, VIRTIO_F_VERSION_1)) {
dev->max_rev = 0;
}
if (virtio_get_num_queues(vdev) > VIRTIO_CCW_QUEUE_MAX) {
error_setg(errp, "The number of virtqueues %d "
"exceeds ccw limit %d", n,
VIRTIO_CCW_QUEUE_MAX);
return;
}
if (virtio_get_num_queues(vdev) > flic->adapter_routes_max_batch) {
error_setg(errp, "The number of virtqueues %d "
"exceeds flic adapter route limit %d", n,
flic->adapter_routes_max_batch);
return;
}
sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
d->hotplugged, 1);
}
| 1threat |
TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *old_op,
TCGOpcode opc, int nargs)
{
int oi = s->gen_next_op_idx;
int prev = old_op - s->gen_op_buf;
int next = old_op->next;
TCGOp *new_op;
tcg_debug_assert(oi < OPC_BUF_SIZE);
s->gen_next_op_idx = oi + 1;
new_op = &s->gen_op_buf[oi];
*new_op = (TCGOp){
.opc = opc,
.prev = prev,
.next = next
};
s->gen_op_buf[next].prev = oi;
old_op->next = oi;
return new_op;
}
| 1threat |
NGINX $request_uri vs $uri : <p>How do you determine when to use <code>$request_uri</code> vs <code>$uri</code>?</p>
<p>According to NGINX documentation, <code>$request_uri</code> is the original request (for example, <code>/foo/bar.php?arg=baz</code> includes arguments and can't be modified) but <code>$uri</code> refers to the altered URI.</p>
<p>If the URI doesn't change, does $uri = $request_uri?</p>
<p>Would it be incorrect or better or worse to use:</p>
<pre><code>map $uri $new_uri {
# do something
}
</code></pre>
<p>vs</p>
<pre><code>map $request_uri $new_uri {
# do something
}
</code></pre>
| 0debug |
Does there exist any specifications for HTTP 202 status monitors? : <p>The <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.3" rel="nofollow noreferrer">HTTP 202 Accepted</a> response is used to accept a task for background processing, and optionally providing a separate URL for monitoring the progress of the task. All <a href="https://stackoverflow.com/questions/14832983/http-status-202-how-to-provide-information-about-async-request-completion">answers</a> and <a href="https://restfulapi.net/http-status-202-accepted/" rel="nofollow noreferrer">posts</a> I've read about it basically suggest everyone to invent their own response types for the submission and monitoring endpoints.</p>
<p>Does there exist any specifications / proposals / conventions (followed by multiple companies) as to how the monitoring URL is returned (an HTTP header or response payload) or what the structure of the monitoring API response is?</p>
<p>Failing that, does any big names (Google, Twitter, etc) implement this pattern in their public APIs, from which to gain insight?</p>
| 0debug |
static av_cold int fdk_aac_decode_init(AVCodecContext *avctx)
{
FDKAACDecContext *s = avctx->priv_data;
AAC_DECODER_ERROR err;
int ret;
s->handle = aacDecoder_Open(avctx->extradata_size ? TT_MP4_RAW : TT_MP4_ADTS, 1);
if (!s->handle) {
av_log(avctx, AV_LOG_ERROR, "Error opening decoder\n");
return AVERROR_UNKNOWN;
}
if (avctx->extradata_size) {
if ((err = aacDecoder_ConfigRaw(s->handle, &avctx->extradata,
&avctx->extradata_size)) != AAC_DEC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to set extradata\n");
return AVERROR_INVALIDDATA;
}
}
if ((err = aacDecoder_SetParam(s->handle, AAC_CONCEAL_METHOD,
s->conceal_method)) != AAC_DEC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to set error concealment method\n");
return AVERROR_UNKNOWN;
}
if (avctx->request_channel_layout > 0 &&
avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE) {
int downmix_channels = -1;
switch (avctx->request_channel_layout) {
case AV_CH_LAYOUT_STEREO:
case AV_CH_LAYOUT_STEREO_DOWNMIX:
downmix_channels = 2;
break;
case AV_CH_LAYOUT_MONO:
downmix_channels = 1;
break;
default:
av_log(avctx, AV_LOG_WARNING, "Invalid request_channel_layout\n");
break;
}
if (downmix_channels != -1) {
if (aacDecoder_SetParam(s->handle, AAC_PCM_MAX_OUTPUT_CHANNELS,
downmix_channels) != AAC_DEC_OK) {
av_log(avctx, AV_LOG_WARNING, "Unable to set output channels in the decoder\n");
} else {
s->anc_buffer = av_malloc(DMX_ANC_BUFFSIZE);
if (!s->anc_buffer) {
av_log(avctx, AV_LOG_ERROR, "Unable to allocate ancillary buffer for the decoder\n");
ret = AVERROR(ENOMEM);
goto fail;
}
if (aacDecoder_AncDataInit(s->handle, s->anc_buffer, DMX_ANC_BUFFSIZE)) {
av_log(avctx, AV_LOG_ERROR, "Unable to register downmix ancillary buffer in the decoder\n");
ret = AVERROR_UNKNOWN;
goto fail;
}
}
}
}
if (s->drc_boost != -1) {
if (aacDecoder_SetParam(s->handle, AAC_DRC_BOOST_FACTOR, s->drc_boost) != AAC_DEC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to set DRC boost factor in the decoder\n");
return AVERROR_UNKNOWN;
}
}
if (s->drc_cut != -1) {
if (aacDecoder_SetParam(s->handle, AAC_DRC_ATTENUATION_FACTOR, s->drc_cut) != AAC_DEC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to set DRC attenuation factor in the decoder\n");
return AVERROR_UNKNOWN;
}
}
if (s->drc_level != -1) {
if (aacDecoder_SetParam(s->handle, AAC_DRC_REFERENCE_LEVEL, s->drc_level) != AAC_DEC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to set DRC reference level in the decoder\n");
return AVERROR_UNKNOWN;
}
}
if (s->drc_heavy != -1) {
if (aacDecoder_SetParam(s->handle, AAC_DRC_HEAVY_COMPRESSION, s->drc_heavy) != AAC_DEC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to set DRC heavy compression in the decoder\n");
return AVERROR_UNKNOWN;
}
}
#ifdef AACDECODER_LIB_VL0
if (aacDecoder_SetParam(s->handle, AAC_PCM_LIMITER_ENABLE, s->level_limit) != AAC_DEC_OK) {
av_log(avctx, AV_LOG_ERROR, "Unable to set in signal level limiting in the decoder\n");
return AVERROR_UNKNOWN;
}
#endif
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
s->decoder_buffer_size = DECODER_BUFFSIZE * DECODER_MAX_CHANNELS;
s->decoder_buffer = av_malloc(s->decoder_buffer_size);
if (!s->decoder_buffer) {
ret = AVERROR(ENOMEM);
goto fail;
}
return 0;
fail:
fdk_aac_decode_close(avctx);
return ret;
}
| 1threat |
how to make a method async with async and awit : i understand the use of async and await and when see any method using can understand easily but not able to make it self.
public static Expression<Func<T, bool>> GetExpression<T>(Field filter)
{
ParameterExpression param = Expression.Parameter(typeof(T), "t");
Expression exp = null;
if (filter != null)
{
exp = GetExpression<T>(param, filter);
}
return Expression.Lambda<Func<T, bool>>(exp, param);
}
private static Expression GetExpression<T>(ParameterExpression param,Field filter)
{
var stringMember = Expression.Call(asString, Expression.Convert(member, typeof(object)));
ConstantExpression constant = Expression.Constant(filter.TextToBeFiltered.ToString().ToLower());
switch (filter.Operation)
{
case FilterEnum.Equals:
return Expression.Equal(stringMember, constant);
case FilterEnum.DoesNotEqual:
return Expression.NotEqual(stringMember, constant);
}
return null;
}
how to make these methods as async using async and await
| 0debug |
How do you grab specific rows from csv file while avoiding others? : <p>Say I have 100 lines in a csv file.</p>
<p>However, I want rows 3-9 and 10-37.</p>
<p>Basically trying to skip certain rows. How could I accomplish this?</p>
| 0debug |
adding delete button to a div : I am going to add a delete button to new items made. this delete button removes the item my-item from the page without affecting others.
I have coded like this but I`m not sure if I`m on the right path.
I`ll be glad if you can help me. :)
<!DOCTYPE HTML>
<html>
<head>
<meta charset = "UTF-8">
<title>Simple Demo</title>
<style>
.my-item{
width:250px;
heigth:180px;
margin:10px;
padding:20px;
background:green;
border:2px solid black;
}
.item-header{
width:150px;
heigth:120px;
margin:5px;
padding:10px;
background:yellow;
border:1px solid black;
}
.item-body{
width:70px;
heigth:50px;
margin:3px;
padding:5px;
background:purple;
border:1px solid black;
}
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function() {
$("#divButton").click(function(){
$(".my-item").clone().appendTo("body")
});
$("#toggle").click(function(){
if ($(".item-body").is(":visible")){
$(".item-body").slideUp("normal");
}else{
$(".item-body").slideDown("normal");
}
});
$("#deleteButton").click(function(){
$(".my-item").append(".my-item"+ "button class="deleteButton">Delete</button>");
});
});
</script>
</head>
<body>
<div class="my-item">
<div class="item-header">
<h2 id="toggle">Click Me!</h2>
<div class="item-body">My Text!
</div>
</div>
</div>
<button id="divButton">Click!</button>
<button id="deleteButton">Delete!</button>
</body>
</html> | 0debug |
def find_Nth_Digit(p,q,N) :
while (N > 0) :
N -= 1;
p *= 10;
res = p // q;
p %= q;
return res; | 0debug |
Java .jar gives "The handle is invalid" message but running program in Netbeans does not. : Java .jar gives "The handle is invalid" message but running program in Netbeans does not. Any ideas where to begin would be helpful. This programs moves databases from one IP to another. | 0debug |
Copying Double to a void pointer in C++ : <p>I'm copying a double value to a Void*.How can I do it in C++.</p>
<p>Currently I've tried in C++10</p>
<p>strcpy(Trade->MtTr.MPData->MPTrXML.da,dCou);</p>
<p>Trade->MtTr.MPData->MPTrXML.da-->this is a Void*</p>
<p>dCou is double.</p>
<p>strcpy(Trade->MtTr.MPData->MPTrXML.da,dCou);</p>
<p>I expect the void* should contain the double value.
In actual I'm getting error as:</p>
<p>error C2665: 'strcpy' : none of the 2 overloads could convert all the argument types</p>
<p>while trying to match the argument list '(void *, double)'</p>
| 0debug |
why are my div boxes widening whenever a large text is written? : i had been working on a project in the past days but i came across with a visual error that show my boxes doesn't have a proper right margin.
i had tried changing the flex on css but i didn't get other good results to fix this so i ha to scrap that idea
```<html>
<head>
<title>math lizard</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="nav">
<ul>
<a href=""><li>tema 1</li></a>
<a href=""><li>tema 2</li></a>
<a href=""><li>tema 3</li></a>
</ul>
</div>
<div class="container-temas">
<div class="tema">
<img src="" class="thumbnail">
<h2 class="titulo-tema">titulo del subtema</h2>
<hr>
<p class="descripcion-breve">Esta descripcion demuestra que tema se esta explicando</p>
<a href=""><p class="boton-tema">Entrar</p></a>
</div>
<div class="tema">
<img src="" class="thumbnail">
<h2 class="titulo-tema">titulo del subtema</h2>
<hr>
<p>Esta descripcion demuestra que tema se esta explicando</p>
<a href=""><p class="boton-tema">Entrar</p></a>
</div>
<div class="tema">
<img src="" class="thumbnail">
<h2 class="titulo-tema">titulo del subtema</h2>
<hr>
<p>Esta descripcion demuestra que tema se esta explicando</p>
<a href=""><p class="boton-tema">Entrar</p></a>
</div>
<div class="tema">
<img src="" class="thumbnail">
<h2 class="titulo-tema">titulo del subtema</h2>
<hr>
<p>Esta descripcion demuestra que tema se esta explicando</p>
<a href=""><p class="boton-tema">Entrar</p></a>
</div>
<div class="tema">
<img src="" class="thumbnail">
<h2 class="titulo-tema">titulo del subtema</h2>
<hr>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut dapibus tincidunt vehicula. Sed nec ante molestie, dignissim sapien et, finibus felis. Mauris a enim eget sapien laoreet interdum id a tellus. Duis blandit et lorem non aliquet. Vivamus id tellus ut eros finibus tempor ac ac sem. Etiam lacinia nisl eu varius ullamcorper. Vestibulum finibus ligula aliquam ipsum fringilla, nec luctus dolor ultrices.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur est est, aliquet ut commodo at, luctus sit amet nunc. Aenean in aliquet neque, vitae commodo tellus. Nulla et semper massa. Quisque tristique turpis ante, non semper libero fringilla a. Praesent et arcu id massa semper iaculis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; </p>
<a href=""><p class="boton-tema">Entrar</p></a>
</div>
</div>
</body>
</html>
```
```* {
margin: 0;
padding: 0;
}
body {
background-color: #003300;
}
.nav {
background-color: #00b300;
margin-bottom: 0%;
}
ul {
margin-left: 75%;
}
li {
padding: 20px;
display: inline-block;
}
a {
text-align: center;
color: white;
list-style: none;
text-decoration: none;
}
li:hover {
-moz-transition-duration: 0.3s;
background-color: #004d00;
}
.post {
padding: 20px;
background-color: white;
margin-right: 5%;
margin-left: 30%;
margin-top: 5%;
border-radius: 15px;
}
h1 {
text-align: center;
}
.form {
background-color: #404040;
margin-left: 1%;
margin-right: 70%;
padding: 20px;
border-radius: 15px;
}
.link {
background-color: #19194d;
margin-left: 15px;
margin-right: 15px;
padding: 10px;
border-radius: 15px;
color: white;
}
.link:hover {
background-color: #0c0c27;
-moz-transition-duration: 0.3s;
}
* {
margin: 0;
padding: 0;
}
body {
background-color: #003300;
}
.nav {
background-color: #00b300;
margin-bottom: 0%;
}
ul {
margin-left: 75%;
}
li {
padding: 20px;
display: inline-block;
}
a {
text-align: center;
color: white;
list-style: none;
text-decoration: none;
}
li:hover {
-moz-transition-duration: 0.3s;
background-color: #004d00;
}
.post {
padding: 20px;
background-color: white;
border-radius: 15px;
}
h1 {
text-align: center;
}
.form {
background-color: #404040;
padding: 20px;
border-radius: 15px;
}
.link {
background-color: #19194d;
margin-left: 15px;
margin-right: 15px;
padding: 10px;
border-radius: 15px;
color: white;
}
.link:hover {
background-color: #0c0c27;
-moz-transition-duration: 0.3s;
}
/* Flex container */
.container {
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 20px;
}
/* Make post larger than form */
.post {
flex: 3;
margin-left: -65%;
}
.form {
flex: 1;
}
.tema {
background-color: white;
margin-top: 20px;
margin-left: 2%;
padding: 20px;
border-radius: 15px;
}
.thumbnail {
border: solid;
width: 100%;
height: 100px;
}
.titulo-tema {
text-align: center;
}
.boton-tema {
background-color: #00b300;
text-align: center;
padding: 20px;
margin-left: 150px;
margin-right: 150px;
margin-top: 20px;
border-radius: 15px;
}
.boton-tema:hover {
background-color: #004d00;
-moz-transition-duration: 0.3s;
}
.container-temas {
display: flex;
justify-content: space-between;
padding: 20px;
flex-wrap: wrap;
}
@media screen and (min-width: 480px) {
ul {
margin-left: 0%;
}
.container {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 20px;
}
.post {
margin-left: 0%;
margin-bottom: -40%;
margin-right: 0%;
}
.form {
margin-right: 20%;
margin-left: 20%;
}
li {
padding: 70px;
}
h1 {
font-size: 50px;
}
p {
font-size: 40px;
}
.titulo-tema {
font-size: 50px;
}
}
@media screen and (min-width: 767px) {
ul {
margin-left: 35%;
}
.container {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 20px;
}
.post {
margin-left: 0%;
margin-bottom: -80%;
margin-right: 0%;
}
.form {
margin-right: 20%;
margin-left: 20%;
}
li {
padding: 70px;
}
h1 {
font-size: 70px;
}
p {
font-size: 40px;
}
.titulo-tema {
font-size: 70px;
}
}
@media screen and (min-width: 1030px) {
ul {
margin-left: 75%;
}
.container {
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 20px;
}
.post {
margin-left: -65%;
margin-bottom: 0%;
margin-right: 0%;
}
.form {
margin-right: 70%;
margin-left: 0%;
margin-bottom: 0%;
}
li {
padding: 20px;
}
h1 {
font-size: 30px;
}
p {
font-size: 20px;
}
.titulo-tema {
font-size: 30px;
}
}
```
i just expect to get a proper margin so this problem won't happend everytime a long text is posted on the index | 0debug |
Call php file inside an html without using input tag : is there any way to call a php file inside an HTML document without using an input tag. I am trying to display some results of my database (as a table) using the form tag (file2.php) but I realised that the only way to display the results is to have an input tag inside the form tag. Is there any way to simply display the results in my html website without using inputs?
My code is
---
<html>
<body>
<img src="file1.php">
<form action="file2.php" method="post">
<input type="submit" value="submit">
</form>
</body>
<html>
My file2.php is
---
<?php
define('DB_NAME', 'name');
define('DB_USER', 'yyyy');
define('DB_PASSWORD', 'xxxx');
define('DB_HOST', 'localhost');
$link=mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link){
die('Could not connect:' .mysql_error());
}
$db_selected = mysql_select_db(DB_NAME,$link);
if(!$db_selected){
die('Can\'t use' .DB_NAME .':' . mysql_error());
}
$cid=$_COOKIE["cid"];
$sql= "SELECT * FROM table WHERE PID='$cid' ORDER BY SUBTIME ASC;";
$result = mysql_query($sql);
echo "<table border=1>
<tr>
<th> SUBMISSION DATE/TIME </th>
<th> SYS </th>
<th> DIA </th>
<th> PULSE </th>
<th> WEIGHT </th>
</tr>";
while ($row = mysql_fetch_array($result)){
echo "<tr>";
echo "<td align='center'>" . $row['SUBTIME'] . "</td>";
echo "<td align='center'>" . $row['SYS'] . "</td>";
echo "<td align='center'>" . $row['DIA'] . "</td>";
echo "<td align='center'>" . $row['PULSE'] . "</td>";
echo "<td align='center'>" . $row['WEIGHT'] . "</td>";
echo "</tr>";
}
if(!mysql_query($sql)){
die('Error:' .mysql_error());
}
mysql_close();
?> | 0debug |
Can you tell me why I get "Can't use query methods that take a query string on a PreparedStatement."? : <p>I keep hitting an error "Can't use query methods that take a query string on a PreparedStatement." when trying to debug the following code & SQL Select query. (Postgres 9.4, jdk 1.8) Maybe I'm blind and it's a simple type, but I could use some help.</p>
<p>My Console Ouput: </p>
<blockquote>
<p>SELECT rowid, firstname, lastname, prefname, email1, email2, email3, type, status, preflang, mbrappid, deviceid, mbrstatus, mbrtype, mbrcat, pr_phonevoice FROM qbirt.person WHERE pr_sms = 47 ORDER BY lastupdt DESC</p>
<p>E R R O R
JDBC Prep'd Stmt error on Primary Phone FKey...
Phone FKey: 47 </p>
<p>SQLException: Can't use query methods that take a query string on a PreparedStatement.
SQLState: 42809
VendorError: 0
org.postgresql.util.PSQLException: Can't use query methods that take a query string on a PreparedStatement.
at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:102) at solutions.demand.qbirt.Person.findMember(Person.java:762)`</p>
</blockquote>
<p>Portion of code:</p>
<pre><code> if (!foundMbr && foundPhoneID > 0) {
if (QbirtUtils.verbose) {
System.out.println("Querying Person by FK ID for phones: " + foundPhoneID + "\n");
}
if (mode.equals(pMode.SMS)) {
qry = "SELECT rowid, firstname, lastname, prefname, email1, email2, email3, type, "
+ "status, preflang, mbrappid, deviceid, mbrstatus, mbrtype, mbrcat, pr_phonevoice "
+ "FROM qbirt.person "
+ "WHERE pr_sms = ? "
+ "ORDER BY lastupdt DESC;";
} else {
if (mode.equals(pMode.VOICE)) {
qry = "SELECT rowid, firstname, lastname, prefname, email1, email2, email3, type, "
+ "status, preflang, mbrappid, deviceid, mbrstatus, mbrtype, mbrcat, pr_phonevoice "
+ "FROM qbirt.person "
+ "WHERE pr_phonevoice = ? "
+ "ORDER BY lastupdt DESC;";
} else {
if (mode.equals(pMode.PHONE)) {
qry = "SELECT DISTINCT ON (rowid) rowid, firstname, lastname, prefname, email1, email2, email3, type, "
+ "status, preflang, mbrappid, deviceid, mbrstatus, mbrtype, mbrcat, pr_phonevoice "
+ "FROM qbirt.person "
+ "WHERE (pr_sms = ? OR pr_phonevoice = ?) "
+ "ORDER BY lastupdt DESC, rowid DESC;";
}
}
}
try {
PreparedStatement pStmt = conn.prepareStatement(qry);
pStmt.setInt(1, foundPhoneID);
if (mode.equals(pMode.PHONE)) {
pStmt.setInt(2, foundPhoneID);
}
System.out.println(pStmt.toString());
ResultSet rs = pStmt.executeQuery(qry); <-------
</code></pre>
<p>I have confirmed that the fields contain the following values:<br>
<code>foundMbr</code> = false, <code>foundPhoneID</code> = 47, <code>mode</code> = SMS, and that <code>qry = "SELECT rowid, firstname, lastname, prefname, email1, email2, email3, type, status, preflang, mbrappid, deviceid, mbrstatus, mbrtype, mbrcat, pr_phonevoice FROM qbirt.person WHERE pr_sms = ? ORDER BY lastupdt DESC;";</code></p>
<p>I get the error on the line: <code>ResultSet rs = pStmt.executeQuery(qry);</code></p>
<p>As you can see in the console, I have even confirmed that the pStmt is holding the correct binding because I print it out. - That said, it seems to be missing the ending ';'. Not sure why that is because I can see it in the qry string. I assume that is just a quirk of the preparedStatment.</p>
<p>I have also copied this exact SQL into pgAdmin III and successfully executed it manually. Although, I did have to add back the ';'. I use virtually this same code in many other areas without problem.</p>
<p>Could it be that the missing ';'?<br>
Maybe some sort of type mismatch? (foundPhoneID is an int., rowid is a serial/integer, pr_sms is an integer FKey)<br>
Could it be the block of if statements that defines the qry string?</p>
<p>TIA!</p>
| 0debug |
Cant get Object String value (Need to convert to String for Compare) : I want to check if the value does exist or not in JTree when trying to add node from Jtree.
(the values does not match case i got object code not string)
Here is the action code for calling existsInTable()
try {
DefaultMutableTreeNode selectedElement = (DefaultMutableTreeNode) TestTree.getSelectionPath().getLastPathComponent();
Object[] row = {selectedElement};
DefaultTableModel model = (DefaultTableModel) myTests_table.getModel();
if (selectedElement.isLeaf() == true && existsInTable(myTests_table, row) == false) {
model.addRow(row);
} else {
JOptionPane.showMessageDialog(null, "Please Choose Test name!", "Error", JOptionPane.WARNING_MESSAGE);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error");
}
Here are the Check method
public boolean existsInTable(JTable table, Object[] testname) {
int row = table.getRowCount();
for (int i = 0; i < row; i++) {
String str = "";
str = table.getValueAt(i, 0).toString();
if (testname.equals(str)) {
System.out.println(str);
JOptionPane.showMessageDialog(null, "data alreadyexist.", "message", JOptionPane.PLAIN_MESSAGE);
return true;
}
}
return false;
} | 0debug |
I know the difference between assert and verify but wanted to know the syntax of verify in selenium webdriver with java : <p>I know the difference between assert and verify but wanted to know the syntax of verify in selenium web driver with java</p>
| 0debug |
static inline TCGv gen_ld8u(TCGv addr, int index)
{
TCGv tmp = new_tmp();
tcg_gen_qemu_ld8u(tmp, addr, index);
return tmp;
}
| 1threat |
void helper_stf_asi(target_ulong addr, int asi, int size, int rd)
{
unsigned int i;
target_ulong val = 0;
helper_check_align(addr, 3);
addr = asi_address_mask(env, asi, addr);
switch (asi) {
case 0xe0:
case 0xe1:
case 0xf0:
case 0xf1:
case 0xf8: LE
case 0xf9: LE
helper_st_asi(addr, val, asi & 0x8f, 4);
default:
break;
switch(size) {
default:
case 4:
val = *((uint32_t *)&env->fpr[rd]);
break;
case 8:
val = *((int64_t *)&DT0);
break;
case 16:
break;
helper_st_asi(addr, val, asi, size); | 1threat |
PostgreSQL(Full Text Search) vs ElasticSearch : <p>Hi I am doing some research before I implement search feature into my service.
I'm currently using PostgreSQL as my main storage. I could definitely use PostgreSQL's built-in Full-Text-Search but the problem is that I have data scattered around several tables. </p>
<p>My service is an e-commerce website. So if a customer searches "good apple laptop", I need to join <code>Brand</code> table, <code>post</code> table and <code>review</code> table(1 post is a combination of several reviews + short summary) to fully search all posts. If I were to use elasticsearch, I could insert complete posts by preprocessing.</p>
<p>From my research, some people said PostgreSQL's FTS and elasticsearch have similar performance and some people said elasticsearch is faster. Which would be better solution for my case?</p>
<p>Thanks in advance</p>
| 0debug |
static bool vfio_listener_skipped_section(MemoryRegionSection *section)
{
return !memory_region_is_ram(section->mr);
}
| 1threat |
static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *buf, const uint8_t *end_buf)
{
int tag, type, count, off, value = 0;
int i, j;
uint32_t *pal;
const uint8_t *rp, *gp, *bp;
tag = tget_short(&buf, s->le);
type = tget_short(&buf, s->le);
count = tget_long(&buf, s->le);
off = tget_long(&buf, s->le);
if(count == 1){
switch(type){
case TIFF_BYTE:
case TIFF_SHORT:
buf -= 4;
value = tget(&buf, type, s->le);
buf = NULL;
break;
case TIFF_LONG:
value = off;
buf = NULL;
break;
case TIFF_STRING:
if(count <= 4){
buf -= 4;
break;
}
default:
value = -1;
buf = start + off;
}
}else if(type_sizes[type] * count <= 4){
buf -= 4;
}else{
buf = start + off;
}
if(buf && (buf < start || buf > end_buf)){
av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n");
return -1;
}
switch(tag){
case TIFF_WIDTH:
s->width = value;
break;
case TIFF_HEIGHT:
s->height = value;
break;
case TIFF_BPP:
if(count == 1) s->bpp = value;
else{
switch(type){
case TIFF_BYTE:
s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) + ((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);
break;
case TIFF_SHORT:
case TIFF_LONG:
s->bpp = 0;
for(i = 0; i < count; i++) s->bpp += tget(&buf, type, s->le);
break;
default:
s->bpp = -1;
}
}
if(count > 4){
av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count);
return -1;
}
switch(s->bpp*10 + count){
case 11:
s->avctx->pix_fmt = PIX_FMT_MONOBLACK;
break;
case 81:
s->avctx->pix_fmt = PIX_FMT_PAL8;
break;
case 243:
s->avctx->pix_fmt = PIX_FMT_RGB24;
break;
case 161:
s->avctx->pix_fmt = PIX_FMT_GRAY16BE;
break;
case 324:
s->avctx->pix_fmt = PIX_FMT_RGBA;
break;
case 483:
s->avctx->pix_fmt = s->le ? PIX_FMT_RGB48LE : PIX_FMT_RGB48BE;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count);
return -1;
}
if(s->width != s->avctx->width || s->height != s->avctx->height){
if(av_image_check_size(s->width, s->height, 0, s->avctx))
return -1;
avcodec_set_dimensions(s->avctx, s->width, s->height);
}
if(s->picture.data[0])
s->avctx->release_buffer(s->avctx, &s->picture);
if(s->avctx->get_buffer(s->avctx, &s->picture) < 0){
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
if(s->bpp == 8){
pal = (uint32_t *) s->picture.data[1];
for(i = 0; i < 256; i++)
pal[i] = i * 0x010101;
}
break;
case TIFF_COMPR:
s->compr = value;
s->predictor = 0;
switch(s->compr){
case TIFF_RAW:
case TIFF_PACKBITS:
case TIFF_LZW:
case TIFF_CCITT_RLE:
break;
case TIFF_G3:
case TIFF_G4:
s->fax_opts = 0;
break;
case TIFF_DEFLATE:
case TIFF_ADOBE_DEFLATE:
#if CONFIG_ZLIB
break;
#else
av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");
return -1;
#endif
case TIFF_JPEG:
case TIFF_NEWJPEG:
av_log(s->avctx, AV_LOG_ERROR, "JPEG compression is not supported\n");
return -1;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n", s->compr);
return -1;
}
break;
case TIFF_ROWSPERSTRIP:
if(type == TIFF_LONG && value == -1)
value = s->avctx->height;
if(value < 1){
av_log(s->avctx, AV_LOG_ERROR, "Incorrect value of rows per strip\n");
return -1;
}
s->rps = value;
break;
case TIFF_STRIP_OFFS:
if(count == 1){
s->stripdata = NULL;
s->stripoff = value;
}else
s->stripdata = start + off;
s->strips = count;
if(s->strips == 1) s->rps = s->height;
s->sot = type;
if(s->stripdata > end_buf){
av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n");
return -1;
}
break;
case TIFF_STRIP_SIZE:
if(count == 1){
s->stripsizes = NULL;
s->stripsize = value;
s->strips = 1;
}else{
s->stripsizes = start + off;
}
s->strips = count;
s->sstype = type;
if(s->stripsizes > end_buf){
av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n");
return -1;
}
break;
case TIFF_PREDICTOR:
s->predictor = value;
break;
case TIFF_INVERT:
switch(value){
case 0:
s->invert = 1;
break;
case 1:
s->invert = 0;
break;
case 2:
case 3:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n", value);
return -1;
}
break;
case TIFF_FILL_ORDER:
if(value < 1 || value > 2){
av_log(s->avctx, AV_LOG_ERROR, "Unknown FillOrder value %d, trying default one\n", value);
value = 1;
}
s->fill_order = value - 1;
break;
case TIFF_PAL:
if(s->avctx->pix_fmt != PIX_FMT_PAL8){
av_log(s->avctx, AV_LOG_ERROR, "Palette met but this is not palettized format\n");
return -1;
}
pal = (uint32_t *) s->picture.data[1];
off = type_sizes[type];
rp = buf;
gp = buf + count / 3 * off;
bp = buf + count / 3 * off * 2;
off = (type_sizes[type] - 1) << 3;
for(i = 0; i < count / 3; i++){
j = (tget(&rp, type, s->le) >> off) << 16;
j |= (tget(&gp, type, s->le) >> off) << 8;
j |= tget(&bp, type, s->le) >> off;
pal[i] = j;
}
break;
case TIFF_PLANAR:
if(value == 2){
av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n");
return -1;
}
break;
case TIFF_T4OPTIONS:
if(s->compr == TIFF_G3)
s->fax_opts = value;
break;
case TIFF_T6OPTIONS:
if(s->compr == TIFF_G4)
s->fax_opts = value;
break;
}
return 0;
}
| 1threat |
static void do_io_interrupt(CPUS390XState *env)
{
LowCore *lowcore;
IOIntQueue *q;
uint8_t isc;
int disable = 1;
int found = 0;
if (!(env->psw.mask & PSW_MASK_IO)) {
cpu_abort(env, "I/O int w/o I/O mask\n");
}
for (isc = 0; isc < ARRAY_SIZE(env->io_index); isc++) {
if (env->io_index[isc] < 0) {
continue;
}
if (env->io_index[isc] > MAX_IO_QUEUE) {
cpu_abort(env, "I/O queue overrun for isc %d: %d\n",
isc, env->io_index[isc]);
}
q = &env->io_queue[env->io_index[isc]][isc];
if (!(env->cregs[6] & q->word)) {
disable = 0;
continue;
}
if (!found) {
uint64_t mask, addr;
found = 1;
lowcore = cpu_map_lowcore(env);
lowcore->subchannel_id = cpu_to_be16(q->id);
lowcore->subchannel_nr = cpu_to_be16(q->nr);
lowcore->io_int_parm = cpu_to_be32(q->parm);
lowcore->io_int_word = cpu_to_be32(q->word);
lowcore->io_old_psw.mask = cpu_to_be64(get_psw_mask(env));
lowcore->io_old_psw.addr = cpu_to_be64(env->psw.addr);
mask = be64_to_cpu(lowcore->io_new_psw.mask);
addr = be64_to_cpu(lowcore->io_new_psw.addr);
cpu_unmap_lowcore(lowcore);
env->io_index[isc]--;
DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__,
env->psw.mask, env->psw.addr);
load_psw(env, mask, addr);
}
if (env->io_index[isc] >= 0) {
disable = 0;
}
continue;
}
if (disable) {
env->pending_int &= ~INTERRUPT_IO;
}
}
| 1threat |
How do I do a patch request using HttpClient in dotnet core? : <p>I am trying to create a <code>Patch</code> request with the<code>HttpClient</code> in dotnet core. I have found the other methods,</p>
<pre><code>using (var client = new HttpClient())
{
client.GetAsync("/posts");
client.PostAsync("/posts", ...);
client.PutAsync("/posts", ...);
client.DeleteAsync("/posts");
}
</code></pre>
<p>but can't seem to find the <code>Patch</code> option. Is it possible to do a <code>Patch</code> request with the <code>HttpClient</code>? If so, can someone show me an example how to do it?</p>
| 0debug |
static SocketAddress *sd_server_config(QDict *options, Error **errp)
{
QDict *server = NULL;
QObject *crumpled_server = NULL;
Visitor *iv = NULL;
SocketAddressFlat *saddr_flat = NULL;
SocketAddress *saddr = NULL;
Error *local_err = NULL;
qdict_extract_subqdict(options, &server, "server.");
crumpled_server = qdict_crumple(server, errp);
if (!crumpled_server) {
goto done;
}
iv = qobject_input_visitor_new(crumpled_server);
visit_type_SocketAddressFlat(iv, NULL, &saddr_flat, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto done;
}
saddr = socket_address_crumple(saddr_flat);
done:
qapi_free_SocketAddressFlat(saddr_flat);
visit_free(iv);
qobject_decref(crumpled_server);
QDECREF(server);
return saddr;
}
| 1threat |
def Odd_Length_Sum(arr):
Sum = 0
l = len(arr)
for i in range(l):
Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i])
return Sum | 0debug |
Is the algorithm that involves n choose k exponetial : Say if we have an algorithm needs to choose k elements from n elements (k>=n), is the time complexity of the particular algorithm exponential and why? | 0debug |
Sed : Substitude all characters between two string by char 'X' : In a bas script, i am trying to in-file replace the characters between two given strings by 'X'. I have bunch of string pair, between which I want the replacement of characters by 'X' should happen.
This is what I am doing.
declare -a cpi_list=('%26Name%3d' '%26Pwd%3d')
myAnd=\%26
newfile="inputlog.txt"
for item in "${cpi_list[@]}";
do
sed -i -e :a -e "s/\($item[X]*\)[^X]\(.*"$myAnd"\)/\1X\2/;ta" $newfile;
done
The input
`CPI.%26Name%3dJASON%26Pwd%3dBOTTLE%26Name%3dCOTT`
I want to make it
`CPI.%26Name%3dXXXXX%26Pwd%3dXXXXXX%26Name%3dXXXX`
But somehow it is not working.
Please help. | 0debug |
int bdrv_snapshot_goto(BlockDriverState *bs,
const char *snapshot_id,
Error **errp)
{
BlockDriver *drv = bs->drv;
int ret, open_ret;
int64_t len;
if (!drv) {
error_setg(errp, "Block driver is closed");
return -ENOMEDIUM;
}
len = bdrv_getlength(bs);
if (len < 0) {
error_setg_errno(errp, -len, "Cannot get block device size");
return len;
}
bdrv_set_dirty(bs, 0, len);
if (drv->bdrv_snapshot_goto) {
ret = drv->bdrv_snapshot_goto(bs, snapshot_id);
if (ret < 0) {
error_setg_errno(errp, -ret, "Failed to load snapshot");
}
return ret;
}
if (bs->file) {
BlockDriverState *file;
QDict *options = qdict_clone_shallow(bs->options);
QDict *file_options;
Error *local_err = NULL;
file = bs->file->bs;
bdrv_ref(file);
qdict_extract_subqdict(options, &file_options, "file.");
QDECREF(file_options);
qdict_put_str(options, "file", bdrv_get_node_name(file));
drv->bdrv_close(bs);
bdrv_unref_child(bs, bs->file);
bs->file = NULL;
ret = bdrv_snapshot_goto(file, snapshot_id, errp);
open_ret = drv->bdrv_open(bs, options, bs->open_flags, &local_err);
QDECREF(options);
if (open_ret < 0) {
bdrv_unref(file);
bs->drv = NULL;
error_propagate(errp, local_err);
return ret < 0 ? ret : open_ret;
}
assert(bs->file->bs == file);
bdrv_unref(file);
return ret;
}
error_setg(errp, "Block driver does not support snapshots");
return -ENOTSUP;
}
| 1threat |
static void check_pred16x16(H264PredContext *h, uint8_t *buf0, uint8_t *buf1,
int codec, int chroma_format, int bit_depth)
{
if (chroma_format == 1) {
int pred_mode;
declare_func(void, uint8_t *src, ptrdiff_t stride);
for (pred_mode = 0; pred_mode < 9; pred_mode++) {
if (check_pred_func(h->pred16x16[pred_mode], "16x16", pred16x16_modes[codec][pred_mode])) {
randomize_buffers();
call_ref(src0, 48);
call_new(src1, 48);
if (memcmp(buf0, buf1, BUF_SIZE))
fail();
bench_new(src1, 48);
}
}
}
}
| 1threat |
static void omap_mcbsp_sink_tick(void *opaque)
{
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
static const int bps[8] = { 0, 1, 1, 2, 2, 2, -255, -255 };
if (!s->tx_rate)
return;
if (s->tx_req)
printf("%s: Tx FIFO underrun\n", __FUNCTION__);
s->tx_req = s->tx_rate << bps[(s->xcr[0] >> 5) & 7];
omap_mcbsp_tx_newdata(s);
timer_mod(s->sink_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
NANOSECONDS_PER_SECOND);
}
| 1threat |
static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr,
AVPacket* avpkt)
{
WmallDecodeCtx *s = avctx->priv_data;
GetBitContext* gb = &s->pgb;
const uint8_t* buf = avpkt->data;
int buf_size = avpkt->size;
int num_bits_prev_frame, packet_sequence_number, spliced_packet;
s->frame.nb_samples = 0;
if (s->packet_done || s->packet_loss) {
s->packet_done = 0;
if (buf_size < avctx->block_align)
return 0;
s->next_packet_start = buf_size - avctx->block_align;
buf_size = avctx->block_align;
s->buf_bit_size = buf_size << 3;
init_get_bits(gb, buf, s->buf_bit_size);
packet_sequence_number = get_bits(gb, 4);
skip_bits(gb, 1);
spliced_packet = get_bits1(gb);
if (spliced_packet)
avpriv_request_sample(avctx, "Bitstream splicing");
num_bits_prev_frame = get_bits(gb, s->log2_frame_size);
if (!s->packet_loss &&
((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
s->packet_loss = 1;
av_log(avctx, AV_LOG_ERROR, "Packet loss detected! seq %x vs %x\n",
s->packet_sequence_number, packet_sequence_number);
}
s->packet_sequence_number = packet_sequence_number;
if (num_bits_prev_frame > 0) {
int remaining_packet_bits = s->buf_bit_size - get_bits_count(gb);
if (num_bits_prev_frame >= remaining_packet_bits) {
num_bits_prev_frame = remaining_packet_bits;
s->packet_done = 1;
}
save_bits(s, gb, num_bits_prev_frame, 1);
if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
decode_frame(s);
} else if (s->num_saved_bits - s->frame_offset) {
av_dlog(avctx, "ignoring %x previously saved bits\n",
s->num_saved_bits - s->frame_offset);
}
if (s->packet_loss) {
s->num_saved_bits = 0;
s->packet_loss = 0;
init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
}
} else {
int frame_size;
s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3;
init_get_bits(gb, avpkt->data, s->buf_bit_size);
skip_bits(gb, s->packet_offset);
if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size &&
(frame_size = show_bits(gb, s->log2_frame_size)) &&
frame_size <= remaining_bits(s, gb)) {
save_bits(s, gb, frame_size, 0);
s->packet_done = !decode_frame(s);
} else if (!s->len_prefix
&& s->num_saved_bits > get_bits_count(&s->gb)) {
s->packet_done = !decode_frame(s);
} else {
s->packet_done = 1;
}
}
if (s->packet_done && !s->packet_loss &&
remaining_bits(s, gb) > 0) {
save_bits(s, gb, remaining_bits(s, gb), 0);
}
*(AVFrame *)data = s->frame;
*got_frame_ptr = s->frame.nb_samples > 0;
s->packet_offset = get_bits_count(gb) & 7;
return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
}
| 1threat |
How to present an empty view in flutter? : <p>How to present an empty view in flutter as Widget.build cannot return null to indicate that there is nothing to render.</p>
| 0debug |
PHP Check if User is already registered : <p>I have an issue with my code to check if a username is already registered. I did a search on here to look at the different solutions and implemented some of them on my code but I still can't seem to get it to work. I tried registering the same username multiple times it still lets register without alerting me that the username is already taken. I apologize if this is easy to solve as I am new to php and mysql.</p>
<p>I tried multiple solutions but none seem to work for me. This is my latest iteration of my code.</p>
<pre><code><?php
session_start();
if (isset($_POST['submit'])) {
$dbCon = mysqli_connect("localhost", "root", "badassrichv", "FootballDB");
if (mysqli_connect_errno()) {
echo "Failed to connect: " . mysqli_connect_error();
}
$username = strip_tags($_POST['name']);
$password = strip_tags($_POST['password']);
$email = strip_tags($_POST['email']);
$checkName = 'SELECT * FROM user WHERE username = "$username"';
$run = mysqli_query($dbCon, $checkName);
$data = mysqli_fetch_array($run, MYSQLI_NUM);
if ($data[0] > 0) {
echo "<script>alert('Name already registered. Input a different name')</script>";
exit();
} else {
$sql = "INSERT INTO user (username, password, email) VALUES ('$username', '$password', '$email')";
}
....More code
</code></pre>
| 0debug |
static void co_sleep_cb(void *opaque)
{
CoSleepCB *sleep_cb = opaque;
aio_co_wake(sleep_cb->co);
} | 1threat |
Delegete function is not firing-Swift 4 : Scenario:
I have a table view and a custom button cell.In controller of cell I have made a delegete to call a function of MainController.
Issue is my cell button action is firing but the delete function not.
CustomCell Controller:
import UIKit
protocol CustChatButtonDelegate: class {
func chatActionClick(cell: CustButtonCell)
}
class CustButtonCell: UITableViewCell {
var delegete:CustChatButtonDelegate?
@IBOutlet weak var btnChat: UIButton!
override func prepareForReuse() {
super.prepareForReuse()
// self.delegete=nil
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
@IBAction func btnChatActionClick(_ sender: Any) {
print("btn click")
self.delegete?.chatActionClick(cell: self)
}
}
MainController:
import UIKit
class ChatController: UIViewController ,UITableViewDelegate, UITableViewDataSource, ChatButtonDelegate,CustChatButtonDelegate {
func chatActionClick(cell: CustButtonCell) {
print("btnClicked")
}
} | 0debug |
Deploying React js Application : <p>I'm super new to the world of React
I built a single page application.</p>
<p>Can I deploy the app to GoDaddy server? How?</p>
<p>I used create-react-app</p>
<p>Bests</p>
| 0debug |
static void add_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels,
int line_size)
{
int i;
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
for(i=0;i<4;i++) {
pixels[0] = cm[pixels[0] + block[0]];
pixels[1] = cm[pixels[1] + block[1]];
pixels[2] = cm[pixels[2] + block[2]];
pixels[3] = cm[pixels[3] + block[3]];
pixels += line_size;
block += 8;
}
}
| 1threat |
Angular 2+ wait for method / observable to complete : <p>I need to check te back-end for authentication status, however te code completes before te observable return is finished. Which would result in an undifined. </p>
<pre><code>canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
this.isAuthenticated();
return this.authenticated;
}
isAuthenticated(){
this.loginService.isAuthenticated()
.subscribe(status => this.authenticated = status)
}
</code></pre>
<p>How would i change this code so i wait for the observable to complete to get the authenticated status before the code returns.</p>
<p>Note: the Angular canActivate method does not allow me to write the code as shown below:</p>
<pre><code>canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
this.loginService.isAuthenticated()
.subscribe(status => {
this.authenticated = status;
return this.authenticated;
});
}
</code></pre>
<p>This results in the followin error:</p>
<blockquote>
<p>Class 'AuthGuard' incorrectly implements interface 'CanActivate'.<br>
Types of property 'canActivate' are incompatible.
Type '(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => void' is not assignable to type '(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => boolean | Observable | Pr...'.
Type 'void' is not assignable to type 'boolean | Observable | Promise'.</p>
</blockquote>
<p>A suggestion for a solution for this error would also be helpful.</p>
| 0debug |
Configuring AutoMapper 4.2 with built in IoC in ASP.NET Core 1.0 MVC6 : <p>I am trying to figure out the proper way to configure AutoMapper in my application's Startup.cs file and then use it throughout my application.</p>
<p>I am trying to use <a href="https://github.com/AutoMapper/AutoMapper/wiki/Migrating-from-static-API" rel="noreferrer">this documentation</a> which somewhat explains how to still give AutoMapper a static feel without the old static API. The example uses StructureMap.</p>
<p>I would like to know how I can do something similar, but in a Core 1.0 app using the built in services container.</p>
<p>I am assuming that in the Configure function I would configure AutoMapper and then in the ConfigureServices function I would add it as a transient.</p>
<p>I am assuming in the end the cleanest and most proper way to do this is using dependency injection. Here is my current attempt but it is not working:</p>
<p><strong>Startup.cs</strong></p>
<pre><code>public IMapper Mapper { get; set; }
private MapperConfiguration MapperConfiguration { get; set; }
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IMapper, Mapper>();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
MapperConfiguration MapperConfiguration = new MapperConfiguration(cfg =>
{
cfg.CreateMap<Product, ProductViewModel>().ReverseMap();
});
Mapper = MapperConfiguration.CreateMapper();
}
</code></pre>
<p><strong>In my controller:</strong></p>
<pre><code>private IMapper _mapper { get; set; }
// Constructor
public ProductsController(IMapper mapper)
{
_mapper = mapper;
}
public IActionResult Create(ProductViewModel vm)
{
Product product = _mapper.Map<ProductViewModel, Product>(vm);
}
</code></pre>
<p>It just isn't working at all... I must be missing some step or doing something wrong.</p>
| 0debug |
debugging simple LISP functions. : <p>I am very new to lisp, and am having a hard time even getting my feet wet. I'm sure once, I have a few functions working, I'll be able to build upon them and work on higher order functions, and more complex problems. </p>
<p>Can someone point out my errors in the following code. </p>
<pre><code>(defun indeHelper(A L N)
(cond (Null N) nil)
((= A (first L) (cons N (indeHelper A (rest L) (+ 1 N)))))
(t (indeHelper A (rest L) (+ 1 N))))
(defun inde(A L)
(funcall indeHelper(A L 1)))
</code></pre>
<p>Also how would I call this? I have one function I think is working ok, but I can't get the syntax for calling it. Thanks for any help.</p>
| 0debug |
import re
def split_lowerstring(text):
return (re.findall('[a-z][^a-z]*', text)) | 0debug |
void hpet_pit_disable(void) {
PITChannelState *s;
s = &pit_state.channels[0];
qemu_del_timer(s->irq_timer);
}
| 1threat |
Recomendation: how to load dynamically a post with laravel : <p>I need a recommendation. I want to have a sidebar with all the titles of the posts and by clicking on any of them that this is loaded with its content in the main section of the page. The idea is that when loading the page not all the contents of each post are loaded, but only when clicking. What system can I use if I am using Laravel?</p>
<p><a href="https://i.stack.imgur.com/xHHEn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xHHEn.png" alt="enter image description here"></a></p>
| 0debug |
static void omap_i2c_send(I2CAdapter *i2c, uint8_t addr,
const uint8_t *buf, uint16_t len)
{
OMAPI2C *s = (OMAPI2C *)i2c;
uint16_t data;
omap_i2c_set_slave_addr(s, addr);
data = len;
memwrite(s->addr + OMAP_I2C_CNT, &data, 2);
data = OMAP_I2C_CON_I2C_EN |
OMAP_I2C_CON_TRX |
OMAP_I2C_CON_MST |
OMAP_I2C_CON_STT |
OMAP_I2C_CON_STP;
memwrite(s->addr + OMAP_I2C_CON, &data, 2);
memread(s->addr + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) != 0);
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_NACK) == 0);
while (len > 1) {
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_XRDY) != 0);
memwrite(s->addr + OMAP_I2C_DATA, buf, 2);
buf = (uint8_t *)buf + 2;
len -= 2;
}
if (len == 1) {
memread(s->addr + OMAP_I2C_STAT, &data, 2);
g_assert((data & OMAP_I2C_STAT_XRDY) != 0);
memwrite(s->addr + OMAP_I2C_DATA, buf, 1);
}
memread(s->addr + OMAP_I2C_CON, &data, 2);
g_assert((data & OMAP_I2C_CON_STP) == 0);
}
| 1threat |
void acpi_add_table(GArray *table_offsets, GArray *table_data)
{
uint32_t offset = cpu_to_le32(table_data->len);
g_array_append_val(table_offsets, offset);
}
| 1threat |
uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len)
{
PCIDevice *pci_dev = pci_dev_find_by_addr(s, addr);
uint32_t config_addr = addr & (PCI_CONFIG_SPACE_SIZE - 1);
uint32_t val;
assert(len == 1 || len == 2 || len == 4);
if (!pci_dev) {
return ~0x0;
}
val = pci_dev->config_read(pci_dev, config_addr, len);
PCI_DPRINTF("%s: %s: addr=%02"PRIx32" val=%08"PRIx32" len=%d\n",
__func__, pci_dev->name, config_addr, val, len);
return val;
}
| 1threat |
Is it possible to have same interface in javaee app and use it in CLI and GUI both? : <p>We have a javaee application whithout any gui. To adding some records to database config. tables( entities) we use manual sql script which is not safe and easy.
We have decided to develop gui and also CLI for our application to handle this issue.
Is it possible to have interfaces in javaee app and use then in both Gui and CLI?
From end-user point of veiw, services and parameters arr same in both gui and cli.
Something like jboss admin web console and jboss cli to deploy an artifact.</p>
| 0debug |
Why do i always get to enter a-1 strings in this string array? : public class Source {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// Declare the variable
int a;
// Read the variable from STDIN
a = in.nextInt();
String strs[]=new String[a];
for(int i=0;i<a;i++)
strs[i]=in.nextInt();
}
} | 0debug |
static int write_l1_entry(BlockDriverState *bs, int l1_index)
{
BDRVQcowState *s = bs->opaque;
uint64_t buf[L1_ENTRIES_PER_SECTOR];
int l1_start_index;
int i, ret;
l1_start_index = l1_index & ~(L1_ENTRIES_PER_SECTOR - 1);
for (i = 0; i < L1_ENTRIES_PER_SECTOR; i++) {
buf[i] = cpu_to_be64(s->l1_table[l1_start_index + i]);
}
ret = qcow2_pre_write_overlap_check(bs,
QCOW2_OL_DEFAULT & ~QCOW2_OL_ACTIVE_L1,
s->l1_table_offset + 8 * l1_start_index, sizeof(buf));
if (ret < 0) {
return ret;
}
BLKDBG_EVENT(bs->file, BLKDBG_L1_UPDATE);
ret = bdrv_pwrite_sync(bs->file, s->l1_table_offset + 8 * l1_start_index,
buf, sizeof(buf));
if (ret < 0) {
return ret;
}
return 0;
}
| 1threat |
How not to see the Null values for Hours when inpout is 24 hr or 48 hours :
DECLARE @Hours AS INT
DECLARE @SubtractDate AS DATETIME
SET @Hours=24 /* User input to have hours */
SET @SubtractDate=DATEADD(hh,@Hours,GETDATE()) - GETDATE()
if @Hours>=24
SELECT CONVERT(VARCHAR(10),DATEDIFF(DAY,'1900-01-01',@SubtractDate))+ ' Day(s) ' +
CONVERT(VARC`enter code here`HAR(10),DATEPART(hh,@SubtractDate))+ ' Hour(s) 'AS [Result]
Else
SELECT CONVERT(VARCHAR(10),DATEPART(hh,@SubtractDate))+ ' Hour(s) ' AS [Result]
| 0debug |
static int ac97_load (QEMUFile *f, void *opaque, int version_id)
{
int ret;
size_t i;
uint8_t active[LAST_INDEX];
AC97LinkState *s = opaque;
if (version_id != 2)
return -EINVAL;
ret = pci_device_load (s->pci_dev, f);
if (ret)
return ret;
qemu_get_be32s (f, &s->glob_cnt);
qemu_get_be32s (f, &s->glob_sta);
qemu_get_be32s (f, &s->cas);
for (i = 0; i < ARRAY_SIZE (s->bm_regs); ++i) {
AC97BusMasterRegs *r = &s->bm_regs[i];
qemu_get_be32s (f, &r->bdbar);
qemu_get_8s (f, &r->civ);
qemu_get_8s (f, &r->lvi);
qemu_get_be16s (f, &r->sr);
qemu_get_be16s (f, &r->picb);
qemu_get_8s (f, &r->piv);
qemu_get_8s (f, &r->cr);
qemu_get_be32s (f, &r->bd_valid);
qemu_get_be32s (f, &r->bd.addr);
qemu_get_be32s (f, &r->bd.ctl_len);
}
qemu_get_buffer (f, s->mixer_data, sizeof (s->mixer_data));
qemu_get_buffer (f, active, sizeof (active));
#ifdef USE_MIXER
record_select (s, mixer_load (s, AC97_Record_Select));
#define V_(a, b) set_volume (s, a, b, mixer_load (s, a))
V_ (AC97_Master_Volume_Mute, AUD_MIXER_VOLUME);
V_ (AC97_PCM_Out_Volume_Mute, AUD_MIXER_PCM);
V_ (AC97_Line_In_Volume_Mute, AUD_MIXER_LINE_IN);
#undef V_
#endif
reset_voices (s, active);
s->bup_flag = 0;
s->last_samp = 0;
return 0;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.