problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
how do I run an entire php project in a web browser, for example lets say i have folder named project, : [for example running all this ei inside it there are php scripts and other folders, so how do run the entire 'Project' contents on a web browser][1]
[1]: https://i.stack.imgur.com/xR1xb.jpg
| 0debug
|
Tracing relationships between items in a dictionary : <p>I have a dictionary that defines a set of relationships, for example:</p>
<pre><code>relationships = {"Fred": ["Mary, John"],
"Mary": ["Fred", "Alex"],
"John": ["Fred"]
"Alex": ["Mary"]}
</code></pre>
<p>I'd like to build some functionality that, given a name I return a list of all the relationships associated with that name. </p>
<p>A direct relationship is signaled by a Key: Value pair (so Mary is directly related to Fred) and a second level relationship is signaled through a "friend of a friend" type relationship. So Alex and Fred have a relationship through Mary. Alex --> Mary --> Fred.</p>
<p>For example:
Input: Fred,
Output: Mary, John, Alex</p>
<p>Input: Alex,
Output: Mary, Fred, John</p>
<p>I'm using this example to try an learn recursion, so I have a recursion solution in mind, but am not sure if this can be done iteratively or how to build the proper recursion to solve this.</p>
| 0debug
|
static int encode_audio_frame(AVFormatContext *s, OutputStream *ost,
const uint8_t *buf, int buf_size)
{
AVCodecContext *enc = ost->st->codec;
AVFrame *frame = NULL;
AVPacket pkt;
int ret, got_packet;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
if (buf && buf_size) {
if (!ost->output_frame) {
ost->output_frame = avcodec_alloc_frame();
if (!ost->output_frame) {
av_log(NULL, AV_LOG_FATAL, "out-of-memory in encode_audio_frame()\n");
exit_program(1);
}
}
frame = ost->output_frame;
if (frame->extended_data != frame->data)
av_freep(&frame->extended_data);
avcodec_get_frame_defaults(frame);
frame->nb_samples = buf_size /
(enc->channels * av_get_bytes_per_sample(enc->sample_fmt));
if ((ret = avcodec_fill_audio_frame(frame, enc->channels, enc->sample_fmt,
buf, buf_size, 1)) < 0) {
av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_fill_audio_frame)\n");
exit_program(1);
}
frame->pts = ost->sync_opts;
ost->sync_opts += frame->nb_samples;
}
got_packet = 0;
update_benchmark(NULL);
if (avcodec_encode_audio2(enc, &pkt, frame, &got_packet) < 0) {
av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_encode_audio2)\n");
exit_program(1);
}
update_benchmark("encode_audio %d.%d", ost->file_index, ost->index);
ret = pkt.size;
if (got_packet) {
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
if (pkt.dts != AV_NOPTS_VALUE) {
int64_t max = ost->st->cur_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT);
pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
if (ost->st->cur_dts && ost->st->cur_dts != AV_NOPTS_VALUE && max > pkt.dts) {
av_log(s, max - pkt.dts > 2 ? AV_LOG_WARNING : AV_LOG_DEBUG, "Audio timestamp %"PRId64" < %"PRId64" invalid, cliping\n", pkt.dts, max);
pkt.pts = pkt.dts = max;
}
}
if (pkt.duration > 0)
pkt.duration = av_rescale_q(pkt.duration, enc->time_base, ost->st->time_base);
write_frame(s, &pkt, ost);
audio_size += pkt.size;
av_free_packet(&pkt);
}
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:audio "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base));
}
return ret;
}
| 1threat
|
String in Folder Name in C++ (Cpp) : I want to name the folder according to the username given by the user. However, to do that (in the method in which I am doing), we have to enter the path of the folder including the name of the folder. I know the path, but, the name of the folder should be the username. The following is my code. Please help me! (Thanks for sharing your knowledge and time, in advance)
`Path="Core\\USERS\\";
crtfol = Path + usrnm;
Sleep(10000);
CreateFolder(crtfol);`
'usrnm' is a string for taking in the username of the user.
'Path' is a string in which I have entered the path of the folder.
'crtfol' is also a string used to combine the path and the username.
'CreateFolder' is the fuction I am using to make folder.
In function CreateFolder, 'crtfol' is the name to be given to the folder.
**Error while compiling**: cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*' for argument '1' to 'void CreateFolder(const char*)'|
Compiling done in Codeblocks.
Thank You!
| 0debug
|
static int mjpeg_decode_init(AVCodecContext *avctx)
{
MJpegDecodeContext *s = avctx->priv_data;
MpegEncContext s2;
s->avctx = avctx;
memset(&s2, 0, sizeof(MpegEncContext));
s2.avctx= avctx;
dsputil_init(&s2.dsp, avctx);
DCT_common_init(&s2);
s->scantable= s2.intra_scantable;
s->idct_put= s2.dsp.idct_put;
s->mpeg_enc_ctx_allocated = 0;
s->buffer_size = 102400;
s->buffer = av_malloc(s->buffer_size);
if (!s->buffer)
return -1;
s->start_code = -1;
s->first_picture = 1;
s->org_height = avctx->coded_height;
build_vlc(&s->vlcs[0][0], bits_dc_luminance, val_dc_luminance, 12);
build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12);
build_vlc(&s->vlcs[1][0], bits_ac_luminance, val_ac_luminance, 251);
build_vlc(&s->vlcs[1][1], bits_ac_chrominance, val_ac_chrominance, 251);
if (avctx->flags & CODEC_FLAG_EXTERN_HUFF)
{
av_log(avctx, AV_LOG_INFO, "mjpeg: using external huffman table\n");
init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8);
mjpeg_decode_dht(s);
}
return 0;
}
| 1threat
|
CSRF Verification failing even with token in payload? : I have the csrf middleware token in my payload however I am still getting this message:
"CSRF verification failed. Request aborted.
You are seeing this message because this HTTPS site requires a '
Referer header' to be sent by your Web browser, but none was sent. Th
is header is required for security reasons, to ensure that your browser i
s not being hijacked by third parties."
import requests
from pyquery import PyQuery
payload = {'email': 'email', 'password': 'pass', "csrfmiddlewaretoken":
"token"}
url = 'https://gyrosco.pe/login/email/'
r = requests.post(url, data=payload)
content = r.text
q = PyQuery(content)
title = q("title").text()
print(title)
print(content)
| 0debug
|
int ff_find_unused_picture(MpegEncContext *s, int shared){
int i;
if(shared){
for(i=0; i<MAX_PICTURE_COUNT; i++){
if(s->picture[i].data[0]==NULL && s->picture[i].type==0) return i;
}
}else{
for(i=0; i<MAX_PICTURE_COUNT; i++){
if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) return i;
}
for(i=0; i<MAX_PICTURE_COUNT; i++){
if(s->picture[i].data[0]==NULL) return i;
}
}
assert(0);
return -1;
}
| 1threat
|
static void opt_top_field_first(const char *arg)
{
top_field_first= atoi(arg);
}
| 1threat
|
static void do_closefd(Monitor *mon, const QDict *qdict)
{
const char *fdname = qdict_get_str(qdict, "fdname");
mon_fd_t *monfd;
LIST_FOREACH(monfd, &mon->fds, next) {
if (strcmp(monfd->name, fdname) != 0) {
continue;
}
LIST_REMOVE(monfd, next);
close(monfd->fd);
qemu_free(monfd->name);
qemu_free(monfd);
return;
}
monitor_printf(mon, "Failed to find file descriptor named %s\n",
fdname);
}
| 1threat
|
static int xen_pt_msixctrl_reg_init(XenPCIPassthroughState *s,
XenPTRegInfo *reg, uint32_t real_offset,
uint32_t *data)
{
PCIDevice *d = &s->dev;
uint16_t reg_field = 0;
reg_field = pci_get_word(d->config + real_offset);
if (reg_field & PCI_MSIX_FLAGS_ENABLE) {
XEN_PT_LOG(d, "MSIX already enabled, disabling it first\n");
xen_host_pci_set_word(&s->real_device, real_offset,
reg_field & ~PCI_MSIX_FLAGS_ENABLE);
}
s->msix->ctrl_offset = real_offset;
*data = reg->init_val;
return 0;
}
| 1threat
|
Unable to run this code can you plaese halp - JavaScript : for (i = 65; i < 99; i++) {
var str[]=String.fromCharCode(i);
$("#div1").html("str");
}
**please help me to print alphabets using javascript**
| 0debug
|
static int handle_tsch(S390CPU *cpu)
{
CPUS390XState *env = &cpu->env;
CPUState *cs = CPU(cpu);
struct kvm_run *run = cs->kvm_run;
int ret;
cpu_synchronize_state(cs);
ret = ioinst_handle_tsch(env, env->regs[1], run->s390_tsch.ipb);
if (ret >= 0) {
setcc(cpu, ret);
ret = 0;
} else if (ret < -1) {
if (run->s390_tsch.dequeued) {
uint16_t subchannel_id = run->s390_tsch.subchannel_id;
uint16_t subchannel_nr = run->s390_tsch.subchannel_nr;
uint32_t io_int_parm = run->s390_tsch.io_int_parm;
uint32_t io_int_word = run->s390_tsch.io_int_word;
uint32_t type = ((subchannel_id & 0xff00) << 24) |
((subchannel_id & 0x00060) << 22) | (subchannel_nr << 16);
kvm_s390_interrupt_internal(cpu, type,
((uint32_t)subchannel_id << 16)
| subchannel_nr,
((uint64_t)io_int_parm << 32)
| io_int_word, 1);
}
ret = 0;
}
return ret;
}
| 1threat
|
static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src,
int destidx, int element, TCGMemOp memop)
{
int vect_off = vec_reg_offset(destidx, element, memop & MO_SIZE);
switch (memop) {
case MO_8:
tcg_gen_st8_i32(tcg_src, cpu_env, vect_off);
break;
case MO_16:
tcg_gen_st16_i32(tcg_src, cpu_env, vect_off);
break;
case MO_32:
tcg_gen_st_i32(tcg_src, cpu_env, vect_off);
break;
default:
g_assert_not_reached();
}
}
| 1threat
|
Add element into array decremented every 2thh times : Hi I'm stuck with some math problem.
If i have simple array:
var x = [
{
'index':0,
"place": 1,
},
{
'index':1,
"place": 4,
},
{
'index':0,
"place": 9,
},
{
'index':1,
"place": 9,
},
{
'index':0,
"place": 9,
},
];
How can i loop at this array and add some element ('row in this case') to match this ?
var x = [
{
'index':0,
"place": 1,
"row":"0",
},
{
'index':1,
"place": 4,
"row":"0",
},
{
'index':0,
"place": 9,
"row":"1",
},
{
'index':1,
"place": 9,
"row":"1",
},
{
'index':0,
"place": 9,
"row":"2",
},
{
'index':0,
"place": 9,
"row":"2",
},
];
Thanks for any advices. I need this to create dynamic Gridlayout in nativescript.
| 0debug
|
static int asf_write_header1(AVFormatContext *s, int64_t file_size,
int64_t data_chunk_size)
{
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
AVDictionaryEntry *tags[5];
int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
int has_title, has_aspect_ratio = 0;
int metadata_count;
AVCodecContext *enc;
int64_t header_offset, cur_pos, hpos;
int bit_rate;
int64_t duration;
ff_metadata_conv(&s->metadata, ff_asf_metadata_conv, NULL);
tags[0] = av_dict_get(s->metadata, "title", NULL, 0);
tags[1] = av_dict_get(s->metadata, "author", NULL, 0);
tags[2] = av_dict_get(s->metadata, "copyright", NULL, 0);
tags[3] = av_dict_get(s->metadata, "comment", NULL, 0);
tags[4] = av_dict_get(s->metadata, "rating", NULL, 0);
duration = asf->duration + PREROLL_TIME * 10000;
has_title = tags[0] || tags[1] || tags[2] || tags[3] || tags[4];
metadata_count = av_dict_count(s->metadata);
bit_rate = 0;
for (n = 0; n < s->nb_streams; n++) {
enc = s->streams[n]->codec;
avpriv_set_pts_info(s->streams[n], 32, 1, 1000);
bit_rate += enc->bit_rate;
if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
&& enc->sample_aspect_ratio.num > 0
&& enc->sample_aspect_ratio.den > 0)
has_aspect_ratio++;
}
if (asf->is_streamed) {
put_chunk(s, 0x4824, 0, 0xc00);
}
ff_put_guid(pb, &ff_asf_header);
avio_wl64(pb, -1);
avio_wl32(pb, 3 + has_title + !!metadata_count + s->nb_streams);
avio_w8(pb, 1);
avio_w8(pb, 2);
header_offset = avio_tell(pb);
hpos = put_header(pb, &ff_asf_file_header);
ff_put_guid(pb, &ff_asf_my_guid);
avio_wl64(pb, file_size);
file_time = 0;
avio_wl64(pb, unix_to_file_time(file_time));
avio_wl64(pb, asf->nb_packets);
avio_wl64(pb, duration);
avio_wl64(pb, asf->duration);
avio_wl64(pb, PREROLL_TIME);
avio_wl32(pb, (asf->is_streamed || !pb->seekable) ? 3 : 2);
avio_wl32(pb, s->packet_size);
avio_wl32(pb, s->packet_size);
avio_wl32(pb, bit_rate ? bit_rate : -1);
end_header(pb, hpos);
hpos = put_header(pb, &ff_asf_head1_guid);
ff_put_guid(pb, &ff_asf_head2_guid);
avio_wl16(pb, 6);
if (has_aspect_ratio) {
int64_t hpos2;
avio_wl32(pb, 26 + has_aspect_ratio * 84);
hpos2 = put_header(pb, &ff_asf_metadata_header);
avio_wl16(pb, 2 * has_aspect_ratio);
for (n = 0; n < s->nb_streams; n++) {
enc = s->streams[n]->codec;
if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
&& enc->sample_aspect_ratio.num > 0
&& enc->sample_aspect_ratio.den > 0) {
AVRational sar = enc->sample_aspect_ratio;
avio_wl16(pb, 0);
avio_wl16(pb, n + 1);
avio_wl16(pb, 26);
avio_wl16(pb, 3);
avio_wl32(pb, 4);
avio_put_str16le(pb, "AspectRatioX");
avio_wl32(pb, sar.num);
avio_wl16(pb, 0);
avio_wl16(pb, n + 1);
avio_wl16(pb, 26);
avio_wl16(pb, 3);
avio_wl32(pb, 4);
avio_put_str16le(pb, "AspectRatioY");
avio_wl32(pb, sar.den);
}
}
end_header(pb, hpos2);
} else {
avio_wl32(pb, 0);
}
end_header(pb, hpos);
if (has_title) {
int len;
uint8_t *buf;
AVIOContext *dyn_buf;
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
hpos = put_header(pb, &ff_asf_comment_header);
for (n = 0; n < FF_ARRAY_ELEMS(tags); n++) {
len = tags[n] ? avio_put_str16le(dyn_buf, tags[n]->value) : 0;
avio_wl16(pb, len);
}
len = avio_close_dyn_buf(dyn_buf, &buf);
avio_write(pb, buf, len);
av_freep(&buf);
end_header(pb, hpos);
}
if (metadata_count) {
AVDictionaryEntry *tag = NULL;
hpos = put_header(pb, &ff_asf_extended_content_header);
avio_wl16(pb, metadata_count);
while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
put_str16(pb, tag->key);
avio_wl16(pb, 0);
put_str16(pb, tag->value);
}
end_header(pb, hpos);
}
if (!asf->is_streamed && s->nb_chapters) {
int ret;
if (ret = asf_write_markers(s))
return ret;
}
for (n = 0; n < s->nb_streams; n++) {
int64_t es_pos;
enc = s->streams[n]->codec;
asf->streams[n].num = n + 1;
asf->streams[n].seq = 1;
switch (enc->codec_type) {
case AVMEDIA_TYPE_AUDIO:
wav_extra_size = 0;
extra_size = 18 + wav_extra_size;
extra_size2 = 8;
break;
default:
case AVMEDIA_TYPE_VIDEO:
wav_extra_size = enc->extradata_size;
extra_size = 0x33 + wav_extra_size;
extra_size2 = 0;
break;
}
hpos = put_header(pb, &ff_asf_stream_header);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
ff_put_guid(pb, &ff_asf_audio_stream);
ff_put_guid(pb, &ff_asf_audio_conceal_spread);
} else {
ff_put_guid(pb, &ff_asf_video_stream);
ff_put_guid(pb, &ff_asf_video_conceal_none);
}
avio_wl64(pb, 0);
es_pos = avio_tell(pb);
avio_wl32(pb, extra_size);
avio_wl32(pb, extra_size2);
avio_wl16(pb, n + 1);
avio_wl32(pb, 0);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
int wavsize = ff_put_wav_header(pb, enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
if (wavsize < 0)
return -1;
if (wavsize != extra_size) {
cur_pos = avio_tell(pb);
avio_seek(pb, es_pos, SEEK_SET);
avio_wl32(pb, wavsize);
avio_seek(pb, cur_pos, SEEK_SET);
}
avio_w8(pb, 0x01);
if (enc->codec_id == AV_CODEC_ID_ADPCM_G726 || !enc->block_align) {
avio_wl16(pb, 0x0190);
avio_wl16(pb, 0x0190);
} else {
avio_wl16(pb, enc->block_align);
avio_wl16(pb, enc->block_align);
}
avio_wl16(pb, 0x01);
avio_w8(pb, 0x00);
} else {
avio_wl32(pb, enc->width);
avio_wl32(pb, enc->height);
avio_w8(pb, 2);
avio_wl16(pb, 40 + enc->extradata_size);
ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 1, 0);
}
end_header(pb, hpos);
}
hpos = put_header(pb, &ff_asf_codec_comment_header);
ff_put_guid(pb, &ff_asf_codec_comment1_header);
avio_wl32(pb, s->nb_streams);
for (n = 0; n < s->nb_streams; n++) {
const AVCodecDescriptor *codec_desc;
const char *desc;
enc = s->streams[n]->codec;
codec_desc = avcodec_descriptor_get(enc->codec_id);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl16(pb, 2);
else if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
avio_wl16(pb, 1);
else
avio_wl16(pb, -1);
if (enc->codec_id == AV_CODEC_ID_WMAV2)
desc = "Windows Media Audio V8";
else
desc = codec_desc ? codec_desc->name : NULL;
if (desc) {
AVIOContext *dyn_buf;
uint8_t *buf;
int len;
if (avio_open_dyn_buf(&dyn_buf) < 0)
return AVERROR(ENOMEM);
avio_put_str16le(dyn_buf, desc);
len = avio_close_dyn_buf(dyn_buf, &buf);
avio_wl16(pb, len / 2);
avio_write(pb, buf, len);
av_freep(&buf);
} else
avio_wl16(pb, 0);
avio_wl16(pb, 0);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
avio_wl16(pb, 2);
avio_wl16(pb, enc->codec_tag);
} else {
avio_wl16(pb, 4);
avio_wl32(pb, enc->codec_tag);
}
if (!enc->codec_tag)
return -1;
}
end_header(pb, hpos);
cur_pos = avio_tell(pb);
header_size = cur_pos - header_offset;
if (asf->is_streamed) {
header_size += 8 + 30 + DATA_HEADER_SIZE;
avio_seek(pb, header_offset - 10 - 30, SEEK_SET);
avio_wl16(pb, header_size);
avio_seek(pb, header_offset - 2 - 30, SEEK_SET);
avio_wl16(pb, header_size);
header_size -= 8 + 30 + DATA_HEADER_SIZE;
}
header_size += 24 + 6;
avio_seek(pb, header_offset - 14, SEEK_SET);
avio_wl64(pb, header_size);
avio_seek(pb, cur_pos, SEEK_SET);
asf->data_offset = cur_pos;
ff_put_guid(pb, &ff_asf_data_header);
avio_wl64(pb, data_chunk_size);
ff_put_guid(pb, &ff_asf_my_guid);
avio_wl64(pb, asf->nb_packets);
avio_w8(pb, 1);
avio_w8(pb, 1);
return 0;
}
| 1threat
|
How to detect green from RGB? : <p>I would like to detect green from a RGB. I would like to know if it's green from all variations. </p>
<p>I have a RGB, and I would like to know if it's green. It includes lighter green and so on. </p>
<p>Is there a way?</p>
| 0debug
|
Get the max length of Sql Server column using an array : I have four columns in my table namely Surname, FirstName, MiddleName, CurrAddress. Is there a way that I can store column names dynamically using an array and get the max length of each the field? Say for example out of the four fields I only need the Surname and FirstName maximum lengths. My code below will only display one column per transaction. Any help is greatly appreciated. Than you!
ALTER PROCEDURE [dbo].[sp_getColumnLength]
@colval nvarchar(50),
@tblval nvarchar(50)
AS
BEGIN
SELECT character_maximum_length as 'Max Length'
FROM information_schema.columns
WHERE column_name=@colval AND table_name = @tblval
END
GO
| 0debug
|
Please help me on this C++ program on array of objects? : #include<iostream.h>
#include<conio.h>
class XIIB
{
char name[30];
int age;
int roll;
float marks;
public:
void getdata(char a[30],int i,int j,float k)
{
name[30]=a[30];
age=i;
roll=j;
marks=k;
}
void putdata(void)
{
cout<<"Name:"<<name<<endl;
cout<<"Age:"<<age<<endl;
cout<<"Roll:"<<roll<<endl;
cout<<"Marks:"<<marks<<endl;
}
};
const int size=5;
XIIB student[size];
void main()
{
char x[30];
int ag;
int rno;
float mrks;
for(int p=0;p<size;p++)
{
cout<<"Enter Name,Age,Roll and Marks of Student"<<p+1<<endl;
cin>>x>>ag>>rno>>mrks;
student[p].getdata(x,ag,rno,mrks);
}
for(p=0;p<size;p++)
{
cout<<"Student"<<p+1<<endl;
student[p].putdata();
}
getch();
}
This program compiles without any error.Also takes the input for Name,Roll No,Age and Marks as expected but it is unable to display the name of the Students.I seem to have made some error in the getdata or putdata functions.Please help me in producing the output as expected.Thanks
| 0debug
|
void check_file_fixed_eof_mmaps(void)
{
char *addr;
char *cp;
unsigned int *p1;
uintptr_t p;
int i;
addr = mmap(NULL, pagesize * 44, PROT_READ,
MAP_PRIVATE | MAP_ANONYMOUS,
-1, 0);
fprintf (stderr, "%s addr=%p", __func__, (void *)addr);
fail_unless (addr != MAP_FAILED);
for (i = 0; i < 0x10; i++)
{
p1 = mmap(addr, pagesize, PROT_READ,
MAP_PRIVATE | MAP_FIXED,
test_fd,
(test_fsize - sizeof *p1) & ~pagemask);
fail_unless (p1 != MAP_FAILED);
p = (uintptr_t) p1;
fail_unless ((p & pagemask) == 0);
fail_unless (p1[(test_fsize & pagemask) / sizeof *p1 - 1]
== ((test_fsize - sizeof *p1) / sizeof *p1));
cp = (void *)p1;
fail_unless (cp[pagesize - 4] == 0);
munmap (p1, pagesize);
addr += pagesize;
}
fprintf (stderr, " passed\n");
}
| 1threat
|
How to refresh current Activity every 10 second? : <p>i have problem with my project Android Studio. Can you help me how to create auto refresh current activity every 10 second without button click?</p>
| 0debug
|
Convert date as TEXT : I am developing software that need to convert date as a text. Like cheqe printing software display amount as a text.
For an example
02/28/2017 should be displayed as
> 28th of February Two Thousand and Seventeen
I am using vb.net 2008. can anyone direct me to how to approach this?
| 0debug
|
CPUState *ppc440ep_init(ram_addr_t *ram_size, PCIBus **pcip,
const unsigned int pci_irq_nrs[4], int do_init,
const char *cpu_model)
{
target_phys_addr_t ram_bases[PPC440EP_SDRAM_NR_BANKS];
target_phys_addr_t ram_sizes[PPC440EP_SDRAM_NR_BANKS];
CPUState *env;
qemu_irq *pic;
qemu_irq *irqs;
qemu_irq *pci_irqs;
if (cpu_model == NULL)
cpu_model = "405";
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to initialize CPU!\n");
exit(1);
}
ppc_dcr_init(env, NULL, NULL);
irqs = qemu_mallocz(sizeof(qemu_irq) * PPCUIC_OUTPUT_NB);
irqs[PPCUIC_OUTPUT_INT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT];
irqs[PPCUIC_OUTPUT_CINT] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT];
pic = ppcuic_init(env, irqs, 0x0C0, 0, 1);
memset(ram_bases, 0, sizeof(ram_bases));
memset(ram_sizes, 0, sizeof(ram_sizes));
*ram_size = ppc4xx_sdram_adjust(*ram_size, PPC440EP_SDRAM_NR_BANKS,
ram_bases, ram_sizes,
ppc440ep_sdram_bank_sizes);
ppc4xx_sdram_init(env, pic[14], PPC440EP_SDRAM_NR_BANKS, ram_bases,
ram_sizes, do_init);
pci_irqs = qemu_malloc(sizeof(qemu_irq) * 4);
pci_irqs[0] = pic[pci_irq_nrs[0]];
pci_irqs[1] = pic[pci_irq_nrs[1]];
pci_irqs[2] = pic[pci_irq_nrs[2]];
pci_irqs[3] = pic[pci_irq_nrs[3]];
*pcip = ppc4xx_pci_init(env, pci_irqs,
PPC440EP_PCI_CONFIG,
PPC440EP_PCI_INTACK,
PPC440EP_PCI_SPECIAL,
PPC440EP_PCI_REGS);
if (!*pcip)
printf("couldn't create PCI controller!\n");
isa_mmio_init(PPC440EP_PCI_IO, PPC440EP_PCI_IOLEN);
if (serial_hds[0] != NULL) {
serial_mm_init(0xef600300, 0, pic[0], PPC_SERIAL_MM_BAUDBASE,
serial_hds[0], 1, 1);
}
if (serial_hds[1] != NULL) {
serial_mm_init(0xef600400, 0, pic[1], PPC_SERIAL_MM_BAUDBASE,
serial_hds[1], 1, 1);
}
return env;
}
| 1threat
|
perl: remove comma from print output : Substitution in grep produces an extra comma in the output.
open(READ,"<","C:/Users/lab/voice_port.txt");
my @file=<READ>;
close(READ);
my @device_name=grep(s/^(\S+)#.*\n$/$1/,@file);
my @port_number=grep(s/Foreign Exchange Station\s(\d{1,2}\/\d{1,2}\/?\d{0,2})\s.*\n$/$1/,@file);
my @port_status=grep(s/.*Administrative State is\s(\S+).*\n$/$1/,@file);
my @number, @device_type=grep(s/.*Station-id name\s(.*)\sStation-id number\s(\+\d+)\n$/$2,$1/,@file);
Printing the values:
for my $x(0..$#port_number)
{
print $device_name[0].",".$port_number[$x].",".$port_status[$x].",".$number[$x].",".$device_type[$x]."\n";
}
Result:
Router1,0/1/1,UP,,+3255413655555,MKD, Reproc
Router1,0/1/2,DOWN,,+3289791148755632,Fax Unbek.
Router1,0/1/3,UP,,+3217825478220844,Kitfax Ler
If comma is removed between port status and number in the "for" cycle, it looks as expected (without extra comma).
Is there a way to remove this extra comma in the grep function?
| 0debug
|
how to set cors setting : my project go-gin
so i tried setting cors
When I submitted the following code,
```
package middleware
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
func Use() {
gin.SetMode(gin.ReleaseMode)
cors.Default()
return
}
```
```
func main() {
log.Printf("Server started")
r := gin.Default()
route.Route(r)
middleware.Use()
log.Fatal(r.Run(":8080"))
}
```
but it was pointed out that cors did not work, and this method worked fine with the application I created before, but I know what the problem is with this application Is not ...
If anyone knows it would be nice to tell you
thanks
| 0debug
|
Why does the comparison ("string" > 0) return false in JavaScript? : <p>Since "string" is a non-empty string, shouldn't it return true? How exactly does this comparison work?</p>
| 0debug
|
What types are special to the Scala compiler? : <p>Scala makes a big deal about how what seem to be language features are implemented as library features.</p>
<p>Is there a list of types that are treated specially by the language?</p>
<p>Either in the specification or as an implementation detail?</p>
<p>That would include, for example, optimizing away matches on tuples.</p>
<p>What about special conventions related to pattern matching, for comprehensions, try-catch blocks and other language constructs?</p>
<p>Is String somehow special to the compiler? I see that String enhancement is just a library implicit conversion, and that String concatenation is supported by <code>Predef</code>, but is that somehow special-cased by the language?</p>
<p>Similarly, I see questions about <code><:<</code> and <code>classOf</code> and <code>asInstanceOf</code>, and it's not clear what is a magical intrinsic. Is there a way to tell the difference, either with a compiler option or by looking at byte code?</p>
<p>I would like to understand if a feature is supported uniformly by implementations such as Scala.JS and Scala-native, or if a feature might actually prove to be implementation-dependent, depending on the library implementation.</p>
| 0debug
|
How to wait until Kubernetes assigned an external IP to a LoadBalancer service? : <p>Creating a <a href="http://kubernetes.io/v1.1/docs/user-guide/services.html#type-loadbalancer" rel="noreferrer">Kubernetes LoadBalancer</a> returns immediatly (ex: <code>kubectl create -f ...</code> or <code>kubectl expose svc NAME --name=load-balancer --port=80 --type=LoadBalancer</code>).</p>
<p>I know a manual way to wait in shell:</p>
<pre><code>external_ip=""
while [ -z $external_ip ]; do
sleep 10
external_ip=$(kubectl get svc load-balancer --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}")
done
</code></pre>
<p>This is however not ideal:</p>
<ul>
<li>Requires at least 5 lines Bash script.</li>
<li>Infinite wait even in case of error (else requires a timeout which increases a lot line count).</li>
<li>Probably not efficient; could use <code>--wait</code> or <code>--wait-once</code> but using those the command never returns.</li>
</ul>
<p>Is there a better way to wait until a service <em>external IP</em> (aka <em>LoadBalancer Ingress IP</em>) is set or failed to set?</p>
| 0debug
|
static inline void t_gen_swapw(TCGv d, TCGv s)
{
TCGv t;
t = tcg_temp_new(TCG_TYPE_TL);
tcg_gen_mov_tl(t, s);
tcg_gen_shli_tl(d, t, 16);
tcg_gen_shri_tl(t, t, 16);
tcg_gen_or_tl(d, d, t);
tcg_temp_free(t);
}
| 1threat
|
What is "()=>{}" in js? : <p>I searched for </p>
<blockquote>
<p>"()=>{} in js"</p>
</blockquote>
<p>on Google
But it's not displaying relative results
What is it?</p>
| 0debug
|
Longest Even word : <p>I need to find the longest even word from a sentence.</p>
<p>I've tried this code for finding the largest word.</p>
<p>But I need the even word.</p>
<p>Can anyone please help me?</p>
<pre><code>function FindlongestWord(input) {
var arrWords = input.split(' ');
var wordlength = 0;
var word = '';
arrWords.forEach(function(wrd) {
if (wordlength < wrd.length) {
wordlength = wrd.length;
word = wrd;
}
});
return word;
}
</code></pre>
| 0debug
|
MySQLSyntaxErrorException: WHERE Clause : <p>I'm trying to retrieve data from my database. However, it gives me an error of:</p>
<pre><code>com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE FORMID = 120002013 AND CLASSIFICATION = 'Private'' at line 1
</code></pre>
<p>Below is my code for retrieving data: </p>
<pre><code>try (Connection conn = myFactory.getConnection()) {
PreparedStatement pstmt = conn.prepareStatement("SELECT CENSUSYEAR, SCHOOLID, CLASSIFICATION, SCHOOLNAME" +
"FROM DIRECTORY_SCHOOL WHERE FORMID = ? AND CLASSIFICATION = ?");
pstmt.setInt(1, formID);
pstmt.setString(2, classification);
ResultSet rs = pstmt.executeQuery();
</code></pre>
<p>What seems to be the problem? Thanks!</p>
| 0debug
|
How can I write this in one line? : <p>Hey So I'm working on a problem that asks me to manipulate a dictionary by grabbing all the keys and values and formatting them into a single string for every key/value pair. I have to do this in one line, or so I think, the problem is better explained in the image.<a href="https://i.stack.imgur.com/aODwN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aODwN.png" alt="enter image description here"></a></p>
| 0debug
|
static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
CPUState *cs;
target_ulong mflags = args[0];
target_ulong resource = args[1];
target_ulong value1 = args[2];
target_ulong value2 = args[3];
target_ulong ret = H_P2;
if (resource == H_SET_MODE_ENDIAN) {
if (value1) {
ret = H_P3;
goto out;
}
if (value2) {
ret = H_P4;
goto out;
}
switch (mflags) {
case H_SET_MODE_ENDIAN_BIG:
CPU_FOREACH(cs) {
PowerPCCPU *cp = POWERPC_CPU(cs);
CPUPPCState *env = &cp->env;
env->spr[SPR_LPCR] &= ~LPCR_ILE;
}
ret = H_SUCCESS;
break;
case H_SET_MODE_ENDIAN_LITTLE:
CPU_FOREACH(cs) {
PowerPCCPU *cp = POWERPC_CPU(cs);
CPUPPCState *env = &cp->env;
env->spr[SPR_LPCR] |= LPCR_ILE;
}
ret = H_SUCCESS;
break;
default:
ret = H_UNSUPPORTED_FLAG;
}
}
out:
return ret;
}
| 1threat
|
static GenericList *next_list(Visitor *v, GenericList *tail, size_t size)
{
StringInputVisitor *siv = to_siv(v);
Range *r;
if (!siv->ranges || !siv->cur_range) {
return NULL;
}
r = siv->cur_range->data;
if (!r) {
return NULL;
}
if (siv->cur < r->begin || siv->cur >= r->end) {
siv->cur_range = g_list_next(siv->cur_range);
if (!siv->cur_range) {
return NULL;
}
r = siv->cur_range->data;
if (!r) {
return NULL;
}
siv->cur = r->begin;
}
tail->next = g_malloc0(size);
return tail->next;
}
| 1threat
|
Firebase Authentication Not working in signed APK : <p>I'm using Firebase Google Sign in. It works perfectly via USB debugging. But when I generate signed APK, it stops working. Its not able to sign in. Using it on Android 5.1 & Android 6.0.1. Also, if the Google play services is not updated, it gives user prompt to update it because of which user may leave the app. How can I turn off the prompt and solve the error?</p>
<pre><code>public class MainActivity extends AppCompatActivity implements GoogleApiClient.OnConnectionFailedListener,
View.OnClickListener {
private Button skip;
private static final String TAG = "GoogleActivity";
private static final int RC_SIGN_IN = 9001;
private ProgressBar pb;
// [START declare_auth]
private FirebaseAuth mAuth;
// [END declare_auth]
// [START declare_auth_listener]
private FirebaseAuth.AuthStateListener mAuthListener;
// [END declare_auth_listener]
private GoogleApiClient mGoogleApiClient;
private TextView mStatusTextView;
private TextView mDetailTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pb=(ProgressBar)findViewById(R.id.signpro);
pb.setVisibility(View.GONE);
skip=(Button)findViewById(R.id.btnskip);
skip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setContentView(R.layout.activity_home);
}
});
// Views
// Button listeners
findViewById(R.id.sign_in_button).setOnClickListener(this);
// [START config_signin]
// Configure Google Sign In
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
// [END config_signin]
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
// [START initialize_auth]
mAuth = FirebaseAuth.getInstance();
// [END initialize_auth]
// [START auth_state_listener]
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
setContentView(R.layout.activity_home);
} else {
// User is signed out
Log.d(TAG, "onAuthStateChanged:signed_out");
}
// [START_EXCLUDE]
// [END_EXCLUDE]
}
};
// [END auth_state_listener]
}
// [START on_start_add_listener]
@Override
public void onStart() {
super.onStart();
mAuth.addAuthStateListener(mAuthListener);
}
// [END on_start_add_listener]
// [START on_stop_remove_listener]
@Override
public void onStop() {
super.onStop();
if (mAuthListener != null) {
mAuth.removeAuthStateListener(mAuthListener);
}
}
// [END on_stop_remove_listener]
// [START onactivityresult]
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
Toast.makeText(this, "Signing you in. Please Wait...", Toast.LENGTH_LONG).show();
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
firebaseAuthWithGoogle(account);
Toast.makeText(this, "Sign In Successful!", Toast.LENGTH_SHORT).show();
} else {
// Google Sign In failed, update UI appropriately
// [START_EXCLUDE]
Toast.makeText(this, "Google Sign In failed. Please Skip.", Toast.LENGTH_SHORT).show();
pb.setVisibility(View.GONE);
// [END_EXCLUDE]
}
}
}
// [END onactivityresult]
// [START auth_with_google]
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());
// [START_EXCLUDE silent]
// [END_EXCLUDE]
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful()) {
Log.w(TAG, "signInWithCredential", task.getException());
Toast.makeText(MainActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
// [START_EXCLUDE]
// [END_EXCLUDE]
}
});
}
// [END auth_with_google]
// [START signin]
private void signIn() {
pb.setVisibility(View.VISIBLE);
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
}
// [END signin]
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
// An unresolvable error has occurred and Google APIs (including Sign-In) will not
// be available.
Log.d(TAG, "onConnectionFailed:" + connectionResult);
Toast.makeText(this, "Google Play Services error.", Toast.LENGTH_SHORT).show();
}
@Override
public void onClick(View v) {
int i = v.getId();
if (i == R.id.sign_in_button) {
signIn();
}
}
}
</code></pre>
| 0debug
|
static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
{
char buf[8 + 8 + 8 + 128];
int ret;
const uint16_t myflags = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM |
NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA |
NBD_FLAG_SEND_WRITE_ZEROES);
bool oldStyle;
qio_channel_set_blocking(client->ioc, false, NULL);
trace_nbd_negotiate_begin();
memset(buf, 0, sizeof(buf));
memcpy(buf, "NBDMAGIC", 8);
oldStyle = client->exp != NULL && !client->tlscreds;
if (oldStyle) {
trace_nbd_negotiate_old_style(client->exp->size,
client->exp->nbdflags | myflags);
stq_be_p(buf + 8, NBD_CLIENT_MAGIC);
stq_be_p(buf + 16, client->exp->size);
stw_be_p(buf + 26, client->exp->nbdflags | myflags);
if (nbd_write(client->ioc, buf, sizeof(buf), errp) < 0) {
error_prepend(errp, "write failed: ");
return -EINVAL;
}
} else {
stq_be_p(buf + 8, NBD_OPTS_MAGIC);
stw_be_p(buf + 16, NBD_FLAG_FIXED_NEWSTYLE | NBD_FLAG_NO_ZEROES);
if (nbd_write(client->ioc, buf, 18, errp) < 0) {
error_prepend(errp, "write failed: ");
return -EINVAL;
}
ret = nbd_negotiate_options(client, myflags, errp);
if (ret != 0) {
if (ret < 0) {
error_prepend(errp, "option negotiation failed: ");
}
return ret;
}
}
trace_nbd_negotiate_success();
return 0;
}
| 1threat
|
static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
{
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
CUVIDPICPARAMS *pp = &ctx->pic_params;
FrameDecodeData *fdd;
NVDECFrame *cf;
AVFrame *cur_frame = s->current_picture.f;
int ret;
ret = ff_nvdec_start_frame(avctx, cur_frame);
if (ret < 0)
return ret;
fdd = (FrameDecodeData*)cur_frame->private_ref->data;
cf = (NVDECFrame*)fdd->hwaccel_priv;
*pp = (CUVIDPICPARAMS) {
.PicWidthInMbs = (cur_frame->width + 15) / 16,
.FrameHeightInMbs = (cur_frame->height + 15) / 16,
.CurrPicIdx = cf->idx,
.field_pic_flag = v->field_mode,
.bottom_field_flag = v->cur_field_type,
.second_field = v->second_field,
.intra_pic_flag = s->pict_type == AV_PICTURE_TYPE_I ||
s->pict_type == AV_PICTURE_TYPE_BI,
.ref_pic_flag = s->pict_type == AV_PICTURE_TYPE_I ||
s->pict_type == AV_PICTURE_TYPE_P,
.CodecSpecific.vc1 = {
.ForwardRefIdx = get_ref_idx(s->last_picture.f),
.BackwardRefIdx = get_ref_idx(s->next_picture.f),
.FrameWidth = cur_frame->width,
.FrameHeight = cur_frame->height,
.intra_pic_flag = s->pict_type == AV_PICTURE_TYPE_I ||
s->pict_type == AV_PICTURE_TYPE_BI,
.ref_pic_flag = s->pict_type == AV_PICTURE_TYPE_I ||
s->pict_type == AV_PICTURE_TYPE_P,
.progressive_fcm = v->fcm == 0,
.profile = v->profile,
.postprocflag = v->postprocflag,
.pulldown = v->broadcast,
.interlace = v->interlace,
.tfcntrflag = v->tfcntrflag,
.finterpflag = v->finterpflag,
.psf = v->psf,
.multires = v->multires,
.syncmarker = v->resync_marker,
.rangered = v->rangered,
.maxbframes = s->max_b_frames,
.panscan_flag = v->panscanflag,
.refdist_flag = v->refdist_flag,
.extended_mv = v->extended_mv,
.dquant = v->dquant,
.vstransform = v->vstransform,
.loopfilter = v->s.loop_filter,
.fastuvmc = v->fastuvmc,
.overlap = v->overlap,
.quantizer = v->quantizer_mode,
.extended_dmv = v->extended_dmv,
.range_mapy_flag = v->range_mapy_flag,
.range_mapy = v->range_mapy,
.range_mapuv_flag = v->range_mapuv_flag,
.range_mapuv = v->range_mapuv,
.rangeredfrm = v->rangeredfrm,
}
};
return 0;
}
| 1threat
|
Python - how to sleep or hibernation computer : <p>How to put to sleep or hibernation computer?
I know i can shutdown with os.system("shutdown") but i dont want complete system shutdown.
It is possible to to this?</p>
| 0debug
|
How to specify webpack-dev-server webpack.config.js file location : <p>I am starting with webpack.</p>
<p>I have been able to specify to webpack the location of webpack.config.js like this:</p>
<pre><code>"webpack --config ./App/webpack.config.js"
</code></pre>
<p>Now I am trying to use the webpack-dev-server with that file also, but I can not find how to specify the webpack.config.js location to it.</p>
<p>This is the relevant part of my package.json</p>
<pre><code>"scripts": {
"start": "webpack-dev-server --config ./App/webpack.config.js --progress --colors",
"build": "webpack --config ./App/webpack.config.js --progress --colors"
}
</code></pre>
<p>How can I pass the ./App/ directory to my webpack-dev-server?</p>
| 0debug
|
I want to print a value in debugger in jsp <script> var url = std.setUrl(); alert(url); </script> : The above code gives an alert instead of printing it to a debugger.
| 0debug
|
What is the defined execution order of ES6 imports? : <p>I've tried searching the internet for the execution order of imported modules. For instance, let's say I have the following code:</p>
<pre><code>import "one"
import "two"
console.log("three");
</code></pre>
<p>Where <code>one.js</code> and <code>two.js</code> are defined as follows:</p>
<pre><code>// one.js
console.log("one");
// two.js
console.log("two");
</code></pre>
<p>Is the console output guaranteed to be:</p>
<pre><code>one
two
three
</code></pre>
<p>Or is it undefined?</p>
| 0debug
|
static int read_mv_component(VP56RangeCoder *c, const uint8_t *p)
{
int bit, x = 0;
if (vp56_rac_get_prob_branchy(c, p[0])) {
int i;
for (i = 0; i < 3; i++)
x += vp56_rac_get_prob(c, p[9 + i]) << i;
for (i = 9; i > 3; i--)
x += vp56_rac_get_prob(c, p[9 + i]) << i;
if (!(x & 0xFFF0) || vp56_rac_get_prob(c, p[12]))
x += 8;
} else {
const uint8_t *ps = p + 2;
bit = vp56_rac_get_prob(c, *ps);
ps += 1 + 3 * bit;
x += 4 * bit;
bit = vp56_rac_get_prob(c, *ps);
ps += 1 + bit;
x += 2 * bit;
x += vp56_rac_get_prob(c, *ps);
}
return (x && vp56_rac_get_prob(c, p[1])) ? -x : x;
}
| 1threat
|
How to get entire source code of FileSystemObject? : <p>I am studying myself some Script Object with looking at reference from MSDN or googling. As skipped the whole properties, methods which object has, I can roughly imagine that how the object was constructed. But, If i can look at entire source code of each object such as FileSystemObject, I gonna much more understand the structure it has. </p>
<p>Is there someone who know how to get the entire source code of each Script's object?</p>
| 0debug
|
static ssize_t nbd_receive_request(QIOChannel *ioc, struct nbd_request *request)
{
uint8_t buf[NBD_REQUEST_SIZE];
uint32_t magic;
ssize_t ret;
ret = read_sync(ioc, buf, sizeof(buf));
if (ret < 0) {
return ret;
}
if (ret != sizeof(buf)) {
LOG("read failed");
return -EINVAL;
}
magic = ldl_be_p(buf);
request->type = ldl_be_p(buf + 4);
request->handle = ldq_be_p(buf + 8);
request->from = ldq_be_p(buf + 16);
request->len = ldl_be_p(buf + 24);
TRACE("Got request: { magic = 0x%" PRIx32 ", .type = %" PRIx32
", from = %" PRIu64 " , len = %" PRIu32 " }",
magic, request->type, request->from, request->len);
if (magic != NBD_REQUEST_MAGIC) {
LOG("invalid magic (got 0x%" PRIx32 ")", magic);
return -EINVAL;
}
return 0;
}
| 1threat
|
How can I manage my own page with facebook graph api? : <p>I'm building a website, and the website has a running facebook page. I want to be able to post to my page from my cms.</p>
<p>The problem is that for getting those permissions I must approve my facebook app the they require things like a screencast of how users are going to login to my app etc.</p>
<p>Is there a simple way to generate an access token for my own page so I can make api calls to manage it?</p>
<p>Daniel.</p>
| 0debug
|
SQL foreign key window issue for newly created EF Code first table : I don't know if anyone face this issue or it's just something else.
I am folloing EF code first architecture.
here is my first class GeneralSettings :
public class PerformanceSurchargeGeneralSettings: FullAuditedEntity
{
public int PerformanceID { get; set; }
public Performance Performance { get; set; }
public int SurchargeId { get; set; }
public Surcharges Surcharge { get; set; }
}
And here is the second class Surcharge :
public class Surcharges : FullAuditedEntity
{
public string Name { get; set; }
public ICollection<PerformanceSurchargeGeneralSettings> PerformanceSurchargeGeneralSettings{ get; set; }
}
Everything works fine, I can add migration, update my database but if I go to table and check for foreign key reference, I can't see primary key table.see below snap.
[![enter image description here][1]][1]
> Even I am not able to find newly added table that is Surcharge in the dropdown of primary key table.
And if I execute SP_help for this table, I can find all foreign keys, see below snap.
[![enter image description here][2]][2]
**SO, I don't understand where exactly issue is?**
[1]: https://i.stack.imgur.com/9dEzd.png
[2]: https://i.stack.imgur.com/xyVTh.png
| 0debug
|
Add parameter on jquery : <pre><code>$(function(){
$(document).on("click", '#btn', function() {
$(document).ready(function(){
var sub=document.getElementById("tables").rows.length;
for(var i=0;i<sub;i++){
var doc=document.getElementById("checkbox"+i);
if(doc.checked!=false){
$("#tables>tr[id='i']").remove();
}
}
});
});
});
</code></pre>
<p>help to add with parameter how to add variable tr[id='i']</p>
| 0debug
|
VB.NET From 'A' to 'ZZZ' : I have seen this in c# and I'm using VB.net. This code is related somehow to what output I want to be
string increment(string str) {
char[] digits = str.ToCharArray();
for (int i = str.length - 1; i >= 0; --i) {
if (digits[i] == 'Z') {
digits[i] = 'A';
} else {
digits[i] += 1;
break;
}
}
return new string(digits);
}
I want to increment 'A' to 'ZZZ' just like from 0 to 999. Where the sequence is like this
AAA
AAB
AAC
...
AAZ
And after the 'AAZ' it will proceed to
ABA
ABC
ABD
ABE
...
ABZ
And so on and so fort up to 'ZZZ'
And also detects lower case or upper case
Thanks in advance for help
| 0debug
|
How to get id attribute with Jquery : I'm trying to get departmentName's id value.I mean i need get departmentID.
example jSON
{
"departmentID": 1,
"departmentName": "BT"
},
my code
saveEvent:function(e){
this.$el.find(".departmentName"); // getting "BT"
this.$el.find(".departmentName").attr("departmentID");//this is not working
this.render();
},
| 0debug
|
PhpMailer SMTP NOTICE: EOF caught while checking if connected : <p>I got an issue with phpMailer, i can't send any e-mail, and it gives me this error:</p>
<pre><code>2016-03-03 21:32:09 SERVER -> CLIENT: 2016-03-03 21:32:09 SMTP NOTICE: EOF caught while checking if connected 2016-03-03 21:32:09 SMTP Error: Could not authenticate. 2016-03-03 21:32:09 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Erreur : SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
</code></pre>
<p>This is my code :</p>
<pre><code><?php require('phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'ssl://smtp.gmail.com';
$mail->SMTPAuth= true;
$mail->Username='myadress@gmail.com';
$mail->Password='passwordgmail';
$mail->Port = 587;
$mail->SMTPDebug = 2;
$mail->SMTPSecure = 'ssl';
$mail->SetFrom('myadress@gmail.com', 'Name');
$mail->AddAddress('someone@gmail.com', 'HisName');
$mail->Subject = 'Subject';
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send()) {
echo 'Error : ' . $mail->ErrorInfo;
} else {
echo 'Ok!!';
}
?>
</code></pre>
<p>I tried all the answers i found, but none of them worked so far. I also tried other ports, the 25 and 465 don't work and give me other errors. If someone could help me please it would be really nice =) . Thank you</p>
| 0debug
|
How to represent binary types of variable in C? : I would like to get a binary representation for all types of variables in C: int, unsigned int, long, unsigned long, short, unsigned short, float, double and char.
If is the best solution, when I getting size of variable (by sizeof) and conversion to binary system?
How to quickly and easily carry out such a conversion?
| 0debug
|
How can I remove jenkins completely from linux : <p>I have deleted jenkins all directories from different folders. But still when I access URL it is showing me jenkins login.</p>
<p>I want to uninstall jenkins completely. Have tried many commands from internet but still jenkins is there on server. </p>
<p>I have only command line access via putty so I tries whatever is possible via command to remove jenkins.</p>
| 0debug
|
Since Java 9 HashMap.computeIfAbsent() throws ConcurrentModificationException on attempt to memoize recursive function results : <p>Today I learned from some JS course what memoization is and tried to implement it in Java. I had a simple recursive function to evaluate n-th Fibonacci number:</p>
<pre><code>long fib(long n) {
if (n < 2) {
return n;
}
return fib(n - 1) + fib(n - 2);
}
</code></pre>
<p>Then I decided to use HashMap in order to cache results of recursive method:</p>
<pre><code>private static <I, O> Function<I, O> memoize(Function<I, O> fn) {
final Map<I, O> cache = new HashMap<>();
return in -> {
if (cache.get(in) != null) {
return cache.get(in);
} else {
O result = fn.apply(in);
cache.put(in, result);
return result;
}
};
}
</code></pre>
<p>This worked as I expected and it allowed me to memoize <code>fib()</code> like this <code>memoize(this::fib)</code></p>
<p>Then I googled the subject of memoization in Java and found the question: <a href="https://stackoverflow.com/questions/27549864/java-memoization-method">Java memoization method</a> where <code>computeIfAbsent</code> was proposed which is much shorter than my conditional expression.</p>
<p>So my final code which I expected to work was:</p>
<pre><code>public class FibMemo {
private final Function<Long, Long> memoizedFib = memoize(this::slowFib);
public long fib(long n) {
return memoizedFib.apply(n);
}
long slowFib(long n) {
if (n < 2) {
return n;
}
return fib(n - 1) + fib(n - 2);
}
private static <I, O> Function<I, O> memoize(Function<I, O> fn) {
final Map<I, O> cache = new HashMap<>();
return in -> cache.computeIfAbsent(in, fn);
}
public static void main(String[] args) {
new FibMemo().fib(50);
}
}
</code></pre>
<p>Since I used Java 11, I got:</p>
<pre><code>Exception in thread "main" java.util.ConcurrentModificationException
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134)
at algocasts.matrix.fibonacci.FibMemo.lambda$memoize$0(FibMemo.java:24)
at algocasts.matrix.fibonacci.FibMemo.fib(FibMemo.java:11)
at algocasts.matrix.fibonacci.FibMemo.slowFib(FibMemo.java:19)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1133)
at algocasts.matrix.fibonacci.FibMemo.lambda$memoize$0(FibMemo.java:24)
</code></pre>
<p>The problem quickly brought me to the following question which is very similar: <a href="https://stackoverflow.com/questions/28840047/recursive-concurrenthashmap-computeifabsent-call-never-terminates-bug-or-fea">Recursive ConcurrentHashMap.computeIfAbsent() call never terminates. Bug or "feature"?</a></p>
<p>except Lukas used ConcurrentHashMap and got never ending loop. In the article related to the question Lukas advised:</p>
<blockquote>
<p>The simplest use-site solution for this concrete problem would be to not use a ConcurrentHashMap, but just a HashMap instead:</p>
</blockquote>
<p><code>static Map<Integer, Integer> cache = new HashMap<>();</code></p>
<p>That's exactly what I was trying to do, but did not succeed with Java 11. I found out empirically that HashMap throws ConcurrentModificationException since Java 9 (thanks SDKMAN):</p>
<pre><code>sdk use java 9.0.7-zulu && javac Test.java && java Test # throws ConcurrentModificationException
sdk use java 8.0.202-zulufx && javac Test.java && java Test # works as expected
</code></pre>
<p>Here are the summary of my attempts:</p>
<ul>
<li>Java 8 && ConcurrentHashMap -> works if input < 13, otherwise endless
loop </li>
<li>Java 9 && ConcurrentHashMap -> works if input < 13, hangs if
input = 14, throws <code>IllegalStateException: Recursive update</code> if input
is 50 </li>
<li>Java 8 && HashMap -> Works! </li>
<li>Java 9 && HashMap -> Throws
<code>ConcurrentModificationException</code> after input >= 3</li>
</ul>
<p>I would like to know why ConcurrentModificationException gets thrown on attempt to use HashMap as a cache for recursive function? Was it a bug in Java 8 allowing me to do so or is it another in Java > 9 which throws ConcurrentModificationException?</p>
| 0debug
|
how do i write code to get text from amountField and convert to a double : I have created a bank account class and a bank account GUI with with amountField to show the amount i wish to withdraw and deposit.
using public void actionPerformed(ActionEvent e) function how can i write code to get text from amountField and convert to a double.
i want to input account details and be able to withdraw and deposit whilst storing values within a string
write event handler for deposit button
write event handler for withdraw button
public class BankAccountGUI extends JFrame implements ActionListener
{
private Label amountLabel = new Label("Amount");
private JTextField amountField = new JTextField(5);
private JButton depositButton = new JButton("DEPOSIT");
private JButton withdrawButton = new JButton("WITHDRAW");
private Label balanceLabel = new Label("Starting Balance = 0" );
private JPanel topPanel = new JPanel();
private JPanel bottomPanel = new JPanel();
private JPanel middlePanel = new JPanel();
BankAccount myAccount = new BankAccount("James","12345");
// declare a new BankAccount object (myAccount) with account number and name of your choice here
public BankAccountGUI()
{
setTitle("BankAccount GUI");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(340, 145);
setLocation(300,300);
depositButton.addActionListener(this);
withdrawButton.addActionListener(this);
topPanel.add(amountLabel);
topPanel.add(amountField);
bottomPanel.add(balanceLabel);
middlePanel.add(depositButton);
middlePanel.add(withdrawButton);
add (BorderLayout.NORTH, topPanel);
add(BorderLayout.SOUTH, bottomPanel);
add(BorderLayout.CENTER, middlePanel);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
}
}
| 0debug
|
bash loops to search for all cloumms : I have a huge file of 200,000 rows and 8k columns and looking to loop or if statement in shell to extract the value '0/1' from each column one by one (column wise) and print that column along with first two colmuns with header as well.
| 0debug
|
Convert SQl To Dcotrine in symfony : i have 3 table and 2 relation, one table is many to many and another table is one to many relation, then i create a query in mysql and is ok but i`m not converting to dql or querybuilder in symfony, please help me.
sample query is
select * FROM `resturant` LEFT JOIN `food`.`food` ON `resturant`.`id` = `food`.`resturant_id` WHERE `food`.`name` LIKE "%pizza%" GROUP BY `resturant`.`name`
| 0debug
|
void qemu_savevm_state_header(QEMUFile *f)
{
trace_savevm_state_header();
qemu_put_be32(f, QEMU_VM_FILE_MAGIC);
qemu_put_be32(f, QEMU_VM_FILE_VERSION);
if (migrate_get_current()->send_configuration ||
enforce_config_section()) {
qemu_put_byte(f, QEMU_VM_CONFIGURATION);
vmstate_save_state(f, &vmstate_configuration, &savevm_state, 0);
}
}
| 1threat
|
Best way to have global css in Vuejs : <p>What is the best way to have a global css file in Vuejs for all components? (Default css like bg color, button styling, etc)</p>
<ul>
<li>import a css file in the index.html</li>
<li>do @import in main component</li>
<li>put all the css in the main component (but that would be a huge file)</li>
</ul>
| 0debug
|
How to send information back and forth from a javascript file to a python file : <p>So I have an html file with javascript and a python file. In the javascript file, the user enters a string. In the python, I would like it to search it in an api, and then return the string to be displayed in the html file. How do I do this? I have looked up how to use AJAX and get/post methods, but nothing has worked so far. Also, I should mention I am using flask.</p>
| 0debug
|
How to place picture on desktop, on top of wallpaper? : <p>How to place picture on desktop, on top of wallpaper?</p>
<p>This is for Fedora 26, Gnome 3.24.2</p>
| 0debug
|
implement wordpress plugin with php code project : <p>as everyone knows the wordpress plugins are written in object programming, my question was knowing that the plugins refer and recall specific classes within the functions of WP. If it were somehow able to implement a WP plugin, in a project with a write code, please refer to the specification.</p>
<p>Connection file to the db, host, username, password</p>
<p>set of the query</p>
<p>and query display in the db.</p>
<p>It is feasible?
are there any guidelines to follow?
tutorial?
news?</p>
| 0debug
|
Why is it impossible to call static methods on Nullable<T> shorthands? : <p>I thought <code>T?</code> is just a compiler shorthand for <code>Nullable<T></code>. According to <a href="https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/nullable-types/" rel="noreferrer">MSDN</a>:</p>
<blockquote>
<p>The syntax <code>T?</code> is shorthand for <code>Nullable<T></code>, where <code>T</code> is a value type.
The two forms are interchangeable.</p>
</blockquote>
<p>However, there is a little (insignificant) difference: Visual Studio doesn't allow me to call static methods on shorthands:</p>
<pre><code>bool b1 = Nullable<int>.Equals(1, 2); //no error
bool b2 = int?.Equals(1, 2); //syntax error "Invalid expression term 'int'"
</code></pre>
<p>Why? Is there any reason for this limitation?</p>
| 0debug
|
static int speex_header(AVFormatContext *s, int idx) {
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
struct speex_params *spxp = os->private;
AVStream *st = s->streams[idx];
uint8_t *p = os->buf + os->pstart;
if (!spxp) {
spxp = av_mallocz(sizeof(*spxp));
os->private = spxp;
}
if (spxp->seq > 1)
return 0;
if (spxp->seq == 0) {
int frames_per_packet;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_SPEEX;
if (os->psize < 68) {
av_log(s, AV_LOG_ERROR, "speex packet too small\n");
return AVERROR_INVALIDDATA;
}
st->codec->sample_rate = AV_RL32(p + 36);
st->codec->channels = AV_RL32(p + 48);
if (st->codec->channels < 1 || st->codec->channels > 2) {
av_log(s, AV_LOG_ERROR, "invalid channel count. Speex must be mono or stereo.\n");
return AVERROR_INVALIDDATA;
}
st->codec->channel_layout = st->codec->channels == 1 ? AV_CH_LAYOUT_MONO :
AV_CH_LAYOUT_STEREO;
spxp->packet_size = AV_RL32(p + 56);
frames_per_packet = AV_RL32(p + 64);
if (frames_per_packet)
spxp->packet_size *= frames_per_packet;
ff_alloc_extradata(st->codec, os->psize);
memcpy(st->codec->extradata, p, st->codec->extradata_size);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
} else
ff_vorbis_comment(s, &st->metadata, p, os->psize);
spxp->seq++;
return 1;
}
| 1threat
|
MySQL error:Error in query (1064) : i get the Mysql error message:
"Error in query (1064): Syntax error near 'IF NOT EXISTS TABLE 'o2o_category'( 'id' int(11) NOT NULL AUTO_INCREMENT, ' at line 2 "
when i run it in the Phpmyadmin SQL command.
The sql is below:
CREATE IF NOT EXISTS TABLE 'o2o_category'(
'id' int(11) NOT NULL AUTO_INCREMENT,
'name' VARCHAR(50) NOT NULL DEFAULT '',
'parent_id' int(10) NOT NULL DEFAULT 0,
'listorder' int(8) NOT NULL DEFAULT 0,
'status' tinyint(1) NOT NULL DEFAULT 0,
'create_time' int(11) NOT NULL DEFAULT 0,
'update_time' int(11) NOT NULL DEFAULT 0,
PRIMARY KEY ('id'),
KEY parent_id('parent_id')
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
Can u give me some clues about what wrong is?
Thanks
| 0debug
|
Disabling AWS RDS backups when creating/updating instances? : <p>I am creating new RDS MySQL instances from snapshots and updating their configurations both via the API and through the UI. Regardless of how I create or update instances, these actions automatically trigger new snapshots to be created through some kind of automatic backup process. Is there a way to disable snapshot creation when performing these actions since I do not need the additional snapshots and their creation is causing an unnecessary delay?</p>
| 0debug
|
static void allocate_buffers(ALACContext *alac)
{
int chan;
for (chan = 0; chan < alac->numchannels; chan++) {
alac->predicterror_buffer[chan] =
av_malloc(alac->setinfo_max_samples_per_frame * 4);
alac->outputsamples_buffer[chan] =
av_malloc(alac->setinfo_max_samples_per_frame * 4);
alac->wasted_bits_buffer[chan] = av_malloc(alac->setinfo_max_samples_per_frame * 4);
}
}
| 1threat
|
Best way to find duplicates from two List : <p>In Java, I have two ArrayLists:</p>
<pre><code>A = [Ab, cd, df, FE, ...]
B = [ab, cde, de, fE, ...]
</code></pre>
<p>If the lists are a little big, the brute force method is very slow:</p>
<pre><code>for(String a : A) {
for(String b : B) {
if(a.equalsIgnoreCase(b)) {
System.out.println("duplicate: " + a "->" + b);
}
}
}
</code></pre>
<p>What's the best way to make it faster, but not super complicated to implement? </p>
| 0debug
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
Utilizing constraint to create a new table in sql : <p>I am trying to create a query based off of the following information below. While attempting to create this, I keep violating the primary key.</p>
<pre class="lang-js prettyprint-override"><code>CREATE TABLE writers
(authorid VARCHAR2(4),
lname VARCHAR2(10),
fname VARCHAR2(10),
isbn VARCHAR2(10),
title VARCHAR2(30) CONSTRAINT title_nn NOT NULL,
CONSTRAINT wt_pk PRIMARY KEY (authorid),
CONSTRAINT wt_fk FOREIGN KEY (isbn) REFERENCES books (isbn));
INSERT INTO writers
(SELECT authorid, fname, lname, isbn, title
FROM author
JOIN bookauthor USING (authorid)
JOIN books USING (isbn));
ALTER TABLE employees
ADD CONSTRAINT et_pk
PRIMARY KEY (ssn);
</code></pre>
<p><a href="https://i.stack.imgur.com/yHTVt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yHTVt.png" alt=""></a></p>
| 0debug
|
Copy files from resources to folder : <p>im trying to copy an folder with 26 files (A-Z) to another directory. So far so good, everything works if i start the program with my IDE. But if im running the exported jar it doesn't work. I allready looked into the jar and the folder which i want to copy is there. </p>
<pre><code>private void copyCharacterFiles() {
for (String s : Utils.ALPHABET) {
try {
File source = new File("resources/characters/" + s.toUpperCase() + ".yml");
File dest = new File(APPLICATION_PATH + PATHSEPARATOR + "characters" + PATHSEPARATOR + s.toUpperCase() + ".yml");
FileChannel sourceChannel = null;
FileChannel destChannel = null;
try {
sourceChannel = new FileInputStream(source).getChannel();
destChannel = new FileOutputStream(dest).getChannel();
destChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
} finally {
sourceChannel.close();
destChannel.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
</code></pre>
<p>Thanks for the help^^</p>
| 0debug
|
I wanted to add the result i get from SELECT MAX(id) FROM balance and sum(totalSEK) from balance) : this is what i currently have but it is not working
select sum(totalSEK) from balance) + ( SELECT MAX(id) FROM balance;) ) as totalSums
| 0debug
|
Visual Studio C++ Build Errors : >I have compilation errors to just simply output a cout message. E.g., cout << "Letter: " << letter <<endl; My errors are in "Letter: ", the second '<<', and 'endl' also. Why is this happening? Not even resintalling visual studio helped.
| 0debug
|
static void bt_submit_sco(struct HCIInfo *info,
const uint8_t *data, int length)
{
struct bt_hci_s *hci = hci_from_info(info);
uint16_t handle;
int datalen;
if (length < 3)
return;
handle = acl_handle((data[1] << 8) | data[0]);
datalen = data[2];
length -= 3;
if (bt_hci_handle_bad(hci, handle)) {
fprintf(stderr, "%s: invalid SCO handle %03x\n",
__FUNCTION__, handle);
return;
}
if (datalen > length) {
fprintf(stderr, "%s: SCO packet too short (%iB < %iB)\n",
__FUNCTION__, length, datalen);
return;
}
}
| 1threat
|
iOS Share Extension: get URL of page when sharing via context menu in Safari : <p><strong>What I want</strong></p>
<p>I'm trying to achieve the following user flow:</p>
<ol>
<li>User is browsing a webpage in iOS Safari.</li>
<li>User selects some content (text and images) and waits for context menu to appear.</li>
<li>User selects the "Share..." item.</li>
<li>User selects my App Extension in the sharing menu that comes up from the bottom.</li>
<li>Selected content and the webpage URL is shared to a remote server via an HTT call.</li>
</ol>
<p><strong>What I tried</strong></p>
<p>I made a Share extension via Xcode. Here's the <code>NSExtension</code> section of my <code>info.plist</code>:</p>
<pre><code><key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsWebPageWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsText</key>
<true/>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
<key>NSExtensionJavaScriptPreprocessingFile</key>
<string>test</string>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
</code></pre>
<p>Here's the <code>test.js</code> file:</p>
<pre><code>var GetURL = function() {};
GetURL.prototype = {
run: function(arguments) {
arguments.completionFunction({"URL": document.URL});
}
};
var ExtensionPreprocessingJS = new GetURL;
</code></pre>
<p>I expected the following result: in <code>viewDidLoad</code> method <code>extensionContext?.inputItems</code> would provide me with several input items, through which I would be able to get the selected content and the web URL.</p>
<p><strong>What goes wrong</strong></p>
<p>In <code>viewDidLoad</code> method <code>extensionContext?.inputItems</code> provides me with only one item -- the plain text representation of the selected content (even when I selected images and text at the same time). I can live with plain text, but I need the webpage URL. </p>
<p><strong>My question</strong></p>
<p>How can I get URL of the opened webpage when using a Share extension to share selected content via context menu in iOS Safari?</p>
| 0debug
|
static void update_initial_timestamps(AVFormatContext *s, int stream_index,
int64_t dts, int64_t pts, AVPacket *pkt)
{
AVStream *st = s->streams[stream_index];
AVPacketList *pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue;
int64_t pts_buffer[MAX_REORDER_DELAY+1];
int64_t shift;
int i, delay;
if (st->first_dts != AV_NOPTS_VALUE ||
dts == AV_NOPTS_VALUE ||
st->cur_dts == AV_NOPTS_VALUE ||
is_relative(dts))
return;
delay = st->codec->has_b_frames;
st->first_dts = dts - (st->cur_dts - RELATIVE_TS_BASE);
st->cur_dts = dts;
shift = st->first_dts - RELATIVE_TS_BASE;
for (i = 0; i<MAX_REORDER_DELAY+1; i++)
pts_buffer[i] = AV_NOPTS_VALUE;
if (is_relative(pts))
pts += shift;
for (; pktl; pktl = get_next_pkt(s, st, pktl)) {
if (pktl->pkt.stream_index != stream_index)
continue;
if (is_relative(pktl->pkt.pts))
pktl->pkt.pts += shift;
if (is_relative(pktl->pkt.dts))
pktl->pkt.dts += shift;
if (st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != AV_NOPTS_VALUE)
st->start_time = pktl->pkt.pts;
if (pktl->pkt.pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY && has_decode_delay_been_guessed(st)) {
pts_buffer[0] = pktl->pkt.pts;
for (i = 0; i<delay && pts_buffer[i] > pts_buffer[i + 1]; i++)
FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]);
pktl->pkt.dts = select_from_pts_buffer(st, pts_buffer, pktl->pkt.dts);
}
}
if (st->start_time == AV_NOPTS_VALUE)
st->start_time = pts;
}
| 1threat
|
static void net_socket_receive(void *opaque, const uint8_t *buf, size_t size)
{
NetSocketState *s = opaque;
uint32_t len;
len = htonl(size);
send_all(s->fd, (const uint8_t *)&len, sizeof(len));
send_all(s->fd, buf, size);
}
| 1threat
|
How to make users able to send and receive messages in my chat website? : <p>I have finished making a chat website using html, CSS, JavaScript and jQuery then I published it. Here its url <a href="http://redapple-chat.com/RedAppleChat.html" rel="nofollow noreferrer">http://redapple-chat.com/RedAppleChat.html</a></p>
<p>But it still without function that make users able to send and receive messages through it.</p>
<p>How could I accomplish that?
Thanks for your valuable time</p>
| 0debug
|
expand the submenu based on active url :
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.menu-sidebar .child-ul {display:none;}
<!-- language: lang-html -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<ul class="menu-sidebar">
<li class="parent-li"><a href="A.html">A</a>
<ul class="child-ul">
<li><a href="../1.html">1</a></li>
<li><a href="../2.html">2</a></li>
<li><a href="3.html">3</a></li>
<li><a href="../4.html" >4</a></li>
<li><a href="../5.html" >5</a></li>
<li><a href="../6.html">6</a></li>
</ul>
</li>
<li class="parent-li"><a href="B.html">B</a>
<ul class="child-ul">
<li><a href="11.html">1</a></li>
<li><a href="12.html" >2</a></li>
<li><a href="13.html" >3</a></li>
<li><a href="14.html" >4</a></li>
<li><a href="15.html" >5</a></li>
<li><a href="16.html" >6</a></li>
<li><a href="17.html" >7</a></li>
<li><a href="18.html" >8</a></li>
<li><a href="19.html" >9</a></li>
<li><a href="20.html" >10</a></li>
<li><a href="21.html" >11</a></li>
</ul>
</li>
<li class="parent-li"><a href="C.html">C</a>
<ul class="child-ul">
<li><a href="21.html">1</a>
</li>
<li><a href="22.html" >2</a>
</li>
<li><a href="23.html" >3</a>
</li>
<li><a href="24.html" >4</a>
</li>
<li><a href="25.html" >5</a>
</li>
<li><a href="26.html">6</a>
</li>
<li><a href="27.html" >7</a>
</li>
<li><a href="28.html" >8</a>
</li>
<li><a href="29.html" >9</a>
</li>
</ul>
</li>
</ul>
<!-- end snippet -->
I have a sidebar list which having submenu. each list has link to different page.i want the submenu to expand on 2 condition
1-when its parent link is active only its children should expand.
2-when any of the child of particular list is active
expand the submenu of a list based on active url.
.[enter image description here][1]
[1]: https://i.stack.imgur.com/kkCmr.png
| 0debug
|
static uint32_t fdctrl_read_data(FDCtrl *fdctrl)
{
FDrive *cur_drv;
uint32_t retval = 0;
int pos;
cur_drv = get_cur_drv(fdctrl);
fdctrl->dsr &= ~FD_DSR_PWRDOWN;
if (!(fdctrl->msr & FD_MSR_RQM) || !(fdctrl->msr & FD_MSR_DIO)) {
FLOPPY_DPRINTF("error: controller not ready for reading\n");
return 0;
}
pos = fdctrl->data_pos;
if (fdctrl->msr & FD_MSR_NONDMA) {
pos %= FD_SECTOR_LEN;
if (pos == 0) {
if (fdctrl->data_pos != 0)
if (!fdctrl_seek_to_next_sect(fdctrl, cur_drv)) {
FLOPPY_DPRINTF("error seeking to next sector %d\n",
fd_sector(cur_drv));
return 0;
}
if (blk_read(cur_drv->blk, fd_sector(cur_drv), fdctrl->fifo, 1)
< 0) {
FLOPPY_DPRINTF("error getting sector %d\n",
fd_sector(cur_drv));
memset(fdctrl->fifo, 0, FD_SECTOR_LEN);
}
}
}
retval = fdctrl->fifo[pos];
if (++fdctrl->data_pos == fdctrl->data_len) {
fdctrl->data_pos = 0;
if (fdctrl->msr & FD_MSR_NONDMA) {
fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00);
} else {
fdctrl_reset_fifo(fdctrl);
fdctrl_reset_irq(fdctrl);
}
}
FLOPPY_DPRINTF("data register: 0x%02x\n", retval);
return retval;
}
| 1threat
|
Calling the month's name : I need help to improve my code. This is just for me, I just wanna learn more. So, I had this assignment in my class about array. I finished coding and submitted already, but I really want to code is for the program to print out the name of the month like "The rainfall value of the month of January: 156.98" rather than "month 1"
here is my code:
First, I created a class without the main method. This class has a constructor, 3 methods.
```public class RainFall {
private double[] rainFall;
public RainFall(double [] r){
//create an array as large as r
rainFall = new double [r.length];
//sopy the elements from r to rainFall
for (int index = 0 ; index < r.length ; index ++)
rainFall[index] = r[index];
}
//total method to get the total value of rain in a year
public double getTotal ()
double total = 0.0; //hold the total rain value
for (int i = 0 ; i < rainFall.length ; i++) //accumulate the rain value through out a year.
{
total += rainFall[i];
}
return total;
}
//get the average value of the rain in a year
public double getAverage(){
return getTotal () / rainFall.length;
}
//get the month with the most rain
public double getHighest ()
{
double highest = rainFall[0];
for(int index = 1 ; index < rainFall.length; index ++){
if(rainFall[index] > highest)
highest = rainFall[index] ;
}
return highest;
}
//get the month with the least rain
public double getLowest ()
{
double lowest = rainFall[0];
for(int index = 1 ; index < rainFall.length; index ++){
if(rainFall[index] < lowest)
lowest = rainFall[index] ;
if(lowest < 0 )
{
System.out.println("NO NEGATIVE NUMBER");
return 0;
}
}
return lowest;
}
}```
Then I created another class with the main method to call other methods:
```import java.util.Scanner;
public class CalculateRain {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final int MONTHS = 12; //the 12 months
//create an array to hold the rain values for a year
double [] rainFall = new double [MONTHS];
getValues(rainFall);
//create a rain fall object
RainFall re = new RainFall (rainFall);
//Display the total, average, highest, lowest values of the rain fall in
// a year
System.out.println("The total value of rain fall in a year: " + re.getTotal());
System.out.println("The average value is: " + re.getAverage());
System.out.println("The highest month has the value: " + re.getHighest());
System.out.println("The lowest month has the value: " + re.getLowest());
}
private static void getValues(double [] array)
{
Scanner keyboard = new Scanner (System.in);
//get the values of the months
for (int i = 0 ; i < array.length ; i ++)
{
System.out.println("Enter the value for the month " + (i+1));
array[i] = keyboard.nextDouble();
if (array[i] < 0 )
{
System.out.println("The value SHOULD NOT BE a NEGATIVE number");
break;
}
}
}
}```
I tried to create another loop inside the for (int i = 0 ; i < array.length ; i ++)
but before that, I created another array to hold the names of the months
```String [] month = {"January", "February","March",etc};```
and inside the for loop I did something like this
```for ( int i = 0 ; i < array.length ; i ++)
{
for (int index = 0; month.length; index++)
{
System.out.println("The rainfall value of the " + month[index]);
array[i] = keyboard.nextDouble();
if (array[i] < 0 )
{
System.out.println("The value SHOULD NOT BE a NEGATIVE number");
break;
}
}
}```
It ran, but I created an infinite loop.
Where did I miss it?
Thank you so much, guys.
| 0debug
|
How use if condition, if first valuable is above zero, then result needs to zero : let apliekamasumma = Double(brutoalga! - socnoalgas - summaapg - 75)
if (apliekamasumma < 0) {
let apliekamasumma = 0
}
Please help me with code.
| 0debug
|
Koin how to inject outside of Android activity / appcompatactivity : <p><strong><a href="https://github.com/Ekito/koin" rel="noreferrer">Koin</a></strong> is a new, lightweight library for DI and can be used in Android as well as in standalone kotlin apps.</p>
<p>Usually you inject dependencies like this:</p>
<pre><code>class SplashScreenActivity : Activity() {
val sampleClass : SampleClass by inject()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
</code></pre>
<p>with the <code>inject()</code> method.</p>
<p>But what about injecting stuff in places where Activity context is not available i.e. <strong>outside of an Activity</strong>?</p>
| 0debug
|
static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MPADecodeContext *s = avctx->priv_data;
uint32_t header;
int ret;
if (buf_size < HEADER_SIZE)
return AVERROR_INVALIDDATA;
header = AV_RB32(buf);
if (ff_mpa_check_header(header) < 0) {
av_log(avctx, AV_LOG_ERROR, "Header missing\n");
return AVERROR_INVALIDDATA;
}
if (avpriv_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) {
s->frame_size = -1;
return AVERROR_INVALIDDATA;
}
avctx->channels = s->nb_channels;
avctx->channel_layout = s->nb_channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
if (!avctx->bit_rate)
avctx->bit_rate = s->bit_rate;
s->frame = data;
ret = mp_decode_frame(s, NULL, buf, buf_size);
if (ret >= 0) {
s->frame->nb_samples = avctx->frame_size;
*got_frame_ptr = 1;
avctx->sample_rate = s->sample_rate;
} else {
av_log(avctx, AV_LOG_ERROR, "Error while decoding MPEG audio frame.\n");
*got_frame_ptr = 0;
if (buf_size == avpkt->size || ret != AVERROR_INVALIDDATA)
return ret;
}
s->frame_size = 0;
return buf_size;
}
| 1threat
|
void error_setg_file_open(Error **errp, int os_errno, const char *filename)
{
error_setg_errno(errp, os_errno, "Could not open '%s'", filename);
}
| 1threat
|
What's the design purpose of Gradle doFirst and doLast? : <p>For example I have the Gradle script like:</p>
<pre><code>myTask_A {
doFirst {
println "first string"
}
doLast {
println "last string"
}
}
</code></pre>
<p>The following two tasks have exactly the same execution result:</p>
<pre><code>myTask_B {
doFirst {
println "first string"
println "last string"
}
}
myTask_C {
doLast {
println "first string"
println "last string"
}
}
</code></pre>
<p>What's the design purpose of the the doFirst & doLast as any of above tasks produces the same result?</p>
| 0debug
|
What is the crash of "The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription"? : <p>I faced the following error (iOS 11):</p>
<blockquote>
<p>This app has crashed because it attempted to access privacy-sensitive
data without a usage description. The app's Info.plist must contain
an <code>NSPhotoLibraryAddUsageDescription</code> key with a string value
explaining to the user how the app uses this data.</p>
</blockquote>
<p>Note that although the application <em>info.plist</em> does contains <code>NSPhotoLibraryUsageDescription</code> it still crashes, why?</p>
| 0debug
|
void qemu_chr_initial_reset(void)
{
CharDriverState *chr;
initial_reset_issued = 1;
TAILQ_FOREACH(chr, &chardevs, next) {
qemu_chr_reset(chr);
}
}
| 1threat
|
React Native animations - translateX and translateY while scaling : <p>My <code>Animated.View</code> has the following style:</p>
<pre><code> {
transform: [
{
scale: this.animatedValue.interpolate({
inputRange: [0, 1],
outputRange: [initialScale, 1]
})},
{
translateX: this.animatedValue.interpolate({
inputRange: [0, 1],
outputRange: [startX, endX]
})},
{
translateY: this.animatedValue.interpolate({
inputRange: [0, 1],
outputRange: [startY, endY]
})},
]
}
</code></pre>
<p>When initialScale is 1 and the animation starts, I see the expected behavior: Animated.View starts at (startX, startY) and linearly moves to (endX, endY). <br/> However, when initialScale is 0.5 for example, the starting point of the view is not (startX, startY), the movement is not linear (a bit spheric) and the end point is still as expected - (endX, endY).</p>
<p>How can I scale my View while keeping a linear movement and expected start position?</p>
| 0debug
|
Method within a method java : <p>I am reading some java code and I came across the following unfamiliar syntax:</p>
<pre><code>controler.addOverridingModule( new AbstractModule() {
@Override
public void install() {
this.addPlanStrategyBinding("RandomTripToCarsharingStrategy").to( RandomTripToCarsharingStrategy.class ) ;
this.addPlanStrategyBinding("CarsharingSubtourModeChoiceStrategy").to( CarsharingSubtourModeChoiceStrategy.class ) ;
}
});
</code></pre>
<p>I am confused because the developer created a new method ("install") within the call to addOverridingModule. Could someone please tell me what is going on here?</p>
<p>Thanks!</p>
| 0debug
|
How to convert u8 to &[u8] in Rust? : <p>I am new and lost in Rust a bit.</p>
<p>I would like to add keys and values to a data store that has a put function that takes two byte string literals:</p>
<pre><code>batch.put(b"foxi", b"maxi");
</code></pre>
<p>I generate a bunch of these k-v pairs:</p>
<pre><code>for _ in 1..1000000 {
let mut ivec = Vec::new();
let s1: u8 = rng.gen();
let s2: u8 = rng.gen();
ivec.push(s1);
ivec.push(s2);
debug!("Adding key: {} and value {}", s1, s2);
vec.push(ivec);
}
let _ = database::write(db, vec);
</code></pre>
<p>I have a fn that tries to add them:</p>
<pre><code>pub fn write(db: DB, vec: Vec<Vec<u8>>) {
let batch = WriteBatch::new();
for v in vec {
batch.put(v[0], v[1]);
}
db.write(&batch).unwrap();
}
</code></pre>
<p>When I try to compile this I get:</p>
<pre><code>error[E0308]: mismatched types
--> src/database.rs:17:19
|
17 | batch.put(v[0], v[1]);
| ^^^^ expected &[u8], found u8
|
= note: expected type `&[u8]`
found type `u8`
error[E0308]: mismatched types
--> src/database.rs:17:25
|
17 | batch.put(v[0], v[1]);
| ^^^^ expected &[u8], found u8
|
= note: expected type `&[u8]`
found type `u8`
</code></pre>
<p>I was ping-ponging with the borrow checker for a while now but I could not get it working. What is the best way to have byte literal strings from u8s?</p>
| 0debug
|
static void xilinx_spips_reset(DeviceState *d)
{
XilinxSPIPS *s = XILINX_SPIPS(d);
int i;
for (i = 0; i < XLNX_SPIPS_R_MAX; i++) {
s->regs[i] = 0;
}
fifo8_reset(&s->rx_fifo);
fifo8_reset(&s->rx_fifo);
s->regs[R_CONFIG] |= MODEFAIL_GEN_EN;
s->regs[R_SLAVE_IDLE_COUNT] = 0xFF;
s->regs[R_TX_THRES] = 1;
s->regs[R_RX_THRES] = 1;
s->regs[R_MOD_ID] = 0x01090106;
s->regs[R_LQSPI_CFG] = R_LQSPI_CFG_RESET;
s->link_state = 1;
s->link_state_next = 1;
s->link_state_next_when = 0;
s->snoop_state = SNOOP_CHECKING;
s->cmd_dummies = 0;
s->man_start_com = false;
xilinx_spips_update_ixr(s);
xilinx_spips_update_cs_lines(s);
}
| 1threat
|
Anaconda: Install specific packages from specific channels using environment.yml : <p>does anyone know how to construct an Anaconda environment.yml file so that it installs specific packages from specific channels?</p>
<p>Something like this:</p>
<pre><code>dependencies:
- numpy
- pandas
- package-A from channel Z
- package-B from channel Y
</code></pre>
<p>All I could find is that you can specify channels using the <strong>channels:</strong> command. But apparently it then grabs the packages from the first channel its available on - but I need some packages from very specific channels (but it exists on multiple ones in different "versions").</p>
| 0debug
|
Would someone please explain the used of return keyword? Thank you : const menu = {
_courses : {
_appatizers: [],
_mains: [],
_deserts: []
},
get courses() {
return {
appatizers: this._courses._appatizers;
mains: this._courses._mains;
deserts: this._courses._deserts;
};
}
I am more concerned of how this return is used as an object;
please explain as much you can to clarify the concept, thank you.
forget about the code.
| 0debug
|
Object Oriented Programming vs. Procedural Programming : <p>I'm trying to write two examples of code in java: OOP and procedural, but I can't think of procedural code example. I have one example of an OOP code below. Can someone give me an example of a procedural code and explain a little as to what it does? </p>
<p>OOP example below:</p>
<pre><code>Class test {
public static void main (String args []){
int test = 6;
if (test == 9){
System.out.println(“True”);
} else {
System.out.println(“False”);
}
}
</code></pre>
| 0debug
|
c# issue couldnt read SeriPort : can anybody check below codes for c#. there is a issue at float sıcaklık = Convert.ToByte(seriPort.ReadExisting()); but i couldnt find to what is wrong? I guess SeriPort couldnt get the data.
Hi, can anybody check below codes for c#. there is a issue at float sıcaklık = Convert.ToByte(seriPort.ReadExisting()); but i couldnt find to what is wrong? I guess SeriPort couldnt get the data.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
SerialPort seriPort;
public Form1()
{
InitializeComponent();
seriPort = new SerialPort();
seriPort.BaudRate = 9600;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
try
{
seriPort.PortName = textBox1.Text;
if (!seriPort.IsOpen)
MessageBox.Show("Bağlantı Kuruldu");
}
catch
{
MessageBox.Show("Bağlantı Kurulmadı!");
}
}
private void timer1_Tick(object sender, EventArgs e)
{
try
{
seriPort.Write("temperature");
float sıcaklık = Convert.ToByte(seriPort.ReadExisting());
textBox2.Text = sıcaklık.ToString();
comboBox1.Items.Add(textBox2.Text);
System.Threading.Thread.Sleep(100);
}
catch (Exception) {}
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Stop();
seriPort.Close();
}
}
}
| 0debug
|
How to group or merge this array of objects in javascript? : <p>I have an array of objects like below for example. </p>
<pre><code>{name: "Mc Donald", quantity: 4, maleCount: 1, femaleCount: 0}
{name: "KFC", quantity: 9, maleCount: 1, femaleCount: 0}
{name: "KFC", quantity: 9, maleCount: 1, femaleCount: 0}
{name: "Mc Donald", quantity: 4, maleCount: 0, femaleCount: 1}
{name: "KFC", quantity: 9, maleCount: 0, femaleCount: 1}
{name: "KFC", quantity: 9, maleCount: 1, femaleCount: 0}
{name: "KFC", quantity: 9, maleCount: 0, femaleCount: 1}
{name: "KFC", quantity: 9, maleCount: 0, femaleCount: 1}
</code></pre>
<p>I want to group them up and adding up all the values in it. For example, the final would be like this: </p>
<pre><code>{name: "Mc Donald", quantity: 8, maleCount: 1, femaleCount: 1}
{name: "KFC", quantity: 54, maleCount: 3, femaleCount: 3}
</code></pre>
<p>How can I achieve this in JavaScript?</p>
<p>I have tried to find some solution online but it is not the one I wanted. For example this <a href="https://stackoverflow.com/questions/31688459/group-array-items-using-object">solution</a></p>
| 0debug
|
static void guess_dc(MpegEncContext *s, int16_t *dc, int w,
int h, int stride, int is_luma)
{
int b_x, b_y;
int16_t (*col )[4] = av_malloc(stride*h*sizeof( int16_t)*4);
uint32_t (*dist)[4] = av_malloc(stride*h*sizeof(uint32_t)*4);
for(b_y=0; b_y<h; b_y++){
int color= 1024;
int distance= -1;
for(b_x=0; b_x<w; b_x++){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_x;
}
col [b_x + b_y*stride][1]= color;
dist[b_x + b_y*stride][1]= distance >= 0 ? b_x-distance : 9999;
}
color= 1024;
distance= -1;
for(b_x=w-1; b_x>=0; b_x--){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_x;
}
col [b_x + b_y*stride][0]= color;
dist[b_x + b_y*stride][0]= distance >= 0 ? distance-b_x : 9999;
}
}
for(b_x=0; b_x<w; b_x++){
int color= 1024;
int distance= -1;
for(b_y=0; b_y<h; b_y++){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_y;
}
col [b_x + b_y*stride][3]= color;
dist[b_x + b_y*stride][3]= distance >= 0 ? b_y-distance : 9999;
}
color= 1024;
distance= -1;
for(b_y=h-1; b_y>=0; b_y--){
int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
int error_j= s->error_status_table[mb_index_j];
int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]);
if(intra_j==0 || !(error_j&ER_DC_ERROR)){
color= dc[b_x + b_y*stride];
distance= b_y;
}
col [b_x + b_y*stride][2]= color;
dist[b_x + b_y*stride][2]= distance >= 0 ? distance-b_y : 9999;
}
}
for (b_y = 0; b_y < h; b_y++) {
for (b_x = 0; b_x < w; b_x++) {
int mb_index, error, j;
int64_t guess, weight_sum;
mb_index = (b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride;
error = s->error_status_table[mb_index];
if (IS_INTER(s->current_picture.f.mb_type[mb_index]))
continue;
if (!(error & ER_DC_ERROR))
continue;
weight_sum = 0;
guess = 0;
for (j = 0; j < 4; j++) {
int64_t weight = 256 * 256 * 256 * 16 / dist[b_x + b_y*stride][j];
guess += weight*(int64_t)col[b_x + b_y*stride][j];
weight_sum += weight;
}
guess = (guess + weight_sum / 2) / weight_sum;
dc[b_x + b_y * stride] = guess;
}
}
av_freep(&col);
av_freep(&dist);
}
| 1threat
|
query = 'SELECT * FROM customers WHERE email = ' + email_input
| 1threat
|
WPF native windows 10 toasts : <p>Using .NET WPF and Windows 10, is there a way to push a local toast notification onto the action center using c#? I've only seen people making custom dialogs for that but there must be a way to do it through the os.</p>
| 0debug
|
static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
TCGMemOpIdx oi, uintptr_t retaddr)
{
size_t mmu_idx = get_mmuidx(oi);
size_t index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
CPUTLBEntry *tlbe = &env->tlb_table[mmu_idx][index];
target_ulong tlb_addr = tlbe->addr_write;
TCGMemOp mop = get_memop(oi);
int a_bits = get_alignment_bits(mop);
int s_bits = mop & MO_SIZE;
retaddr -= GETPC_ADJ;
if (unlikely(a_bits > 0 && (addr & ((1 << a_bits) - 1)))) {
cpu_unaligned_access(ENV_GET_CPU(env), addr, MMU_DATA_STORE,
mmu_idx, retaddr);
}
if (unlikely(addr & ((1 << s_bits) - 1))) {
goto stop_the_world;
}
if ((addr & TARGET_PAGE_MASK)
!= (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) {
if (!VICTIM_TLB_HIT(addr_write, addr)) {
tlb_fill(ENV_GET_CPU(env), addr, MMU_DATA_STORE, mmu_idx, retaddr);
}
tlb_addr = tlbe->addr_write & ~TLB_INVALID_MASK;
}
if (unlikely(tlb_addr & TLB_NOTDIRTY)) {
tlb_set_dirty(ENV_GET_CPU(env), addr);
tlb_addr = tlb_addr & ~TLB_NOTDIRTY;
}
if (unlikely(tlb_addr & ~TARGET_PAGE_MASK)) {
goto stop_the_world;
}
if (unlikely(tlbe->addr_read != tlb_addr)) {
tlb_fill(ENV_GET_CPU(env), addr, MMU_DATA_LOAD, mmu_idx, retaddr);
goto stop_the_world;
}
return (void *)((uintptr_t)addr + tlbe->addend);
stop_the_world:
cpu_loop_exit_atomic(ENV_GET_CPU(env), retaddr);
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.