problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
How to use multiple accounts of AWS SES for Email Marketing : <p>This is about a web startup. We are working on Email Marketing to get more registrations on our Platform. We have more than 1 Million relevant email addresses collected from web scraping (bounce rate is around 5%).</p>
<p>So we are sending inbound (transactional & notification) mails to our users. Apart from that we are also using AWS SES to send outbound invitation mails to scraped email id's. Recently AWS raised question about the nature of mails we are sending. (During ses account creation, i had stated that this ses account will be used for transactional emails only).</p>
<p>My questions are:</p>
<ol>
<li>shall I create another SES account and then verify the same domain or shall i purchase another domain and verify that on in order to send the outbound marketing mails from that account? (I don't want AWS SES to blacklist my domain)</li>
<li>How can I send Marketing emails (in bulk amount) via SES given that my bounce rate won't cross 5% normally?</li>
<li>How do other startups & Companies using SES handle this problem? What are the best-practices if any?</li>
</ol>
| 0debug
|
Why is my javascript calculator not working? : <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Calculator</title>
<style>
input
{
height:100px;
width:150px;
border-radius:10px;
border-style:none;
background-color:black;
color:white;
}
.abcde
/*for display purposes*/
{
background-color:blue;
height:100px;
width:608px;
border-radius: 10px;
color:white;
font-size:100px;
}
</style>
<h1>Basic calculator</h1>
</head>
<body>
<script>
// function clearfunc()
// {
// document.getElementById("abcd").innerHTML="0";
// }
function show(id)
{
if(id=="zero")
document.getElementById("abcd").innerHTML="0";
else if(id=="one")
document.getElementById("abcd").innerHTML="1";
else if(id=="two")
document.getElementById("abcd").innerHTML="2";
else if(id=="three")
document.getElementById("abcd").innerHTML="3";
else if(id=="four")
document.getElementById("abcd").innerHTML="4";
else if(id=="five")
document.getElementById("abcd").innerHTML="5";
else if(id=="six")
document.getElementById("abcd").innerHTML="6";
else if(id=="seven")
document.getElementById("abcd").innerHTML="7";
else if(id=="eight")
document.getElementById("abcd").innerHTML="8";
else if(id=="nine")
document.getElementById("abcd").innerHTML="9";
else if(id=="clear")
document.getElementById("abcd").innerHTML="";
}
function afterPlus(id)
{
var whichOperator="";
if(id=="equal")
{
b=Number(document.getElementById("abcd").innerHTML);
switch(whichOperator)
{
case "plus":
document.getElementById("abcd").innerHTML=(a+b);
break;
case "minus":
document.getElementById("abcd").innerHTML=(a-b);
break;
case "mul":
document.getElementById("abcd").innerHTML=(a*b);
break;
case "divide":
document.getElementById("abcd").innerHTML=(a/b);
break;
default:
document.getElementById("ans").innerHTML=b;
}
}
else
{
whichOperator=id; //eg i need + - * and / to be got
a=Number(document.getElementById("abcd").innerHTML);
}
}
</script>
<div class="abcde" id="abcd">
</div>
<input type="button" value="0" id="zero" onclick="return show(this.id)">
<input type="button" value="1" id="one" onclick="return show(this.id)">
<input type="button" value="2" id="two" onclick="return show(this.id)">
<input type="button" value="+" id="plus" onclick="return afterPlus(this.id)"> <br>
<input type="button" value="3" id="three" onclick="return show(this.id)">
<input type="button" value="4" id="four" onclick="return show(this.id)">
<input type="button" value="5" id="five" onclick="return show(this.id)">
<input type="button" value="-" id="minus" onclick="return afterPlus(this.id)"> <br>
<input type="button" value="6" id="six" onclick="return show(this.id)">
<input type="button" value="7" id="seven" onclick="return show(this.id)">
<input type="button" value="8" id="eight" onclick="return show(this.id)">
<input type="button" value="*" id="mul" onclick="return afterPlus(this.id)"> <br>
<input type="button" value="9" id="nine" onclick="return show(this.id)">
<input type="button" value="C" id="clear" onclick="return show(this.id)">
<input type="button" value="=" id="equal" onclick="return afterPlus(this.id)">
<input type="button" value="/" id="divide" onclick="return afterPlus(this.id)">
</body>
</html>
i think i have done everything fine.
expected output-:
i press 1.
1 is displayed through function show(id)
now 1 is in paragraph id="abcd"
then user presses +
it's id="plus" is passed to function afterplus(id).
i check if id==equals or not.
if the id!=equal, then store a=previous value as a number as well as the operator as a string.
else if id==equal then, i need to save b as the past number.
then switch case will run, the operator id =(+ * / -) will be used in switch case and the proper calculation will be done.
| 0debug
|
static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr) {
MpegEncContext * const s = &h->s;
const int mb_xy= mb_x + mb_y*s->mb_stride;
int linesize, uvlinesize;
int dir;
if( h->sps.mb_aff ) {
return;
}
linesize = s->linesize;
uvlinesize = s->uvlinesize;
for( dir = 0; dir < 2; dir++ )
{
int edge;
const int mbm_xy = dir == 0 ? mb_xy -1 : mb_xy - s->mb_stride;
int start = h->slice_table[mbm_xy] == 255 ? 1 : 0;
if (h->deblocking_filter==2 && h->slice_table[mbm_xy] != h->slice_table[mb_xy])
start = 1;
for( edge = start; edge < 4; edge++ ) {
int mbn_xy = edge > 0 ? mb_xy : mbm_xy;
int bS[4];
int qp;
if( IS_INTRA( s->current_picture.mb_type[mb_xy] ) ||
IS_INTRA( s->current_picture.mb_type[mbn_xy] ) ) {
bS[0] = bS[1] = bS[2] = bS[3] = ( edge == 0 ? 4 : 3 );
} else {
int i;
for( i = 0; i < 4; i++ ) {
int x = dir == 0 ? edge : i;
int y = dir == 0 ? i : edge;
int b_idx= 8 + 4 + x + 8*y;
int bn_idx= b_idx - (dir ? 8:1);
if( h->non_zero_count_cache[b_idx] != 0 ||
h->non_zero_count_cache[bn_idx] != 0 ) {
bS[i] = 2;
}
else if( h->slice_type == P_TYPE ) {
if( h->ref_cache[0][b_idx] != h->ref_cache[0][bn_idx] ||
ABS( h->mv_cache[0][b_idx][0] - h->mv_cache[0][bn_idx][0] ) >= 4 ||
ABS( h->mv_cache[0][b_idx][1] - h->mv_cache[0][bn_idx][1] ) >= 4 )
bS[i] = 1;
else
bS[i] = 0;
} else {
return;
}
}
if(bS[0]+bS[1]+bS[2]+bS[3] == 0)
continue;
}
qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
if( dir == 0 ) {
filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp );
if( (edge&1) == 0 ) {
int chroma_qp = ( h->chroma_qp +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgecv( h, &img_cb[2*edge], uvlinesize, bS, chroma_qp );
filter_mb_edgecv( h, &img_cr[2*edge], uvlinesize, bS, chroma_qp );
}
} else {
filter_mb_edgeh( h, &img_y[4*edge*linesize], linesize, bS, qp );
if( (edge&1) == 0 ) {
int chroma_qp = ( h->chroma_qp +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgech( h, &img_cb[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );
filter_mb_edgech( h, &img_cr[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );
}
}
}
}
}
| 1threat
|
Super Mario movement for adding speed Unity2D : <p>I already get basic movement: left, right and jump. Using GetKeyDown/Up.</p>
<p>I need the player to running combine 2 different button pressed.</p>
<p>By: press and hold a button and press the rightkey to speeding up The player to right direction.</p>
<p>I need your help</p>
| 0debug
|
How to make a custom directory so that I can cd directory in Matlab : Suppose I have a directory
cur='C:\Windows\debug';
Then I can run `cd(cur)` now. But I'm not used to use the function format.I hope I can use `cd cur` directory.Is possible in *Matlab*?
| 0debug
|
int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
const int16_t *in, int buffer_length,
int filter_length, int stop_on_overflow,
int shift, int rounder)
{
int i,n;
for (n = 0; n < buffer_length; n++) {
int sum = rounder;
for (i = 1; i <= filter_length; i++)
sum -= filter_coeffs[i-1] * out[n-i];
sum = ((sum >> 12) + in[n]) >> shift;
if (sum + 0x8000 > 0xFFFFU) {
if (stop_on_overflow)
return 1;
sum = (sum >> 31) ^ 32767;
}
out[n] = sum;
}
return 0;
}
| 1threat
|
int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
const char *version, const char *serial, const char *model,
uint64_t wwn,
uint32_t cylinders, uint32_t heads, uint32_t secs,
int chs_trans)
{
uint64_t nb_sectors;
s->bs = bs;
s->drive_kind = kind;
bdrv_get_geometry(bs, &nb_sectors);
if (cylinders < 1 || cylinders > 16383) {
error_report("cyls must be between 1 and 16383");
return -1;
}
if (heads < 1 || heads > 16) {
error_report("heads must be between 1 and 16");
return -1;
}
if (secs < 1 || secs > 63) {
error_report("secs must be between 1 and 63");
return -1;
}
s->cylinders = cylinders;
s->heads = heads;
s->sectors = secs;
s->chs_trans = chs_trans;
s->nb_sectors = nb_sectors;
s->wwn = wwn;
s->smart_enabled = 1;
s->smart_autosave = 1;
s->smart_errors = 0;
s->smart_selftest_count = 0;
if (kind == IDE_CD) {
bdrv_set_dev_ops(bs, &ide_cd_block_ops, s);
bdrv_set_buffer_alignment(bs, 2048);
} else {
if (!bdrv_is_inserted(s->bs)) {
error_report("Device needs media, but drive is empty");
return -1;
}
if (bdrv_is_read_only(bs)) {
error_report("Can't use a read-only drive");
return -1;
}
}
if (serial) {
pstrcpy(s->drive_serial_str, sizeof(s->drive_serial_str), serial);
} else {
snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),
"QM%05d", s->drive_serial);
}
if (model) {
pstrcpy(s->drive_model_str, sizeof(s->drive_model_str), model);
} else {
switch (kind) {
case IDE_CD:
strcpy(s->drive_model_str, "QEMU DVD-ROM");
break;
case IDE_CFATA:
strcpy(s->drive_model_str, "QEMU MICRODRIVE");
break;
default:
strcpy(s->drive_model_str, "QEMU HARDDISK");
break;
}
}
if (version) {
pstrcpy(s->version, sizeof(s->version), version);
} else {
pstrcpy(s->version, sizeof(s->version), qemu_get_version());
}
ide_reset(s);
bdrv_iostatus_enable(bs);
return 0;
}
| 1threat
|
i wanna sum these two arrays with for loop ex. num_array[1]+num2_array[5] num_array[2]+num2_array[4] : i wan to sum two arrays 1)num_array 2)num2_array using for loops... please help me
thank you
<!-- begin snippet: js hide: false -->
<!-- language: lang-js -->
var num_array,num2_array;
var i,j,sum=0;
for(i=0;i<6;i++)
{
num_array[i] = get_integer("NUMBER: ","");
while(num_array[i] < 1 && num_array[i] > 500)
{
num_array[i] = get_integer("Enter a number inn limit of 1 to 500",0);
}
}
for(i=5;i>=0;i--)
{
num2_array[i] = num_array[i];
show_message(num2_array[i]);
}
<!-- end snippet -->
| 0debug
|
Copy Range & Paste To First Blank Column : I want to copy range and paste in first blank column, but I'm getting errors! I appreciate any help from you, here is my code:
Sub Report()
Dim lRow As Long
Dim lCol As Long
Application.DisplayAlerts = False
Sheets("Chart").Select
Range("D9:D17").Select
Selection.Copy
Sheets("Report").Select
lCol = Cells(4, Columns.Count).End(xlToLeft).Column + 1
Range("lCol:lCol+9").Paste
End Sub
| 0debug
|
Google Play services out of date. Requires 10084000 but found 9879470. Can't update : <p>I am making an android app with Firebase. These are the lines causing problems:</p>
<pre><code>dependencies {
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
</code></pre>
<p>I get this error:</p>
<pre><code>Google Play services out of date. Requires 10084000 but found 9879470.
</code></pre>
<p>I run the app on an emulator. It doesn't seem possible to update GPS on the emulator, since it doesn't have Google Play Store.</p>
<p>In SDK Manager, it says the version of Google Player services is 38.</p>
<p>There is no apparent way to update this either.</p>
| 0debug
|
Why does polymorphism not apply on arrays in C++? : <pre><code>#include <iostream>
using namespace std;
struct Base
{
virtual ~Base()
{
cout << "~Base(): " << b << endl;
}
int b = 1;
};
struct Derived : Base
{
~Derived() override
{
cout << "~Derived(): " << d << endl;
}
int d = 2;
};
int main()
{
Base* p = new Derived[4];
delete[] p;
}
</code></pre>
<p>The output is as follws: (Visual Studio 2015 with Clang 3.8)</p>
<pre><code>~Base(): 1
~Base(): 2
~Base(): -2071674928
~Base(): 1
</code></pre>
<p>Why does polymorphism not apply on arrays in C++?</p>
| 0debug
|
static void http_write_packet(void *opaque,
unsigned char *buf, int size)
{
HTTPContext *c = opaque;
if (c->buffer_ptr == c->buffer_end || !c->buffer_ptr)
c->buffer_ptr = c->buffer_end = c->buffer;
if (c->buffer_end - c->buffer + size > IOBUFFER_MAX_SIZE)
abort();
memcpy(c->buffer_end, buf, size);
c->buffer_end += size;
}
| 1threat
|
window.location.href = 'http://attack.com?user=' + user_input;
| 1threat
|
I keep getting this error and I'm not sure why : TypeError: unsupported operand type(s) for ** or pow(): 'builtin_function_or_method' and 'float'
from math import pi,sqrt,exp
s=2
x=1
m=0
y=(1/((sqrt(2*pi))*s))*(exp**(-1./2)*((x-m)/s)**2)
print (y)
| 0debug
|
I do not understand why I am getting this error: 'else' without a previous 'if'. please anyone? : <p>I am trying to write a code that would calculate the average of as many test scores as the user wants. However, when compiling it with g++ compiler, I get the error:</p>
<p>'else' without a previous 'if'</p>
<p>the only 'else' statement of the code is in the following for loop. that's why i am omitting the rest of the code. Anyone, please tell me what i am doing wrong here. I can't seem to find the answer anywhere. Thanks in advance!</p>
<pre><code>int i, j;
cout >>"How many tests' scores you want to average; \n";
cin << i;
// Assuming i > 0
int test[i]
for (j = 0; j < i; j++)
{
if (j == 0)
cout <<"Enter the 1st score: \n";
cin >> test[j];
if (j == 1)
cout <<"Enter the 2nd score: \n";
cin >> test[j];
if (j == 2)
cout <<"Enter the 3rd score: \n";
cin >> test[j];
else
cout <<"Enter the "<< (j+1) <<"th score: \n";
cin >> test[j];
}
</code></pre>
| 0debug
|
static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
strList **missing_feats)
{
X86CPU *xc;
FeatureWord w;
Error *err = NULL;
strList **next = missing_feats;
if (xcc->kvm_required && !kvm_enabled()) {
strList *new = g_new0(strList, 1);
new->value = g_strdup("kvm");;
*missing_feats = new;
return;
}
xc = X86_CPU(object_new(object_class_get_name(OBJECT_CLASS(xcc))));
x86_cpu_load_features(xc, &err);
if (err) {
strList *new = g_new0(strList, 1);
new->value = g_strdup("type");
*next = new;
next = &new->next;
}
x86_cpu_filter_features(xc);
for (w = 0; w < FEATURE_WORDS; w++) {
uint32_t filtered = xc->filtered_features[w];
int i;
for (i = 0; i < 32; i++) {
if (filtered & (1UL << i)) {
strList *new = g_new0(strList, 1);
new->value = g_strdup(x86_cpu_feature_name(w, i));
*next = new;
next = &new->next;
}
}
}
object_unref(OBJECT(xc));
}
| 1threat
|
void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool tso_enable,
bool csum_enable, uint32_t gso_size)
{
struct tcp_hdr l4hdr;
assert(pkt);
assert(csum_enable || !tso_enable);
pkt->virt_hdr.gso_type = net_tx_pkt_get_gso_type(pkt, tso_enable);
switch (pkt->virt_hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
case VIRTIO_NET_HDR_GSO_NONE:
pkt->virt_hdr.hdr_len = 0;
pkt->virt_hdr.gso_size = 0;
break;
case VIRTIO_NET_HDR_GSO_UDP:
pkt->virt_hdr.gso_size = IP_FRAG_ALIGN_SIZE(gso_size);
pkt->virt_hdr.hdr_len = pkt->hdr_len + sizeof(struct udp_header);
break;
case VIRTIO_NET_HDR_GSO_TCPV4:
case VIRTIO_NET_HDR_GSO_TCPV6:
iov_to_buf(&pkt->vec[NET_TX_PKT_PL_START_FRAG], pkt->payload_frags,
0, &l4hdr, sizeof(l4hdr));
pkt->virt_hdr.hdr_len = pkt->hdr_len + l4hdr.th_off * sizeof(uint32_t);
pkt->virt_hdr.gso_size = IP_FRAG_ALIGN_SIZE(gso_size);
break;
default:
g_assert_not_reached();
}
if (csum_enable) {
switch (pkt->l4proto) {
case IP_PROTO_TCP:
pkt->virt_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
pkt->virt_hdr.csum_start = pkt->hdr_len;
pkt->virt_hdr.csum_offset = offsetof(struct tcp_hdr, th_sum);
break;
case IP_PROTO_UDP:
pkt->virt_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
pkt->virt_hdr.csum_start = pkt->hdr_len;
pkt->virt_hdr.csum_offset = offsetof(struct udp_hdr, uh_sum);
break;
default:
break;
}
}
}
| 1threat
|
Weird numpad applications in nano only when using putty through windows : I am using ubuntu on an old PC of mine and i am communicating to it using putty through a windows laptop
when using the terminal everything is fine and i can use numpad very normal
12345689/*- and the num lock key
however when i open anything in nano all these keys have functions i guess
numlock does a very weird thing and all the other keys are similar
the 4 2 6 8 do left down right up respectively as if the num lock is disabled but it isn't disabled and when i try to re enable it the button doesnt work
i did search about this and found a few solution to change putty settings and i did and it had no effect i think i must change the nano perefences but i am a beginner with linux so i don't know how
thanks!
| 0debug
|
How can I solve this problem with arrays in C++? (Beginner level.) : I am an enthusiast programmer, but I don't know much of arrays in C++. I have found page Edabit for small challenges. I am now working on the challenge: Get arithmetic mean of the given array. Now I have code like that:
```c++
#include <iostream>
int data;
using namespace std;
int mean(int data);
int main()
{
int data[] = { 1, 2, 3, 4 };
cout << mean(data);
}
int mean(int data)
{
double mean = 0;
for (int i = 0; i < sizeof(data) / sizeof(data[0]); i++)
{
mean += data[i];
}
mean /= sizeof(data) / sizeof(data[0]);
}
```
and I am stuck. I use Visual Studio 2019 on Windows 7 Professional, and I have underlined 3 characters ( data[i], and 2x data[0]). For this x Visual Studio says 'expression must have pointer-to-object type'. (By the way, what is the advance of addresses and pointers? I haven't learned them because I thought that I will never use them.) And I have no idea what he means with this. I only know what pointer is (at least I think).
I have tried with several Stack Overflow questions, GeeksForGeeks website and a lot of other stuff. But I am stuck.
-----------------------------------------------
For this, who haven't read the whole question:
**The question:** What is wrong with the upper code, where Visual Studio 2019 says 'expression must have pointer-to-object type' (Error E0142)?
Thank you for your effort!
*P.S.
Don't tell me the whole answer. ;) I will guess it alone, but I just can't go through this problem.*
| 0debug
|
static int h263_probe(AVProbeData *p)
{
int code;
const uint8_t *d;
if (p->buf_size < 6)
return 0;
d = p->buf;
code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2);
if (code == 0x20) {
return 50;
}
return 0;
}
| 1threat
|
How do I associate an Elastic IP with a Fargate container? : <p>I'm exploring using the new Fargate option for my ECS containers. One constraint is that the running task must always be accessible at the same Public IP address.</p>
<p>My first thought was to allocate an Elastic IP but I can't tell what to associate it to. It seems an Elastic IP can be associated to an instance (which is irrelevant for Fargate) or a Network Interface. However, if I associate it with an ENI, I can't see how to ensure my task's container has that Network Interface. When creating a Service, I see that I can put it in a VPC, but that's it.</p>
<p>From experimentation, if I kill a task so that the service restarts a new one, or if I update the service to run a new task revision - the container that starts running the new task will have a new ENI each time.</p>
<p>Is there some way to ensure that a given service has the same public IP address, even if its tasks are killed and restarted?</p>
| 0debug
|
How to bring credentials into a Docker container during build : <p>I'm wondering whether there are best practices on how to inject credentials into a Docker container during a <code>docker build</code>.
In my Dockerfile I need to fetch resources webservers which require basic authentication and I'm thinking about a proper way on how to bring the credentials into the container without hardcoding them.</p>
<p>What about a .netrc file and using it with <code>curl --netrc ...</code>? But what about security? I do no like the idea of having credentials being saved in a source repository together with my Dockerfile.</p>
<p>Is there for example any way to inject credentials using parameters or environment variables?</p>
<p>Any ideas?</p>
| 0debug
|
static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
{
MpegTSContext *ts = filter->u.section_filter.opaque;
SectionHeader h1, *h = &h1;
PESContext *pes;
AVStream *st;
const uint8_t *p, *p_end, *desc_list_end, *desc_end;
int program_info_length, pcr_pid, pid, stream_type;
int desc_list_len, desc_len, desc_tag;
int comp_page = 0, anc_page = 0;
char language[4] = {0};
#ifdef DEBUG_SI
av_log(ts->stream, AV_LOG_DEBUG, "PMT: len %i\n", section_len);
av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len);
#endif
p_end = section + section_len - 4;
p = section;
if (parse_section_header(h, &p, p_end) < 0)
return;
#ifdef DEBUG_SI
av_log(ts->stream, AV_LOG_DEBUG, "sid=0x%x sec_num=%d/%d\n",
h->id, h->sec_num, h->last_sec_num);
#endif
if (h->tid != PMT_TID)
return;
clear_program(ts, h->id);
pcr_pid = get16(&p, p_end) & 0x1fff;
if (pcr_pid < 0)
return;
add_pid_to_pmt(ts, h->id, pcr_pid);
#ifdef DEBUG_SI
av_log(ts->stream, AV_LOG_DEBUG, "pcr_pid=0x%x\n", pcr_pid);
#endif
program_info_length = get16(&p, p_end) & 0xfff;
if (program_info_length < 0)
return;
p += program_info_length;
if (p >= p_end)
return;
for(;;) {
language[0] = 0;
st = 0;
stream_type = get8(&p, p_end);
if (stream_type < 0)
break;
pid = get16(&p, p_end) & 0x1fff;
if (pid < 0)
break;
desc_list_len = get16(&p, p_end) & 0xfff;
if (desc_list_len < 0)
break;
desc_list_end = p + desc_list_len;
if (desc_list_end > p_end)
break;
for(;;) {
desc_tag = get8(&p, desc_list_end);
if (desc_tag < 0)
break;
if (stream_type == STREAM_TYPE_PRIVATE_DATA) {
if((desc_tag == 0x6A) || (desc_tag == 0x7A)) {
stream_type = STREAM_TYPE_AUDIO_AC3;
} else if(desc_tag == 0x7B) {
stream_type = STREAM_TYPE_AUDIO_DTS;
}
}
desc_len = get8(&p, desc_list_end);
desc_end = p + desc_len;
if (desc_end > desc_list_end)
break;
#ifdef DEBUG_SI
av_log(ts->stream, AV_LOG_DEBUG, "tag: 0x%02x len=%d\n",
desc_tag, desc_len);
#endif
switch(desc_tag) {
case DVB_SUBT_DESCID:
if (stream_type == STREAM_TYPE_PRIVATE_DATA)
stream_type = STREAM_TYPE_SUBTITLE_DVB;
language[0] = get8(&p, desc_end);
language[1] = get8(&p, desc_end);
language[2] = get8(&p, desc_end);
language[3] = 0;
get8(&p, desc_end);
comp_page = get16(&p, desc_end);
anc_page = get16(&p, desc_end);
break;
case 0x0a:
language[0] = get8(&p, desc_end);
language[1] = get8(&p, desc_end);
language[2] = get8(&p, desc_end);
language[3] = 0;
break;
default:
break;
}
p = desc_end;
}
p = desc_list_end;
#ifdef DEBUG_SI
av_log(ts->stream, AV_LOG_DEBUG, "stream_type=%d pid=0x%x\n",
stream_type, pid);
#endif
switch(stream_type) {
case STREAM_TYPE_AUDIO_MPEG1:
case STREAM_TYPE_AUDIO_MPEG2:
case STREAM_TYPE_VIDEO_MPEG1:
case STREAM_TYPE_VIDEO_MPEG2:
case STREAM_TYPE_VIDEO_MPEG4:
case STREAM_TYPE_VIDEO_H264:
case STREAM_TYPE_VIDEO_VC1:
case STREAM_TYPE_AUDIO_AAC:
case STREAM_TYPE_AUDIO_AC3:
case STREAM_TYPE_AUDIO_DTS:
case STREAM_TYPE_SUBTITLE_DVB:
if(ts->pids[pid]){
assert(ts->pids[pid]->type == MPEGTS_PES);
pes= ts->pids[pid]->u.pes_filter.opaque;
st= pes->st;
}else{
pes = add_pes_stream(ts, pid, pcr_pid, stream_type);
if (pes)
st = new_pes_av_stream(pes, 0);
}
add_pid_to_pmt(ts, h->id, pid);
if(st)
av_program_add_stream_index(ts->stream, h->id, st->index);
break;
default:
break;
}
if (st) {
if (language[0] != 0) {
memcpy(st->language, language, 4);
}
if (stream_type == STREAM_TYPE_SUBTITLE_DVB) {
st->codec->sub_id = (anc_page << 16) | comp_page;
}
}
}
ts->stop_parse++;
mpegts_close_filter(ts, filter);
}
| 1threat
|
Do something when player touches GameObject : <p>I would ask how to do the first person controler, if touches a GameObject, then the game automaticly change screen
(It would be nice if there was a code snippet in the answer for me to understand better)
Thank you in advance.</p>
| 0debug
|
Spark: Find Each Partition Size for RDD : <p>What's the best way of finding each partition size for a given RDD. I'm trying to debug a skewed Partition issue, I've tried this:</p>
<pre><code>l = builder.rdd.glom().map(len).collect() # get length of each partition
print('Min Parition Size: ',min(l),'. Max Parition Size: ', max(l),'. Avg Parition Size: ', sum(l)/len(l),'. Total Partitions: ', len(l))
</code></pre>
<p>It works fine for small RDDs, but for bigger RDDs, it is giving OOM error. My idea is that <code>glom()</code> is causing this to happen. But anyway, just wanted to know if there is any better way to do it?</p>
| 0debug
|
Select matching element/rename HTML tag in Visual Studio Code : <p>Let's say I've got the following code</p>
<p><code>
<div class="footer">
<div>Foo</div>
</div>
</code></p>
<p>How can I change <code>.footer</code> from a <code>div</code> element to a <code>footer</code> element?</p>
<p>That is, if I have the cursor in <code>div</code> I'm looking for a keyboard shortcut that selects the opening and closing tags of an element. I believe I've used emmet to do this before in Sublime, but I can't seem to find similar functionality in Code. (Ideally this would work in JSX files too...)</p>
| 0debug
|
How do I read an ArrayList with a FileReader in java? : The oracle documentation indicates that the FileReader Class takes basic arrays only, yet I have heard there is a way around this. How do I log the contents of any ArrayList? Thank you!
| 0debug
|
linq to sql how to select data from two tables with groupby and orderby : SELECT TOP (5) Sales.Product, Sales.Product_Price, COUNT(*) AS CNT, Products.Category, Products.IMG_URL, Products.Rate_Avg
FROM Sales INNER JOIN
Products ON Sales.Product = Products.Product
GROUP BY Sales.Product, Sales.Product_Price, Products.Category, Products.IMG_URL, Products.Rate_Avg
HAVING (COUNT(*) > 1)
ORDER BY CNT DESC
| 0debug
|
static void v9fs_write(void *opaque)
{
ssize_t err;
int32_t fid;
uint64_t off;
uint32_t count;
int32_t len = 0;
int32_t total = 0;
size_t offset = 7;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
QEMUIOVector qiov_full;
QEMUIOVector qiov;
offset += pdu_unmarshal(pdu, offset, "dqd", &fid, &off, &count);
v9fs_init_qiov_from_pdu(&qiov_full, pdu, offset, count, true);
trace_v9fs_write(pdu->tag, pdu->id, fid, off, count, qiov_full.niov);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (fidp->fid_type == P9_FID_FILE) {
if (fidp->fs.fd == -1) {
err = -EINVAL;
goto out;
}
} else if (fidp->fid_type == P9_FID_XATTR) {
err = v9fs_xattr_write(s, pdu, fidp, off, count,
qiov_full.iov, qiov_full.niov);
goto out;
} else {
err = -EINVAL;
goto out;
}
qemu_iovec_init(&qiov, qiov_full.niov);
do {
qemu_iovec_reset(&qiov);
qemu_iovec_copy(&qiov, &qiov_full, total, qiov_full.size - total);
if (0) {
print_sg(qiov.iov, qiov.niov);
}
do {
len = v9fs_co_pwritev(pdu, fidp, qiov.iov, qiov.niov, off);
if (len >= 0) {
off += len;
total += len;
}
} while (len == -EINTR && !pdu->cancelled);
if (len < 0) {
err = len;
goto out_qiov;
}
} while (total < count && len > 0);
offset = 7;
offset += pdu_marshal(pdu, offset, "d", total);
err = offset;
trace_v9fs_write_return(pdu->tag, pdu->id, total, err);
out_qiov:
qemu_iovec_destroy(&qiov);
out:
put_fid(pdu, fidp);
out_nofid:
qemu_iovec_destroy(&qiov_full);
complete_pdu(s, pdu, err);
}
| 1threat
|
Asynchronous api calls with redux-saga : <p>I am following <a href="http://yelouafi.github.io/redux-saga/docs/basics/UsingSagaHelpers.html" rel="noreferrer">redux-saga documentation</a> on helpers, and so far it seems pretty straight forward, however I stumbled upon an issue when it comes to performing an api call (as you will see link to the docs points to such example)</p>
<p>There is a part <code>Api.fetchUser</code> that is not explained, thus I don't quiet understand if that is something we need to handle with libraries like <a href="https://github.com/mzabriskie/axios" rel="noreferrer">axios</a> or <a href="https://github.com/visionmedia/superagent" rel="noreferrer">superagent</a>? or is that something else. And are saga effects like <code>call, put</code> etc.. equivalents of <code>get, post</code>? if so, why are they named that way? Essentially I am trying to figure out a correct way to perform a simple post call to my api at url <code>example.com/sessions</code> and pass it data like <code>{ email: 'email', password: 'password' }</code></p>
| 0debug
|
How do I change the number of decimal places on axis labels in ggplot2? : <p>Specifically, this is in a facet_grid. Have googled extensively for similar questions but not clear on the syntax or where it goes. What I want is for every number on the y-axes to have two digits after the decimal, even if the trailing one is 0. Is this a parameter in scale_y_continuous or element_text or...?</p>
<pre><code>row1 <- ggplot(sector_data[sector_data$sector %in% pages[[x]],], aes(date,price)) + geom_line() +
geom_hline(yintercept=0,size=0.3,color="gray50") +
facet_grid( ~ sector) +
scale_x_date( breaks='1 year', minor_breaks = '1 month') +
scale_y_continuous( labels = ???) +
theme(panel.grid.major.x = element_line(size=1.5),
axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.title.y=element_blank(),
axis.text.y=element_text(size=8),
axis.ticks=element_blank()
)
</code></pre>
| 0debug
|
Wordpress Header changing,Im very beginner of wordpress : Im Asp.net Core developer in my company, but our wordpress developer has some problems so they give me his job to me, and i dont have any wordpress experience, please help.
My problem is that our website design header is transperent when you are entering at site.
but when you scroll down header changes and becomes background white
I want to my header be always like second time when you scroll down, i want white background for header. Please help me guys.
You can also check http://modern-house.ge
| 0debug
|
static void ncq_cb(void *opaque, int ret)
{
NCQTransferState *ncq_tfs = (NCQTransferState *)opaque;
IDEState *ide_state = &ncq_tfs->drive->port.ifs[0];
if (ret == -ECANCELED) {
return;
}
ncq_tfs->drive->port_regs.scr_act &= ~(1 << ncq_tfs->tag);
if (ret < 0) {
ide_state->error = ABRT_ERR;
ide_state->status = READY_STAT | ERR_STAT;
ncq_tfs->drive->port_regs.scr_err |= (1 << ncq_tfs->tag);
} else {
ide_state->status = READY_STAT | SEEK_STAT;
}
ahci_write_fis_sdb(ncq_tfs->drive->hba, ncq_tfs->drive->port_no,
(1 << ncq_tfs->tag));
DPRINTF(ncq_tfs->drive->port_no, "NCQ transfer tag %d finished\n",
ncq_tfs->tag);
block_acct_done(bdrv_get_stats(ncq_tfs->drive->port.ifs[0].bs),
&ncq_tfs->acct);
qemu_sglist_destroy(&ncq_tfs->sglist);
ncq_tfs->used = 0;
}
| 1threat
|
static int decode_block_progressive(MJpegDecodeContext *s, int16_t *block,
uint8_t *last_nnz, int ac_index,
int16_t *quant_matrix,
int ss, int se, int Al, int *EOBRUN)
{
int code, i, j, level, val, run;
if (*EOBRUN) {
(*EOBRUN)--;
return 0;
}
{
OPEN_READER(re, &s->gb);
for (i = ss; ; i++) {
UPDATE_CACHE(re, &s->gb);
GET_VLC(code, re, &s->gb, s->vlcs[2][ac_index].table, 9, 2);
run = ((unsigned) code) >> 4;
code &= 0xF;
if (code) {
i += run;
if (code > MIN_CACHE_BITS - 16)
UPDATE_CACHE(re, &s->gb);
{
int cache = GET_CACHE(re, &s->gb);
int sign = (~cache) >> 31;
level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;
}
LAST_SKIP_BITS(re, &s->gb, code);
if (i >= se) {
if (i == se) {
j = s->scantable.permutated[se];
block[j] = level * quant_matrix[j] << Al;
break;
}
av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
return AVERROR_INVALIDDATA;
}
j = s->scantable.permutated[i];
block[j] = level * quant_matrix[j] << Al;
} else {
if (run == 0xF) {
i += 15;
if (i >= se) {
av_log(s->avctx, AV_LOG_ERROR, "ZRL overflow: %d\n", i);
return AVERROR_INVALIDDATA;
}
} else {
val = (1 << run);
if (run) {
UPDATE_CACHE(re, &s->gb);
val += NEG_USR32(GET_CACHE(re, &s->gb), run);
LAST_SKIP_BITS(re, &s->gb, run);
}
*EOBRUN = val - 1;
break;
}
}
}
CLOSE_READER(re, &s->gb);
}
if (i > *last_nnz)
*last_nnz = i;
return 0;
}
| 1threat
|
static inline void write_back_non_zero_count(H264Context *h){
MpegEncContext * const s = &h->s;
const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
int n;
for( n = 0; n < 16+4+4; n++ )
h->non_zero_count[mb_xy][n] = h->non_zero_count_cache[scan8[n]];
}
| 1threat
|
void qmp_block_job_cancel(const char *device,
bool has_force, bool force, Error **errp)
{
BlockJob *job = find_block_job(device);
if (!has_force) {
force = false;
}
if (!job) {
error_set(errp, QERR_BLOCK_JOB_NOT_ACTIVE, device);
return;
}
if (job->paused && !force) {
error_setg(errp, "The block job for device '%s' is currently paused",
device);
return;
}
trace_qmp_block_job_cancel(job);
block_job_cancel(job);
}
| 1threat
|
react native login with redux and react navigation : I am new in React Native and i am looking for an example how to do the following:
I have 3 screens : Splash, Login and MainScreen.
The flow is :
First screen is Splash. While splash screen is presented the app check if the user is logged in. If yes it forwards to MainScreen screen otherwise to the Login screen. After the user logged in it forwards to MainScreen.
I want to use redux and react navigation modules.
Can some one give me a full example in gitup?
Thanks
Elad
| 0debug
|
SchroFrame *ff_create_schro_frame(AVCodecContext *avctx,
SchroFrameFormat schro_frame_fmt)
{
AVFrame *p_pic;
SchroFrame *p_frame;
int y_width, uv_width;
int y_height, uv_height;
int i;
y_width = avctx->width;
y_height = avctx->height;
uv_width = y_width >> (SCHRO_FRAME_FORMAT_H_SHIFT(schro_frame_fmt));
uv_height = y_height >> (SCHRO_FRAME_FORMAT_V_SHIFT(schro_frame_fmt));
p_pic = av_frame_alloc();
if (!p_pic)
return NULL;
if (ff_get_buffer(avctx, p_pic, AV_GET_BUFFER_FLAG_REF) < 0) {
av_frame_free(&p_pic);
return NULL;
}
p_frame = schro_frame_new();
p_frame->format = schro_frame_fmt;
p_frame->width = y_width;
p_frame->height = y_height;
schro_frame_set_free_callback(p_frame, free_schro_frame, p_pic);
for (i = 0; i < 3; ++i) {
p_frame->components[i].width = i ? uv_width : y_width;
p_frame->components[i].stride = p_pic->linesize[i];
p_frame->components[i].height = i ? uv_height : y_height;
p_frame->components[i].length =
p_frame->components[i].stride * p_frame->components[i].height;
p_frame->components[i].data = p_pic->data[i];
if (i) {
p_frame->components[i].v_shift =
SCHRO_FRAME_FORMAT_V_SHIFT(p_frame->format);
p_frame->components[i].h_shift =
SCHRO_FRAME_FORMAT_H_SHIFT(p_frame->format);
}
}
return p_frame;
}
| 1threat
|
Get Max value comparing multiple columns and return specific values : <p>I have a Dataframe like:</p>
<pre><code>Sequence Duration1 Value1 Duration2 Value2 Duration3 Value3
1001 145 10 125 53 458 33
1002 475 20 175 54 652 45
1003 685 57 687 87 254 88
1004 125 54 175 96 786 96
1005 475 21 467 32 526 32
1006 325 68 301 54 529 41
1007 125 97 325 85 872 78
1008 129 15 429 41 981 82
1009 547 47 577 52 543 83
1010 666 65 722 63 257 87
</code></pre>
<p>I want to find the maximum value of Duration in (Duration1,Duration2,Duration3) and return the corresponding Value & Sequence.</p>
<p>My Desired Output:</p>
<pre><code>Sequence,Duration3,Value3
1008, 981, 82
</code></pre>
| 0debug
|
What typescript type do I use with useRef() hook when setting current manually? : <p>How can I use a React ref as a mutable instance, with Typescript? The current property appears to be typed as read-only.</p>
<p>I am using React + Typescript to develop a library that interacts with input fields that are NOT rendered by React. I want to capture a reference to the HTML element and then bind React events to it. </p>
<pre><code> const inputRef = useRef<HTMLInputElement>();
const { elementId, handler } = props;
// Bind change handler on mount/ unmount
useEffect(() => {
inputRef.current = document.getElementById(elementId);
if (inputRef.current === null) {
throw new Exception(`Input with ID attribute ${elementId} not found`);
}
handler(inputRef.current.value);
const callback = debounce((e) => {
eventHandler(e, handler);
}, 200);
inputRef.current.addEventListener('keypress', callback, true);
return () => {
inputRef.current.removeEventListener('keypress', callback, true);
};
});
</code></pre>
<p>It generates compiler errors: <code>semantic error TS2540: Cannot assign to 'current' because it is a read-only property.</code></p>
<p>I also tried <code>const inputRef = useRef<{ current: HTMLInputElement }>();</code> This lead to this compiler error:</p>
<pre><code>Type 'HTMLElement | null' is not assignable to type '{ current: HTMLInputElement; } | undefined'.
Type 'null' is not assignable to type '{ current: HTMLInputElement; } | undefined'.
</code></pre>
| 0debug
|
How to load another groovy script in the same Jenkins node? : <p>When loading a pipeline script from another pipeline script, the two pipelines don't get executed on the same node : the first one is executed on my master node and the second gets executed on a slave node.</p>
<p>I'm using Jenkins pipelines with <code>Pipeline Script from SCM</code> option for a lot of jobs in this way :</p>
<ul>
<li><p>Each of my jobs defines their corresponding Git repo URL with <code>Poll SCM</code> option so that the repository gets automatically polled when a change is made to my code (basic job usage).</p></li>
<li><p>Each of my jobs define a simple <code>Jenkinsfile</code> at the root of their repository, and the pipeline script inside does basically nothing but loading a more generic pipeline.</p></li>
</ul>
<p><em>E.g.</em> :</p>
<pre><code>node {
// --- Load the generic pipeline ---
checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'http://github/owner/pipeline-repo.git']]]
load 'common-pipeline.groovy'
}()
</code></pre>
<p>My <em>common-pipeline.groovy</em> pipeline does the actual stuff such as building, releasing or deploying artifacts, e.g. :</p>
<pre><code>{ ->
node() {
def functions = load 'common/functions.groovy'
functions.build()
functions.release()
functions.deploy()
}
}
</code></pre>
<p>Now I <strong>don't want to force the node for each job</strong> so both pipelines have <code>node("master")</code> or <code>node("remote")</code> because I really don't want to be handling that manually, however I'd like that once the first pipeline runs on a specific node (either <em>master</em>, <em>slave1</em>, <em>slave2</em>, <em>slave3</em>) the second/loaded pipeline gets executed on the same node, because otherwise my actual Git repository code is not available from other node's workspace...</p>
<p>Is there any way I can specify that I want my second pipeline to be executed on the same node as the first, or maybe pass an argument when using the <code>load</code> step ?</p>
| 0debug
|
Invalid WPF name? : <p>Can someone please explain to me why this name is invalid?</p>
<p>'stackPanelOneZeroZeroPercentBasicBuybackStartNormalBracketMotorplusEndNormalBracket StartNormalBracketOneEightZeroOneEndNormalBracketStartNormalBracketUnderwrittenEndNormalBracket' is not a valid value for property 'Name'.</p>
| 0debug
|
static void spr_read_decr (DisasContext *ctx, int gprn, int sprn)
{
if (use_icount) {
gen_io_start();
}
gen_helper_load_decr(cpu_gpr[gprn], cpu_env);
if (use_icount) {
gen_io_end();
gen_stop_exception(ctx);
}
}
| 1threat
|
static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
QDict *options, Error **errp)
{
QemuOpts *opts;
SocketAddress *gsconf = NULL;
SocketAddressList *curr = NULL;
QDict *backing_options = NULL;
Error *local_err = NULL;
char *str = NULL;
const char *ptr;
size_t num_servers;
int i, type;
opts = qemu_opts_create(&runtime_json_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
goto out;
}
num_servers = qdict_array_entries(options, GLUSTER_OPT_SERVER_PATTERN);
if (num_servers < 1) {
error_setg(&local_err, QERR_MISSING_PARAMETER, "server");
goto out;
}
ptr = qemu_opt_get(opts, GLUSTER_OPT_VOLUME);
if (!ptr) {
error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_VOLUME);
goto out;
}
gconf->volume = g_strdup(ptr);
ptr = qemu_opt_get(opts, GLUSTER_OPT_PATH);
if (!ptr) {
error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_PATH);
goto out;
}
gconf->path = g_strdup(ptr);
qemu_opts_del(opts);
for (i = 0; i < num_servers; i++) {
str = g_strdup_printf(GLUSTER_OPT_SERVER_PATTERN"%d.", i);
qdict_extract_subqdict(options, &backing_options, str);
opts = qemu_opts_create(&runtime_type_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, backing_options, &local_err);
if (local_err) {
goto out;
}
ptr = qemu_opt_get(opts, GLUSTER_OPT_TYPE);
if (!ptr) {
error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_TYPE);
error_append_hint(&local_err, GERR_INDEX_HINT, i);
goto out;
}
gsconf = g_new0(SocketAddress, 1);
if (!strcmp(ptr, "tcp")) {
ptr = "inet";
}
type = qapi_enum_parse(SocketAddressType_lookup, ptr,
SOCKET_ADDRESS_TYPE__MAX, -1, NULL);
if (type != SOCKET_ADDRESS_TYPE_INET
&& type != SOCKET_ADDRESS_TYPE_UNIX) {
error_setg(&local_err,
"Parameter '%s' may be 'inet' or 'unix'",
GLUSTER_OPT_TYPE);
error_append_hint(&local_err, GERR_INDEX_HINT, i);
goto out;
}
gsconf->type = type;
qemu_opts_del(opts);
if (gsconf->type == SOCKET_ADDRESS_TYPE_INET) {
opts = qemu_opts_create(&runtime_inet_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, backing_options, &local_err);
if (local_err) {
goto out;
}
ptr = qemu_opt_get(opts, GLUSTER_OPT_HOST);
if (!ptr) {
error_setg(&local_err, QERR_MISSING_PARAMETER,
GLUSTER_OPT_HOST);
error_append_hint(&local_err, GERR_INDEX_HINT, i);
goto out;
}
gsconf->u.inet.host = g_strdup(ptr);
ptr = qemu_opt_get(opts, GLUSTER_OPT_PORT);
if (!ptr) {
error_setg(&local_err, QERR_MISSING_PARAMETER,
GLUSTER_OPT_PORT);
error_append_hint(&local_err, GERR_INDEX_HINT, i);
goto out;
}
gsconf->u.inet.port = g_strdup(ptr);
ptr = qemu_opt_get(opts, GLUSTER_OPT_TO);
if (ptr) {
gsconf->u.inet.has_to = true;
}
ptr = qemu_opt_get(opts, GLUSTER_OPT_IPV4);
if (ptr) {
gsconf->u.inet.has_ipv4 = true;
}
ptr = qemu_opt_get(opts, GLUSTER_OPT_IPV6);
if (ptr) {
gsconf->u.inet.has_ipv6 = true;
}
if (gsconf->u.inet.has_to) {
error_setg(&local_err, "Parameter 'to' not supported");
goto out;
}
if (gsconf->u.inet.has_ipv4 || gsconf->u.inet.has_ipv6) {
error_setg(&local_err, "Parameters 'ipv4/ipv6' not supported");
goto out;
}
qemu_opts_del(opts);
} else {
opts = qemu_opts_create(&runtime_unix_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, backing_options, &local_err);
if (local_err) {
goto out;
}
ptr = qemu_opt_get(opts, GLUSTER_OPT_SOCKET);
if (!ptr) {
error_setg(&local_err, QERR_MISSING_PARAMETER,
GLUSTER_OPT_SOCKET);
error_append_hint(&local_err, GERR_INDEX_HINT, i);
goto out;
}
gsconf->u.q_unix.path = g_strdup(ptr);
qemu_opts_del(opts);
}
if (gconf->server == NULL) {
gconf->server = g_new0(SocketAddressList, 1);
gconf->server->value = gsconf;
curr = gconf->server;
} else {
curr->next = g_new0(SocketAddressList, 1);
curr->next->value = gsconf;
curr = curr->next;
}
gsconf = NULL;
QDECREF(backing_options);
backing_options = NULL;
g_free(str);
str = NULL;
}
return 0;
out:
error_propagate(errp, local_err);
qapi_free_SocketAddress(gsconf);
qemu_opts_del(opts);
g_free(str);
QDECREF(backing_options);
errno = EINVAL;
return -errno;
}
| 1threat
|
what does this instructions mean? : Iam learn assemble and have some problems with understanding with instructions, what means "sub $0x10,%rsp" and why gcc copied this "mov $0x0,%eax" two times
0x0000000000001135 <+0>: push %rbp
0x0000000000001136 <+1>: mov %rsp,%rbp
0x0000000000001139 <+4>: sub $0x10,%rsp
0x000000000000113d <+8>: movl $0xa,-0x4(%rbp)
0x0000000000001144 <+15>: mov -0x4(%rbp),%eax
0x0000000000001147 <+18>: mov %eax,%esi
0x0000000000001149 <+20>: lea 0xeb4(%rip),%rdi # 0x2004
0x0000000000001150 <+27>: mov $0x0,%eax
0x0000000000001155 <+32>: callq 0x1030 <printf@plt>
0x000000000000115a <+37>: mov $0x0,%eax
0x000000000000115f <+42>: leaveq
0x0000000000001160 <+43>: retq
| 0debug
|
SUBSET AND FILTER NOT GIVING PROPER ANSWER : I HAVE FOLLOWING DATASET AND USED SUBSET AND FILTER TO SEGMENT THE DATA:
KL
ID C1
A 597.69
B 239.64
C 601.3
D 4052.6
E 73.73
F 74.06
G 124
H 0
I 0
J 0
K 0
L 122.45
M 152.88
N 123.32
O 354.12
WHEN I APPLIED SUBSET CONDITIONS
cl4 = subset(KL, C1 > "300.00")
OUTPUT IS:
ID C1
A 597.69
C 601.30
D 4052.60
E 73.73
F 74.06
O 354.12
WHY IS IT STILL SHOWING NUMBER LESS THAN 300?
I HAVE TRIED FILTER ALSO BUT THE OUTPUT IS SAME
KINDLY PROVIDE REASON AND SOLUTION.
THANKS IN ADVANCE FOR PROVIDING ANSWERS
| 0debug
|
static void check_loopfilter(void)
{
LOCAL_ALIGNED_32(uint8_t, base0, [32 + 16 * 16 * 2]);
LOCAL_ALIGNED_32(uint8_t, base1, [32 + 16 * 16 * 2]);
VP9DSPContext dsp;
int dir, wd, wd2, bit_depth;
static const char *const dir_name[2] = { "h", "v" };
static const int E[2] = { 20, 28 }, I[2] = { 10, 16 };
static const int H[2] = { 7, 11 }, F[2] = { 1, 1 };
declare_func(void, uint8_t *dst, ptrdiff_t stride, int E, int I, int H);
for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) {
ff_vp9dsp_init(&dsp, bit_depth, 0);
for (dir = 0; dir < 2; dir++) {
int midoff = (dir ? 8 * 8 : 8) * SIZEOF_PIXEL;
int midoff_aligned = (dir ? 8 * 8 : 16) * SIZEOF_PIXEL;
uint8_t *buf0 = base0 + midoff_aligned;
uint8_t *buf1 = base1 + midoff_aligned;
for (wd = 0; wd < 3; wd++) {
if (check_func(dsp.loop_filter_8[wd][dir],
"vp9_loop_filter_%s_%d_8_%dbpp",
dir_name[dir], 4 << wd, bit_depth)) {
randomize_buffers(0, 0, 8);
memcpy(buf1 - midoff, buf0 - midoff,
16 * 8 * SIZEOF_PIXEL);
call_ref(buf0, 16 * SIZEOF_PIXEL >> dir, E[0], I[0], H[0]);
call_new(buf1, 16 * SIZEOF_PIXEL >> dir, E[0], I[0], H[0]);
if (memcmp(buf0 - midoff, buf1 - midoff, 16 * 8 * SIZEOF_PIXEL))
fail();
bench_new(buf1, 16 * SIZEOF_PIXEL >> dir, E[0], I[0], H[0]);
}
}
midoff = (dir ? 16 * 8 : 8) * SIZEOF_PIXEL;
midoff_aligned = (dir ? 16 * 8 : 16) * SIZEOF_PIXEL;
buf0 = base0 + midoff_aligned;
buf1 = base1 + midoff_aligned;
if (check_func(dsp.loop_filter_16[dir],
"vp9_loop_filter_%s_16_16_%dbpp",
dir_name[dir], bit_depth)) {
randomize_buffers(0, 0, 16);
randomize_buffers(0, 8, 16);
memcpy(buf1 - midoff, buf0 - midoff, 16 * 16 * SIZEOF_PIXEL);
call_ref(buf0, 16 * SIZEOF_PIXEL, E[0], I[0], H[0]);
call_new(buf1, 16 * SIZEOF_PIXEL, E[0], I[0], H[0]);
if (memcmp(buf0 - midoff, buf1 - midoff, 16 * 16 * SIZEOF_PIXEL))
fail();
bench_new(buf1, 16 * SIZEOF_PIXEL, E[0], I[0], H[0]);
}
for (wd = 0; wd < 2; wd++) {
for (wd2 = 0; wd2 < 2; wd2++) {
if (check_func(dsp.loop_filter_mix2[wd][wd2][dir],
"vp9_loop_filter_mix2_%s_%d%d_16_%dbpp",
dir_name[dir], 4 << wd, 4 << wd2, bit_depth)) {
randomize_buffers(0, 0, 16);
randomize_buffers(1, 8, 16);
memcpy(buf1 - midoff, buf0 - midoff, 16 * 16 * SIZEOF_PIXEL);
#define M(a) (((a)[1] << 8) | (a)[0])
call_ref(buf0, 16 * SIZEOF_PIXEL, M(E), M(I), M(H));
call_new(buf1, 16 * SIZEOF_PIXEL, M(E), M(I), M(H));
if (memcmp(buf0 - midoff, buf1 - midoff, 16 * 16 * SIZEOF_PIXEL))
fail();
bench_new(buf1, 16 * SIZEOF_PIXEL, M(E), M(I), M(H));
#undef M
}
}
}
}
}
report("loopfilter");
}
| 1threat
|
How to fix this very simple but sloppy if statement? : So I've been looking on how to make a simple coin flip script using javascript and I see these videos of people that seem to over-complicate things using 20 different elements or whatever you call them. So what I set out to do is create a "magic 8 ball" kind of script but using only things that a super noob such as myself would know, instead of trying to memorize so many different things. So I have it working so that I have a text box, then next to it is a button when pressed it will execute a function. The problem I'm having is instead of returning a number when using Math.floor(Math.random() * 4) I want to return the words like "yes" "no" "maybe" ect. What I'm wondering, is what the () do in Math.random. Anyway, instead of trying to explain what I did here is my javascript using the most simple statements I could. The first statement works if nothing is typed in it says "please enter a question" but the rest doesn't.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
function checkFunction() {
if (question.value == '') {
document.getElementById("fortune").innerHTML = "Please Enter A Question";
} else {
Math.floor(Math.random(data) * 4);
if (data == 0) {
document.getElementById("fortune").innerHTML = "Maybe";
} else if (data == 1) {
document.getElementById("fortune").innerHTML = "Try Again";
} else if (data == 2) {
document.getElementById("fortune").innerHTML = "Yes";
} else if (data == 3) {
document.getElementById("fortune").innerHTML = "No";
} else {
return "Invalid";
}
}
}
<!-- end snippet -->
I don't care if its long, I just want it to be simple. I don't want to have to define a bunch of variables and mess around with calling them up because I'm just trying to take it a step at a time. I'm basically trying to figure out the maximum potential of an if statement before moving on and learning new things.
| 0debug
|
Is `string.assign(string.data(), 5)` well-defined or UB? : <p>A coworker wanted to write this:</p>
<pre><code>std::string_view strip_whitespace(std::string_view sv);
std::string line = "hello ";
line = strip_whitespace(line);
</code></pre>
<p>I said that returning <code>string_view</code> made me uneasy <em>a priori</em>, and furthermore, the aliasing here looked like UB to me.</p>
<p>I can say with certainty that <code>line = strip_whitespace(line)</code> in this case is equivalent to <code>line = std::string_view(line.data(), 5)</code>. I believe that will call <a href="http://eel.is/c++draft/basic.string#string.cons-itemdecl:16" rel="noreferrer"><code>string::operator=(const T&) [with T=string_view]</code></a>, which is defined to be equivalent to <a href="http://eel.is/c++draft/basic.string#string.assign-itemdecl:4" rel="noreferrer"><code>line.assign(const T&) [with T=string_view]</code></a>, which is defined to be equivalent to <a href="http://eel.is/c++draft/basic.string#string.assign-itemdecl:6" rel="noreferrer"><code>line.assign(line.data(), 5)</code></a>, which is defined to do this:</p>
<pre><code>Preconditions: [s, s + n) is a valid range.
Effects: Replaces the string controlled by *this with a copy of the range [s, s + n).
Returns: *this.
</code></pre>
<p>But this doesn't say what happens when there's aliasing.</p>
<p>I asked this question on the cpplang Slack yesterday and got mixed answers. Looking for super authoritative answers here, and/or empirical analysis of real library vendors' implementations.</p>
<hr>
<p><a href="https://godbolt.org/z/y_R8-9" rel="noreferrer">I wrote test cases</a> for <code>string::assign</code>, <code>vector::assign</code>, <code>deque::assign</code>, <code>list::assign</code>, and <code>forward_list::assign</code>.</p>
<ul>
<li>Libc++ makes all of these test cases work.</li>
<li>Libstdc++ makes them all work except for <code>forward_list</code>, which segfaults.</li>
<li>I don't know about MSVC's library.</li>
</ul>
<p>The segfault in libstdc++ gives me hope that this is UB; but I also see both libc++ and libstdc++ going to great effort to make this work at least in the common cases.</p>
| 0debug
|
static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv)
{
static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
int64_t end = avio_tell(pb) + klv->length;
uint64_t size;
uint64_t orig_size;
uint64_t plaintext_size;
uint8_t ivec[16];
uint8_t tmpbuf[16];
int index;
if (!mxf->aesc && s->key && s->keylen == 16) {
mxf->aesc = av_malloc(av_aes_size);
if (!mxf->aesc)
return -1;
av_aes_init(mxf->aesc, s->key, 128, 1);
}
avio_skip(pb, klv_decode_ber_length(pb));
klv_decode_ber_length(pb);
plaintext_size = avio_rb64(pb);
klv_decode_ber_length(pb);
avio_read(pb, klv->key, 16);
if (!IS_KLV_KEY(klv, mxf_essence_element_key))
return -1;
index = mxf_get_stream_index(s, klv);
if (index < 0)
return -1;
klv_decode_ber_length(pb);
orig_size = avio_rb64(pb);
if (orig_size < plaintext_size)
return -1;
size = klv_decode_ber_length(pb);
if (size < 32 || size - 32 < orig_size)
return -1;
avio_read(pb, ivec, 16);
avio_read(pb, tmpbuf, 16);
if (mxf->aesc)
av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1);
if (memcmp(tmpbuf, checkv, 16))
av_log(s, AV_LOG_ERROR, "probably incorrect decryption key\n");
size -= 32;
av_get_packet(pb, pkt, size);
size -= plaintext_size;
if (mxf->aesc)
av_aes_crypt(mxf->aesc, &pkt->data[plaintext_size],
&pkt->data[plaintext_size], size >> 4, ivec, 1);
pkt->size = orig_size;
pkt->stream_index = index;
avio_skip(pb, end - avio_tell(pb));
return 0;
}
| 1threat
|
how to get output from a loop which is inside a function in php? : guys i'm scraching my head for hours over this problem. As, i'm basically trying to fetch values from a loop inside a function to pass it to another foreach loop to get the desired results.And it is not working as i intend to. pl,point me in the right direction.
here is the code:
function ff($s) {
$project="";
foreach ($s as $i=> $r ){
$r["friend_one"] == $_SESSION['uname'] ? $friends[]= $r["friend_two"] : $friends[] = $r["friend_one"];
$friend=$friends[$i];
$totalids=$project->totalids($_SESSION['uname'],$friend);
}
return $totalids;
}
$totalid= ff($f);
print_r($totalid);
foreach ($totalid as $v){
$id=$v['user_id'];
//other logic to get desired results
}
| 0debug
|
Unexpected use of 'self' no-restricted-globals React : <p>Trying to write a Service Worker for my PWA app, caugth this error. I used Google/Mozilla samples for service workers, but, anyway. </p>
<pre><code>var CACHE_NAME = 'test-cache';
var urlsToCache = [
'/'
];
self.addEventListener('install', function (event) {
event.waitUntil(
caches.open(CACHE_NAME)
.then(function (cache) {
console.log('Opened cache');
return cache.addAll(urlsToCache);
})
);
});
</code></pre>
| 0debug
|
static void intel_hda_realize(PCIDevice *pci, Error **errp)
{
IntelHDAState *d = INTEL_HDA(pci);
uint8_t *conf = d->pci.config;
d->name = object_get_typename(OBJECT(d));
pci_config_set_interrupt_pin(conf, 1);
conf[0x40] = 0x01;
memory_region_init_io(&d->mmio, OBJECT(d), &intel_hda_mmio_ops, d,
"intel-hda", 0x4000);
pci_register_bar(&d->pci, 0, 0, &d->mmio);
if (d->msi != ON_OFF_AUTO_OFF) {
msi_init(&d->pci, d->old_msi_addr ? 0x50 : 0x60, 1, true, false);
}
hda_codec_bus_init(DEVICE(pci), &d->codecs, sizeof(d->codecs),
intel_hda_response, intel_hda_xfer);
}
| 1threat
|
static void decorrelation(PSContext *ps, INTFLOAT (*out)[32][2], const INTFLOAT (*s)[32][2], int is34)
{
LOCAL_ALIGNED_16(INTFLOAT, power, [34], [PS_QMF_TIME_SLOTS]);
LOCAL_ALIGNED_16(INTFLOAT, transient_gain, [34], [PS_QMF_TIME_SLOTS]);
INTFLOAT *peak_decay_nrg = ps->peak_decay_nrg;
INTFLOAT *power_smooth = ps->power_smooth;
INTFLOAT *peak_decay_diff_smooth = ps->peak_decay_diff_smooth;
INTFLOAT (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay;
INTFLOAT (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay;
#if !USE_FIXED
const float transient_impact = 1.5f;
const float a_smooth = 0.25f;
#endif
const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
int i, k, m, n;
int n0 = 0, nL = 32;
const INTFLOAT peak_decay_factor = Q31(0.76592833836465f);
memset(power, 0, 34 * sizeof(*power));
if (is34 != ps->is34bands_old) {
memset(ps->peak_decay_nrg, 0, sizeof(ps->peak_decay_nrg));
memset(ps->power_smooth, 0, sizeof(ps->power_smooth));
memset(ps->peak_decay_diff_smooth, 0, sizeof(ps->peak_decay_diff_smooth));
memset(ps->delay, 0, sizeof(ps->delay));
memset(ps->ap_delay, 0, sizeof(ps->ap_delay));
}
for (k = 0; k < NR_BANDS[is34]; k++) {
int i = k_to_i[k];
ps->dsp.add_squares(power[i], s[k], nL - n0);
}
#if USE_FIXED
for (i = 0; i < NR_PAR_BANDS[is34]; i++) {
for (n = n0; n < nL; n++) {
int decayed_peak;
int denom;
decayed_peak = (int)(((int64_t)peak_decay_factor * \
peak_decay_nrg[i] + 0x40000000) >> 31);
peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]);
power_smooth[i] += (power[i][n] - power_smooth[i] + 2) >> 2;
peak_decay_diff_smooth[i] += (peak_decay_nrg[i] - power[i][n] - \
peak_decay_diff_smooth[i] + 2) >> 2;
denom = peak_decay_diff_smooth[i] + (peak_decay_diff_smooth[i] >> 1);
if (denom > power_smooth[i]) {
int p = power_smooth[i];
while (denom < 0x40000000) {
denom <<= 1;
p <<= 1;
}
transient_gain[i][n] = p / (denom >> 16);
}
else {
transient_gain[i][n] = 1 << 16;
}
}
}
#else
for (i = 0; i < NR_PAR_BANDS[is34]; i++) {
for (n = n0; n < nL; n++) {
float decayed_peak = peak_decay_factor * peak_decay_nrg[i];
float denom;
peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]);
power_smooth[i] += a_smooth * (power[i][n] - power_smooth[i]);
peak_decay_diff_smooth[i] += a_smooth * (peak_decay_nrg[i] - power[i][n] - peak_decay_diff_smooth[i]);
denom = transient_impact * peak_decay_diff_smooth[i];
transient_gain[i][n] = (denom > power_smooth[i]) ?
power_smooth[i] / denom : 1.0f;
}
}
#endif
for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) {
int b = k_to_i[k];
#if USE_FIXED
int g_decay_slope;
if (k - DECAY_CUTOFF[is34] <= 0) {
g_decay_slope = 1 << 30;
}
else if (k - DECAY_CUTOFF[is34] >= 20) {
g_decay_slope = 0;
}
else {
g_decay_slope = (1 << 30) - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]);
}
#else
float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]);
g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f);
#endif
memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
for (m = 0; m < PS_AP_LINKS; m++) {
memcpy(ap_delay[k][m], ap_delay[k][m]+numQMFSlots, 5*sizeof(ap_delay[k][m][0]));
}
ps->dsp.decorrelate(out[k], delay[k] + PS_MAX_DELAY - 2, ap_delay[k],
phi_fract[is34][k],
(const INTFLOAT (*)[2]) Q_fract_allpass[is34][k],
transient_gain[b], g_decay_slope, nL - n0);
}
for (; k < SHORT_DELAY_BAND[is34]; k++) {
int i = k_to_i[k];
memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
ps->dsp.mul_pair_single(out[k], delay[k] + PS_MAX_DELAY - 14,
transient_gain[i], nL - n0);
}
for (; k < NR_BANDS[is34]; k++) {
int i = k_to_i[k];
memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
ps->dsp.mul_pair_single(out[k], delay[k] + PS_MAX_DELAY - 1,
transient_gain[i], nL - n0);
}
}
| 1threat
|
MYSQL Check if username already exists in database : <p>My code was working but after I inserted a query to check if the first name in MYSQL database already exists, it does not work anymore. Here you can see my code, if you have any tip on how to make this work, I will appreciate it. Thank you very much!</p>
<p>I have tried to work with mysql_num_rows command, but it seems like I didn't use it correctly. </p>
<pre><code><?php
require_once __DIR__.'/connect.php';
$sName = $_POST['txtName'];
$query = mysql_query("SELECT * FROM users WHERE firstName = '$sName' ");
if (mysql_num_rows ($query) > 0){
echo 'User with this name already exists';
}else{
try {
$stmt = $db->prepare('INSERT INTO users
VALUES (null, :sName, :sLastName, :sEmail, :sCountry )');
$stmt->bindValue(':sName', $sName);
$stmt->execute();
echo 'New user was successfully inserted';
} catch (PDOEXception $ex) {
echo $ex;
}
}
</code></pre>
| 0debug
|
301 redirect http://www.domain.com/cgi-sys/suspendedpage.cgi to the homepage--> http://www.domain.com/ : i tried this but did not work
Redirect 301 /cgi-sys/suspendedpage.cgi/ http://www.domain.com/
is there a way to redirect it?
| 0debug
|
How Display 3 Posts in one Loop ??? Laravel : <pre><code> <?php $i=1; ?>
<?php $dayes = DB::table('days')->where('Doc',$item->id)->get(); ?>
@foreach($dayes as $DAY)
<?php $timess = DB::table('times')->where('days_id',$DAY->id)->get(); ?>
@foreach($timess as $timer)
<div class="table-times"> </div>
<?php $i++; ?>
</div>
@endforeach
@endforeach
</code></pre>
<p>i need to display class table-times 3 in one loop </p>
| 0debug
|
Will JS be aligned with the ECMAScript specs regarding the "typeof null"? : <p>In the <a href="https://www.ecma-international.org/ecma-262/9.0/index.html#sec-terms-and-definitions-null-type" rel="nofollow noreferrer">ECMAScript specs</a>, it is clearly stated that <code>Null</code> is a type whose one and only value is <code>null</code>:</p>
<pre><code>4.3.12 null value
primitive value that represents the intentional absence of any object value
4.3.13 Null type
type whose sole value is the null value
</code></pre>
<p>My question is very simple: why on earth we've got the below:</p>
<pre><code>typeof null
>"object"
</code></pre>
<p>Is there any intent to correct/amend this? (either the specs or the JS language)</p>
| 0debug
|
What is updateValueAndValidity : <p><a href="https://angular.io/docs/ts/latest/api/forms/index/FormControl-class.html" rel="noreferrer">These docs</a> state the following:</p>
<blockquote>
<p>If emitEvent is true, this change will cause a valueChanges event on
the FormControl to be emitted. This defaults to true (as it falls
through to updateValueAndValidity).</p>
</blockquote>
<p>What is this <code>updateValueAndValidity</code>?</p>
| 0debug
|
Inject namespace experimental to std : <p>Is it bad or good parctice to inject namespace <code>std::experimental</code> into <code>std</code> like following?</p>
<pre><code>namespace std
{
namespace experimental
{
}
using namespace experimental;
}
#include <experimental/optional>
int main()
{
std::optional< int > o;
return 0;
}
</code></pre>
<p>Or even in more modern form:</p>
<pre><code>#if __has_include(<optional>)
# include <optional>
#elif __has_include(<experimental/optional>)
# include <experimental/optional>
namespace std
{
using namespace experimental;
}
#else
#error !
#endif
int main()
{
std::optional< int > o;
return 0;
}
</code></pre>
<p>The intention to introduce <code>std::experimental</code> "sub-namespace" is clear because <code>std::experimental</code> currently contains <a href="http://en.cppreference.com/w/cpp/experimental">a plenty of <strong>new</strong> libraries</a>. I think it is very likely all them will migrate into <code>namespace std</code> without any substantial changes and user code written currently can rely upon this (am I totally wrong?). Otherwise all this code should be refactored to change from <code>std::experimental::</code> to <code>std::</code> in the future. It is not big deal, but there may be reasons not to do so.</p>
<p>The question is about both production code and not-too-serious code.</p>
| 0debug
|
bootstrap-table hide column in mobile view : <p>I have a checkbox column which should only be visible on desktop and not on Mobile or Tabs.</p>
<p>There are no options available in the documentation to hide/show any columns based on the devise.</p>
<p>Can we do this?</p>
| 0debug
|
static ssize_t v9fs_synth_readlink(FsContext *fs_ctx, V9fsPath *path,
char *buf, size_t bufsz)
{
errno = ENOSYS;
return -1;
}
| 1threat
|
How can i get the values of id2 using vba excel? : <?xml version="1.0" encoding="utf-16"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<id xmlns="id.services/">
<ids1>
<response xmlns="">`enter code here`
<ids xmlns="ids">
<Id-info id0="123" id1="0" id2="2345" xmlns=""></Id-info>
<Id-info id0="456" id1="1" id2="6789" xmlns=""></Id-info>
</ids>
</response>
</ids1>
</id>
</s:Body>
</s:Envelope>
I tried:--
Dim xmlDoc As DOMDocument30
Set xmlDoc = New DOMDocument30
xmlDoc.Load ("C:test.xml")
Dim id As String
id = xmlDoc.SelectSingleNode("//ids/Id-info").Attributes.getNamedItem("id2").Text
| 0debug
|
static inline void gen_bcond(DisasContext *ctx, int type)
{
uint32_t bo = BO(ctx->opcode);
int l1;
TCGv target;
ctx->exception = POWERPC_EXCP_BRANCH;
if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
target = tcg_temp_local_new();
if (type == BCOND_CTR)
tcg_gen_mov_tl(target, cpu_ctr);
else if (type == BCOND_TAR)
gen_load_spr(target, SPR_TAR);
else
tcg_gen_mov_tl(target, cpu_lr);
} else {
TCGV_UNUSED(target);
}
if (LK(ctx->opcode))
gen_setlr(ctx, ctx->nip);
l1 = gen_new_label();
if ((bo & 0x4) == 0) {
TCGv temp = tcg_temp_new();
if (unlikely(type == BCOND_CTR)) {
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
return;
}
tcg_gen_subi_tl(cpu_ctr, cpu_ctr, 1);
if (NARROW_MODE(ctx)) {
tcg_gen_ext32u_tl(temp, cpu_ctr);
} else {
tcg_gen_mov_tl(temp, cpu_ctr);
}
if (bo & 0x2) {
tcg_gen_brcondi_tl(TCG_COND_NE, temp, 0, l1);
} else {
tcg_gen_brcondi_tl(TCG_COND_EQ, temp, 0, l1);
}
tcg_temp_free(temp);
}
if ((bo & 0x10) == 0) {
uint32_t bi = BI(ctx->opcode);
uint32_t mask = 0x08 >> (bi & 0x03);
TCGv_i32 temp = tcg_temp_new_i32();
if (bo & 0x8) {
tcg_gen_andi_i32(temp, cpu_crf[bi >> 2], mask);
tcg_gen_brcondi_i32(TCG_COND_EQ, temp, 0, l1);
} else {
tcg_gen_andi_i32(temp, cpu_crf[bi >> 2], mask);
tcg_gen_brcondi_i32(TCG_COND_NE, temp, 0, l1);
}
tcg_temp_free_i32(temp);
}
gen_update_cfar(ctx, ctx->nip);
if (type == BCOND_IM) {
target_ulong li = (target_long)((int16_t)(BD(ctx->opcode)));
if (likely(AA(ctx->opcode) == 0)) {
gen_goto_tb(ctx, 0, ctx->nip + li - 4);
} else {
gen_goto_tb(ctx, 0, li);
}
gen_set_label(l1);
gen_goto_tb(ctx, 1, ctx->nip);
} else {
if (NARROW_MODE(ctx)) {
tcg_gen_andi_tl(cpu_nip, target, (uint32_t)~3);
} else {
tcg_gen_andi_tl(cpu_nip, target, ~3);
}
tcg_gen_exit_tb(0);
gen_set_label(l1);
gen_update_nip(ctx, ctx->nip);
tcg_gen_exit_tb(0);
}
if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
tcg_temp_free(target);
}
}
| 1threat
|
Determine how many times a substring occurs adjacently in a string in Python : <p>I want to calculate how many times a substring occurs "adjacently" in a string,
for example, given the string "8448442844" and the substring "844", I want the result "2".
I know the string.count(substring) function, in this example, using this function, I will get the result "3". But I want the result "2". How can I achieve my goal, thanks in advance.</p>
| 0debug
|
void ide_atapi_cmd_reply_end(IDEState *s)
{
int byte_count_limit, size, ret;
#ifdef DEBUG_IDE_ATAPI
printf("reply: tx_size=%d elem_tx_size=%d index=%d\n",
s->packet_transfer_size,
s->elementary_transfer_size,
s->io_buffer_index);
#endif
if (s->packet_transfer_size <= 0) {
s->status = READY_STAT | SEEK_STAT;
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD;
ide_transfer_stop(s);
ide_set_irq(s->bus);
#ifdef DEBUG_IDE_ATAPI
printf("status=0x%x\n", s->status);
#endif
} else {
if (s->lba != -1 && s->io_buffer_index >= s->cd_sector_size) {
ret = cd_read_sector(s, s->lba, s->io_buffer, s->cd_sector_size);
if (ret < 0) {
ide_transfer_stop(s);
ide_atapi_io_error(s, ret);
return;
}
s->lba++;
s->io_buffer_index = 0;
}
if (s->elementary_transfer_size > 0) {
size = s->cd_sector_size - s->io_buffer_index;
if (size > s->elementary_transfer_size)
size = s->elementary_transfer_size;
s->packet_transfer_size -= size;
s->elementary_transfer_size -= size;
s->io_buffer_index += size;
ide_transfer_start(s, s->io_buffer + s->io_buffer_index - size,
size, ide_atapi_cmd_reply_end);
} else {
s->nsector = (s->nsector & ~7) | ATAPI_INT_REASON_IO;
byte_count_limit = s->lcyl | (s->hcyl << 8);
#ifdef DEBUG_IDE_ATAPI
printf("byte_count_limit=%d\n", byte_count_limit);
#endif
if (byte_count_limit == 0xffff)
byte_count_limit--;
size = s->packet_transfer_size;
if (size > byte_count_limit) {
if (byte_count_limit & 1)
byte_count_limit--;
size = byte_count_limit;
}
s->lcyl = size;
s->hcyl = size >> 8;
s->elementary_transfer_size = size;
if (s->lba != -1) {
if (size > (s->cd_sector_size - s->io_buffer_index))
size = (s->cd_sector_size - s->io_buffer_index);
}
s->packet_transfer_size -= size;
s->elementary_transfer_size -= size;
s->io_buffer_index += size;
ide_transfer_start(s, s->io_buffer + s->io_buffer_index - size,
size, ide_atapi_cmd_reply_end);
ide_set_irq(s->bus);
#ifdef DEBUG_IDE_ATAPI
printf("status=0x%x\n", s->status);
#endif
}
}
}
| 1threat
|
setting up OpenVPN to limit access to certain http dirs : <p>Im trying to configure everything in order to allow only VPN users to accesss to certain folders (wp-admin etc) and the thing is that by following some tutorials like <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04" rel="nofollow">https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04</a> i can connect to my openvpn (it gives me a 10.8.0.X ip through tun0 and the external IP is my server's one when checking at <a href="http://www.whatsmyip.org/" rel="nofollow">http://www.whatsmyip.org/</a> but when i enter my own server domain in my browser it sees my real IP (getenv('REMOTE_ADDR') shows my real IP) and not the one from the VPN so i cant set up a .htaccess file to restrict to my own server IP.</p>
<p>As a summary of above tutorial config, i have:</p>
<h2>/etc/openvpn/server.conf</h2>
<pre><code>dh2048.pem
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"
user nobody
group nogroup
</code></pre>
<h2>/proc/sys/net/ipv4/ip_forward</h2>
<pre><code>1
</code></pre>
<h2>/etc/sysctl.conf</h2>
<pre><code>net.ipv4.ip_forward=1
</code></pre>
<h2>/etc/default/ufw</h2>
<pre><code>DEFAULT_FORWARD_POLICY="ACCEPT"
</code></pre>
<h2>/etc/ufw/before.rules</h2>
<pre><code># START OPENVPN RULES
# NAT table rules
*nat
:POSTROUTING ACCEPT [0:0]
# Allow traffic from OpenVPN client to eth0
-A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE
COMMIT
# END OPENVPN RULES
</code></pre>
<h2>ufw status verbose:</h2>
<pre><code>root@XXX:/# ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), allow (routed)
New profiles: skip
To Action From
-- ------ ----
1194/udp ALLOW IN Anywhere
22/tcp ALLOW IN Anywhere
53 (Bind9) ALLOW IN Anywhere
80/tcp (Apache) ALLOW IN Anywhere
443/tcp (Apache Secure) ALLOW IN Anywhere
1194/udp (v6) ALLOW IN Anywhere (v6)
22/tcp (v6) ALLOW IN Anywhere (v6)
53 (Bind9 (v6)) ALLOW IN Anywhere (v6)
80/tcp (Apache (v6)) ALLOW IN Anywhere (v6)
443/tcp (Apache Secure (v6)) ALLOW IN Anywhere (v6)
</code></pre>
<p>Is there something im missing or a different workaround?</p>
<p>Thank you in advance,</p>
| 0debug
|
Remove last digit from input type="tel" in HTML : <p>I have full dialpad code .</p>
<p>Clear button clear all text from dialpad window. but i want to delete only last digit which i dial from dialpad.</p>
<p>language only javascript,jquery and html.</p>
| 0debug
|
Android Room: How to read from two tables at the same time - duplicate id column : <p>I'm new to Android Room. I want to read from a table and also read from a related table. The relationship is pretty common. One table defines instances. The other table defines types. Imagine an Animal table and an AnimalType table. Pretty much any time that the Animal table has to be read, the AnimalType table needs to be read as well. E.g., we want to shows the animals name (from the Animal table) and the monkey icon (from the AnimalType table).</p>
<p>Based on an example from the Android Room documentation, this is the data class to model it:</p>
<pre><code>public class AnimalWithType {
@Embedded
private Animal animal;
@Embedded
private AnimalType type;
...
</code></pre>
<p>The DAO can query the data with a single query. Room should be smart enough to populate the two child classes.</p>
<pre><code>@Dao
public interface ZooDao
@Query("select * from animal join animal_type on (animal.id = animal_type.id)")
List<AnimalWithType> getAllAnimals();
</code></pre>
<p>As always theory is pretty. Reality is broken. The result is the following error:</p>
<pre><code>Error:(8, 8) error: Multiple fields have the same columnName: id. Field names: animal > id, animalType > id.
</code></pre>
<p>Apparently, Room is confused about getting only one "id" column in the query and which class it belongs. There are two potential solutions:
1) We could create a column name alias for building_type.id and tell Room about it.
2) We already know that the foreign key from the Animal table to the AnimalType table (perhaps animal_type_id) has the other id column.</p>
<p>The question is how do we communicate that to Room. Is Room even able to handle that case?</p>
<p>Tips on how to solve this problem are appreciated. I hope that Room doesn't require doing something awkward like giving every id column a unique name.</p>
| 0debug
|
Semaphore execution when has 4 processes : Can any one please explain this for me??
2. In the following code, four processes produce output using the routine “printf” and synchronize using three semaphores “R”, “S” and “T.” We assume ‘printf’ won’t cause context switch.
Semaphore R=1, S = 3, T = 0; /* initialization */
/* process 1 */ /* process 2 */ /* process 3 */ /*process 4 */ while(true) { while(true) { while(true) { while(true) { P(S); P(T); P(T); P(R); printf(‘A’); printf (‘B’); printf (‘D’); printf (‘E’); printf (‘C’); V(R); V(T); V(T); } } } } How many A and B’s are printed when this set of processes runs? A
Thanks
| 0debug
|
Install SourceTree without an Atlassian account? : <p>I'm trying to use SourceTree for a class that I'm teaching. In order to do that we need to install SourceTree onto the school's Windows computers. </p>
<p>When we try to install SourceTree (Version 1.9.10.0) it demands an Atlassian account before it will start. Obviously this is wrong - since we're trying to install SourceTree onto a shared computer (into a VM, to be specific) we don't have just one account (and, on top of that, we're using SourceTree with GitLab, not BitBucket/Atlassian, so we don't need their account anyways).</p>
<p>Is it possible to install SourceTree but skip the 'create an Atlassian account' step during the install process?</p>
<p>(We'd be ok with having the students create accounts later on, when they first start using it - we just don't want all the students to share a single BitBucket account by default)</p>
| 0debug
|
static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
MSIMessage *msg, IOHandler *handler)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
VFIOMSIVector *vector;
int ret;
trace_vfio_msix_vector_do_use(vdev->vbasedev.name, nr);
vector = &vdev->msi_vectors[nr];
if (!vector->use) {
vector->vdev = vdev;
vector->virq = -1;
if (event_notifier_init(&vector->interrupt, 0)) {
error_report("vfio: Error: event_notifier_init failed");
}
vector->use = true;
msix_vector_use(pdev, nr);
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
handler, NULL, vector);
if (vector->virq >= 0) {
if (!msg) {
vfio_remove_kvm_msi_virq(vector);
} else {
vfio_update_kvm_msi_virq(vector, *msg, pdev);
}
} else {
vfio_add_kvm_msi_virq(vdev, vector, nr, true);
}
if (vdev->nr_vectors < nr + 1) {
vfio_disable_irqindex(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_INDEX);
vdev->nr_vectors = nr + 1;
ret = vfio_enable_vectors(vdev, true);
if (ret) {
error_report("vfio: failed to enable vectors, %d", ret);
}
} else {
int argsz;
struct vfio_irq_set *irq_set;
int32_t *pfd;
argsz = sizeof(*irq_set) + sizeof(*pfd);
irq_set = g_malloc0(argsz);
irq_set->argsz = argsz;
irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD |
VFIO_IRQ_SET_ACTION_TRIGGER;
irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
irq_set->start = nr;
irq_set->count = 1;
pfd = (int32_t *)&irq_set->data;
if (vector->virq >= 0) {
*pfd = event_notifier_get_fd(&vector->kvm_interrupt);
} else {
*pfd = event_notifier_get_fd(&vector->interrupt);
}
ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set);
g_free(irq_set);
if (ret) {
error_report("vfio: failed to modify vector, %d", ret);
}
}
clear_bit(nr, vdev->msix->pending);
if (find_first_bit(vdev->msix->pending,
vdev->nr_vectors) == vdev->nr_vectors) {
memory_region_set_enabled(&vdev->pdev.msix_pba_mmio, false);
trace_vfio_msix_pba_disable(vdev->vbasedev.name);
}
return 0;
}
| 1threat
|
How can I create a object from a class : I just started programming in c++ and I don't understand why Xcode says that " Variable Type 'Rect' is an abstract class"..
You can find a part of my code here:
Thank you in advance for your help,
main(){
Rect r1(10,5,"R1");
return 0;
}
class Rect : public Figure
{
public:
Rect(int l, int h,std::string Label) : Figure(l), _h(h),_Label(Label) {};
~Rect(){};
std:: vector<std::string> toString() const;
protected:
int _h;
int _l;
std::string _Label;
};
class Figure
{
public:
Figure(int l):_l(l){}
virtual std::vector<std::string> toStrings() const =0;
virtual ~Figure();
protected:
int _l;
};
| 0debug
|
void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(x86_defs); i++)
(*cpu_fprintf)(f, "x86 %16s\n", x86_defs[i].name);
}
| 1threat
|
Google App Engine Firewall: Restrict access to all services but the default one : <p>I have a GAE project (flexible) consisting of 1 default and 2 subservices:</p>
<ul>
<li><code>foo.appspot.com</code></li>
<li><code>service1.foo.appspot.com</code></li>
<li><code>service2.foo.appspot.com</code></li>
</ul>
<p>Now I want to use <code>foo.appspot.com</code> as API proxy & auth gateway to the internal services <code>service1</code> and <code>service2</code>. The proxy itself I wrote and it is working fine.</p>
<p>I am struggling with adjusting the GAE Firewall to forbid incoming world traffic to <code>service1</code> and <code>service2</code> because I would like force an API user to send requests to <code>foo.appspot.com</code>. Traffic to the default service <code>foo</code> should be allowed.</p>
<p>It seems I can just enter IPs in the Firewall settings but not service names. The docs says that it should work but does not show how.</p>
<p>Thanks for the help!</p>
| 0debug
|
How can I convert this function to nodejs : <p>I have this php function for encrypt data, how can I convert it to NodeJS?</p>
<pre><code><?php
function Encrypt($input, $key_seed){
$input = trim($input);
$block = mcrypt_get_block_size('tripledes', 'ecb');
$len = strlen($input);
$padding = $block - ($len % $block);
$input .= str_repeat(chr($padding),$padding);
// generate a 24 byte key from the md5 of the seed
$key = substr(md5($key_seed),0,24);
$iv_size = mcrypt_get_iv_size(MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB);
echo "--" . $iv_size . "\n";
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
// encrypt
$encrypted_data = mcrypt_encrypt(MCRYPT_TRIPLEDES, $key,
$input, MCRYPT_MODE_ECB, $iv);
// clean up output and return base64 encoded
return base64_encode($encrypted_data);
}
</code></pre>
<p>Help me please! Thank you!</p>
| 0debug
|
Default code folding by individual chunk in rmarkdown : <p>I am writing up a lesson in HTML using rmarkdown to demonstrate how to implement analytic methods in R, and because of this the document has a lot of code that is needed to understand those methods, but also a lot of code that is used only for generating plots and figures. I would like to show the first sort of code by default, and leave the plotting code available for students to view but hidden by default.</p>
<p>I know that rmarkdown has recently added support for code folding by setting the <code>code_folding</code> html_document argument to either <code>show</code> or <code>hide</code>. However, this either leaves all code chunks unfolded or folded by default -- is there any way to indicate whether <strong>individual</strong> code chunks should be shown or folded by default while allowing code folding?</p>
<p>Thank you!</p>
| 0debug
|
please help me for getting eroor : select "gt.shiftkerja","i.jenis","i.konsinyasi","gp.group" from "tbl_ikhd gt"@PG
join "tbl_ikdt dt"@PG on "gt.notransaksi"="dt.notransaksi"
join "tbl_item i"@PG on "dt.kodeitem"="i.kodeitem"
LEFT JOIN "group_posting gp"@PG on "gp.kode_group"="i.jenis"and "gp.konsinyasi"="i.konsinyasi"
where to_char("gt.tanggal", 'YYYY-MM-DD')='2017-09-08' group by "gt.shiftkerja","i.jenis","i.konsinyasi","gp.group" order by "gt.shiftkerja","gp.group";
this my error status: ORA-28500: connection from ORACLE to a non-Oracle system returned this message: ERROR: relation "group_posting gp" does not exist; No query has been executed with that handle {42P01,NativeErr = 1} ORA-02063: preceding 3 lines from PG
| 0debug
|
Hey guys, new to C and am having trouble with this work assignment. I use a C89 compiler btw : Write a program that sort its command-line arguments of 10 numbers, which are assumed to be integers. The first command-line argument indicate whether the sorting is in descending order (-d) or ascending order (-a), if the user enters an invalid option, the program should display an error message. Example runs of the program:
./sort –a 5 2 92 424 53 42 8 12 23 41
output: 2 5 8 12 23 41 42 53 92 424
./sort –d 5 2 92 424 53 42 8 12 23 41
output: 424 92 53 42 41 23 12 8 5 2
1) Use the selection_sort function provided for project 5. Create another function that’s similar but sorts in descending order.
2) Use string library functions to process the first command line argument.
3) Use atoi function in <stdlib.h> to convert a string to integer form.
4) Compile the program to generate the executable as sort:
gcc –Wall –o sort command_sort.c
What I have so far is:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//function prototype
void swap(int *arr, int i, int j);
//main function
int main(int argc, char *argv[])
{
//declare the required variables
int array[10];
int maxIndex = 0, minIndex =0;
int i = 0, j = 0, n = 2;
//check whether the number of arguments are less than 2 or not
if (argc < 2)
{
//print the error message
printf("Data is insuffient! Please insert proper input at command line. \n");
}
else
{
// read the integers from the command line
for (i = 0; i < 10; i++)
array[i] = atoi(argv[2 + i]);
}
printf("Selection sort on integer arrays \n\n");
//print the elements that are read from the command line
printf("Elements before sorting are: \n");
//print the sorted elements
for(i =0;i<10;i++)
printf("%d ", array[i]);
printf("\n");
//check whether the first argument is -a, if
//-a sort the elements in the array in asscending order
if (strcmp(argv[1], "-a") == 0)
{
//logic to sort the elements in asscending order using selection sort
for (i = 0; i < 10; ++i)
{
minIndex = i;
for (int j = i + 1; j < 10; ++j)
{
if (array[j] < array[minIndex])
minIndex = j;
}
swap(array, minIndex, i);
}
}
//check whether the first argument is -d, if
//-d sort the elements in the array in descending order
if (strcmp(argv[1], "-d") == 0)
{
//logic to sort the elements in descending order using selection sort
for (i = 0; i < 10; ++i)
{
maxIndex = i;
for (j = i + 1; j < 10; ++j)
{
if (array[j] > array[maxIndex])
maxIndex = j;
}
swap(array, maxIndex, i);
}
}
//print the elements
printf("\nElements after sorting are: \n");
//print the sorted elements
for(i =0;i<10;i++)
printf("%d ", array[i]);
printf("\n\n");
return 0;
}
//definition of swap function
void swap(int *arr, int i, int j)
{
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
| 0debug
|
int avfilter_config_links(AVFilterContext *filter)
{
int (*config_link)(AVFilterLink *);
unsigned i;
int ret;
for (i = 0; i < filter->nb_inputs; i ++) {
AVFilterLink *link = filter->inputs[i];
AVFilterLink *inlink = link->src->nb_inputs ?
link->src->inputs[0] : NULL;
if (!link) continue;
link->current_pts = AV_NOPTS_VALUE;
switch (link->init_state) {
case AVLINK_INIT:
continue;
case AVLINK_STARTINIT:
av_log(filter, AV_LOG_INFO, "circular filter chain detected\n");
return 0;
case AVLINK_UNINIT:
link->init_state = AVLINK_STARTINIT;
if ((ret = avfilter_config_links(link->src)) < 0)
return ret;
if (!(config_link = link->srcpad->config_props)) {
if (link->src->nb_inputs != 1) {
av_log(link->src, AV_LOG_ERROR, "Source filters and filters "
"with more than one input "
"must set config_props() "
"callbacks on all outputs\n");
return AVERROR(EINVAL);
}
} else if ((ret = config_link(link)) < 0) {
av_log(link->src, AV_LOG_ERROR,
"Failed to configure output pad on %s\n",
link->src->name);
return ret;
}
switch (link->type) {
case AVMEDIA_TYPE_VIDEO:
if (!link->time_base.num && !link->time_base.den)
link->time_base = inlink ? inlink->time_base : AV_TIME_BASE_Q;
if (!link->sample_aspect_ratio.num && !link->sample_aspect_ratio.den)
link->sample_aspect_ratio = inlink ?
inlink->sample_aspect_ratio : (AVRational){1,1};
if (inlink && !link->frame_rate.num && !link->frame_rate.den)
link->frame_rate = inlink->frame_rate;
if (inlink) {
if (!link->w)
link->w = inlink->w;
if (!link->h)
link->h = inlink->h;
} else if (!link->w || !link->h) {
av_log(link->src, AV_LOG_ERROR,
"Video source filters must set their output link's "
"width and height\n");
return AVERROR(EINVAL);
}
break;
case AVMEDIA_TYPE_AUDIO:
if (inlink) {
if (!link->sample_rate)
link->sample_rate = inlink->sample_rate;
if (!link->time_base.num && !link->time_base.den)
link->time_base = inlink->time_base;
if (!link->channel_layout)
link->channel_layout = inlink->channel_layout;
} else if (!link->sample_rate) {
av_log(link->src, AV_LOG_ERROR,
"Audio source filters must set their output link's "
"sample_rate\n");
return AVERROR(EINVAL);
}
if (!link->time_base.num && !link->time_base.den)
link->time_base = (AVRational) {1, link->sample_rate};
}
if ((config_link = link->dstpad->config_props))
if ((ret = config_link(link)) < 0) {
av_log(link->src, AV_LOG_ERROR,
"Failed to configure input pad on %s\n",
link->dst->name);
return ret;
}
link->init_state = AVLINK_INIT;
}
}
return 0;
}
| 1threat
|
How many subsisiaries can i have in netsuite? I have Oneworld Netsuite solution : I need to create 500 subsisdiaries. But This subsidiaries only stayed actives 1 year.
can be possible in netsuite?
| 0debug
|
Split a word in letters in java no specific character : I am a beginner in Java and I have this situation:
You input a word which is a string. What I want to do is to put the letters in an odd position in a variable and thoes on an even position in other variable...
But I have been reading online and all I can find is how to split by a specific character like: "/", "-" or "`". But I don`t have one.. show what should I use...
Should I solve this in an other way....
EX:
String S = "alfabet";
and I want to print out:
add = "afbl";
even = "lae";
System.out.println(odd + " " + even);
| 0debug
|
Linux commands in BASH shell : I am trying to execute this command for a linux assignment, but I cannot figure out what the command should be? I know to append to a file you use the >> but I am not sure how to redirect and append the output together.
"9. Redirect the output of the process list (ps) only for httpd process appending it to final.txt (file created in step 5)"
Thank you!
| 0debug
|
How to fix Argument labels '(bytes:, length:)' do not match any available overloads error? : I have converted an Object-C project to Swift 4 and I am getting the following error on below line:
> Argument labels '(bytes:, length:)' do not match any available
> overloads
Swift:
let data = Data(bytes: [0x80, 0xbe, 0xf5, 0xac, 0xff], length: 5)
**Objective-C**
NSData *data = [NSData dataWithBytes:(Byte[]){0x80,0xBE,0xF5,0xAC,0xFF} length:5];
| 0debug
|
How to protect my node.js source code? : I found some solutions. Such as `enclosejs` and `nexe`. They all compile files to a executable file.
But in my situation, I want to keep some files without compile for user config, and compile other files.
It's possible to do this?
| 0debug
|
My variable returns an invalid syntax and i don't know why : <p>I am new to python, just picked it up again after a long time. My code is here basically a die rolling simulator and I can't seem to figure out the "invalid syntax" I get after the second line.
my code ----> <a href="https://pastebin.com/XPNq0tup" rel="nofollow noreferrer">https://pastebin.com/XPNq0tup</a>
Any and all help would be appreciated.</p>
<pre><code>from random import randint
var = raw_imput("How many dices do you want, 1 or 2?"
rollagain = 'yes'
</code></pre>
<p>the rollagain variable is where I encounter the error.</p>
| 0debug
|
How to use curl to access the github graphql API : <p>After referring this <a href="https://developer.github.com/early-access/graphql/guides/accessing-graphql/" rel="noreferrer">guide</a> I needed to access the github <code>graphql</code> by using <code>curl</code> for a testing purpose. I tried this simple command </p>
<pre><code>curl -i -H "Authorization: bearer myGithubAccessToken" -X POST -d '{"query": "query {repository(owner: "wso2", name: "product-is") {description}}"}' https://api.github.com/graphql
</code></pre>
<p>but it gives me</p>
<blockquote>
<p>problems parsing JSON</p>
</blockquote>
<p>what I am doing wrong. I spent nearly 2 hours trying to figure it and tried different examples but none of them worked. Can you please be kind enough help me resolve this</p>
| 0debug
|
Extract unit test results from multi-stage Docker build (.NET Core 2.0) : <p>I am building a .NET Core 2.0 web API and I am creating a Docker image. I am quite new to Docker so apologies if the question has been answered before.</p>
<p>I have the following Docker file for creating the image. In particular, I run the unit tests during the build process and the results are output to <code>./test/test_results.xml</code> (in a temporary container created during the build, I guess). My question is, how do I access these test results after the build has finished?</p>
<pre><code>FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app
# Copy main csproj file for DataService
COPY src/DataService.csproj ./src/
RUN dotnet restore ./src/DataService.csproj
# Copy test csproj file for DataService
COPY test/DataService.Tests.csproj ./test/
RUN dotnet restore ./test/DataService.Tests.csproj
# Copy everything else (excluding elements in dockerignore)
COPY . ./
# Run the unit tests
RUN dotnet test --results-directory ./ --logger "trx;LogFileName=test_results.xml" ./test/DataService.Tests.csproj
# Publish the app to the out directory
RUN dotnet publish ./src/DataService.csproj -c Release -o out
# Build the runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
EXPOSE 5001
COPY --from=build-env /app/src/out .
# Copy test results to the final image as well??
# COPY --from=build-env /app/test/test_results.xml .
ENTRYPOINT ["dotnet", "DataService.dll"]
</code></pre>
<p>One approach that I have taken is to comment in the line <code># COPY --from=build-env /app/test/test_results.xml .</code>. This puts the <code>test_results.xml</code> in my final image. I can then extract these results and remove the <code>test_results.xml</code> from the final image using the following powershell script.</p>
<pre><code>$id=$(docker create dataservice)
docker cp ${id}:app/test_results.xml ./test/test_results.xml
docker start $id
docker exec $id rm -rf /app/test_results.xml
docker commit $id dataservice
docker rm -vf $id
</code></pre>
<p>This however seems ugly and I am wondering is there a cleaner way to do it.</p>
<p>I was hoping that there was a way to mount a volume during <code>docker build</code> but it does not appear that this is going to be supported in the official Docker.</p>
<p>I am looking now at creating a separate image, solely for the unit tests.</p>
<p>Not sure if there is a recommended way of achieving what I want.</p>
| 0debug
|
How to implement Task Scheduler Manager on C# ? : I want to write a Scheduler Manager.
My Scheduler Manager contain 3 type of running task
- each XX seconds ( ex. each 15 seconds )
- every day at same time ( ex. every day at 7 a.m )
- emergency task - this is task that UI can add and will run imitatively
My problem is that i don't know how to implement the alarm that will popup at the time that the task need to run.
I can calculate the time between 'now' and the target time and using Timer.Interval that will wait for the right time to popup the task
But is there better way to implement this ?
| 0debug
|
How to add where clause to ThenInclude : <p>I have 3 entities:</p>
<p><code>Questionnaire.cs</code>:</p>
<pre><code>public class Questionnaire
{
public int Id { get; set; }
public string Name { get; set; }
public ICollection<Question> Questions { get; set; }
}
</code></pre>
<p><code>Question.cs</code>:</p>
<pre><code>public class Question
{
public int Id { get; set; }
public string Text { get; set; }
public ICollection<Answer> Answers { get; set; }
}
</code></pre>
<p>and <code>Answer.cs</code>: </p>
<pre><code>public class Answer
{
public int Id { get; set; }
public string UserId { get; set; }
public string TextAnswer { get; set; }
}
</code></pre>
<p>So I saved the questionnaire with answers but now i want to retrieve filtered questionnaire with questions and its answers. So i wrote linq for that, but it throws me an error, is there anything i do wrong? here is the example:</p>
<pre><code>questionnaire = _context.Questionnaires.Include(qn => qn.Questions)
.ThenInclude(question => question.Answers.Where(a => a.UserId == userId))
.FirstOrDefault(qn => qn.Id == questionnaireId);
</code></pre>
<p>And i am getting </p>
<blockquote>
<p>Message = "The property expression 'q => {from Answer a in q.Answers
where Equals([a].UserId, __userId_0) select [a]}' is not valid. The
expression should represent a property access: 't => t.MyProperty'.</p>
</blockquote>
<p>Any ideas how to solve this problem? </p>
| 0debug
|
How do i move an Azure DevOps project to a different organization? : <p>I've got a project in an <em>old</em> org (from VSTS), that i want to move to my new one.</p>
<p>I can't see any options in Azure DevOps on migrating projects, or any information on the interwebs.</p>
<p>Anyone know how to do it?</p>
<p>Thanks</p>
| 0debug
|
I can receive notification from firebase cloud messagaing but how can i display on user interface : public class MyFirebaseMessagingService extends FirebaseMessagingService{
private static final String TAG="MyFirebaseMsgService";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG,"FROM:"+remoteMessage.getFrom());
//check if the message contains data
if(remoteMessage.getData().size()>0){
Log.d(TAG,"Message data:"+remoteMessage.getData());
//check if the message contains notification
if(remoteMessage.getNotification()!=null){
Log.d(TAG,"Message body:"+remoteMessage.getNotification().getBody());
sendNotification(remoteMessage.getNotification().getBody());
}
}
}
| 0debug
|
static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
IVITile *tile, AVCodecContext *avctx)
{
int x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
mv_scale, blks_per_mb;
IVIMbInfo *mb, *ref_mb;
int row_offset = band->mb_size * band->pitch;
mb = tile->mbs;
ref_mb = tile->ref_mbs;
offs = tile->ypos * band->pitch + tile->xpos;
if (!ref_mb &&
((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv))
mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
mv_x = mv_y = 0;
for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
mb_offset = offs;
for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
mb->xpos = x;
mb->ypos = y;
mb->buf_offs = mb_offset;
if (get_bits1(&ctx->gb)) {
if (ctx->frame_type == FRAMETYPE_INTRA) {
av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
return -1;
mb->type = 1;
mb->cbp = 0;
mb->q_delta = 0;
if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
mb->mv_x = mb->mv_y = 0;
if (band->inherit_mv){
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
} else {
if (band->inherit_mv) {
mb->type = ref_mb->type;
} else if (ctx->frame_type == FRAMETYPE_INTRA) {
mb->type = 0;
} else {
mb->type = get_bits1(&ctx->gb);
blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
mb->cbp = get_bits(&ctx->gb, blks_per_mb);
mb->q_delta = 0;
if (band->qdelta_present) {
if (band->inherit_qdelta) {
if (ref_mb) mb->q_delta = ref_mb->q_delta;
} else if (mb->cbp || (!band->plane && !band->band_num &&
(ctx->frame_flags & 8))) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
if (!mb->type) {
mb->mv_x = mb->mv_y = 0;
} else {
if (band->inherit_mv){
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
} else {
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_y += IVI_TOSIGNED(mv_delta);
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_x += IVI_TOSIGNED(mv_delta);
mb->mv_x = mv_x;
mb->mv_y = mv_y;
mb++;
if (ref_mb)
ref_mb++;
mb_offset += band->mb_size;
offs += row_offset;
align_get_bits(&ctx->gb);
return 0;
| 1threat
|
Zig Zag structured programming - C : I need a code in which I enter integeres all the time untill I enter something !integer. The code needs to print me the integers who meet the following condition:
integer "abcde": "a > b, b < c, c > d, d < e" or "a < b, b > c, c < d, d > e"
example: 343, 4624, 6231209
I have a code written by myself and works for most of the integers but somehow it doesnt work for some
#include <stdio.h>
int main()
{
int a;
while(scanf("%d", &a))
{
int a1 = a;
int cifra = 0, cifra1 = 0, cifra2 = 0;
while(a1 > 0){
cifra = a1 % 10;
cifra1 = (a1 / 10) % 10;
cifra2 = (a1 / 100) % 10;
a1 = a1 / 10;
if(cifra == cifra1 || cifra1 == cifra2)
{
break;
}
if((cifra < cifra1 && cifra1 > cifra2) || (cifra > cifra1 && cifra1 < cifra2))
{
printf("%d\n", a);
break;
}
else
{
break;
}
}
}
return 0;
}
| 0debug
|
ngx-toastr, Toast not showing in Angular 7 : <p>I'm currently developing a web app using Angular 7. I wanted to include ngx-toastr to send notifications to users but it isn't working as expected. When I trigger a toast nothing happens, except for a box in the size of a toast is appearing in bottom right corner but only when hovered over by the coursor.
Following an example of how I trigger the toastr function. Test is invoked by the click of a button. </p>
<pre><code>import {ToastrService} from 'ngx-toastr';
@Component({
selector: 'app-action-controls',
templateUrl: './action-controls.component.html',
styleUrls: ['./action-controls.component.scss']
})
export class Notification implements OnInit {
test(){
this.toast.success("I'm a toast!", "Success!");
}
constructor(private toast: ToastrService) { }
}
</code></pre>
<p>I includet the library css files in the angular.json file in my project like this: </p>
<pre><code> ...
"styles": [
"src/styles.scss",
"node_modules/bootstrap/scss/bootstrap.scss",
"node_modules/ngx-toastr/toastr.css"
],
...
</code></pre>
<p>And like this in my app.module.ts file:</p>
<pre><code>...
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {ToastrModule} from 'ngx-toastr';
...
imports: [
...
BrowserAnimationsModule,
ToastrModule.forRoot({
timeOut: 1000,
positionClass: 'toast-bottom-right'
})
]
...
</code></pre>
<p>I can't figure out what i'm doing wrong, has anyone had similar experiences? Many thanks in advance!</p>
| 0debug
|
ld linker error "cpu model hidden symbol" : <p>I'm getting an ld error when attempting to compile an sfml program on ubuntu 16.04. This is apparently a known issue, and there is supposed to be a workaround, but I don't understand what is it...</p>
<p><a href="http://web.archive.org/web/20160509014317/https://gitlab.peach-bun.com/pinion/SFML/commit/3383b4a472f0bd16a8161fb8760cd3e6333f1782.patch" rel="noreferrer">http://web.archive.org/web/20160509014317/https://gitlab.peach-bun.com/pinion/SFML/commit/3383b4a472f0bd16a8161fb8760cd3e6333f1782.patch</a></p>
<p>The error spat out by ld is</p>
<pre><code>hidden symbol `__cpu_model' in /usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a(cpuinfo.o) is referenced by DSO
</code></pre>
<p>There is no relevant code to this - as I understand it this error is produced on all ubuntu 16.04 systems with g++ 5, if the program to be linked contains objects such as <code>sf::Texture</code> and <code>sf::Sprite</code>. (I don't know any more detail than this.)</p>
<p>I have tried also compiling with g++ 4.9, but the same error occurs.</p>
<p>My compile line is <code>g++-4.9 --std=c++11 -Wall main.cpp -lsfml-graphics -lsfml-window -lsfml-system -o a.out</code></p>
<p>Has anyone else experienced this error and resolved it successfully?</p>
| 0debug
|
Markdown metadata format : <p>Is there a standard or convention for embedding metadata in a Markdown formatted post, such as the publication date or post author for conditional rendering by the renderer?</p>
<p>Looks like this <a href="https://github.com/blog/1647-viewing-yaml-metadata-in-your-documents" rel="noreferrer">Yaml metadata</a> format might be it.</p>
<p>There are all kinds of strategies, e.g. an accompanying file <code>mypost.meta.edn</code>, but I'm hoping to keep it all in one file.</p>
| 0debug
|
How to sort an array of objects in ascending order? : <p>I have a data like,</p>
<pre><code>option = [
{
"field": "bac",
"title": "BAC",
"hidden": true
},
{
"field": "vm",
"title": "VM",
"hidden": false
},
{
"field": "cad",
"title": "CAD",
"hidden": true
},
{
"field": "boom",
"title": "BOOM",
"hidden": true
}
];
</code></pre>
<p>Now i have to sort based on title, can someone help me how do i do that?</p>
<p>I tried like,</p>
<pre><code>_.each(option, function(e)){
arr.push(e.title);
}
arr.sort();
</code></pre>
<p>now getting every object and arranging, is that anyway to get this done more precise..</p>
<p>Thanks,</p>
| 0debug
|
EF7: The term 'add-migration' is not recognized as the name of a cmdlet : <p>I have framework version set to: dnx46 in project.json.
Also have the following packages:</p>
<pre><code> "dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final"
}
</code></pre>
<p>However when I got into running enable-migrations command I get the following:</p>
<p>The term 'enable-migrations' is not recognized as the name of a cmdlet</p>
<p>Does anyone know how I get EF migrations running in latest .NET?</p>
| 0debug
|
static void mmubooke_create_initial_mapping(CPUPPCState *env,
target_ulong va,
hwaddr pa)
{
ppcemb_tlb_t *tlb = &env->tlb.tlbe[0];
tlb->attr = 0;
tlb->prot = PAGE_VALID | ((PAGE_READ | PAGE_WRITE | PAGE_EXEC) << 4);
tlb->size = 1 << 31;
tlb->EPN = va & TARGET_PAGE_MASK;
tlb->RPN = pa & TARGET_PAGE_MASK;
tlb->PID = 0;
tlb = &env->tlb.tlbe[1];
tlb->attr = 0;
tlb->prot = PAGE_VALID | ((PAGE_READ | PAGE_WRITE | PAGE_EXEC) << 4);
tlb->size = 1 << 31;
tlb->EPN = 0x80000000 & TARGET_PAGE_MASK;
tlb->RPN = 0x80000000 & TARGET_PAGE_MASK;
tlb->PID = 0;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.