problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
How to display this type of view in recyclerview in android? : i user GridLayoutManager to Recycler view but i require every four row this (provide image) type view
give me solution
[This type view][1]
[1]: https://i.stack.imgur.com/lnW8Y.jpg
| 0debug
|
FlowType React Context : <p>Is there a way to make React <a href="https://facebook.github.io/react/docs/context.html" rel="noreferrer">Context</a> type-safe with flow type?</p>
<p>For example :</p>
<pre><code>Button.contextTypes = {
color: React.PropTypes.string
};
</code></pre>
| 0debug
|
I want to map array2 values to array1 indexes those have values 3 and 5 and want to output array like this-Array : Array1 ( [0] => [1] => [2] => 3 [3] => [4] => 5 [5] => [6] => )
Array2 ( [0] => URD [1] => ISL )
I want to map array2 values to array1 indexes those have values 3 and 5 and want to output array like this- Array ( [0] => [1] => [2] => URD [3] => [4] => ISL [5] => [6] => )# solution please** used this method
$newArray = array_values(array_filter(array_merge($array1,$array2)));
but its output is-Array([0] => 3[1] => 5[2] => URD[3] => ISL)
output should be- Array ( [0] => [1] => [2] => URD [3] => [4] => ISL [5] => [6] => )
| 0debug
|
delete(0, END) doesent work for me : delete(0, END) Does not work for some reason. It does not give any error codes and the rest of the code seems fine. The delete(0, END) wont delete the 0's i get in my entry boxes from the intvar and i cant figure out why it wont work. im using delete in another code and it works there. Could any one help me out?
here is my code.
import tkinter as tk
from tkinter import ttk
import io
from tkinter import filedialog
E=tk.E
W=tk.W
N=tk.N
S=tk.S
VERTICAL=tk.VERTICAL
END=tk.END
class Demo1(tk.Frame):
def __init__(self, master):
tk.Frame.__init__(self, master)
self.master = master
self.Frame = tk.Frame(self.master, borderwidth=10)
self.Frame.grid(column=0, row=0, sticky=(N, W, E, S))
button1 = tk.Button(self.Frame, text="Special Rk märkning", command=self.new_window, width = 25)
button1.grid(column=0, row=0, sticky=(W, E), columnspan=4)
button2 = tk.Button(self.Frame, text="Billerud kabelmärkningar", command=self.new_window, width = 25)
button2.grid(column=0, row=1, sticky=(W, E), columnspan=4)
def new_window(self):
Billerud(self)
class Billerud:
def __init__(self, master):
self.master = master
top1 = tk.Toplevel()
top1.title("Billerud")
top1.resizable(width=False, height=False)
#fönster designern här bästems fönster ramar, rader och columner
Frame1 = tk.Frame(top1)
Frame1.grid(column=1, row=0, sticky=(N, W, E, S), padx=5, pady=5)
Frame1.columnconfigure(0, weight=1)
Frame1.rowconfigure(0, weight=1)
#Koden är en del av entry's endast nummer restriktion
vcmd = (Frame1.register(self.validate),
'%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W')
#create text editor
self.text_entry = tk.Text(Frame1, width=25,height=20)
self.text_entry.grid(column=0, row=0, sticky=(W, E))
scrollbar = tk.Scrollbar(Frame1, orient=VERTICAL)
scrollbar.grid(column=0, row=0, sticky=(N, E, S))
# koppla ihop listbox med scrollbar
self.text_entry.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=self.text_entry.yview)
self.a1 = tk.StringVar()
self.a2 = tk.StringVar()
self.a3 = tk.IntVar()
self.a4 = tk.StringVar()
self.a5 = tk.IntVar()
text1 = tk.Label(Frame1, text="Kabelnamn:", font=("Helvetica", 12, "bold")).grid(column=0, row=1, sticky=(W), columnspan=2)
Kabelnamn_entry = tk.Entry(Frame1, font=('Helvetica', 12, 'bold'), textvariable=self.a1)
Kabelnamn_entry.grid(column=0, row=2, sticky=(W, E), columnspan=2)
text2 = tk.Label(Frame1, text="Kabelnummer:", font=("Helvetica", 12, "bold")).grid(column=0, row=3, sticky=(W), columnspan=2)
Kabelnummer_entry = tk.Entry(Frame1, font=('Helvetica', 12, 'bold'), textvariable=self.a2)
Kabelnummer_entry.grid(column=0, row=4, sticky=(W, E), columnspan=2)
text3 = tk.Label(Frame1, text="Parter från: Till:", font=("Helvetica", 12, "bold")).grid(column=0, row=5, sticky=(W), columnspan=1)
part1_entry = tk.Entry(Frame1, font=('Helvetica', 12, 'bold'), textvariable=self.a3, validate = 'key', validatecommand = vcmd, width = 11)
part1_entry.grid(column=0, row=6, sticky=(W), columnspan=1)
part1_entry.delete(0, END)
part2_entry = tk.Entry(Frame1, font=('Helvetica', 12, 'bold'), textvariable=self.a5, validate = 'key', validatecommand = vcmd, width = 11)
part2_entry.grid(column=0, row=6, sticky=(E), columnspan=1)
part2_entry.delete(0, END)
button1 = tk.Button(Frame1, text="Make", command=self.funktion, width = 16)
button1.grid(column=0, row=7, sticky=(W, E), columnspan=4)
button2 = tk.Button(Frame1, text="Spara", command=self.file_save, width = 16)
button2.grid(column=0, row=8, sticky=(W, E), columnspan=4)
top1.update()
top1.resizable(width=False, height=False)
top1.mainloop()
def validate(self, action, index, value_if_allowed,
prior_value, text, validation_type, trigger_type, widget_name):
if text in '0123456789.-+':
try:
float(value_if_allowed)
return True
except ValueError:
return False
else:
return False
def file_save(self):
file = tk.filedialog.asksaveasfile(defaultextension=".txt", mode='wt', filetypes = (("txt files","*.txt"),("all files","*.*")))
if file:
data = self.text_entry.get('1.0', END+'-1c')
file.write(data)
file.close()
def funktion(self):
value1 = (self.a1.get())
value2 = (self.a2.get())
value3 = (self.a3.get())
value4 = (self.a4.get())
value5 = (self.a5.get())
for parts in range(value3-1, value5):
print('{}-{}-{}-{}\n'.format(value1, value2, parts+1, parts+1))
self.text_entry.insert(END, '{}-{}-{}-{}\n'.format(value1, value2, parts+1, parts+1))
self.a4.set('{}-{}-{}-{}\n'.format(value1, value2, parts+1, parts+1))
def close_windows(self):
self.master.destroy()
def main():
root = tk.Tk()
app = Demo1(root)
root.protocol("WM_DELETE_WINDOW")
root.mainloop()
if __name__ == '__main__':
main()
| 0debug
|
I got error when submitting the app at itunes : [enter image description here][1]
[1]: https://i.stack.imgur.com/s6q1g.png
Hi, there
I got error message at itunes. I need help.
| 0debug
|
static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid)
{
MXFContext *mxf = arg;
MXFPartition *partition;
UID op;
uint64_t footer_partition;
if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions))
return AVERROR(ENOMEM);
mxf->partitions = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions));
if (!mxf->partitions)
return AVERROR(ENOMEM);
if (mxf->parsing_backward) {
memmove(&mxf->partitions[mxf->last_forward_partition+1],
&mxf->partitions[mxf->last_forward_partition],
(mxf->partitions_count - mxf->last_forward_partition)*sizeof(*mxf->partitions));
partition = mxf->current_partition = &mxf->partitions[mxf->last_forward_partition];
} else {
mxf->last_forward_partition++;
partition = mxf->current_partition = &mxf->partitions[mxf->partitions_count];
}
memset(partition, 0, sizeof(*partition));
mxf->partitions_count++;
switch(uid[13]) {
case 2:
partition->type = Header;
break;
case 3:
partition->type = BodyPartition;
break;
case 4:
partition->type = Footer;
break;
default:
av_log(mxf->fc, AV_LOG_ERROR, "unknown partition type %i\n", uid[13]);
return AVERROR_INVALIDDATA;
}
partition->closed = partition->type == Footer || !(uid[14] & 1);
partition->complete = uid[14] > 2;
avio_skip(pb, 8);
partition->this_partition = avio_rb64(pb);
partition->previous_partition = avio_rb64(pb);
footer_partition = avio_rb64(pb);
avio_skip(pb, 16);
partition->index_sid = avio_rb32(pb);
avio_skip(pb, 8);
partition->body_sid = avio_rb32(pb);
avio_read(pb, op, sizeof(UID));
if (footer_partition) {
if (mxf->footer_partition && mxf->footer_partition != footer_partition) {
av_log(mxf->fc, AV_LOG_ERROR, "inconsistent FooterPartition value: %li != %li\n",
mxf->footer_partition, footer_partition);
} else {
mxf->footer_partition = footer_partition;
}
}
av_dlog(mxf->fc, "PartitionPack: ThisPartition = 0x%lx, PreviousPartition = 0x%lx, "
"FooterPartition = 0x%lx, IndexSID = %i, BodySID = %i\n",
partition->this_partition,
partition->previous_partition, footer_partition,
partition->index_sid, partition->body_sid);
if (op[12] == 1 && op[13] == 1) mxf->op = OP1a;
else if (op[12] == 1 && op[13] == 2) mxf->op = OP1b;
else if (op[12] == 1 && op[13] == 3) mxf->op = OP1c;
else if (op[12] == 2 && op[13] == 1) mxf->op = OP2a;
else if (op[12] == 2 && op[13] == 2) mxf->op = OP2b;
else if (op[12] == 2 && op[13] == 3) mxf->op = OP2c;
else if (op[12] == 3 && op[13] == 1) mxf->op = OP3a;
else if (op[12] == 3 && op[13] == 2) mxf->op = OP3b;
else if (op[12] == 3 && op[13] == 3) mxf->op = OP3c;
else if (op[12] == 0x10) mxf->op = OPAtom;
else
av_log(mxf->fc, AV_LOG_ERROR, "unknown operational pattern: %02xh %02xh\n", op[12], op[13]);
return 0;
}
| 1threat
|
Sequelize Where if not null : <p>Lets say I want to do a select command with</p>
<p><code>WHERE ID=2134</code></p>
<p><strong>But</strong> if the user does not provide the id then it should just not bother with the WHERE ID (since it is null)</p>
<p>How can I handle this with Sequelize? </p>
| 0debug
|
static av_cold int vaapi_encode_check_config(AVCodecContext *avctx)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAStatus vas;
int i, n, err;
VAProfile *profiles = NULL;
VAEntrypoint *entrypoints = NULL;
VAConfigAttrib attr[] = {
{ VAConfigAttribRateControl },
{ VAConfigAttribEncMaxRefFrames },
};
n = vaMaxNumProfiles(ctx->hwctx->display);
profiles = av_malloc_array(n, sizeof(VAProfile));
if (!profiles) {
err = AVERROR(ENOMEM);
goto fail;
}
vas = vaQueryConfigProfiles(ctx->hwctx->display, profiles, &n);
if (vas != VA_STATUS_SUCCESS) {
av_log(ctx, AV_LOG_ERROR, "Failed to query profiles: %d (%s).\n",
vas, vaErrorStr(vas));
err = AVERROR(ENOSYS);
goto fail;
}
for (i = 0; i < n; i++) {
if (profiles[i] == ctx->va_profile)
break;
}
if (i >= n) {
av_log(ctx, AV_LOG_ERROR, "Encoding profile not found (%d).\n",
ctx->va_profile);
err = AVERROR(ENOSYS);
goto fail;
}
n = vaMaxNumEntrypoints(ctx->hwctx->display);
entrypoints = av_malloc_array(n, sizeof(VAEntrypoint));
if (!entrypoints) {
err = AVERROR(ENOMEM);
goto fail;
}
vas = vaQueryConfigEntrypoints(ctx->hwctx->display, ctx->va_profile,
entrypoints, &n);
if (vas != VA_STATUS_SUCCESS) {
av_log(ctx, AV_LOG_ERROR, "Failed to query entrypoints for "
"profile %u: %d (%s).\n", ctx->va_profile,
vas, vaErrorStr(vas));
err = AVERROR(ENOSYS);
goto fail;
}
for (i = 0; i < n; i++) {
if (entrypoints[i] == ctx->va_entrypoint)
break;
}
if (i >= n) {
av_log(ctx, AV_LOG_ERROR, "Encoding entrypoint not found "
"(%d / %d).\n", ctx->va_profile, ctx->va_entrypoint);
err = AVERROR(ENOSYS);
goto fail;
}
vas = vaGetConfigAttributes(ctx->hwctx->display,
ctx->va_profile, ctx->va_entrypoint,
attr, FF_ARRAY_ELEMS(attr));
if (vas != VA_STATUS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to fetch config "
"attributes: %d (%s).\n", vas, vaErrorStr(vas));
return AVERROR(EINVAL);
}
for (i = 0; i < FF_ARRAY_ELEMS(attr); i++) {
if (attr[i].value == VA_ATTRIB_NOT_SUPPORTED) {
continue;
}
switch (attr[i].type) {
case VAConfigAttribRateControl:
if (!(ctx->va_rc_mode & attr[i].value)) {
av_log(avctx, AV_LOG_ERROR, "Rate control mode is not "
"supported: %x\n", attr[i].value);
err = AVERROR(EINVAL);
goto fail;
}
break;
case VAConfigAttribEncMaxRefFrames:
{
unsigned int ref_l0 = attr[i].value & 0xffff;
unsigned int ref_l1 = (attr[i].value >> 16) & 0xffff;
if (avctx->gop_size > 1 && ref_l0 < 1) {
av_log(avctx, AV_LOG_ERROR, "P frames are not "
"supported (%x).\n", attr[i].value);
err = AVERROR(EINVAL);
goto fail;
}
if (avctx->max_b_frames > 0 && ref_l1 < 1) {
av_log(avctx, AV_LOG_ERROR, "B frames are not "
"supported (%x).\n", attr[i].value);
err = AVERROR(EINVAL);
goto fail;
}
}
break;
}
}
err = 0;
fail:
av_freep(&profiles);
av_freep(&entrypoints);
return err;
}
| 1threat
|
How can I run a c++ script in debug in visual studio code? : <p>I have to run a c++ script in debug on Visual Studio Code, but I'm not able to do it.
It says me that It is not able to find the file raise.c</p>
<p>Unable to open 'raise.c': Unable to read file (Error: File not found (/build/glibc-B9XfQf/glibc-2.28/sysdeps/unix/sysv/linux/raise.c)).</p>
<p>What is the problem?</p>
| 0debug
|
static int dump_init(DumpState *s, int fd, bool paging, bool has_filter,
int64_t begin, int64_t length, Error **errp)
{
CPUState *cpu;
int nr_cpus;
Error *err = NULL;
int ret;
if (runstate_is_running()) {
vm_stop(RUN_STATE_SAVE_VM);
s->resume = true;
} else {
s->resume = false;
}
cpu_synchronize_all_states();
nr_cpus = 0;
CPU_FOREACH(cpu) {
nr_cpus++;
}
s->errp = errp;
s->fd = fd;
s->has_filter = has_filter;
s->begin = begin;
s->length = length;
guest_phys_blocks_init(&s->guest_phys_blocks);
guest_phys_blocks_append(&s->guest_phys_blocks);
s->start = get_start_block(s);
if (s->start == -1) {
error_set(errp, QERR_INVALID_PARAMETER, "begin");
goto cleanup;
}
ret = cpu_get_dump_info(&s->dump_info, &s->guest_phys_blocks);
if (ret < 0) {
error_set(errp, QERR_UNSUPPORTED);
goto cleanup;
}
s->note_size = cpu_get_note_size(s->dump_info.d_class,
s->dump_info.d_machine, nr_cpus);
if (s->note_size < 0) {
error_set(errp, QERR_UNSUPPORTED);
goto cleanup;
}
memory_mapping_list_init(&s->list);
if (paging) {
qemu_get_guest_memory_mapping(&s->list, &s->guest_phys_blocks, &err);
if (err != NULL) {
error_propagate(errp, err);
goto cleanup;
}
} else {
qemu_get_guest_simple_memory_mapping(&s->list, &s->guest_phys_blocks);
}
s->nr_cpus = nr_cpus;
s->page_size = TARGET_PAGE_SIZE;
s->page_shift = ffs(s->page_size) - 1;
get_max_mapnr(s);
uint64_t tmp;
tmp = DIV_ROUND_UP(DIV_ROUND_UP(s->max_mapnr, CHAR_BIT), s->page_size);
s->len_dump_bitmap = tmp * s->page_size;
if (s->has_filter) {
memory_mapping_filter(&s->list, s->begin, s->length);
}
s->phdr_num = 1;
if (s->list.num < UINT16_MAX - 2) {
s->phdr_num += s->list.num;
s->have_section = false;
} else {
s->have_section = true;
s->phdr_num = PN_XNUM;
s->sh_info = 1;
if (s->list.num <= UINT32_MAX - 1) {
s->sh_info += s->list.num;
} else {
s->sh_info = UINT32_MAX;
}
}
if (s->dump_info.d_class == ELFCLASS64) {
if (s->have_section) {
s->memory_offset = sizeof(Elf64_Ehdr) +
sizeof(Elf64_Phdr) * s->sh_info +
sizeof(Elf64_Shdr) + s->note_size;
} else {
s->memory_offset = sizeof(Elf64_Ehdr) +
sizeof(Elf64_Phdr) * s->phdr_num + s->note_size;
}
} else {
if (s->have_section) {
s->memory_offset = sizeof(Elf32_Ehdr) +
sizeof(Elf32_Phdr) * s->sh_info +
sizeof(Elf32_Shdr) + s->note_size;
} else {
s->memory_offset = sizeof(Elf32_Ehdr) +
sizeof(Elf32_Phdr) * s->phdr_num + s->note_size;
}
}
return 0;
cleanup:
guest_phys_blocks_free(&s->guest_phys_blocks);
if (s->resume) {
vm_start();
}
return -1;
}
| 1threat
|
How to make an attempt for only 3 times. In my case, when staff got 3 fail attempts(staff id) it would go back to the main screen. : Iam doing voting system for an assignment, 5 classes, votingInterface,votingController,staff,admin,candidates and 3 file.txt (admin, staff,candidate). what i need to do is to modify the code, and allow the staff to enter a password to get voted(which i did) but messy too.If staff fail 3 attempts of staff id,, it would go back to the screen. You can see pretty much in this method below. I am new to Java and I need help pls
public void manageVote()
{
boolean moveOn = false;
while(moveOn == false)
{
System.out.print("Please enter your staff ID :");
String input = getInput();
theStaff = vc.getStaff(Integer.parseInt(input));
if(theStaff != null)
{
String pass = null;
System.out.print("Enter your password");
pass=getInput().trim();
if((theStaff.getPass()).equals(pass))
{
getStaffVote();
//moveOn=true;
}
else
{
System.out.println("Incorrect username/password.");
}
try
{
if(theStaff.hasVoted() == 1)
{
System.out.println("\nYou have voted and cannot vote again\nGood bye...!");
moveOn = true;
}
else if (theStaff.hasVoted() == 0)
{
getStaffVote();
moveOn = true;
}
else
{
System.out.println("There seems to be a problem. Contact your administrator");
}
}
catch(NumberFormatException e)
{
System.out.println("Invalid entry - you must enter a number\nPlease try again");
}
catch(NullPointerException e)
{
System.out.println("Error! Staff ID not found.\nPress ENTER to try again or \"q\" to QUIT : " );
if ("q".equalsIgnoreCase(getInput()))
{
System.out.println("Good bye!");
moveOn = true;
}
}
}
System.out.print("going back to voting screen...");
}
}
*enter code here*
| 0debug
|
static void bonito_pciconf_writel(void *opaque, target_phys_addr_t addr,
uint32_t val)
{
PCIBonitoState *s = opaque;
DPRINTF("bonito_pciconf_writel "TARGET_FMT_plx" val %x \n", addr, val);
s->dev.config_write(&s->dev, addr, val, 4);
}
| 1threat
|
static int read_tfra(MOVContext *mov, AVIOContext *f)
{
MOVFragmentIndex* index = NULL;
int version, fieldlength, i, j, err;
int64_t pos = avio_tell(f);
uint32_t size = avio_rb32(f);
if (avio_rb32(f) != MKBETAG('t', 'f', 'r', 'a')) {
return -1;
}
av_log(mov->fc, AV_LOG_VERBOSE, "found tfra\n");
index = av_mallocz(sizeof(MOVFragmentIndex));
if (!index) {
return AVERROR(ENOMEM);
}
mov->fragment_index_count++;
if ((err = av_reallocp(&mov->fragment_index_data,
mov->fragment_index_count *
sizeof(MOVFragmentIndex*))) < 0) {
av_freep(&index);
return err;
}
mov->fragment_index_data[mov->fragment_index_count - 1] =
index;
version = avio_r8(f);
avio_rb24(f);
index->track_id = avio_rb32(f);
fieldlength = avio_rb32(f);
index->item_count = avio_rb32(f);
index->items = av_mallocz(
index->item_count * sizeof(MOVFragmentIndexItem));
if (!index->items) {
return AVERROR(ENOMEM);
}
for (i = 0; i < index->item_count; i++) {
int64_t time, offset;
if (version == 1) {
time = avio_rb64(f);
offset = avio_rb64(f);
} else {
time = avio_rb32(f);
offset = avio_rb32(f);
}
index->items[i].time = time;
index->items[i].moof_offset = offset;
for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
avio_r8(f);
for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
avio_r8(f);
for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
avio_r8(f);
}
avio_seek(f, pos + size, SEEK_SET);
return 0;
}
| 1threat
|
static void select_frame(AVFilterContext *ctx, AVFrame *frame)
{
SelectContext *select = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
double res;
if (isnan(select->var_values[VAR_START_PTS]))
select->var_values[VAR_START_PTS] = TS2D(frame->pts);
if (isnan(select->var_values[VAR_START_T]))
select->var_values[VAR_START_T] = TS2D(frame->pts) * av_q2d(inlink->time_base);
select->var_values[VAR_N ] = inlink->frame_count;
select->var_values[VAR_PTS] = TS2D(frame->pts);
select->var_values[VAR_T ] = TS2D(frame->pts) * av_q2d(inlink->time_base);
select->var_values[VAR_POS] = av_frame_get_pkt_pos(frame) == -1 ? NAN : av_frame_get_pkt_pos(frame);
switch (inlink->type) {
case AVMEDIA_TYPE_AUDIO:
select->var_values[VAR_SAMPLES_N] = frame->nb_samples;
break;
case AVMEDIA_TYPE_VIDEO:
select->var_values[VAR_INTERLACE_TYPE] =
!frame->interlaced_frame ? INTERLACE_TYPE_P :
frame->top_field_first ? INTERLACE_TYPE_T : INTERLACE_TYPE_B;
select->var_values[VAR_PICT_TYPE] = frame->pict_type;
#if CONFIG_AVCODEC
if (select->do_scene_detect) {
char buf[32];
select->var_values[VAR_SCENE] = get_scene_score(ctx, frame);
snprintf(buf, sizeof(buf), "%f", select->var_values[VAR_SCENE]);
av_dict_set(avpriv_frame_get_metadatap(frame), "lavfi.scene_score", buf, 0);
}
#endif
break;
}
select->select = res = av_expr_eval(select->expr, select->var_values, NULL);
av_log(inlink->dst, AV_LOG_DEBUG,
"n:%f pts:%f t:%f key:%d",
select->var_values[VAR_N],
select->var_values[VAR_PTS],
select->var_values[VAR_T],
(int)select->var_values[VAR_KEY]);
switch (inlink->type) {
case AVMEDIA_TYPE_VIDEO:
av_log(inlink->dst, AV_LOG_DEBUG, " interlace_type:%c pict_type:%c scene:%f",
select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_P ? 'P' :
select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_T ? 'T' :
select->var_values[VAR_INTERLACE_TYPE] == INTERLACE_TYPE_B ? 'B' : '?',
av_get_picture_type_char(select->var_values[VAR_PICT_TYPE]),
select->var_values[VAR_SCENE]);
break;
case AVMEDIA_TYPE_AUDIO:
av_log(inlink->dst, AV_LOG_DEBUG, " samples_n:%d consumed_samples_n:%d",
(int)select->var_values[VAR_SAMPLES_N],
(int)select->var_values[VAR_CONSUMED_SAMPLES_N]);
break;
}
if (res == 0) {
select->select_out = -1;
} else if (isnan(res) || res < 0) {
select->select_out = 0;
} else {
select->select_out = FFMIN(ceilf(res)-1, select->nb_outputs-1);
}
av_log(inlink->dst, AV_LOG_DEBUG, " -> select:%f select_out:%d\n", res, select->select_out);
if (res) {
select->var_values[VAR_PREV_SELECTED_N] = select->var_values[VAR_N];
select->var_values[VAR_PREV_SELECTED_PTS] = select->var_values[VAR_PTS];
select->var_values[VAR_PREV_SELECTED_T] = select->var_values[VAR_T];
select->var_values[VAR_SELECTED_N] += 1.0;
if (inlink->type == AVMEDIA_TYPE_AUDIO)
select->var_values[VAR_CONSUMED_SAMPLES_N] += frame->nb_samples;
}
select->var_values[VAR_PREV_PTS] = select->var_values[VAR_PTS];
select->var_values[VAR_PREV_T] = select->var_values[VAR_T];
}
| 1threat
|
document.location = 'http://evil.com?username=' + user_input;
| 1threat
|
i want to Get Single Value From SQLite Database [C#] : <p>i am trying to get single value from sqlite database but i am facing error</p>
<p>so i can do some action to this value or check it </p>
<p><img src="https://www11.0zz0.com/2019/03/25/18/254767394.jpg" alt="a busy cat"></p>
<pre><code>dbConnection StartConn = new dbConnection();
SQLiteConnection MyConnetion = StartConn.GetConnection();
SQLiteCommand Cm = new SQLiteCommand(" select * from Users where user_username = '" + txtBxUserName.Text + "' and user_password = '" + txtBxPassword.Text + "'", MyConnetion);
MyConnetion.Open();
SQLiteDataReader dr = Cm.ExecuteReader();
dr.Read();
int count = Convert.ToInt32(Cm.ExecuteScalar());
if (count != 0)
{
globalVariables.userFullName = dr["user_name"].ToString();
globalVariables.appLoginUser = dr["user_username"].ToString();
globalVariables.appPasswordUser = dr["user_password"].ToString();
globalVariables.userPermissions = dr["user_permissions"].ToString();
mainForm newMainForm = new mainForm();
newMainForm.Show();
this.Hide();
MyConnetion.Close();
</code></pre>
| 0debug
|
import bisect
def right_insertion(a, x):
i = bisect.bisect_right(a, x)
return i
| 0debug
|
Hacker accessing PHP function through SSL by using exitant session : <p>A person execute a PHP function through SSL by using curl. I added verification by IP adresse for session and I added HTTPS feature to the website, but even now that not working. I'm using CodeIgniter and I'm a C/C++ programmer, not a very good PHP programmer. Can someone tell me how the person does that?</p>
<p>I try to prevent it, but it wount stop.</p>
| 0debug
|
void qemu_ram_free(ram_addr_t addr)
{
RAMBlock *block;
QLIST_FOREACH(block, &ram_list.blocks, next) {
if (addr == block->offset) {
QLIST_REMOVE(block, next);
if (block->flags & RAM_PREALLOC_MASK) {
;
} else if (mem_path) {
#if defined (__linux__) && !defined(TARGET_S390X)
if (block->fd) {
munmap(block->host, block->length);
close(block->fd);
} else {
qemu_vfree(block->host);
}
#endif
} else {
#if defined(TARGET_S390X) && defined(CONFIG_KVM)
munmap(block->host, block->length);
qemu_vfree(block->host);
#endif
}
qemu_free(block);
return;
}
}
}
| 1threat
|
static int64_t wav_seek_tag(AVIOContext *s, int64_t offset, int whence)
{
return avio_seek(s, offset + (offset & 1), whence);
}
| 1threat
|
vuetify.js how to get full width of v-container : <p>I'm new to <code>vuetify.js</code> and started playing around with it.</p>
<p><a href="https://i.stack.imgur.com/evNFt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/evNFt.png" alt="enter image description here"></a></p>
<p>This is my code.</p>
<p><strong>Admin-panel.vue</strong></p>
<pre><code><v-content class="yellow">
<v-container>
<v-layout>
<router-view></router-view>
</v-layout>
</v-container>
</v-content>
</code></pre>
<p><strong>create-user.vue</strong></p>
<pre><code><template>
<v-container class="red">
<v-layout class="blue">
<v-flex md12>
form
</v-flex>
</v-layout>
</v-container>
</template>
</code></pre>
<p>Here I can see <code>v-container</code> element gets the full width available.
What I want is my <code>v-container</code> inside the create-user component to get the that same width. (Yellow will disappear and red will fill the screen)</p>
<p>How do I achieve this?</p>
| 0debug
|
How to display the last four blog posts using Json api in div tag : display latest blog post wordpress api in html
html
<div id="content" class="content">
</div>
javascript
<script>
$(document).ready(function(){
$.getJSON( "https://startupet.com/blog/wp-json/wp/v2/posts",
function(
data ) {
console.log(data);
});
})
</script>
"im get image post and title "
json file : https://startupet.com/blog/wp-json/wp/v2/posts
| 0debug
|
Refined and existential types for runtime values : <p>Suppose I want to map between some strings and integer identifiers, and I want my types to make it impossible to get a runtime failure because someone tried to look up an id that was out of range. Here's one straightforward API:</p>
<pre><code>trait Vocab {
def getId(value: String): Option[Int]
def getValue(id: Int): Option[String]
}
</code></pre>
<p>This is annoying, though, if users will typically be getting their ids from <code>getId</code> and therefore know they're valid. The following is an improvement in that sense:</p>
<pre><code>trait Vocab[Id] {
def getId(value: String): Option[Id]
def getValue(id: Id): String
}
</code></pre>
<p>Now we could have something like this:</p>
<pre><code>class TagId private(val value: Int) extends AnyVal
object TagId {
val tagCount: Int = 100
def fromInt(id: Int): Option[TagId] =
if (id >= 0 && id < tagCount) Some(new TagId(id)) else None
}
</code></pre>
<p>And then our users can work with <code>Vocab[TagId]</code> and not have to worry about checking whether <code>getValue</code> lookups failed in the typical case, but they can still look up arbitrary integers if they need to. It's still pretty awkward, though, since we have to write a separate type for each kind of thing we want a vocabulary for.</p>
<p>We can also do something like this with <a href="https://github.com/fthomas/refined" rel="noreferrer">refined</a>:</p>
<pre><code>import eu.timepit.refined.api.Refined
import eu.timepit.refined.numeric.Interval.ClosedOpen
import shapeless.Witness
class Vocab(values: Vector[String]) {
type S <: Int
type P = ClosedOpen[Witness.`0`.T, S]
def size: S = values.size.asInstanceOf[S]
def getId(value: String): Option[Refined[Int, P]] = values.indexOf(value) match {
case -1 => None
case i => Some(Refined.unsafeApply[Int, P](i))
}
def getValue(id: Refined[Int, P]): String = values(id.value)
}
</code></pre>
<p>Now even though <code>S</code> isn't known at compile time, the compiler is still able to keep track of the fact that the ids it gives us are between zero and <code>S</code>, so that we don't have to worry about the possibility of failure when we go back to values (if we're using the same <code>vocab</code> instance, of course).</p>
<p>What I want is to be able to write this:</p>
<pre><code>val x = 2
val vocab = new Vocab(Vector("foo", "bar", "qux"))
eu.timepit.refined.refineV[vocab.P](x).map(vocab.getValue)
</code></pre>
<p>So that users can easily look up arbitrary integers when they really need to. This doesn't compile, though:</p>
<pre><code>scala> eu.timepit.refined.refineV[vocab.P](x).map(vocab.getValue)
<console>:17: error: could not find implicit value for parameter v: eu.timepit.refined.api.Validate[Int,vocab.P]
eu.timepit.refined.refineV[vocab.P](x).map(vocab.getValue)
^
</code></pre>
<p>I can make it compile by providing a <code>Witness</code> instance for <code>S</code>:</p>
<pre><code>scala> implicit val witVocabS: Witness.Aux[vocab.S] = Witness.mkWitness(vocab.size)
witVocabS: shapeless.Witness.Aux[vocab.S] = shapeless.Witness$$anon$1@485aac3c
scala> eu.timepit.refined.refineV[vocab.P](x).map(vocab.getValue)
res1: scala.util.Either[String,String] = Right(qux)
</code></pre>
<p>And of course it fails (at runtime but safely) when the value is out of range:</p>
<pre><code>scala> val y = 3
y: Int = 3
scala> println(eu.timepit.refined.refineV[vocab.P](y).map(vocab.getValue))
Left(Right predicate of (!(3 < 0) && (3 < 3)) failed: Predicate failed: (3 < 3).)
</code></pre>
<p>I could also put the witness definition inside my <code>Vocab</code> class and then import <code>vocab._</code> to make it available when I need this, but what I really want is to be able to provide <code>refineV</code> support without extra imports or definitions.</p>
<p>I've tried various stuff like this:</p>
<pre><code>object Vocab {
implicit def witVocabS[V <: Vocab](implicit
witV: Witness.Aux[V]
): Witness.Aux[V#S] = Witness.mkWitness(witV.value.size)
}
</code></pre>
<p>But this still requires an explicit definition for each <code>vocab</code> instance:</p>
<pre><code>scala> implicit val witVocabS: Witness.Aux[vocab.S] = Vocab.witVocabS
witVocabS: shapeless.Witness.Aux[vocab.S] = shapeless.Witness$$anon$1@1bde5374
scala> eu.timepit.refined.refineV[vocab.P](x).map(vocab.getValue)
res4: scala.util.Either[String,String] = Right(qux)
</code></pre>
<p>I know I could implement <code>witVocabS</code> with a macro, but I feel like there should be a nicer way to do this kind of thing, since it seems like a pretty reasonable use case (and I'm not very familiar with refined, so it's entirely possible that I'm missing something obvious).</p>
| 0debug
|
static void unin_data_write(void *opaque, hwaddr addr,
uint64_t val, unsigned len)
{
UNINState *s = opaque;
PCIHostState *phb = PCI_HOST_BRIDGE(s);
UNIN_DPRINTF("write addr %" TARGET_FMT_plx " len %d val %"PRIx64"\n",
addr, len, val);
pci_data_write(phb->bus,
unin_get_config_reg(phb->config_reg, addr),
val, len);
}
| 1threat
|
Implements exceptions on Java Digital Clock : <p>i try to develop digital clock using java. i still new in java. the problem is, i try to implement exception on my code but i did not know how to make it.</p>
<p>my make code as below</p>
<p>Main Class</p>
<pre><code>import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class DigitalClock extends JFrame {
JLabel jLabClock;
ClockThread ct;
public DigitalClock(){
JFrame f = new JFrame("Digital Clock");
jLabClock = new JLabel("00:00:00 AM");
f.getContentPane().setBackground(Color.BLACK);
f.setLayout(new FlowLayout());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jLabClock.setFont(new Font("DS-Digital", Font.BOLD, 50));
jLabClock.setForeground(new java.awt.Color(15, 245, 15));
f.add(jLabClock);
f.pack();
f.setLocationRelativeTo(null);
ct = new ClockThread(this);
f.setVisible(true);
f.setResizable(false);
}
public static void main(String[] args) {
DigitalClock digitalClock = new DigitalClock();
}
}
</code></pre>
<p>Thread Class</p>
<pre><code>import java.util.Calendar;
import java.util.GregorianCalendar;
public class ClockThread extends Thread{
DigitalClock dc;
int timeRun = 0;
public ClockThread(DigitalClock dc){
this.dc = dc;
start();
}
@Override
public void run(){
while(timeRun == 0){
Calendar cal = new GregorianCalendar();
int hour = cal.get(Calendar.HOUR);
int min = cal.get(Calendar.MINUTE);
int sec = cal.get(Calendar.SECOND);
int am_pm = cal.get(Calendar.AM_PM);
String day_night = "";
if (am_pm == 1){
day_night = "PM";
}
else{
day_night = "AM";
}
String time = hour + ":" + min + ":" + sec + " " + day_night;
dc.jLabClock.setText(time);
}
}
}
</code></pre>
<p>this code work fine to me but i just want to try use exception on my code. can somebody help me, please</p>
| 0debug
|
Function in R - Transforming A Yes/No variable in a 1/0 variable : <p>I need to set a function that help me in restore the Yes/No variable in 0/1 one.</p>
<p>A function should be</p>
<pre><code>x<-function(DataFrame,VariableName,Yes,No){
.....
}
</code></pre>
<p>I set up this code but run only out the function because R do not read the variable setted in () after the dollar sign.</p>
<pre><code>dummy<-function(DB,varr){
BD$varr <- as.character(DB$varr)
DB[BD$varr=="Yes"]<-"1"
DB[BD$varr=="No"]<-"0"
}
</code></pre>
| 0debug
|
Flutter ListView lazy loading : <p>How can I realize items lazy loading for endless listview? I want to load more items by network when user scroll to the end of listview.</p>
| 0debug
|
static CURLState *curl_init_state(BlockDriverState *bs, BDRVCURLState *s)
{
CURLState *state = NULL;
int i, j;
do {
for (i=0; i<CURL_NUM_STATES; i++) {
for (j=0; j<CURL_NUM_ACB; j++)
if (s->states[i].acb[j])
continue;
if (s->states[i].in_use)
continue;
state = &s->states[i];
state->in_use = 1;
break;
}
if (!state) {
qemu_mutex_unlock(&s->mutex);
aio_poll(bdrv_get_aio_context(bs), true);
qemu_mutex_lock(&s->mutex);
}
} while(!state);
if (!state->curl) {
state->curl = curl_easy_init();
if (!state->curl) {
return NULL;
}
curl_easy_setopt(state->curl, CURLOPT_URL, s->url);
curl_easy_setopt(state->curl, CURLOPT_SSL_VERIFYPEER,
(long) s->sslverify);
if (s->cookie) {
curl_easy_setopt(state->curl, CURLOPT_COOKIE, s->cookie);
}
curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, (long)s->timeout);
curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION,
(void *)curl_read_cb);
curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state);
curl_easy_setopt(state->curl, CURLOPT_PRIVATE, (void *)state);
curl_easy_setopt(state->curl, CURLOPT_AUTOREFERER, 1);
curl_easy_setopt(state->curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(state->curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(state->curl, CURLOPT_ERRORBUFFER, state->errmsg);
curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1);
if (s->username) {
curl_easy_setopt(state->curl, CURLOPT_USERNAME, s->username);
}
if (s->password) {
curl_easy_setopt(state->curl, CURLOPT_PASSWORD, s->password);
}
if (s->proxyusername) {
curl_easy_setopt(state->curl,
CURLOPT_PROXYUSERNAME, s->proxyusername);
}
if (s->proxypassword) {
curl_easy_setopt(state->curl,
CURLOPT_PROXYPASSWORD, s->proxypassword);
}
#if LIBCURL_VERSION_NUM >= 0x071304
curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS);
curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS);
#endif
#ifdef DEBUG_VERBOSE
curl_easy_setopt(state->curl, CURLOPT_VERBOSE, 1);
#endif
}
QLIST_INIT(&state->sockets);
state->s = s;
return state;
}
| 1threat
|
will the app store reject my app if I use a javascript sdk for the backend? : <p>I'm using Trigger.io to make an app I can deploy to both the app store and google play.
I'm researching baas backends that offer native sdk's for android and apple, but also offer javascript sdk's which I assume are meant for things like Trigger or Phonegap.
My question is do the app store guidelines favor one kind of back end service over another? Is javascript risky for backend? I just want to be sure before I pay for a service. The services I'm considering are cloudmine and shephertz. </p>
| 0debug
|
static int lsi_scsi_init(PCIDevice *dev)
{
LSIState *s = DO_UPCAST(LSIState, dev, dev);
uint8_t *pci_conf;
pci_conf = s->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_LSI_LOGIC);
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_LSI_53C895A);
pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_SCSI);
pci_conf[PCI_SUBSYSTEM_ID] = 0x00;
pci_conf[PCI_SUBSYSTEM_ID + 1] = 0x10;
pci_conf[PCI_LATENCY_TIMER] = 0xff;
pci_conf[PCI_INTERRUPT_PIN] = 0x01;
s->mmio_io_addr = cpu_register_io_memory(lsi_mmio_readfn,
lsi_mmio_writefn, s,
DEVICE_NATIVE_ENDIAN);
s->ram_io_addr = cpu_register_io_memory(lsi_ram_readfn,
lsi_ram_writefn, s,
DEVICE_NATIVE_ENDIAN);
pci_register_bar(&s->dev, 0, 256,
PCI_BASE_ADDRESS_SPACE_IO, lsi_io_mapfunc);
pci_register_bar_simple(&s->dev, 1, 0x400, 0, s->mmio_io_addr);
pci_register_bar(&s->dev, 2, 0x2000,
PCI_BASE_ADDRESS_SPACE_MEMORY, lsi_ram_mapfunc);
QTAILQ_INIT(&s->queue);
scsi_bus_new(&s->bus, &dev->qdev, 1, LSI_MAX_DEVS, lsi_command_complete);
if (!dev->qdev.hotplugged) {
return scsi_bus_legacy_handle_cmdline(&s->bus);
}
return 0;
}
| 1threat
|
void timerlistgroup_deinit(QEMUTimerListGroup *tlg)
{
QEMUClockType type;
for (type = 0; type < QEMU_CLOCK_MAX; type++) {
timerlist_free(tlg->tl[type]);
}
}
| 1threat
|
How to Write string format in angularjs like as c#? : <p>This is my code</p>
<pre><code>$http.get("/Student/GetStudentById?studentId=" + $scope.studentId + "&collegeId=" + $scope.collegeId)
.then(function (result) {
});
</code></pre>
<p>In the above code use http service for get student details based on id. but i want to write the above service string.format like in c#.net</p>
<pre><code>(eg:- string.format("/Student/GetStudentById/{0}/collegeId/{1}",studentId,collegeId)
</code></pre>
| 0debug
|
How to create asossiative array in wrapping class : I have made a array associative like this , and i know how to take get value from a dict with index 10
var dict = new Dictionary<int, Dictionary<string, int[]>>
{
{
10, new Dictionary<string, int[]>
{
{"first", new[] {57, 57, 5, 0}},
{"second", new[] {42, 58, 13, 8}}
}
},
{
40, new Dictionary<string, int[]>
{
{"first", new[] {4, 24, 5, 0}},
{"second", new[] {42, 58, 23, 8}}
}
}
};
foreach (var item in dict[10])
{
foreach (var test in item.Value)
{
Console.WriteLine(test); //This will show value with key 10
}
}`
after that i want to change this code to make my code more elegant and maintainable by wrapping the dict in class
first class
class DataContainer
{
public DataContainer()
{
}
public int index { get; set; }
public DataValue DataValue { get; set; }
}
Second class
class DataValue
{
public DataValue()
{
IntegerValues = new List<int>();
}
public string name { get; set; }
public List<int> IntegerValues { get; set; }
}
after that i want to fill my data like i inserted in dict dictionary
but i confuse how to make it
i have tried with this below code
public List<DataContainer> harakatSininilMabsutoh = new List<DataContainer>(){
new DataContainer{index = 10 , DataValue = new List<DataValue>()
{
new DataValue{name = "first",IntegerValues = {9,55,18,11}},
new DataValue{name = "second" ,IntegerValues = {5,54,18,11}},
}
}
}
But i got the error error result
after that i want to try to show a integervalue which has index = 10
But i got an error
| 0debug
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
connecting HTML to PHP file using ajax : <p>I have created an application using xampp (apache and mysql). I have the following HTML code:</p>
<pre><code> <!DOCTYPE html>
<html>
<head>
<title>Name</title>
</head>
<body>
<div id="main">
<h1>Details</h1>
<div id="name">
<h2>Name</h2>
<hr/>
<Form Name ="form1" Method ="POST" ACTION = "name.php">
<label>Name: </label>
<input type="text" name="per_name" id="name" required="required" placeholder="please enter name"/><br/><br />
<label>Age: </label>
<input type="text" name="per_age" id="age" required="required" placeholder="please enter age"/><br/><br />
<input type="submit" value=" Submit " name="submit"/><br />
</form>
</div>
</div>
</div>
</body>
</html>
</code></pre>
<p>and the following PHP code:</p>
<pre><code><?php
if(isset($_POST["submit"])){
$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "details";
$connection = new mysqli($servername, $username, $password, $dbname);
if ($connection->connect_error) {
die("Connection failed: " . $connection->connect_error);
}
$sql = "INSERT INTO persons (person_name, person_age)
VALUES ('".$_POST["per_name"]."','".$_POST["per_age"]."')";
if ($connection->query($sql) === TRUE) {
echo "person added";
} else {
echo "person not added";
}
$connection->close();
}
?>
</code></pre>
<p>Instead of calling the php file using <code><Form Name ="form1" Method ="POST" ACTION = "name.php"></code> how would i create a simple ajax file to call the PHP file? i have tried to do this but can't seem to get anywhere, can anyone help me please? AJAX:</p>
<pre><code>$(document).ready(function(){
$("#submit").click(function(){
// AJAX Code To Submit Form.
$.ajax({
type: "POST",
url: "name.php",
data: dataString,
cache: false,
success: function(result){
alert(result);
});
}
return false;
});
});
</code></pre>
| 0debug
|
static int vnc_display_connect(VncDisplay *vd,
SocketAddressLegacy **saddr,
size_t nsaddr,
SocketAddressLegacy **wsaddr,
size_t nwsaddr,
Error **errp)
{
QIOChannelSocket *sioc = NULL;
if (nwsaddr != 0) {
error_setg(errp, "Cannot use websockets in reverse mode");
return -1;
}
if (nsaddr != 1) {
error_setg(errp, "Expected a single address in reverse mode");
return -1;
}
vd->is_unix = saddr[0]->type == SOCKET_ADDRESS_LEGACY_KIND_UNIX;
sioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse");
if (qio_channel_socket_connect_sync(sioc, saddr[0], errp) < 0) {
return -1;
}
vnc_connect(vd, sioc, false, false);
object_unref(OBJECT(sioc));
return 0;
}
| 1threat
|
static int sd_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
{
BDRVSheepdogState *s = bs->opaque;
BDRVSheepdogState *old_s;
char vdi[SD_MAX_VDI_LEN], tag[SD_MAX_VDI_TAG_LEN];
char *buf = NULL;
uint32_t vid;
uint32_t snapid = 0;
int ret = 0, fd;
old_s = g_malloc(sizeof(BDRVSheepdogState));
memcpy(old_s, s, sizeof(BDRVSheepdogState));
pstrcpy(vdi, sizeof(vdi), s->name);
snapid = strtoul(snapshot_id, NULL, 10);
if (snapid) {
tag[0] = 0;
} else {
pstrcpy(tag, sizeof(tag), s->name);
}
ret = find_vdi_name(s, vdi, snapid, tag, &vid, 1);
if (ret) {
error_report("Failed to find_vdi_name");
goto out;
}
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
error_report("failed to connect");
ret = fd;
goto out;
}
buf = g_malloc(SD_INODE_SIZE);
ret = read_object(fd, buf, vid_to_vdi_oid(vid), s->inode.nr_copies,
SD_INODE_SIZE, 0, s->cache_enabled);
closesocket(fd);
if (ret) {
goto out;
}
memcpy(&s->inode, buf, sizeof(s->inode));
if (!s->inode.vm_state_size) {
error_report("Invalid snapshot");
ret = -ENOENT;
goto out;
}
s->is_snapshot = true;
g_free(buf);
g_free(old_s);
return 0;
out:
memcpy(s, old_s, sizeof(BDRVSheepdogState));
g_free(buf);
g_free(old_s);
error_report("failed to open. recover old bdrv_sd_state.");
return ret;
}
| 1threat
|
So i'm trying to use a method to print another method. Help please? : public static void main(String[] args)
{
System.out.println("Hello and welcome! Please enter the following: ");
String q = null, s = "nul";
userName(q);
userGender(s);
print(userName(q));
print(userGender(s)); //how to achieve something like this?
}
public static void userName(String x)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter name: ");
String n = sc.nextLine();
}
public static void userGender(String y)
{
Scanner sd = new Scanner(System.in);
System.out.print("Enter Gender: ");
String v = sd.next().toString();
}
public static void print(String a)
{
System.out.println(a);
}
So I was trying to make it so that a method would be used to print another method after they were done executing but I couldn't get the desired result and it gave an error.
can somebody please help?
| 0debug
|
av_cold void ff_rl_init(RLTable *rl,
uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3])
{
int8_t max_level[MAX_RUN + 1], max_run[MAX_LEVEL + 1];
uint8_t index_run[MAX_RUN + 1];
int last, run, level, start, end, i;
if (static_store && rl->max_level[0])
return;
for (last = 0; last < 2; last++) {
if (last == 0) {
start = 0;
end = rl->last;
} else {
start = rl->last;
end = rl->n;
}
memset(max_level, 0, MAX_RUN + 1);
memset(max_run, 0, MAX_LEVEL + 1);
memset(index_run, rl->n, MAX_RUN + 1);
for (i = start; i < end; i++) {
run = rl->table_run[i];
level = rl->table_level[i];
if (index_run[run] == rl->n)
index_run[run] = i;
if (level > max_level[run])
max_level[run] = level;
if (run > max_run[level])
max_run[level] = run;
}
if (static_store)
rl->max_level[last] = static_store[last];
else
rl->max_level[last] = av_malloc(MAX_RUN + 1);
memcpy(rl->max_level[last], max_level, MAX_RUN + 1);
if (static_store)
rl->max_run[last] = static_store[last] + MAX_RUN + 1;
else
rl->max_run[last] = av_malloc(MAX_LEVEL + 1);
memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1);
if (static_store)
rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2;
else
rl->index_run[last] = av_malloc(MAX_RUN + 1);
memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
}
}
| 1threat
|
how to calculate average lenght of time in a list : I have a csv file with two columns: date and price.
I am trying to figure out how long, on average the price stays within a certain range. Let say my values are [10, 7.7, 9.5, 15, 8.8, 9.3, 7.7, 16] For example when the value is between 8 - 9.9, how long on average before it is >14 (not going backwards). 9.5 passes 14 in 1 day. 8.8 in 3 days. 9.3 in 2 days. 7.7 in 1 day. So the average is (1 + 3 + 2 + 1 )/4 = 1.75 days.
I am trying to create a program that does that calculation for me but I am having problems.
first the pseudocode:
create new function
iterate over the rows (for i in rows:)
check for the presence of median price range where I want the check to start (if 8 < x < 9.9), store x as initial value variable y
time to reset and increment the index, for next row increment index i
when x leaves bound (if x > 14) store index i in dictionary z (not sure this step makes sense)
after all rows are iterated through, average all indexes stored in z
code:
from itertools import*
list = [10, 7.7, 9.5, 15, 8.8, 9.3, 7.7, 16] (in reality this will be a csv file with rows)
def new_function()
for i in list:
while 8 < x < 9.99:
elif x > 14 (store index in z?)
average = sum(z)/len(z)
print(average)
| 0debug
|
Join Query All left rows and join bit indicator : So I have this 3 tables:
**T1**
T1
--
ID
--
1
2
3
4
5
**T2**
T2
--
ID
--
1
2
3
**T1_2 that connects (N-N) T1 with T2**
T1_2
-----------
ID_T1|ID_T2
-----|-----
1 |2
3 |2
And I would like to get the following result
EXPECETED RESULT
-----------------
IS_CONNECTED|ID_T1
-----------------
1 |1
0 |2
1 |3
0 |4
0 |5
I'm trying with LEFT OUTER JOIN but no close to what I want.
| 0debug
|
static void runstate_init(void)
{
const RunStateTransition *p;
memset(&runstate_valid_transitions, 0, sizeof(runstate_valid_transitions));
for (p = &runstate_transitions_def[0]; p->from != RUN_STATE_MAX; p++) {
runstate_valid_transitions[p->from][p->to] = true;
}
}
| 1threat
|
Fastest way to compare 2 lists objects : <p>I allow a user to download some data to csv. They can then edit some columns and then upload it back. I need a speed efficient way to compare certain columns between like objects to see what changed.</p>
<p>Currently I pull the original data from the DB and make it a list so it's all in memory. There is about 100k items so it's not that bad. That part takes less than a second. Then I load in the csv file and put it to list. Both lists have the same class type.</p>
<p>Then I loop over the csv data (as they probably removed some rows which they didn't change but they could still have changed a lot of rows). For each row in the csv list I query the list that came from the DB to find that object. Now I have the csv object and the object from the database as the same structure. Then I run it through a custom object compare function that looks at certain columns to see if anything changed.</p>
<p>If something did change I have to validate what they entered is a valid value by query another reference list for that column. If it's not valid I write it out to an exceptions list. At the end if there are no exceptions I save to db. If there are exceptions I don't save anything and I show them the list of errors.</p>
<p>The detail compare provides a list of columns and the old vs new values that changed. I need this to query the reference list to make sure the new value is valid before I make the change. It's fairly inefficient but it gives great detail to the user about what may be an issue with an upload which is very valuable.</p>
<p>This is very slow. I'm looking for ways to speed it up while still being able to give the user detailed information about why it may have failed so they can correct it.</p>
<pre><code>// get all the new records from the csv
var newData = csv.GetRecords<MyTable>().ToArray();
// select all data from database to list
var origData = ctx.MyTable.Select(s => s).ToList();
// look for any changes in the new data and update the database. note we are looping over the new data so if they removed some data from the csv file it just won't loop over those and they won't change
foreach (var d in newData)
{
// find data so we can compare between new (csv) and current (from db) to see what possibly changed
var oData = (from o in origData
where o.id == d.id
select o).FirstOrDefault();
// only the columns in the updatableColumns list are compared
var diff = d.DetailedCompare(oData, comparableColumns.ToList());
if (diff.Count > 0)
{
// even though there are differences between the csv record and db record doesn't mean what the user input is valid. only existing ref data is valid and needs to be checked before a change is made
bool changed = false;
// make a copy of this original data and we'll check after if we actually were able to make a change to it (was the value provided valid)
var data = CopyRecord(oData);
// update this record's data fields that have changed with the new data
foreach (var v in diff)
{
// special check for setting a value to NULL as its always valid to do this but wouldn't show up in ref data to pass the next check below
if (v.valA == null)
{
oData.GetType().GetProperty(v.Prop).SetValue(oData, v.valA);
oData.UpdatedBy = user;
oData.UpdatedDate = DateTime.Now;
changed = true;
}
// validate that the value for this column is in the ref table before allowing an update. note exception if not so we can tell the user
else if (refData[v.Prop].Where(a => a.value == v.valA.ToString()).FirstOrDefault() != null)
{
// update the current objects values with the new objects value as it changed and is a valid value based on the ref data defined for that column
oData.GetType().GetProperty(v.Prop).SetValue(oData, v.valA);
oData.UpdatedBy = user;
oData.UpdatedDate = DateTime.Now;
changed = true;
}
else
{
// the value provided isn't valid for this column so note this to tell the user
exceptions.Add(string.Format("Error: ID: {0}, Value: '{1}' is not valid for column [{2}]. Add the reference data if needed and re-import.", d.id, v.valA, v.Prop));
}
}
// we only need to reattach and save off changes IF we actually changed something to a valid ref value and we had no exceptions for this record
if (changed && exceptions.Count == 0)
{
// because our current object was in memory we will reattached it to EF so we can mark it as changed and SaveChanges() will write it back to the DB
ctx.MyTable.Attach(oData);
ctx.Entry(oData).State = EntityState.Modified;
// add a history record for the change to this product
CreateHistoryRecord(data, user);
}
}
}
// wait until the very end before making DB changed. we don't save anything if there are exceptions or nothing changed
if (exceptions.Count == 0)
{
ctx.SaveChanges();
}
</code></pre>
| 0debug
|
Duplicate a view programmatically from an already existing view : <p>I was trying the following code and was getting an error because there is no such constructor defined.</p>
<p><code>View v = new View(findViewById(R.id.divider));</code></p>
<p>Is there any simple way to copy a view into another?</p>
| 0debug
|
Binding in ViewHolder : <p>This will be theoretical question.</p>
<p>As everyone we use RecyclerView in many parts of the app. Sometimes RecyclerView contains different items, not only image for example, but ads, hints etc. And that's why we can use getViewType() method in Adapter. </p>
<p>But problem occurs when we have many viewTypes and binding this in Adapter is not elegant. So here is the question, <strong>is it nice and good pattern to bind data in ViewHolder?</strong></p>
<p>Let's say we have list of apps.</p>
<p>Every app has name for simplicity. Our ViewHolder looks like this:</p>
<pre><code>class AppViewHolder extends RecyclerView.ViewHolder {
public TextView nameText;
AppViewHolder(View itemView) {
super(itemView)
nameText = (TextView) itemView.findViewById(R.id.text_name);
}
}
</code></pre>
<p>Now we could add bind method:</p>
<pre><code>public void bind(App app) {
nameText.setText(app.getName());
}
</code></pre>
<p>Is it good pattern?</p>
<p>Another solution would be using ViewModel. Because we have different items in RecyclerView, our Adapter could contain list of class which is base class for every ViewModel.</p>
<p>So basic class is:</p>
<pre><code>class RecyclerViewItem {}
</code></pre>
<p>Now class which is ViewModel for App.</p>
<pre><code>class AppRecyclerViewItem extends RecyclerViewItem {
App app;
...
}
</code></pre>
<p>and our Adapter just has list of RecyclerViewItems:</p>
<pre><code>class Adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
List<RecyclerViewItem> items;
...
}
</code></pre>
<p>So with this approach (I mean using ViewModel) is it better to add bind method in ViewHolder, or in ViewModel?</p>
| 0debug
|
Rename failed in Xcode 9 : <p>I used "renamed" function to rename a variable named "DefaultRequestURL" in Xcode 9, it alert this:
<a href="https://i.stack.imgur.com/iPgPk.jpg" rel="noreferrer">alert image</a>
I have checked the file "ComposeController.swift", there is no "DefaultRequestURL"。
I have restart Xcode and do "Product -> Clean", it still failed.</p>
<p>why this? What should I do?</p>
| 0debug
|
Windows command to download a file from URL : <p>I want to download a file using the windows command from url. I want to know if there is a command like <strong>wget</strong> in windows.</p>
<p>Thank you </p>
| 0debug
|
How to explicitly set samesite=None on a flask response : <p>Due to changes arriving in Chrome during July, I need to modify my app to explicitly provide the SameSite=None key value. This is due to the RFC treating the absence of this setting in a more impacting way than if it is present but set to None. </p>
<p>However on the set_cookie method, the samesite parameter is defaulted to None which results in it not being written into the set-cookie. How can I force this into the set-cookie part of the response?</p>
<p>When I try to set the samesite=None with the following code</p>
<pre><code>resp.set_cookie('abcid', 'Hello', domain=request_data.domain, path='/', samesite=None, max_age=63072000)
</code></pre>
<p>This does not show any SameSite detail in the returned set-cookie</p>
<blockquote>
<p>abcid=Hello; Domain=.localhost; Expires=Tue, 29-Jun-2021 22:34:02 GMT; Max-Age=63072000; Path=/</p>
</blockquote>
<p>And if I try and explicitly set the value of Lax (which is one of the accepted values per rfc) as so</p>
<pre><code>resp.set_cookie('abcid', "Hello", domain=request_data.domain, path='/', samesite="Lax", max_age=63072000)
</code></pre>
<p>I get back the set-cookie which explicitly has the SameSite=Lax setting</p>
<blockquote>
<p>abcid=Hello; Domain=.localhost; Expires=Tue, 29-Jun-2021 23:03:10 GMT; Max-Age=63072000; Path=/; SameSite=Lax</p>
</blockquote>
<p>I have tried None, "None", and "" but these either crash the application or omit the SameSite in the resultant response.</p>
<p>Any help would be gratefully received</p>
| 0debug
|
static char *pcibus_get_dev_path(DeviceState *dev)
{
PCIDevice *d = container_of(dev, PCIDevice, qdev);
PCIDevice *t;
int slot_depth;
int domain_len = strlen("DDDD:00");
int slot_len = strlen(":SS.F");
int path_len;
char *path, *p;
;
slot_depth = 0;
for (t = d; t; t = t->bus->parent_dev) {
++slot_depth;
}
path_len = domain_len + slot_len * slot_depth;
path = malloc(path_len + 1 );
path[path_len] = '\0';
snprintf(path, domain_len, "%04x:00", pci_find_domain(d->bus));
p = path + path_len;
for (t = d; t; t = t->bus->parent_dev) {
p -= slot_len;
snprintf(p, slot_len, ":%02x.%x", PCI_SLOT(t->devfn), PCI_FUNC(d->devfn));
}
return path;
}
| 1threat
|
import re
def text_match_wordz(text):
patterns = '\w*z.\w*'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!')
| 0debug
|
IndexOutOfRange even when it is in range WPF : I have a very interesting question.
String[] values = new String[3];
values = line.Split(';');
Console.Write("Val:" + values[0] + ", " + values[1] + ", " + values[2]);
Could someone tell me why I get an "IndexOutOfRangeException" when it is in range?
EDIT:
The line has 3 sectors, for example "1:2:3". The console writes out the Val: ... but in the output i still get an IndexOutOfRangeException.
| 0debug
|
Using Multiple Select Boxes in HTML Form : <p>I am a beginner with PHP coding. I am working on a website for a Salon and the site has a form where users can book appointments in the form of sending an email and i am trying to POST values from multiple select boxes i have in the HTML form and sending that data along with the other fields in an email. The other fields are POST-ing fine. But the select boxes are not working. Below is the code i'm working with:</p>
<pre><code><?php
$clnt_name = $_POST['w_p_c_name'];
$clnt_email = $_POST['w_p_c_email'];
$clnt_phn_no = $_POST['w_p_c_number'];
$rsrvtn_date = $_POST['w_p_c_date'];
$hair_cut = $POST['opt_hair_cut'];
$colr_whl_hair = $POST['opt_colouring_whole_hair'];
$colr_retouch = $POST['opt_colouring_retouch_roots'];
$colr_highlight = $POST['opt_colouring_highlighting'];
$rebonding = $POST['opt_rebonding'];
$relax_straight = $POST['opt_relaxing_straightening'];
$perming = $POST['opt_perming'];
$threading = $POST['opt_threading'];
$bleaching = $POST['opt_bleaching'];
$manicure = $POST['opt_manicure'];
$pedicure = $POST['opt_pedicure'];
$nail = $POST['opt_nail'];
$gel_nail = $POST['opt_gel_nail'];
$massage = $POST['opt_massage'];
$scrub = $POST['opt_scrub'];
$wax_face = $POST['opt_wax_face'];
$wax_arms = $POST['opt_wax_arms'];
$wax_leg = $POST['opt_wax_leg'];
$wax_body = $POST['opt_wax_body'];
$wax_intimate = $POST['opt_wax_intimate'];
$makeup = $POST['opt_makeup'];
$hijab = $POST['opt_hijab'];
$hairstyle_blodry = $POST['opt_hairstyle_blowdry'];
$hairstyle_iron = $POST['opt_hairstyle_iron'];
$hairstyle_spcl = $POST['opt_hairstyle_special'];
$hair_trmnt = $POST['opt_hair_treatment'];
$face_cleaning = $POST['opt_face_cleaning'];
$facials = $POST['opt_facials'];
$face_trmnt = $POST['opt_face_treatments'];
$scrub_ladies = $POST['opt_scrubs_ladies'];
$massage_ladies = $POST['opt_massage_ladies'];
$data = "Name : ".$clnt_name."\nEmail : ".$clnt_email."\nPhone : ".$clnt_phn_no."\nRequested Date : ".$rsrvtn_date."\nServices Requested :\n\n".$hair_cut."\n".$colr_whl_hair."\n".$colr_retouch."\n".$colr_highlight."\n".$rebonding."\n".$relax_straight."\n".$perming."\n".$threading."\n".$bleaching."\n".$manicure."\n".$pedicure."\n".$nail."\n".$gel_nail."\n".$massage."\n".$scrub."\n".$wax_face."\n".$wax_arms."\n".$wax_leg."\n".$wax_body."\n".$wax_intimate."\n".$makeup."\n".$hijab."\n".$hairstyle_blodry."\n".$hairstyle_iron."\n".$hairstyle_spcl."\n".$hair_trmnt."\n".$face_cleaning."\n".$facials."\n".$face_trmnt."\n".$scrub_ladies."\n".$massage_ladies;
$file = "services.xlxs";
$subject = "Reservation Booking";
$mail_message1 = "Hi ".$clnt_name." We have received your request for a reservation with the following details.\n\n".$data."\n\nWe will be calling to confirm the reservation shortly.\n\nThank you";
$to_rsvtn = "reservation@uxanisalon.com";
$subject2 = "Reservation";
$mail_message2 = "There has been a new request for a reservation. Details are listed below: \n\n".$data;
file_put_contents($file, $data1 . PHP_EOL, FILE_APPEND);
file_put_contents($file, $data2 . PHP_EOL, FILE_APPEND);
file_put_contents($file, $data3 . PHP_EOL, FILE_APPEND);
mail($clnt_email, $subject, $mail_message1, "From:" . $to_rsvtn);
mail($to_rsvtn, $subject2, $mail_message2, "From:" . $to_rsvtn);
header('Location: ba-complete.html');
?>
</code></pre>
<p>Any help is much appreciated.</p>
| 0debug
|
I have a header which has two list item. when I zoom screen the text breaks . how I can fix that : I have a header which has two list item. when I zoom screen the text breaks . how I can fix that ?
| 0debug
|
How do I check if two input fields have values using JQuery? : <p>I would like to execute a block of code if two input fields have values. Here's the code that I have so far but I believe I typed the syntax wrong.</p>
<pre><code>jQuery(document).ready( function($) {
$('button').click(function(){
if ($('#signonname').length > 0) && ($('#signonpassword').length > 0) {
// do something
} else {
alert('Fields are not filled out');
}
});
});
</code></pre>
| 0debug
|
How to update single value inside specific array item in redux : <p>I have an issue where re-rendering of state causes ui issues and was suggested to only update specific value inside my reducer to reduce amount of re-rendering on a page.</p>
<p>this is example of my state</p>
<pre><code>{
name: "some name",
subtitle: "some subtitle",
contents: [
{title: "some title", text: "some text"},
{title: "some other title", text: "some other text"}
]
}
</code></pre>
<p>and I am currently updating it like this</p>
<pre><code>case 'SOME_ACTION':
return { ...state, contents: action.payload }
</code></pre>
<p>where <code>action.payload</code> is a whole array containing new values. But now I actually just need to update text of second item in contents array, and something like this doesn't work</p>
<pre><code>case 'SOME_ACTION':
return { ...state, contents[1].text: action.payload }
</code></pre>
<p>where <code>action.payload</code> is now a text I need for update.</p>
| 0debug
|
Parse error: syntax error, unexpected T_IF on line 115 : <p>when trying to run a php script I get the error 'Unexpected T_IF'
Yes, it is a botnet script, however I am just researching about networking, I have no intentions to use it.
And yes, I did try putting a semi colon, no luck.
Full script: <a href="https://github.com/Visgean/Zeus/blob/translation/source/server%5Bphp%5D/install/index.php" rel="nofollow">https://github.com/Visgean/Zeus/blob/translation/source/server%5Bphp%5D/install/index.php</a></p>
<pre><code>"`r_reports_db` bool NOT NULL default '1', ".
"`r_reports_db_edit` bool NOT NULL default '1', ".
"`r_reports_files` bool NOT NULL default '1', ".
"`r_reports_files_edit` bool NOT NULL default '1', ".
/*EVAL_BEGIN*/if (configBool('jabber_notifier'))return /*THIS IS ERROR*/
"\"`r_reports_jn` bool NOT NULL default '1', \".";
/*EVAL_END*/
"`r_system_info` bool NOT NULL default '1', ".
"`r_system_options` bool NOT NULL default '1', ".
"`r_system_user` bool NOT NULL default '1', ".
"`r_system_users` bool NOT NULL default '1'";
//RЎRєSЂReRїS, C <P ± RѕS, P ° Rј.
$_TABLES['botnet_scripts'] =
</code></pre>
| 0debug
|
<a href="www.example.com">example</a> redirects to mysite.com/www.example.com? : <p>Example: </p>
<pre><code><a href="www.example.com"> Click here to go to www.example.com!</a>
</code></pre>
<p>and</p>
<pre><code><a href="http://www.example.com"> Click here to go to www.example.com!</a>
</code></pre>
<p>The first one redirects to the following URL: <code>http://www.currentsite.com/www.example.com</code>
while the second one works perfectly fine.</p>
<p>here's the code I'm using: (ruby on rails)</p>
<pre><code><%=h link_to @user.details.website, @user.details.website, :class => 'link'%>
</code></pre>
<p>The only solution I have would be checking for <code>http://</code> and add it if it's not already there.</p>
| 0debug
|
static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len,
DMADirection dir)
{
dma_addr_t addr;
DMADirection expected_dir;
if (pci->dma_regs[DMA_CMD] & DMA_CMD_DIR) {
expected_dir = DMA_DIRECTION_FROM_DEVICE;
} else {
expected_dir = DMA_DIRECTION_TO_DEVICE;
}
if (dir != expected_dir) {
trace_esp_pci_error_invalid_dma_direction();
return;
}
if (pci->dma_regs[DMA_STAT] & DMA_CMD_MDL) {
qemu_log_mask(LOG_UNIMP, "am53c974: MDL transfer not implemented\n");
}
addr = pci->dma_regs[DMA_SPA];
if (pci->dma_regs[DMA_WBC] < len) {
len = pci->dma_regs[DMA_WBC];
}
pci_dma_rw(PCI_DEVICE(pci), addr, buf, len, dir);
pci->dma_regs[DMA_WBC] -= len;
pci->dma_regs[DMA_WAC] += len;
}
| 1threat
|
void object_property_add_link(Object *obj, const char *name,
const char *type, Object **child,
void (*check)(Object *, const char *,
Object *, Error **),
ObjectPropertyLinkFlags flags,
Error **errp)
{
Error *local_err = NULL;
LinkProperty *prop = g_malloc(sizeof(*prop));
gchar *full_type;
ObjectProperty *op;
prop->child = child;
prop->check = check;
prop->flags = flags;
full_type = g_strdup_printf("link<%s>", type);
op = object_property_add(obj, name, full_type,
object_get_link_property,
check ? object_set_link_property : NULL,
object_release_link_property,
prop,
&local_err);
if (local_err) {
error_propagate(errp, local_err);
g_free(prop);
goto out;
}
op->resolve = object_resolve_link_property;
out:
g_free(full_type);
}
| 1threat
|
AWS cloudformation error: Template validation error: Template error: resource NotificationsTopic does not support attribute type Arn in Fn::GetAtt : <p>I am trying to create an AWS cloudformation stack using a yaml template.
The goal is to create a sns topic for some notifications.
I want to output the topic arn, to be able to subscribe multiple functions to that topic by just specifying the topic arn.</p>
<p>However I am getting an error when I try to create the stack from the aws console: </p>
<p>"Template validation error: Template error: resource NotificationsTopic does not support attribute type Arn in Fn::GetAtt"</p>
<p>I have done exactly the same for s3 buckets, dynamodb tables, and all working good, but for some reason, with SNS topic I cannot get the ARN.</p>
<p>I want to avoid hardcoding the topic arn in all functions that are subscribed. Because if one day the the ARN topic changes, I'll need to change all functions, instead I want to import the topic arn in all functions and use it. This way I will have to modify nothing if for any reason I have a new arn topic in the future.</p>
<p>This is the template:</p>
<pre><code> Parameters:
stage:
Type: String
Default: dev
AllowedValues:
- dev
- int
- uat
- prod
Resources:
NotificationsTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: !Sub 'notifications-${stage}'
Subscription:
- SNS Subscription
TopicName: !Sub 'notifications-${stage}'
Outputs:
NotificationsTopicArn:
Description: The notifications topic Arn.
Value: !GetAtt NotificationsTopic.Arn
Export:
Name: !Sub '${AWS::StackName}-NotificationsTopicArn'
NotificationsTopicName:
Description: Notifications topic name.
Value: !Sub 'notifications-${stage}'
Export:
Name: !Sub '${AWS::StackName}-NotificationsTopicName'
</code></pre>
| 0debug
|
int qemu_register_machine(QEMUMachine *m)
{
char *name = g_strconcat(m->name, TYPE_MACHINE_SUFFIX, NULL);
TypeInfo ti = {
.name = name,
.parent = TYPE_MACHINE,
.class_init = machine_class_init,
.class_data = (void *)m,
};
type_register(&ti);
g_free(name);
return 0;
}
| 1threat
|
JavaScript: How to filter object into list of keys where nested property meets condition? : <p>How can I filter an object into an array of keys matching a particular condition on nested object values. For example if I want to filter the following</p>
<pre><code>let object = {
'key1': {
'value': 'one'
},
'key2': {
'value': 'two'
},
'key3': {
'value': 'two'
}
}
</code></pre>
<p>by children that have <code>'value': 'two'</code> to produce</p>
<pre><code>['key2', 'key3']
</code></pre>
<p>how might I achieve this.</p>
| 0debug
|
I want to make an infinity loop with two void functions in c++ : <p>I was wondering if there is a way to make an infinity loop the first function will call the second and the second will call the first and so on. Please make a code in C++. Thanks already.</p>
| 0debug
|
How can i add a main line and main column for my table? : my table :
'L1' 'B'
'L2' 'B'
'L3' 'A'
'L4' 'C'
'L5' 'B'
'L6' 'C'
'L7' 'C'
'L8' 'A'
How i'd like my table to be :
Line1 Line2
Col1 'L1' 'B'
Col2 'L2' 'B'
Col3 'L3' 'A'
Col4 'L4' 'C'
Col5 'L5' 'B'
Col6 'L6' 'C'
Col7 'L7' 'C'
Col8 'L8' 'A'
Then how can i find all lines with B as column, would something like b_values = `table( 'B' == table(:,2))`
expected output:
Line1 Line2
Col1 'L1' 'B'
Col2 'L2' 'B'
Col5 'L5' 'B'
| 0debug
|
How to fix 'Static HTML elements with event handlers require a role.'? : <p>My reactjs styledcomponent contains this code:</p>
<pre><code><a styling="link" onClick={() => this.gotoLink()}>
<SomeComponent />
</a>
</code></pre>
<p>This works fine but the eslint is complaining:</p>
<pre><code>Static HTML elements with event handlers require a role.
</code></pre>
<p>How can I fix this error?</p>
| 0debug
|
Angular show class active on Navbar : <p>I know I can use <code>[routerLinkActive]="['active']"</code>, in fact I'm using it and works fine when I click the button on navbar and redirect's to <code>example.com/home</code>, but if I use only <code>example.com</code>, the is no active class, <code>/home</code> and only the url are the same component, how can I solve this?</p>
| 0debug
|
Notice: Undefined variable: tipe in on line : <p>I'm a student and currently I'm learning about PHP, i'm stuck at this, I really don't understand, and I hope there someone can teach me how to fix this things</p>
<p>The error shows:
Notice: Undefined variable: tipe in C:\xampp\htdocs\q\admin\tambahjadwal.php on line 13
semua form harus diisi!</p>
<pre><code><?php
include"../koneksi/koneksi.php";
if(isset($_POST['tipe'])){
$berangkat=strip_tags($_POST['tipe']);
$dari=strip_tags($_POST['lokasi']);
$ke=strip_tags($_POST['harga']);
$waktu=strip_tags($_POST['fasilitas']);
$harga=strip_tags($_POST['max']);
$gambar=$_FILES['gambar']['tmp_name'];
$gambar_name=$_FILES[ 'gambar']['name'];
if($gambar&&$tipe&&$lokasi&&$harga&&$fasilitas&&$max){
move_uploaded_file($gambar, '../gambar/'.$gambar_name);
$insert="insert into hotel values('','$gambar_name','$tipe','$lokasi','$harga','$fasilitas','$max')";
$hasil=mysql_query($insert);
echo"<script>alert('jadwal berhasil ditambah');window.location.href='index.php';</script>";
}else{
echo"semua form harus diisi!";
}}
?>
<html>
<body>
<h2>Tambah Hotel</h2><br />
<form action="#" method="post" enctype="multipart/form-data">
<table width="850" border="0">
<tr>
<td width="360" align="right">gambar</td>
<td width="14" align="center">:</td>
<td width="462"><input type="file" name="gambar" required="required" /></td>
</tr>
<tr>
<td align="right">Tipe</td>
<td align="center">:</td>
<td><input type="text" name="tipe"" class="input" required="required" /></td>
</tr>
<tr>
<td align="right">Lokasi</td>
<td align="center">:</td>
<td><input type="text" name="lokasi" class="input" required="required" /></td>
</tr>
<tr>
<td align="right">Harga</td>
<td align="center">:</td>
<td><input type="text" name="harga" class="input" required="required" /></td>
</tr>
<tr>
<td align="right">Fasilitas</td>
<td align="center">:</td>
<td><input type="text" name="fasilitas" class="input" required="required" /></td>
</tr>
<tr>
<td align="right">Maksimal</td>
<td align="center">:</td>
<td><input type="text" name="max" class="input" required="required" /></td>
</tr>
<tr>
<td height="73" align="right"><input type="reset" value="reset" class="button" /></td>
<td>&nbsp;</td>
<td><input type="submit" value="tambah" class="button" onclick="return confirm('apakah anda yakin?')" /></td>
</tr>
</table>
</form>
</body>
</html>
</code></pre>
<p>and koneksi.php</p>
<pre><code><?php
mysql_connect("localhost","root","");
mysql_select_db("a");
?>
</code></pre>
| 0debug
|
Map only non-nil values : <p>I am serialising some json into objects with a failable json initialiser like this:</p>
<pre><code> sections = {
let sectionJsons = json["sections"] as! [[String:AnyObject]]
return sectionJsons.map {
DynamicSection($0)
}
}()
</code></pre>
<p>DynamicSection's init: </p>
<pre><code>init?(_ json:[String:AnyObject]) {
super.init()
//Boring stuff that can fail
</code></pre>
<p>I want to only append the DynamicSections that passed the init to sections. How can I accomplish this?</p>
<p>I <em>can</em> use <code>filter</code>+<code>map</code> like </p>
<pre><code>return sectionJsons.filter { DynamicSection($0) != nil }.map { DynamicSection($0)! }
</code></pre>
<p>But that leads to initing the DynamicSection twice, which i'd like to avoid. Is there any better way to do this?</p>
| 0debug
|
In Unity, How to Stop Popup for "Show Unity Splashscreen" : <p>I'm just now learning how to use Unity to mess around in SteamVR. Every time I press the play button to test out my scene, I get this annoying popup. The tutorial I'm following doesn't have this problem. How can I get the popup to go away for good? I always "Accept" it and it tells me "I made the right choice" but then it just comes back next time. And... it pops up randomly as well...</p>
<p><a href="https://i.stack.imgur.com/GP3Bu.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GP3Bu.png" alt="Show Unity Splashscreen Popup"></a></p>
| 0debug
|
How do I enable DataTable JS? : I am trying to make a function table to be a data table but as a noob am failing.
I want search and pagination Datatable. Can anyone help?
$(document).ready(function(){
function fetch_data()
{
$.ajax({
url:"fetch.php",
method:"POST",
dataType:"json",
success:function(data)
{
var html = '';
for(var count = 0; count < data.length; count++)
{
html += '<tr>';
html += '<td><input type="checkbox" id="'+data[count].id+'" data-name="'+data[count].name+'" data-address="'+data[count].address+'" data-gender="'+data[count].gender+'" data-designation="'+data[count].designation+'" data-age="'+data[count].age+'" class="check_box" /></td>';
html += '<td>'+data[count].name+'</td>';
html += '<td>'+data[count].address+'</td>';
html += '<td>'+data[count].gender+'</td>';
html += '<td>'+data[count].designation+'</td>';
html += '<td>'+data[count].age+'</td></tr>';
}
$('tbody').html(html);
}
});
}
fetch_data();
| 0debug
|
I want call a function inside a key : so I am learning javascript since the start of this year so I dont know much.
{key:"setup",value:function() { code } }
I wanna call the function(?) "setup" but I dont know how. There is a way do to it ?
| 0debug
|
Break loops in C# using while statement : i am writing a c# program that prints 'true'if number <=20 and false if number > 20 using while loop but the program keeps on executing.
i want to break the program if it reaches certain number e.g. number > 26
please help me to solve the issue.
The code for the program is:
public static void Main()
{
Console.WriteLine("Please enter a number");
int numnber = Convert.ToInt32(Console.ReadLine());
while (numnber <= 20)
{
Console.WriteLine("True");
Console.ReadLine();
int number1 = numnber++;
while (numnber > 20)
{
Console.WriteLine("False");
Console.ReadLine();
}
}
| 0debug
|
scala - how to add a new column to Dataframe depending on the values of another one? : <p>I've created a dataframe with info about sales. Now I want to add a column (<code>metric1</code>) with booleans to the dataframe which values will depend on the <code>sl.review</code> field: if <code>sl.review</code> contains an empty string, then <code>metric1</code> will be false and <code>true</code> otherwise if there is a review in <code>sl.review</code>. </p>
<pre><code>val salesDf: DataFrame = salesRawDf.select($"stores", explode($"sales").as("sl"))
.select($"stores.id", $"stores.name", $"sl.id", $"sl.current_sales", $"sl.review")
</code></pre>
<p>How is it possible to achieve with DataFrame? I've read this related <a href="https://stackoverflow.com/questions/29909448/add-new-column-in-dataframe-base-on-existing-column">question</a> but still can't figure out how to implement this in my case.</p>
| 0debug
|
int nbd_client_co_flush(BlockDriverState *bs)
{
NbdClientSession *client = nbd_get_client_session(bs);
struct nbd_request request = { .type = NBD_CMD_FLUSH };
struct nbd_reply reply;
ssize_t ret;
if (!(client->nbdflags & NBD_FLAG_SEND_FLUSH)) {
return 0;
}
if (client->nbdflags & NBD_FLAG_SEND_FUA) {
request.type |= NBD_CMD_FLAG_FUA;
}
request.from = 0;
request.len = 0;
nbd_coroutine_start(client, &request);
ret = nbd_co_send_request(bs, &request, NULL, 0);
if (ret < 0) {
reply.error = -ret;
} else {
nbd_co_receive_reply(client, &request, &reply, NULL, 0);
}
nbd_coroutine_end(client, &request);
return -reply.error;
}
| 1threat
|
What does |= signify in C++? : <p>I was going through the source code of Intel's deep learning framework Caffe, when I came across <code>|=</code>. I've never seen that before in any code. In fact, I found it twice in the code. <a href="https://github.com/intel/caffe/blob/master/src/caffe/net.cpp#L188" rel="nofollow noreferrer">Line 188</a>:</p>
<pre><code>need_backward |= blob_need_backward_[blob_id];
</code></pre>
<p>and <a href="https://github.com/intel/caffe/blob/master/src/caffe/net.cpp#L254" rel="nofollow noreferrer">line 254</a>:</p>
<pre><code>need_backward |= param_need_backward;
</code></pre>
<p>I realize that they both are housed in a for loop which might signify some kind of relation. I'm just assuming. </p>
| 0debug
|
<Provider> does not support changing `store` on the fly in reactnative + redux : <p>error message - </p>
<p>Provider does not support changing store on the fly. It is most likely that you see this error because you updated to Redux 2.x and React Redux 2.x which no longer hot reload reducers automatically. See <a href="https://github.com/reactjs/react-redux/releases/tag/v2.0.0" rel="noreferrer">https://github.com/reactjs/react-redux/releases/tag/v2.0.0</a> for the migration instructions.</p>
<p>configureStore.js -</p>
<pre><code>import { createStore,applyMiddleware } from 'redux';
import ReduxThunk from 'redux-thunk';
import reducers from './reducers';
export default function configureStore(initialState) {
const store = createStore(reducers,{},applyMiddleware(ReduxThunk));
if (module.hot) {
// console.log("in module.hot");
console.log(reducers);
module.hot.accept( () => {
const nextRootReducer = require('./reducers/index').default;
store.replaceReducer(nextRootReducer)
});
}
return store;
}
</code></pre>
<p>App.js -</p>
<pre><code>render(){
const store = configureStore();
return(
<Provider store = {store}>
<Container>
<Login/>
</Container>
</Provider>
</code></pre>
<p>refrence -
video - <a href="https://www.youtube.com/watch?v=t2WXfAqLXJw" rel="noreferrer">https://www.youtube.com/watch?v=t2WXfAqLXJw</a><br>
github - <a href="https://github.com/reactjs/react-redux/releases/tag/v2.0.0" rel="noreferrer">https://github.com/reactjs/react-redux/releases/tag/v2.0.0</a></p>
<p>solution given in video is implemented</p>
| 0debug
|
How to change JSON structure in JavaScript : <p>I need to change JSON structure but I'm struggling how to do it, and also I'm not sure if I need to create a new object or I can just work on the current one?</p>
<p>Anyway this is the JSON I want to change:</p>
<pre><code>{
"start": [
{"time": 22, "value": 324, "year": 2016},
{"time": 142, "value": 234, "year": 2016},
...
],
"end": [
{"time": 123, "value": 254, "year": 2016},
...
]
}
</code></pre>
<p>And change it to this:</p>
<pre><code>{
"key": "start",
"values": [
{"time": 22, "value": 324, "year": 2016},
{"time": 142, "value": 234, "year": 2016},
...
]
}, {
"key": "end",
"values": [
{"time": 123, "value": 254, "year": 2016},
...
]
}
</code></pre>
| 0debug
|
How to convert a Kotlin data class object to map? : <p>Is there any easy way or any standard library method to convert a Kotlin data class object to a map/dictionary of it's properties by property names? Can reflection be avoided?</p>
| 0debug
|
Get r_liteprofile and r_emailaddress - api.linkedin.com/v2 : <p>How to get email address and lite profile from linkedIn api v2 (api.linkedin.com/v2)</p>
<p>Can not get email from <a href="https://api.linkedin.com/v2/me?oauth2_access_token=xxxx" rel="noreferrer">https://api.linkedin.com/v2/me?oauth2_access_token=xxxx</a></p>
<p>Requested &scope=r_emailaddress%20r_liteprofile</p>
| 0debug
|
number dataframe greater row colum : How can I select numbers whose values are greater than 5? And how to determine which row and column are these numbers in? That is, how do I get a data frame like this
df=data.frame(co1=c(5,9,6,1,6),co2=(8,5,4,6,2),co3=(6,5,4,1,2),co4=(6,1,5,3,2),co5=c(5,1,2,6,8)
rownames(df)=c("row1","row2","row3","row4","row5")
df
# co1 co2 co3 co4 co5
#row1 5 8 6 6 5
#row2 9 5 5 1 1
#row3 6 4 4 5 2
#row4 1 6 1 3 6
#row5 6 2 2 2 8
| 0debug
|
int gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,
int search_pc)
{
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
uint32_t pc_start;
uint16_t *gen_opc_end;
int j, lj = -1;
pc_start = tb->pc;
gen_opc_ptr = gen_opc_buf;
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
gen_opparam_ptr = gen_opparam_buf;
ctx.nip = pc_start;
ctx.tb = tb;
ctx.exception = EXCP_NONE;
#if defined(CONFIG_USER_ONLY)
ctx.mem_idx = 0;
#else
ctx.supervisor = 1 - msr_pr;
ctx.mem_idx = (1 - msr_pr);
#endif
#if defined (DO_SINGLE_STEP)
msr_se = 1;
#endif
env->access_type = ACCESS_CODE;
while (ctx.exception == EXCP_NONE && gen_opc_ptr < gen_opc_end) {
if (search_pc) {
if (loglevel > 0)
fprintf(logfile, "Search PC...\n");
j = gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
gen_opc_instr_start[lj++] = 0;
gen_opc_pc[lj] = ctx.nip;
gen_opc_instr_start[lj] = 1;
}
}
#if defined PPC_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "----------------\n");
fprintf(logfile, "nip=%08x super=%d ir=%d\n",
ctx.nip, 1 - msr_pr, msr_ir);
}
#endif
ctx.opcode = ldl_code((void *)ctx.nip);
#if defined PPC_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "translate opcode %08x (%02x %02x %02x)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode));
}
#endif
ctx.nip += 4;
table = ppc_opcodes;
handler = table[opc1(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc2(ctx.opcode)];
if (is_indirect_opcode(handler)) {
table = ind_table(handler);
handler = table[opc3(ctx.opcode)];
}
}
if (handler->handler == &gen_invalid) {
if (loglevel > 0) {
fprintf(logfile, "invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) 0x%08x %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, msr_ir);
} else {
printf("invalid/unsupported opcode: "
"%02x - %02x - %02x (%08x) 0x%08x %d\n",
opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, msr_ir);
}
} else {
if ((ctx.opcode & handler->inval) != 0) {
if (loglevel > 0) {
fprintf(logfile, "invalid bits: %08x for opcode: "
"%02x -%02x - %02x (0x%08x) (0x%08x)\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
} else {
printf("invalid bits: %08x for opcode: "
"%02x -%02x - %02x (0x%08x) (0x%08x)\n",
ctx.opcode & handler->inval, opc1(ctx.opcode),
opc2(ctx.opcode), opc3(ctx.opcode),
ctx.opcode, ctx.nip - 4);
}
RET_INVAL(ctxp);
break;
}
}
(*(handler->handler))(&ctx);
if ((msr_be && ctx.exception == EXCP_BRANCH) ||
(msr_se && (ctx.nip < 0x100 ||
ctx.nip > 0xF00 ||
(ctx.nip & 0xFC) != 0x04) &&
ctx.exception != EXCP_SYSCALL && ctx.exception != EXCP_RFI &&
ctx.exception != EXCP_TRAP)) {
RET_EXCP(ctxp, EXCP_TRACE, 0);
}
if ((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) {
RET_EXCP(ctxp, EXCP_BRANCH, 0);
}
}
if (ctx.exception == EXCP_NONE) {
gen_op_b((unsigned long)ctx.tb, ctx.nip);
} else if (ctx.exception != EXCP_BRANCH) {
gen_op_set_T0(0);
}
#if 1
gen_op_set_T0(0);
#endif
gen_op_exit_tb();
*gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
tb->size = 0;
#if 0
if (loglevel > 0) {
page_dump(logfile);
}
#endif
} else {
tb->size = ctx.nip - pc_start;
}
#ifdef DEBUG_DISAS
if (loglevel & CPU_LOG_TB_CPU) {
fprintf(logfile, "---------------- excp: %04x\n", ctx.exception);
cpu_ppc_dump_state(env, logfile, 0);
}
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "IN: %s\n", lookup_symbol((void *)pc_start));
disas(logfile, (void *)pc_start, ctx.nip - pc_start, 0, 0);
fprintf(logfile, "\n");
}
if (loglevel & CPU_LOG_TB_OP) {
fprintf(logfile, "OP:\n");
dump_ops(gen_opc_buf, gen_opparam_buf);
fprintf(logfile, "\n");
}
#endif
env->access_type = ACCESS_INT;
return 0;
}
| 1threat
|
int target_mprotect(abi_ulong start, abi_ulong len, int prot)
{
abi_ulong end, host_start, host_end, addr;
int prot1, ret;
#ifdef DEBUG_MMAP
printf("mprotect: start=0x" TARGET_FMT_lx
"len=0x" TARGET_FMT_lx " prot=%c%c%c\n", start, len,
prot & PROT_READ ? 'r' : '-',
prot & PROT_WRITE ? 'w' : '-',
prot & PROT_EXEC ? 'x' : '-');
#endif
if ((start & ~TARGET_PAGE_MASK) != 0)
return -EINVAL;
len = TARGET_PAGE_ALIGN(len);
end = start + len;
if (end < start)
return -EINVAL;
if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
return -EINVAL;
if (len == 0)
return 0;
host_start = start & qemu_host_page_mask;
host_end = HOST_PAGE_ALIGN(end);
if (start > host_start) {
prot1 = prot;
for(addr = host_start; addr < start; addr += TARGET_PAGE_SIZE) {
prot1 |= page_get_flags(addr);
}
if (host_end == host_start + qemu_host_page_size) {
for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
prot1 |= page_get_flags(addr);
}
end = host_end;
}
ret = mprotect(g2h(host_start), qemu_host_page_size, prot1 & PAGE_BITS);
if (ret != 0)
return ret;
host_start += qemu_host_page_size;
}
if (end < host_end) {
prot1 = prot;
for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
prot1 |= page_get_flags(addr);
}
ret = mprotect(g2h(host_end - qemu_host_page_size), qemu_host_page_size,
prot1 & PAGE_BITS);
if (ret != 0)
return ret;
host_end -= qemu_host_page_size;
}
if (host_start < host_end) {
ret = mprotect(g2h(host_start), host_end - host_start, prot);
if (ret != 0)
return ret;
}
page_set_flags(start, start + len, prot | PAGE_VALID);
return 0;
}
| 1threat
|
Last Item in recyclerview is cut off : <p>I am using recyclerview to display a list of items and constraint layout is the parent view. The layout is displayed below: </p>
<pre><code> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<!-- Load the toolbar here -->
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:minHeight="?android:attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="@color/colorPrimary"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:visibility="visible"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
<ImageView
android:id="@+id/imageViewContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toTopOf="parent"
android:visibility="gone"
android:src="@drawable/empty_category"/>
<TextView
android:id="@+id/textViewContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="Empty Category"
android:textStyle="bold"
android:textColor="@color/colorPrimary"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageViewContent" />
</android.support.constraint.ConstraintLayout>
The adapter layout for each row is presented below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/framelayoutImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/buttonCart"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<ImageView
android:id="@+id/imageViewCoverArt"
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="center" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#59000000"
android:orientation="vertical">
<TextView
android:id="@+id/textViewPrice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"
android:layout_marginLeft="10dp"
android:clickable="false"
android:text="$220"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="@android:color/white"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"
android:layout_marginLeft="10dp"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:maxLength="17"
android:maxLines="1"
android:text="Lorem ipsum dolor sit amet, consecte"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="@android:color/white" />
</LinearLayout>
</FrameLayout>
<Button
android:id="@+id/buttonCart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="8dp"
android:background="@drawable/buttonshape"
android:text="Add to Cart"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@android:color/white"
android:textStyle="bold"
/>
</LinearLayout>
</code></pre>
<p>After running my application the layouts are presented in the image below:</p>
<p><a href="https://i.stack.imgur.com/dnhfp.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/dnhfp.jpg" alt="enter image description here"></a></p>
<p>I tried adding a bottom margin to the recycle view, but this has not resolved the issue. I used the following links as references: <a href="https://stackoverflow.com/questions/32742724/recyclerview-is-cutting-off-the-last-item/32743510">RecyclerView is cutting off the last item</a>, <a href="https://stackoverflow.com/questions/31097219/recyclerview-cutting-off-last-item">RecyclerView cutting off last item</a> and tried making those changes with no luck </p>
| 0debug
|
Java IO: Resource file getting modified in IDE but not in jar : <p>I am successfully able to read and write to a file in eclipse. I am also able to read from a file in the jar. However, I am not able to write to the file in the jar. It is located in a class folder called res. I have also unzipped the jar file and it contains the file I need to write to but it is not modified after the first run.</p>
<p>How can I do this?</p>
<p>I have tried <code>BufferedWriter</code> and <code>PrintWriter</code> but no effect. I tried using<code>FileOutputStream</code> but I cannot construct it using <code>getClass().getResourceAsStream(path)</code> as it returns an <code>InputStream</code>.</p>
| 0debug
|
void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, int size)
{
if (!f->ops->writev_buffer) {
qemu_put_buffer(f, buf, size);
return;
}
if (f->last_error) {
return;
}
f->bytes_xfer += size;
add_to_iovec(f, buf, size);
}
| 1threat
|
What are Torch Scripts in PyTorch? : <p>I've just found that PyTorch docs expose something that is called <a href="https://pytorch.org/docs/stable/jit.html?highlight=model%20features" rel="noreferrer">Torch Scripts</a>. However, I do not know:</p>
<ul>
<li>When they should be used?</li>
<li>How they should be used?</li>
<li>What are their benefits?</li>
</ul>
| 0debug
|
static void openpic_reset(DeviceState *d)
{
OpenPICState *opp = FROM_SYSBUS(typeof (*opp), sysbus_from_qdev(d));
int i;
opp->glbc = GLBC_RESET;
opp->frep = ((opp->nb_irqs -1) << FREP_NIRQ_SHIFT) |
((opp->nb_cpus -1) << FREP_NCPU_SHIFT) |
(opp->vid << FREP_VID_SHIFT);
opp->pint = 0;
opp->spve = -1 & opp->spve_mask;
opp->tifr = opp->tifr_reset;
for (i = 0; i < opp->max_irq; i++) {
opp->src[i].ipvp = opp->ipvp_reset;
opp->src[i].ide = opp->ide_reset;
}
for (i = 0; i < MAX_CPU; i++) {
opp->dst[i].pctp = 15;
opp->dst[i].pcsr = 0x00000000;
memset(&opp->dst[i].raised, 0, sizeof(IRQ_queue_t));
opp->dst[i].raised.next = -1;
memset(&opp->dst[i].servicing, 0, sizeof(IRQ_queue_t));
opp->dst[i].servicing.next = -1;
}
for (i = 0; i < MAX_TMR; i++) {
opp->timers[i].ticc = 0;
opp->timers[i].tibc = TIBC_CI;
}
opp->glbc = 0;
}
| 1threat
|
Code is not giving me the desired output , please help me : def main ():
found = False
coffee_file=('c:/test/coffee.txt','r')
search=input("Enter a description to search :- ")
descr=coffee_file.readline()
while (descr !=''):
qty=(coffee_file.readline())
descr=descr.rstrip('\n')
qty=qty.rstrip('\n')
if('search'==descr):
print("Description :- ", descr)
print("Quantity :- ",qty)
print
found= True
descr=coffee_file.readline()
coffee_file.close()
main()
Throws me AttributeError: 'tuple' object has no attribute 'readline'
Can someone please help me here ?
| 0debug
|
Clean up "Replica Sets" when updating deployments? : <p>Every time a deployment gets updated, a new replica set is added to a long list. Should the old rs be cleaned?</p>
| 0debug
|
static void start_auth_vencrypt_subauth(VncState *vs)
{
switch (vs->vd->subauth) {
case VNC_AUTH_VENCRYPT_TLSNONE:
case VNC_AUTH_VENCRYPT_X509NONE:
VNC_DEBUG("Accept TLS auth none\n");
vnc_write_u32(vs, 0);
start_client_init(vs);
break;
case VNC_AUTH_VENCRYPT_TLSVNC:
case VNC_AUTH_VENCRYPT_X509VNC:
VNC_DEBUG("Start TLS auth VNC\n");
start_auth_vnc(vs);
break;
#ifdef CONFIG_VNC_SASL
case VNC_AUTH_VENCRYPT_TLSSASL:
case VNC_AUTH_VENCRYPT_X509SASL:
VNC_DEBUG("Start TLS auth SASL\n");
return start_auth_sasl(vs);
#endif
default:
VNC_DEBUG("Reject subauth %d server bug\n", vs->vd->auth);
vnc_write_u8(vs, 1);
if (vs->minor >= 8) {
static const char err[] = "Unsupported authentication type";
vnc_write_u32(vs, sizeof(err));
vnc_write(vs, err, sizeof(err));
}
vnc_client_error(vs);
}
}
| 1threat
|
SBT Error: "Failed to construct terminal; falling back to unsupported..." : <p>I have run into an ERROR with SBT today. It can best be shown with the <code>sbt sbt-version</code> command:</p>
<p>Run on 5/29/17:</p>
<pre><code>eric@linux-x2vq:~$ sbt sbt-version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option
MaxPermSize=256M; support was removed in 8.0
[info] Set current project to eric (in build file:/home/eric/)
[info] 0.13.13
</code></pre>
<p>Run on 6/1/17:</p>
<pre><code>eric@linux-x2vq:~$ sbt sbt-version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option
MaxPermSize=256M; support was removed in 8.0
[ERROR] Failed to construct terminal; falling back to unsupported
java.lang.NumberFormatException: For input string: "0x100"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at jline.internal.InfoCmp.parseInfoCmp(InfoCmp.java:59)
at jline.UnixTerminal.parseInfoCmp(UnixTerminal.java:233)
at jline.UnixTerminal.<init>(UnixTerminal.java:64)
at jline.UnixTerminal.<init>(UnixTerminal.java:49)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at jline.TerminalFactory.getFlavor(TerminalFactory.java:209)
at jline.TerminalFactory.create(TerminalFactory.java:100)
at jline.TerminalFactory.get(TerminalFactory.java:184)
at jline.TerminalFactory.get(TerminalFactory.java:190)
at sbt.ConsoleLogger$.ansiSupported(ConsoleLogger.scala:123)
at sbt.ConsoleLogger$.<init>(ConsoleLogger.scala:117)
at sbt.ConsoleLogger$.<clinit>(ConsoleLogger.scala)
at sbt.GlobalLogging$.initial(GlobalLogging.scala:43)
at sbt.StandardMain$.initialGlobalLogging(Main.scala:64)
at sbt.StandardMain$.initialState(Main.scala:73)
at sbt.xMain.run(Main.scala:29)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
[info] Set current project to eric (in build file:/home/eric/)
[info] 0.13.13
</code></pre>
<p>No changes (that I know of) to either my SBT or Java setup.</p>
<p>Any ideas on what might be causing this or how to fix the error?</p>
<p>Thank you!</p>
| 0debug
|
How to convert time in utc second and timezone offset in second to date string format in "yyyy-mm-dd" in java8? : I have a date in utc second and its time zone offset in sec. I would like to convert it to daten string in format yyyy-mm-dd using java8 ZoneOffset class. For example
time = 1574962442,
offset = 3600
--> date string in yyyy-mm-dd
| 0debug
|
static int omap_validate_tipb_addr(struct omap_mpu_state_s *s,
target_phys_addr_t addr)
{
return range_covers_byte(0xfffb0000, 0xffff0000 - 0xfffb0000, addr);
}
| 1threat
|
How to match not null + not empty? : <p>I have to do some queries on a messy database. Some columns are filled with either <code>null</code> or empty string. I can do query like this:</p>
<pre><code>select * from a where b is not null and b <> '';
</code></pre>
<p>But is there a shortcut for this case? (match every "not empty" values) Something like: </p>
<pre><code>select * from a where b is filled;
</code></pre>
| 0debug
|
how do i make this bitwise code more concise? : my bitwise code which works is ..
#!/bin/bash -e
random=$((RANDOM % 32));
bitWiseAnd() {
local IFS='&'
printf "%s\n" "$(( $* ))"
}
echo "random=${random}";
if [ $(bitWiseAnd ${random} "0x10") -ne 0 ]; then
echo "1"
else
echo "0"
fi
if [ $(bitWiseAnd ${random} "0x8") -ne 0 ]; then
echo "1"
else
echo "0"
fi
if [ $(bitWiseAnd ${random} "0x4") -ne 0 ]; then
echo "1"
else
echo "0"
fi
if [ $(bitWiseAnd ${random} "0x2") -ne 0 ]; then
echo "1"
else
echo "0"
fi
if [ $(bitWiseAnd ${random} "0x1") -ne 0 ]; then
echo "1"
else
echo "0"
fi
example output is ...
> random=15
> 0
> 1
> 1
> 1
> 1
I have no idea how this code works, how would i make this code more concise?
many thanks
| 0debug
|
when i want to connect have this problem "error": "Internal Server Error", "message": "No message available", : <p><a href="https://i.stack.imgur.com/waLH8.png" rel="nofollow noreferrer"> i have this code i can create a user i can get the username and password but i have an error when i want to connect </a></p>
<p>@PostMapping("/signin")</p>
<pre><code>public ResponseEntity<?> authenticateUser(@Valid @RequestBody LoginRequest loginRequest) {
System.out.println("a"+loginRequest.getUsername()+loginRequest.getPassword());
Authentication authentication = authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(loginRequest.getUsername(), loginRequest.getPassword()));
System.out.println("a"+loginRequest.getUsername()+loginRequest.getPassword());
// new RuntimeException("Error: cccccc is not found.");
SecurityContextHolder.getContext().setAuthentication(authentication);
String jwt = jwtUtils.generateJwtToken(authentication);
new RuntimeException("Error: cccccc is not found."+ jwt);
// new RuntimeException("Error: cccccc is not found.");
UserDetailslmpl userDetails = (UserDetailslmpl) authentication.getPrincipal();
List<String> roles = userDetails.getAuthorities().stream()
.map(item -> item.getAuthority())
.collect(Collectors.toList());
// new RuntimeException("Error: aaaa is not found.");
return ResponseEntity.ok(new JwtResponse(jwt,
userDetails.getId(),
userDetails.getUsername(),
userDetails.getEmail(),
roles));
}
</code></pre>
<p><a href="https://i.stack.imgur.com/LftFB.png" rel="nofollow noreferrer">this is the error</a></p>
<p><a href="https://i.stack.imgur.com/DZSHG.png" rel="nofollow noreferrer">the error on postman</a></p>
| 0debug
|
i got these Errors like these : I got errors while running runtests.py...
I use ubuntu 16.04 and Django version 1.6.5...I copied code from github
./runtests.py: line 3: os.environ[DJANGO_SETTINGS_MODULE]: command not found ./runtests.py: line 4: syntax error near unexpected token `(' ./runtests.py: line 4: `test_dir = os.path.dirname(__file__)'
my runtest.py file:
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'test-settings'
test_dir = os.path.dirname(__file__)
sys.path.insert(0, test_dir)
import django
from django.test.utils import get_runner
from django.conf import settings
def runtests():
if django.VERSION >= (1, 7):
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner(verbosity=1, interactive=True)
failures = test_runner.run_tests(
['quiz', 'essay', 'multichoice', 'true_false']
)
sys.exit(bool(failures))
if __name__ == '__main__':
runtests()
| 0debug
|
static int frame_thread_init(AVCodecContext *avctx)
{
int thread_count = avctx->thread_count;
AVCodec *codec = avctx->codec;
AVCodecContext *src = avctx;
FrameThreadContext *fctx;
int i, err = 0;
if (!thread_count) {
int nb_cpus = get_logical_cpus(avctx);
if (nb_cpus > 1)
thread_count = avctx->thread_count = nb_cpus + 1;
}
if (thread_count <= 1) {
avctx->active_thread_type = 0;
return 0;
}
avctx->thread_opaque = fctx = av_mallocz(sizeof(FrameThreadContext));
fctx->threads = av_mallocz(sizeof(PerThreadContext) * thread_count);
pthread_mutex_init(&fctx->buffer_mutex, NULL);
fctx->delaying = 1;
for (i = 0; i < thread_count; i++) {
AVCodecContext *copy = av_malloc(sizeof(AVCodecContext));
PerThreadContext *p = &fctx->threads[i];
pthread_mutex_init(&p->mutex, NULL);
pthread_mutex_init(&p->progress_mutex, NULL);
pthread_cond_init(&p->input_cond, NULL);
pthread_cond_init(&p->progress_cond, NULL);
pthread_cond_init(&p->output_cond, NULL);
p->parent = fctx;
p->avctx = copy;
if (!copy) {
err = AVERROR(ENOMEM);
goto error;
}
*copy = *src;
copy->thread_opaque = p;
copy->pkt = &p->avpkt;
if (!i) {
src = copy;
if (codec->init)
err = codec->init(copy);
update_context_from_thread(avctx, copy, 1);
} else {
copy->priv_data = av_malloc(codec->priv_data_size);
if (!copy->priv_data) {
err = AVERROR(ENOMEM);
goto error;
}
memcpy(copy->priv_data, src->priv_data, codec->priv_data_size);
copy->internal = av_malloc(sizeof(AVCodecInternal));
if (!copy->internal) {
err = AVERROR(ENOMEM);
goto error;
}
*(copy->internal) = *(src->internal);
copy->internal->is_copy = 1;
if (codec->init_thread_copy)
err = codec->init_thread_copy(copy);
}
if (err) goto error;
if (!pthread_create(&p->thread, NULL, frame_worker_thread, p))
p->thread_init = 1;
}
return 0;
error:
frame_thread_free(avctx, i+1);
return err;
}
| 1threat
|
Python dictionary printing specific value : <p>I have this variable with two dictionaries in it:</p>
<pre><code>dic = {"id": 2125, "role": "Policy", "visible": "Users", "name": "Peering", "phone": "", "email": "peering@fb.com"}, {"id": 2568, "role": "NOC", "visible": "Users", "name": "Network Operations", "phone": "+1 650 308 7200", "email": "noc@fb.com"}
</code></pre>
<p>I want to print de e-mail addresses which belongs to 'role' NOC!!</p>
<p>I can use </p>
<pre><code>for key in dic:
if key['role']=='NOC':
print(key['email'])
</code></pre>
<p>But I don't want to use if key['role']=='NOC': . Anyone a better idea? to print email address which belongs to a specific role.</p>
| 0debug
|
roundAndPackFloatx80(
int8 roundingPrecision, flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1
STATUS_PARAM)
{
int8 roundingMode;
flag roundNearestEven, increment, isTiny;
int64 roundIncrement, roundMask, roundBits;
roundingMode = STATUS(float_rounding_mode);
roundNearestEven = ( roundingMode == float_round_nearest_even );
if ( roundingPrecision == 80 ) goto precision80;
if ( roundingPrecision == 64 ) {
roundIncrement = LIT64( 0x0000000000000400 );
roundMask = LIT64( 0x00000000000007FF );
}
else if ( roundingPrecision == 32 ) {
roundIncrement = LIT64( 0x0000008000000000 );
roundMask = LIT64( 0x000000FFFFFFFFFF );
}
else {
goto precision80;
}
zSig0 |= ( zSig1 != 0 );
if ( ! roundNearestEven ) {
if ( roundingMode == float_round_to_zero ) {
roundIncrement = 0;
}
else {
roundIncrement = roundMask;
if ( zSign ) {
if ( roundingMode == float_round_up ) roundIncrement = 0;
}
else {
if ( roundingMode == float_round_down ) roundIncrement = 0;
}
}
}
roundBits = zSig0 & roundMask;
if ( 0x7FFD <= (uint32_t) ( zExp - 1 ) ) {
if ( ( 0x7FFE < zExp )
|| ( ( zExp == 0x7FFE ) && ( zSig0 + roundIncrement < zSig0 ) )
) {
goto overflow;
}
if ( zExp <= 0 ) {
if ( STATUS(flush_to_zero) ) return packFloatx80( zSign, 0, 0 );
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
|| ( zExp < 0 )
|| ( zSig0 <= zSig0 + roundIncrement );
shift64RightJamming( zSig0, 1 - zExp, &zSig0 );
zExp = 0;
roundBits = zSig0 & roundMask;
if ( isTiny && roundBits ) float_raise( float_flag_underflow STATUS_VAR);
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
zSig0 += roundIncrement;
if ( (int64_t) zSig0 < 0 ) zExp = 1;
roundIncrement = roundMask + 1;
if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
roundMask |= roundIncrement;
}
zSig0 &= ~ roundMask;
return packFloatx80( zSign, zExp, zSig0 );
}
}
if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;
zSig0 += roundIncrement;
if ( zSig0 < roundIncrement ) {
++zExp;
zSig0 = LIT64( 0x8000000000000000 );
}
roundIncrement = roundMask + 1;
if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
roundMask |= roundIncrement;
}
zSig0 &= ~ roundMask;
if ( zSig0 == 0 ) zExp = 0;
return packFloatx80( zSign, zExp, zSig0 );
precision80:
increment = ( (int64_t) zSig1 < 0 );
if ( ! roundNearestEven ) {
if ( roundingMode == float_round_to_zero ) {
increment = 0;
}
else {
if ( zSign ) {
increment = ( roundingMode == float_round_down ) && zSig1;
}
else {
increment = ( roundingMode == float_round_up ) && zSig1;
}
}
}
if ( 0x7FFD <= (uint32_t) ( zExp - 1 ) ) {
if ( ( 0x7FFE < zExp )
|| ( ( zExp == 0x7FFE )
&& ( zSig0 == LIT64( 0xFFFFFFFFFFFFFFFF ) )
&& increment
)
) {
roundMask = 0;
overflow:
float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR);
if ( ( roundingMode == float_round_to_zero )
|| ( zSign && ( roundingMode == float_round_up ) )
|| ( ! zSign && ( roundingMode == float_round_down ) )
) {
return packFloatx80( zSign, 0x7FFE, ~ roundMask );
}
return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
}
if ( zExp <= 0 ) {
isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
|| ( zExp < 0 )
|| ! increment
|| ( zSig0 < LIT64( 0xFFFFFFFFFFFFFFFF ) );
shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 );
zExp = 0;
if ( isTiny && zSig1 ) float_raise( float_flag_underflow STATUS_VAR);
if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( roundNearestEven ) {
increment = ( (int64_t) zSig1 < 0 );
}
else {
if ( zSign ) {
increment = ( roundingMode == float_round_down ) && zSig1;
}
else {
increment = ( roundingMode == float_round_up ) && zSig1;
}
}
if ( increment ) {
++zSig0;
zSig0 &=
~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
if ( (int64_t) zSig0 < 0 ) zExp = 1;
}
return packFloatx80( zSign, zExp, zSig0 );
}
}
if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;
if ( increment ) {
++zSig0;
if ( zSig0 == 0 ) {
++zExp;
zSig0 = LIT64( 0x8000000000000000 );
}
else {
zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
}
}
else {
if ( zSig0 == 0 ) zExp = 0;
}
return packFloatx80( zSign, zExp, zSig0 );
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.