problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
int ff_pca(PCA *pca, double *eigenvector, double *eigenvalue){
int i, j, k, pass;
const int n= pca->n;
double z[n];
memset(eigenvector, 0, sizeof(double)*n*n);
for(j=0; j<n; j++){
pca->mean[j] /= pca->count;
eigenvector[j + j*n] = 1.0;
for(i=0; i<=j; i++){
pca->covariance[j + i*n] /= pca->count;
pca->covariance[j + i*n] -= pca->mean[i] * pca->mean[j];
pca->covariance[i + j*n] = pca->covariance[j + i*n];
}
eigenvalue[j]= pca->covariance[j + j*n];
z[j]= 0;
}
for(pass=0; pass < 50; pass++){
double sum=0;
for(i=0; i<n; i++)
for(j=i+1; j<n; j++)
sum += fabs(pca->covariance[j + i*n]);
if(sum == 0){
for(i=0; i<n; i++){
double maxvalue= -1;
for(j=i; j<n; j++){
if(eigenvalue[j] > maxvalue){
maxvalue= eigenvalue[j];
k= j;
}
}
eigenvalue[k]= eigenvalue[i];
eigenvalue[i]= maxvalue;
for(j=0; j<n; j++){
double tmp= eigenvector[k + j*n];
eigenvector[k + j*n]= eigenvector[i + j*n];
eigenvector[i + j*n]= tmp;
}
}
return pass;
}
for(i=0; i<n; i++){
for(j=i+1; j<n; j++){
double covar= pca->covariance[j + i*n];
double t,c,s,tau,theta, h;
if(pass < 3 && fabs(covar) < sum / (5*n*n))
continue;
if(fabs(covar) == 0.0)
continue;
if(pass >=3 && fabs((eigenvalue[j]+z[j])/covar) > (1LL<<32) && fabs((eigenvalue[i]+z[i])/covar) > (1LL<<32)){
pca->covariance[j + i*n]=0.0;
continue;
}
h= (eigenvalue[j]+z[j]) - (eigenvalue[i]+z[i]);
theta=0.5*h/covar;
t=1.0/(fabs(theta)+sqrt(1.0+theta*theta));
if(theta < 0.0) t = -t;
c=1.0/sqrt(1+t*t);
s=t*c;
tau=s/(1.0+c);
z[i] -= t*covar;
z[j] += t*covar;
#define ROTATE(a,i,j,k,l) {\
double g=a[j + i*n];\
double h=a[l + k*n];\
a[j + i*n]=g-s*(h+g*tau);\
a[l + k*n]=h+s*(g-h*tau); }
for(k=0; k<n; k++) {
if(k!=i && k!=j){
ROTATE(pca->covariance,FFMIN(k,i),FFMAX(k,i),FFMIN(k,j),FFMAX(k,j))
}
ROTATE(eigenvector,k,i,k,j)
}
pca->covariance[j + i*n]=0.0;
}
}
for (i=0; i<n; i++) {
eigenvalue[i] += z[i];
z[i]=0.0;
}
}
return -1;
}
| 1threat
|
DECLARE_LOOP_FILTER(mmxext)
DECLARE_LOOP_FILTER(sse2)
DECLARE_LOOP_FILTER(ssse3)
#endif
#define VP8_LUMA_MC_FUNC(IDX, SIZE, OPT) \
c->put_vp8_epel_pixels_tab[IDX][0][2] = ff_put_vp8_epel ## SIZE ## _h6_ ## OPT; \
c->put_vp8_epel_pixels_tab[IDX][2][0] = ff_put_vp8_epel ## SIZE ## _v6_ ## OPT; \
c->put_vp8_epel_pixels_tab[IDX][2][2] = ff_put_vp8_epel ## SIZE ## _h6v6_ ## OPT
#define VP8_MC_FUNC(IDX, SIZE, OPT) \
c->put_vp8_epel_pixels_tab[IDX][0][1] = ff_put_vp8_epel ## SIZE ## _h4_ ## OPT; \
c->put_vp8_epel_pixels_tab[IDX][1][0] = ff_put_vp8_epel ## SIZE ## _v4_ ## OPT; \
c->put_vp8_epel_pixels_tab[IDX][1][1] = ff_put_vp8_epel ## SIZE ## _h4v4_ ## OPT; \
c->put_vp8_epel_pixels_tab[IDX][1][2] = ff_put_vp8_epel ## SIZE ## _h6v4_ ## OPT; \
c->put_vp8_epel_pixels_tab[IDX][2][1] = ff_put_vp8_epel ## SIZE ## _h4v6_ ## OPT; \
VP8_LUMA_MC_FUNC(IDX, SIZE, OPT)
#define VP8_BILINEAR_MC_FUNC(IDX, SIZE, OPT) \
c->put_vp8_bilinear_pixels_tab[IDX][0][1] = ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT; \
c->put_vp8_bilinear_pixels_tab[IDX][0][2] = ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT; \
c->put_vp8_bilinear_pixels_tab[IDX][1][0] = ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT; \
c->put_vp8_bilinear_pixels_tab[IDX][1][1] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \
c->put_vp8_bilinear_pixels_tab[IDX][1][2] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \
c->put_vp8_bilinear_pixels_tab[IDX][2][0] = ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT; \
c->put_vp8_bilinear_pixels_tab[IDX][2][1] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \
c->put_vp8_bilinear_pixels_tab[IDX][2][2] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT
av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
{
mm_flags = mm_support();
#if HAVE_YASM
if (mm_flags & FF_MM_MMX) {
c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx;
c->vp8_idct_add = ff_vp8_idct_add_mmx;
c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_mmx;
c->put_vp8_epel_pixels_tab[0][0][0] =
c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmx;
c->put_vp8_epel_pixels_tab[1][0][0] =
c->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmx;
c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmx;
c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmx;
c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmx;
c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmx;
c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmx;
c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmx;
c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_mmx;
c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_mmx;
c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmx;
c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_mmx;
}
if (mm_flags & FF_MM_MMX2) {
VP8_LUMA_MC_FUNC(0, 16, mmxext);
VP8_MC_FUNC(1, 8, mmxext);
VP8_MC_FUNC(2, 4, mmxext);
VP8_BILINEAR_MC_FUNC(0, 16, mmxext);
VP8_BILINEAR_MC_FUNC(1, 8, mmxext);
VP8_BILINEAR_MC_FUNC(2, 4, mmxext);
c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmxext;
c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmxext;
c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmxext;
c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmxext;
c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmxext;
c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmxext;
c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_mmxext;
c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_mmxext;
c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmxext;
c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_mmxext;
}
if (mm_flags & FF_MM_SSE) {
c->put_vp8_epel_pixels_tab[0][0][0] =
c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_sse;
}
if (mm_flags & (FF_MM_SSE2|FF_MM_SSE2SLOW)) {
VP8_LUMA_MC_FUNC(0, 16, sse2);
VP8_MC_FUNC(1, 8, sse2);
VP8_BILINEAR_MC_FUNC(0, 16, sse2);
VP8_BILINEAR_MC_FUNC(1, 8, sse2);
c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_sse2;
c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_sse2;
c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_sse2;
c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_sse2;
c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_mmxext;
c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmxext;
}
if (mm_flags & FF_MM_SSE2) {
c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_sse2;
c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_sse2;
}
if (mm_flags & FF_MM_SSSE3) {
VP8_LUMA_MC_FUNC(0, 16, ssse3);
VP8_MC_FUNC(1, 8, ssse3);
VP8_MC_FUNC(2, 4, ssse3);
VP8_BILINEAR_MC_FUNC(0, 16, ssse3);
VP8_BILINEAR_MC_FUNC(1, 8, ssse3);
VP8_BILINEAR_MC_FUNC(2, 4, ssse3);
c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_ssse3;
c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_ssse3;
c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_ssse3;
c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_ssse3;
c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_ssse3;
c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_ssse3;
c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_ssse3;
c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_ssse3;
}
if (mm_flags & FF_MM_SSE4) {
c->vp8_idct_dc_add = ff_vp8_idct_dc_add_sse4;
}
#endif
}
| 1threat
|
iPad connected through USB disappears off Safari Develop menu after a short while on iOS 11 : <p>iPad is on iOS 11, trying to debug using safari develop menu. I am using a MacBook Pro 2016 on MacOS Sierra. The iPad name appears in the develop menu for about 5 seconds. After this time it disappears.</p>
<p>If I unplug the iPad and re-plug it, the name appears, again, only briefly. Then it disappears again.</p>
<p>Anyone sharing the same issue? Any fixes would be appreciated.</p>
| 0debug
|
For(a,b) function (or not)? : <p>I met a line in python code:</p>
<pre><code>onevariable for(a,b) in range(1,10)
</code></pre>
<p>Can you help me how it should be 'read'? Couldn't 'google' any example of 'for' with brackets. Very strange line</p>
| 0debug
|
How do I include .dll file in executable using pyinstaller? : <p>I want to generate a single executable file from my python script.
For this I use pyinstaller. I had issues with mkl libraries because I use numpy in the script.</p>
<p>I used this <a href="https://github.com/pyinstaller/pyinstaller/issues/1881" rel="noreferrer" title="hook">hook</a> so solve the issue, it worked fine. But it does not work if I copy the single executable file to another directory and execute it. I guess I have to copy the hook also. But I just want to have one single file that I can use at other computers without copying <code>.dll's</code> or the hook.</p>
<p>I also changed the <code>.spec</code> file as described <a href="https://pythonhosted.org/PyInstaller/spec-files.html" rel="noreferrer">here</a> and added the necessary files to the <code>binaries</code>-variable. That also works as long as the <code>.dll's</code> are in the provided directory for the <code>binaries</code>-variable , but that won't work when I use the executable on a computer that doesn't have these <code>.dll's</code>.</p>
<p>I tried using the <code>--hidden-import= FILENAME</code> option. This also solves the issue, but just when the <code>.dll's</code> are provided somewhere.</p>
<p>What I'm looking for is a possibility to bundle the <code>.dll's</code> into the single executable file so that I have one file that works independently.</p>
| 0debug
|
Equation solving with absolute in it : <p>I have an equation which I want to simplify in order to retrieve the solution. But the equation contains absolute in it. How can it be more simplified?</p>
<pre><code>d = abs(X²-vs²)/2*a1 + abs(vf²-X²)/2*a2
</code></pre>
<p><strong>abs</strong> is the absolute of the value inside the parenthesis</p>
<p><strong>X</strong> is the unknown and we know <strong>d, vs, a1, vf</strong> and <strong>a2</strong></p>
<p>So in the end the equation would be X = ....</p>
| 0debug
|
Preserving variable contents in bash : I have the following code:
WD="$(pwd)"
echo $WD
cd
echo $WD
Say I am working under /home/USER/sandbox, the output of the above is:
/home/USER/sandbox
/home/USER
Why does WD not preserve its value? Is there any way to get it to preserve its value?
| 0debug
|
How do I enter into another form by clicking 5 buttons? : <p>I'm trying to write a code in Java. I've created a form where I have to type a code by clicking the buttons I've created. So, when I type btn1, btn2, btn3, btn4 and btn5 and then I click the 'Enter' button, it will lead me to the form i want. I've tried many different options but I just can't find a way to go through it. If somebody could help me, I'd be so thankful.
P.s I'm new at Java, so forgive me if i could'nt explain the thing properly.</p>
<pre><code> private void btnEnterStateChanged(javax.swing.event.ChangeEvent evt) {
// TODO add your handling code here:
if(btn1.isSelected() && btn2.isSelected()
&& btn3.isSelected() && btn4.isSelected() && btn4.isSelected())
{
LoginForm login = new LoginForm();
login.setVisible(true);
}
else {
JOptionPane.showMessageDialog(this,
"Wrong code!");
}
}
</code></pre>
| 0debug
|
Why does this code output a syntax error? (python) : <pre><code>from random import randint as random
names = ['Ninja','xXx_leet1337_xXx','robert87','nic0','y2ih8','roxky','Wierdio','a3rt','BeastyBoy','bobby']
active_players = names
deaths = (' shotgunned ', ' sniped ', ' ran over ', ' rifled ')
def findDeath():
current_death = deaths[random(0,3)
while len(active_players) >= 2:
findDeath()
if current_death = ' sniped ':
sniper_length = str(random(5,100))+ 'm'
print(active_players[random(0,9)]+' '+current_death+'from '+sniper_length)
else:
print(active_players)
</code></pre>
<p>Output:
File "..\Playground\", line 11
while len(active_players) >= 2:
^
SyntaxError: invalid syntax</p>
<p>Why?</p>
| 0debug
|
How to speed up c code? : <p>I am wondering if there is any way to speed up this simple .c program I made alongside a friend. Is there any things I could change to clean it up as well? And maybe add a pop up to say how many images it has processed. Thanks!</p>
<pre><code>#include "stdio.h"
#include "string.h"
#include "malloc.h"
#define DDS_MAGIC "DDS "
int ipos[10240];
int iposind=0;
int tfilelen;
char* TransBuf=NULL;
int main(int argc, char** argv){
int i,r;
FILE* sFile=NULL;
FILE* tFile=NULL;
char ifn[256];
char ofn[256];
char qc;
if (argc !=2){
printf("usage: %s filename\n",argv[0]);
return 0;
}
strcpy(ifn,argv[1]);
sFile=fopen(argv[1],"rb");
fseek(sFile,0,SEEK_END);
tfilelen=ftell(sFile);
fseek(sFile,0,SEEK_SET);
TransBuf=(char*)malloc(tfilelen);
for(i=0,r=0;r<tfilelen;){
/* read the file in */
i=fread(TransBuf+r,1,tfilelen-r,sFile);
if(i>0)r+=i;
}
qc=DDS_MAGIC[0];
for(i=0;i<tfilelen;i++){
if(TransBuf[i]!=qc)continue;
if(strncmp(DDS_MAGIC,TransBuf+i,4)==0){
ipos[iposind]=i;
iposind++;
}
}
ipos[iposind]=tfilelen;
for(i=0;i<iposind;i++){
char* s;
int l;
int j;
s=TransBuf+ipos[i];
l=ipos[i+1]-ipos[i];
if(l<4)continue; /* don't write out dds files with no data*/
/* write each dds segment to it's own file */
sprintf(ofn,"%s_%d.dds",ifn,i);
tFile=fopen(ofn,"w+b");
for(j=0,r=0;r<l;){
j=fwrite(s+j,1,l-r,tFile);
if(j>0)r+=j;
}
fclose(tFile);
system("pause");
}
printf("extracted %d files\n",i);
return 0;
}
</code></pre>
| 0debug
|
Parsing JSON String Android : <p>how can i parse such JSON string (but i have dynamic values)</p>
<pre><code>{
"data":{
"dynamicValue1":{
"serial":"1",
"name":"ABC"
},
"dynamicValue2":{
"serial":"2",
"name":"DEF"
},
"dynamicValue3":{
"serial":"3",
"name":"GHI"
}
}
}
</code></pre>
<p>most codes i saw before for static values, but i want help please thanks in advance.</p>
| 0debug
|
convert "unspecified encoding" string to a binary string of zeros and ones : well ,i have an assignment to implement the operation modes of the DES algorithm
in CBC mode : i am stuck at the point where the output of the encryption function gives bytes like this : b'\xe4\x06-\x95\xf5!P4'
(i am using DES library from Crypto.Cipher)
i don't know what is that representation or how to convert it to a binary string of zeros and ones , to xor it with the 2nd plain text.
any help would be highly appreciated
| 0debug
|
How to stop moving UIVIew on keyboad appearing in iOS? : Whenever I click on text field UiView will move up. How to stop this.
| 0debug
|
How to install local packages using pip as part of a docker build? : <p>I've got a package that I want to build into a docker image which depends on an adjacent package on my system.</p>
<p>My <code>requirements.txt</code> looks something like this:</p>
<pre>
-e ../other_module
numpy==1.0.0
flask==0.12.5
</pre>
<p>When I call <code>pip install -r requirements.txt</code> in a virtualenv this works fine. However, if I call this in a Dockerfile, e.g.:</p>
<pre>
ADD requirements.txt /app
RUN pip install -r requirements.txt
</pre>
<p>and run using <code>docker build .</code> I get an error saying the following:</p>
<p><code>../other_module should either be a path to a local project or a VCS url beginning with svn+, git+, hg+, or bzr+</code></p>
<p>What, if anything, am I doing wrong here?</p>
| 0debug
|
background-color in css is not working when navigating from one form to another : <p>When I try to navigate from one form to another form, background-color in css is not working.</p>
<p>login_form_success.php</p>
<pre><code><div class="alert alert-success">Welcome <?php echo $_SESSION['uname']; ?>Signed in !</div>
</code></pre>
<p>style.css</p>
<pre><code>.alert alert-success{
background-color: greenyellow;
}
</code></pre>
| 0debug
|
int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
AVFrame *frame,
int *got_frame_ptr,
AVPacket *avpkt)
{
AVCodecInternal *avci = avctx->internal;
int planar, channels;
int ret = 0;
*got_frame_ptr = 0;
avctx->pkt = avpkt;
if (!avpkt->data && avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
return AVERROR(EINVAL);
}
apply_param_change(avctx, avpkt);
avcodec_get_frame_defaults(frame);
if (!avctx->refcounted_frames)
av_frame_unref(&avci->to_free);
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);
if (ret >= 0 && *got_frame_ptr) {
avctx->frame_number++;
frame->pkt_dts = avpkt->dts;
if (frame->format == AV_SAMPLE_FMT_NONE)
frame->format = avctx->sample_fmt;
if (!avctx->refcounted_frames) {
avci->to_free = *frame;
avci->to_free.extended_data = avci->to_free.data;
memset(frame->buf, 0, sizeof(frame->buf));
frame->extended_buf = NULL;
frame->nb_extended_buf = 0;
}
} else if (frame->data[0])
av_frame_unref(frame);
}
planar = av_sample_fmt_is_planar(frame->format);
channels = av_get_channel_layout_nb_channels(frame->channel_layout);
if (!(planar && channels > AV_NUM_DATA_POINTERS))
frame->extended_data = frame->data;
return ret;
}
| 1threat
|
void avpriv_tak_parse_streaminfo(GetBitContext *gb, TAKStreamInfo *s)
{
uint64_t channel_mask = 0;
int frame_type, i;
s->codec = get_bits(gb, TAK_ENCODER_CODEC_BITS);
skip_bits(gb, TAK_ENCODER_PROFILE_BITS);
frame_type = get_bits(gb, TAK_SIZE_FRAME_DURATION_BITS);
s->samples = get_bits64(gb, TAK_SIZE_SAMPLES_NUM_BITS);
s->data_type = get_bits(gb, TAK_FORMAT_DATA_TYPE_BITS);
s->sample_rate = get_bits(gb, TAK_FORMAT_SAMPLE_RATE_BITS) +
TAK_SAMPLE_RATE_MIN;
s->bps = get_bits(gb, TAK_FORMAT_BPS_BITS) +
TAK_BPS_MIN;
s->channels = get_bits(gb, TAK_FORMAT_CHANNEL_BITS) +
TAK_CHANNELS_MIN;
if (get_bits1(gb)) {
skip_bits(gb, TAK_FORMAT_VALID_BITS);
if (get_bits1(gb)) {
for (i = 0; i < s->channels; i++) {
int value = get_bits(gb, TAK_FORMAT_CH_LAYOUT_BITS);
if (value < FF_ARRAY_ELEMS(tak_channel_layouts))
channel_mask |= tak_channel_layouts[value];
}
}
}
s->ch_layout = channel_mask;
s->frame_samples = tak_get_nb_samples(s->sample_rate, frame_type);
}
| 1threat
|
why it can not work when i click on the operation first? : <p>I try to use this code but it works when i click number first when i
click on operation first. it doesn't work.example sin(30) not work
when i click 2sin(30). it works. can anyone help me?
</p>
<pre>
public class MainActivity extends ActionBarActivity {
// IDs of all the numeric buttons
private int[] numericButtons = {R.id.btnZero, R.id.btnOne, R.id.btnTwo, R.id.btnThree, R.id.btnFour, R.id.btnFive, R.id.btnSix, R.id.btnSeven, R.id.btnEight, R.id.btnNine};
// IDs of all the operator buttons
private int[] operatorButtons = {R.id.btnAdd, R.id.btnSubtract, R.id.btnMultiply, R.id.btnDivide,R.id.buttonSqr,R.id.tan,R.id.cos,
R.id.sin,R.id.open_bracket,R.id.close_bracket};
// TextView used to display the output
private EditText txtScreen;
// Represent whether the lastly pressed key is numeric or not
private boolean lastNumeric;
// Represent that current state is in error or not
private boolean stateError;
// If true, do not allow to add another DOT
private boolean lastDot;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Find the TextView
this.txtScreen = (EditText) findViewById(R.id.txtScreen);
// Find and set OnClickListener to numeric buttons
setNumericOnClickListener();
// Find and set OnClickListener to operator buttons, equal button and decimal point button
setOperatorOnClickListener();
}
//Find and set OnClickListener to numeric buttons.
private void setNumericOnClickListener() {
// Create a common OnClickListener
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
// Just append/set the text of clicked button
Button button = (Button) v;
if (stateError) {
// If current state is Error, replace the error message
txtScreen.setText(button.getText());
stateError = false;
} else {
// If not, already there is a valid expression so append to it
txtScreen.append(button.getText());
}
// Set the flag
lastNumeric = true;
}
};
// Assign the listener to all the numeric buttons
for (int id : numericButtons) {
findViewById(id).setOnClickListener(listener);
}
}
//Find and set OnClickListener to operator buttons, equal button and decimal point button.
private void setOperatorOnClickListener() {
// Create a common OnClickListener for operators
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
// If the current state is Error do not append the operator
// If the last input is number only, append the operator
if (lastNumeric && !stateError) {
Button button = (Button) v;
txtScreen.append(button.getText());
lastNumeric = false;
lastDot = false; // Reset the DOT flag
}
}
};
// Assign the listener to all the operator buttons
for (int id : operatorButtons) {
findViewById(id).setOnClickListener(listener);
}
// Decimal point
findViewById(R.id.btnDot).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (lastNumeric && !stateError && !lastDot) {
txtScreen.append(".");
lastNumeric = false;
lastDot = true;
}
}
});
//delete
findViewById(R.id.btndel).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (txtScreen.getText().toString().length() > 1) {
//remove string
String screen_new = txtScreen.getText().toString().substring(0, txtScreen.getText().toString().length() - 1);
txtScreen.setText(screen_new);
} else {
txtScreen.setText("");
}
lastNumeric = false;
stateError = false;
lastDot = false;
}
});
// Clear button
findViewById(R.id.btnClear).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
txtScreen.setText(""); // Clear the screen
// Reset all the states and flags
lastNumeric = false;
stateError = false;
lastDot = false;
}
});
// Equal button
findViewById(R.id.btnEqual).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onEqual();
}
});
}
//Logic to calculate the solution
private void onEqual() {
// If the current state is error, nothing to do.
// If the last input is a number only, solution can be found.
if (lastNumeric && !stateError) {
// Read the expression
String txt = txtScreen.getText().toString();
txt = txt.replaceAll("x", "*").replaceAll("÷", "/");
// Create an Expression (A class from exp4j library)
Expression expression = new ExpressionBuilder(txt).build();
try {
// Calculate the result and display
double result = expression.evaluate();
txtScreen.setText(Double.toString(result));
lastDot = true; // Result contains a dot
} catch (ArithmeticException ex) {
// Display an error message
txtScreen.setText("Error");
stateError = true;
lastNumeric = false;
}
}
}
}
</pre>
| 0debug
|
static void mov_parse_stsd_subtitle(MOVContext *c, AVIOContext *pb,
AVStream *st, MOVStreamContext *sc,
int size)
{
MOVAtom fake_atom = { .size = size };
if (st->codec->codec_tag != AV_RL32("mp4s"))
mov_read_glbl(c, pb, fake_atom);
st->codec->width = sc->width;
st->codec->height = sc->height;
}
| 1threat
|
Its hard to explain but i needs some assistence : Module Module1
Function UnexpectedInput(y, x)
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("Unexpected Input ! ( " & y & " ) ")
Console.WriteLine("Please Try Again...")
Console.ResetColor()
Console.WriteLine("")
Return x
End Function
Dim choice As String
Sub Main()
Console.WriteLine("Please Register to use this program. If you already have an account please choose Loign.")
Space(1)
Console.WriteLine("1. Login ")
Console.WriteLine("2. Register ")
Console.WriteLine("3. Exit ")
Space(1)
Console.WriteLine("##########################")
choice = Console.ReadLine()
Console.WriteLine("##########################")
If choice = "1" Then
Console.WriteLine("Login()")
Console.ReadLine()
ElseIf choice = "2" Then
Console.WriteLine("Register()")
Console.ReadLine()
ElseIf choice = "3" Then
Console.WriteLine("Exitnow()")
Console.ReadLine()
Else
UnexpectedInput(choice, "Main()")
End If
End Sub
End Module
------------------------------------------------------------------------------
The return x doesn't work it just closes the application. I had it working and now it doesn't work... I'm completely stuck and I'm a newbie so if you do fix this please explain how and why it wasn't working in fairly normal words . Thank you for your time and please get back to me ASAP :) XD
| 0debug
|
static inline void stw_phys_internal(target_phys_addr_t addr, uint32_t val,
enum device_endian endian)
{
uint8_t *ptr;
MemoryRegionSection *section;
section = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
addr = memory_region_section_addr(section, addr);
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
val = bswap16(val);
}
#else
if (endian == DEVICE_BIG_ENDIAN) {
val = bswap16(val);
}
#endif
io_mem_write(section->mr, addr, val, 2);
} else {
unsigned long addr1;
addr1 = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr);
ptr = qemu_get_ram_ptr(addr1);
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
stw_le_p(ptr, val);
break;
case DEVICE_BIG_ENDIAN:
stw_be_p(ptr, val);
break;
default:
stw_p(ptr, val);
break;
}
invalidate_and_set_dirty(addr1, 2);
}
}
| 1threat
|
How to display key from value in given dictionary in python? : <p>I want a function which will take value from user and display the respective key of the dictionary</p>
<p>Ex. d={'name':'ayush','age':21,'Hobby':'cricket'}</p>
<p>Please enter the value : ayush
Key related to entered value is: name</p>
| 0debug
|
int cpu_signal_handler(int host_signum, void *pinfo,
void *puc)
{
siginfo_t *info = pinfo;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
ucontext_t *uc = puc;
#else
ucontext_t *uc = puc;
#endif
unsigned long pc;
int is_write;
pc = IAR_sig(uc);
is_write = 0;
#if 0
if (DSISR_sig(uc) & 0x00800000) {
is_write = 1;
}
#else
if (TRAP_sig(uc) != 0x400 && (DSISR_sig(uc) & 0x02000000)) {
is_write = 1;
}
#endif
return handle_cpu_signal(pc, (unsigned long)info->si_addr,
is_write, &uc->uc_sigmask);
}
| 1threat
|
How to api-query for the default vhost : <p>The RabbitMQ <a href="https://www.rabbitmq.com/access-control.html" rel="noreferrer">documentation</a> states:</p>
<pre><code>Default Virtual Host and User
When the server first starts running, and detects that its database is uninitialised or has been deleted, it initialises a fresh database with the following resources:
a virtual host named /
</code></pre>
<p>The <a href="http://hg.rabbitmq.com/rabbitmq-management/raw-file/3646dee55e02/priv/www-api/help.html" rel="noreferrer">api</a> has things like:</p>
<pre><code>/api/exchanges/#vhost#/?name?/bindings
</code></pre>
<p>where "?name?" is a specific exchange-name.</p>
<p>However, what does one put in for the <strong>#vhost#</strong> for the <strong><em>default</em></strong>-vhost?</p>
| 0debug
|
Negation in condition while sending FCM message : <p>I am subscribing to a topic which is my application version in Android.</p>
<pre><code>FirebaseMessaging.getInstance().subscribeToTopic(APP_VERSION);
</code></pre>
<p>Now every time I launch an update, I have to unsubscribe to an old version and subscribe to a new version so if I send an update notification only old users will get it. Instead, it would be great if I just negate a version. </p>
<pre><code>"condition": "!'2.1.1' in topics",
</code></pre>
<p>Is something like this exists in FCM?</p>
| 0debug
|
Vuetify - How to set background color : <p>I am using Vuetify with the Light theme. By default this sets the background of the main content to a light grey. I need it to be white.</p>
<p>I'd like to override this by modifying the stylus variables, but I can't seem to figure out which variable sets the background color. </p>
<p>I followed all the steps in the <a href="https://vuetifyjs.com/en/style/theme" rel="noreferrer">docs</a>, and I can change the font throughout the app by setting <code>$body-font-family = 'Open Sans'</code> in my main.styl file (so I know I have the webpack build set up correctly)</p>
<p>I have tried <code>$body-bg-light = '#fff'</code> in my main.styl, but that doesn't seem to change anything at all. If I set <code>$material-light.background = '#fff'</code> I get an error.</p>
| 0debug
|
import math
def volume_cone(r,h):
volume = (1.0/3) * math.pi * r * r * h
return volume
| 0debug
|
static int vorbis_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
vorbis_context *vc = avctx->priv_data;
AVFrame *frame = data;
GetBitContext *gb = &vc->gb;
float *channel_ptrs[255];
int i, len, ret;
av_dlog(NULL, "packet length %d \n", buf_size);
frame->nb_samples = vc->blocksize[1] / 2;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
if (vc->audio_channels > 8) {
for (i = 0; i < vc->audio_channels; i++)
channel_ptrs[i] = (float *)frame->extended_data[i];
} else {
for (i = 0; i < vc->audio_channels; i++) {
int ch = ff_vorbis_channel_layout_offsets[vc->audio_channels - 1][i];
channel_ptrs[ch] = (float *)frame->extended_data[i];
}
}
init_get_bits(gb, buf, buf_size*8);
if ((len = vorbis_parse_audio_packet(vc, channel_ptrs)) <= 0)
return len;
if (!vc->first_frame) {
vc->first_frame = 1;
*got_frame_ptr = 0;
return buf_size;
}
av_dlog(NULL, "parsed %d bytes %d bits, returned %d samples (*ch*bits) \n",
get_bits_count(gb) / 8, get_bits_count(gb) % 8, len);
frame->nb_samples = len;
*got_frame_ptr = 1;
return buf_size;
}
| 1threat
|
How to concatenate this array : <p>How do i concatenate these two arrays to get the expected output?</p>
<pre class="lang-js prettyprint-override"><code>let bidder= [
[1,2,3,4],
[5,6,7,8]
]
let arr1 = [9,10,11,12]
</code></pre>
<p>expected result</p>
<pre class="lang-js prettyprint-override"><code>[
(4) [...],
(4) [...],
(4) [...],
]
</code></pre>
| 0debug
|
void signal_init(void)
{
struct sigaction act;
int i;
sigfillset(&act.sa_mask);
act.sa_flags = SA_SIGINFO;
act.sa_sigaction = host_signal_handler;
for(i = 1; i < NSIG; i++) {
sigaction(i, &act, NULL);
}
memset(sigact_table, 0, sizeof(sigact_table));
first_free = &sigqueue_table[0];
for(i = 0; i < MAX_SIGQUEUE_SIZE - 1; i++)
sigqueue_table[i].next = &sigqueue_table[i + 1];
sigqueue_table[MAX_SIGQUEUE_SIZE - 1].next = NULL;
}
| 1threat
|
int check_codec_match(AVCodecContext *ccf, AVCodecContext *ccs, int stream)
{
int matches = 1;
#define CHECK_CODEC(x) (ccf->x != ccs->x)
if (CHECK_CODEC(codec_id) || CHECK_CODEC(codec_type)) {
http_log("Codecs do not match for stream %d\n", stream);
matches = 0;
} else if (CHECK_CODEC(bit_rate) || CHECK_CODEC(flags)) {
http_log("Codec bitrates do not match for stream %d\n", stream);
matches = 0;
} else if (ccf->codec_type == AVMEDIA_TYPE_VIDEO) {
if (CHECK_CODEC(time_base.den) ||
CHECK_CODEC(time_base.num) ||
CHECK_CODEC(width) ||
CHECK_CODEC(height)) {
http_log("Codec width, height or framerate do not match for stream %d\n", stream);
matches = 0;
}
} else if (ccf->codec_type == AVMEDIA_TYPE_AUDIO) {
if (CHECK_CODEC(sample_rate) ||
CHECK_CODEC(channels) ||
CHECK_CODEC(frame_size)) {
http_log("Codec sample_rate, channels, frame_size do not match for stream %d\n", stream);
matches = 0;
}
} else {
http_log("Unknown codec type for stream %d\n", stream);
matches = 0;
}
return matches;
}
| 1threat
|
No provider for ControlContainer when a child component has a ngModelGroup : <p>I can't seem to figure this out, it's simply not working.</p>
<p>This is the original <a href="http://embed.plnkr.co/LLf7Il/" rel="noreferrer">plunker</a> which is written by Pascal Prekht , which is an explanation on template driven forms: </p>
<p>And <a href="https://embed.plnkr.co/Q8pjSIVJHhfubILtvqWw/" rel="noreferrer">here</a> is my fork which is exactly the same thing , except I'm trying to load one of the fieldsets as a separate child component.</p>
<p>Here is the code :</p>
<pre><code>@Component({
selector:'form-group-component',
template:`
<fieldset ngModelGroup="anotherAddress">
<div>
<label>Street2:</label>
<input type="text" name="street2" ngModel>
</div>
</fieldset>
`
})
export class FormGroupComponent{
}
@Component({
selector: 'form-component',
directives:[FormGroupComponent],
template: `
<form #form="ngForm">
<form-group-component></form-group-component>
<fieldset ngModelGroup="address">
<div>
<label>Street:</label>
<input type="text" name="street" ngModel>
</div>
<div>
<label>Zip:</label>
<input type="text" name="zip" ngModel>
</div>
<div>
<label>City:</label>
<input type="text" name="city" ngModel>
</div>
</fieldset>
</form>
`
})
export class FormComponent {
}
</code></pre>
<p>So after cutting one of the feildsets and loading it inside a seperate directive , it won't work anymore!,</p>
<p>There are couple of closed issues , but non of them is working.</p>
<p><a href="https://github.com/mgechev/angular2-seed/issues/399" rel="noreferrer">This </a>
and <a href="https://github.com/angular/angular/issues/6374" rel="noreferrer">This</a></p>
| 0debug
|
I GOT ERROR "missing ) after argument list" : got error "missing ) after the argument list"
$('.next-btn').append("<a class="actionsubmit" ng-click="onSubmit('hello.html')">Check</a>");
| 0debug
|
How to recover deleted iPython Notebooks : <p>I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash).</p>
<p>Does anyone know how I can recover the notebook? I am using Mac OS X.</p>
<p>Thanks!</p>
| 0debug
|
static int transcode(void)
{
int ret, i;
AVFormatContext *is, *os;
OutputStream *ost;
InputStream *ist;
uint8_t *no_packet;
int no_packet_count = 0;
int64_t timer_start;
int key;
if (!(no_packet = av_mallocz(nb_input_files)))
exit_program(1);
ret = transcode_init();
if (ret < 0)
goto fail;
if (!using_stdin) {
av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n");
}
timer_start = av_gettime();
for (; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
int64_t cur_time= av_gettime();
if (!using_stdin) {
static int64_t last_time;
if (received_nb_signals)
break;
if(cur_time - last_time >= 100000 && !run_as_daemon){
key = read_key();
last_time = cur_time;
}else
key = -1;
if (key == 'q')
break;
if (key == '+') av_log_set_level(av_log_get_level()+10);
if (key == '-') av_log_set_level(av_log_get_level()-10);
if (key == 's') qp_hist ^= 1;
if (key == 'h'){
if (do_hex_dump){
do_hex_dump = do_pkt_dump = 0;
} else if(do_pkt_dump){
do_hex_dump = 1;
} else
do_pkt_dump = 1;
av_log_set_level(AV_LOG_DEBUG);
}
if (key == 'c' || key == 'C'){
char buf[4096], target[64], command[256], arg[256] = {0};
double time;
int k, n = 0;
fprintf(stderr, "\nEnter command: <target> <time> <command>[ <argument>]\n");
i = 0;
while ((k = read_key()) != '\n' && k != '\r' && i < sizeof(buf)-1)
if (k > 0)
buf[i++] = k;
buf[i] = 0;
if (k > 0 &&
(n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s",
target, time, command, arg);
for (i = 0; i < nb_filtergraphs; i++) {
FilterGraph *fg = filtergraphs[i];
if (fg->graph) {
if (time < 0) {
ret = avfilter_graph_send_command(fg->graph, target, command, arg, buf, sizeof(buf),
key == 'c' ? AVFILTER_CMD_FLAG_ONE : 0);
fprintf(stderr, "Command reply for stream %d: ret:%d res:%s\n", i, ret, buf);
} else {
ret = avfilter_graph_queue_command(fg->graph, target, command, arg, 0, time);
}
}
}
} else {
av_log(NULL, AV_LOG_ERROR,
"Parse error, at least 3 arguments were expected, "
"only %d given in string '%s'\n", n, buf);
}
}
if (key == 'd' || key == 'D'){
int debug=0;
if(key == 'D') {
debug = input_streams[0]->st->codec->debug<<1;
if(!debug) debug = 1;
while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE))
debug += debug;
}else
if(scanf("%d", &debug)!=1)
fprintf(stderr,"error parsing debug value\n");
for(i=0;i<nb_input_streams;i++) {
input_streams[i]->st->codec->debug = debug;
}
for(i=0;i<nb_output_streams;i++) {
ost = output_streams[i];
ost->st->codec->debug = debug;
}
if(debug) av_log_set_level(AV_LOG_DEBUG);
fprintf(stderr,"debug=%d\n", debug);
}
if (key == '?'){
fprintf(stderr, "key function\n"
"? show this help\n"
"+ increase verbosity\n"
"- decrease verbosity\n"
"c Send command to filtergraph\n"
"D cycle through available debug modes\n"
"h dump packets/hex press to cycle through the 3 states\n"
"q quit\n"
"s Show QP histogram\n"
);
}
}
if (!need_output()) {
av_log(NULL, AV_LOG_VERBOSE, "No more output streams to write to, finishing.\n");
break;
}
file_index = select_input_file(no_packet);
if (file_index < 0) {
if (no_packet_count) {
no_packet_count = 0;
memset(no_packet, 0, nb_input_files);
usleep(10000);
continue;
}
break;
}
is = input_files[file_index]->ctx;
ret = av_read_frame(is, &pkt);
if (ret == AVERROR(EAGAIN)) {
no_packet[file_index] = 1;
no_packet_count++;
continue;
}
if (ret < 0) {
input_files[file_index]->eof_reached = 1;
for (i = 0; i < input_files[file_index]->nb_streams; i++) {
ist = input_streams[input_files[file_index]->ist_index + i];
if (ist->decoding_needed)
output_packet(ist, NULL);
}
if (opt_shortest)
break;
else
continue;
}
no_packet_count = 0;
memset(no_packet, 0, nb_input_files);
if (do_pkt_dump) {
av_pkt_dump_log2(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump,
is->streams[pkt.stream_index]);
}
if (pkt.stream_index >= input_files[file_index]->nb_streams)
goto discard_packet;
ist_index = input_files[file_index]->ist_index + pkt.stream_index;
ist = input_streams[ist_index];
if (ist->discard)
goto discard_packet;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts *= ist->ts_scale;
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts *= ist->ts_scale;
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s "
"next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%"PRId64"\n",
ist_index, av_get_media_type_string(ist->st->codec->codec_type),
av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &ist->st->time_base),
av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &ist->st->time_base),
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base),
input_files[ist->file_index]->ts_offset);
}
if (pkt.dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && !copy_ts) {
int64_t pkt_dts = av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
int64_t delta = pkt_dts - ist->next_dts;
if (is->iformat->flags & AVFMT_TS_DISCONT) {
if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&
ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_dts+1<ist->pts){
input_files[ist->file_index]->ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, input_files[ist->file_index]->ts_offset);
pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
}
} else {
if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_dts+1<ist->pts){
av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt.dts, ist->next_dts, pkt.stream_index);
pkt.dts = AV_NOPTS_VALUE;
}
if (pkt.pts != AV_NOPTS_VALUE){
int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q);
delta = pkt_pts - ist->next_dts;
if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_pts+1<ist->pts) {
av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt.pts, ist->next_dts, pkt.stream_index);
pkt.pts = AV_NOPTS_VALUE;
}
}
}
}
if ((ret = output_packet(ist, &pkt)) < 0 ||
((ret = poll_filters()) < 0 && ret != AVERROR_EOF)) {
char buf[128];
av_strerror(ret, buf, sizeof(buf));
av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n",
ist->file_index, ist->st->index, buf);
if (exit_on_error)
exit_program(1);
av_free_packet(&pkt);
continue;
}
discard_packet:
av_free_packet(&pkt);
print_report(0, timer_start, cur_time);
}
for (i = 0; i < nb_input_streams; i++) {
ist = input_streams[i];
if (!input_files[ist->file_index]->eof_reached && ist->decoding_needed) {
output_packet(ist, NULL);
}
}
poll_filters();
flush_encoders();
term_exit();
for (i = 0; i < nb_output_files; i++) {
os = output_files[i]->ctx;
av_write_trailer(os);
}
print_report(1, timer_start, av_gettime());
for (i = 0; i < nb_output_streams; i++) {
ost = output_streams[i];
if (ost->encoding_needed) {
av_freep(&ost->st->codec->stats_in);
avcodec_close(ost->st->codec);
}
}
for (i = 0; i < nb_input_streams; i++) {
ist = input_streams[i];
if (ist->decoding_needed) {
avcodec_close(ist->st->codec);
}
}
ret = 0;
fail:
av_freep(&no_packet);
if (output_streams) {
for (i = 0; i < nb_output_streams; i++) {
ost = output_streams[i];
if (ost) {
if (ost->stream_copy)
av_freep(&ost->st->codec->extradata);
if (ost->logfile) {
fclose(ost->logfile);
ost->logfile = NULL;
}
av_freep(&ost->st->codec->subtitle_header);
av_free(ost->forced_kf_pts);
av_dict_free(&ost->opts);
}
}
}
return ret;
}
| 1threat
|
with node.js on app engine, is it better to use task queues or pub/sub : <p>We have been moving our apis from python to node. We have used task queues with our Python app engine apis. With node.js now supported on app engine, do you suggest we use task queues or cloud pub/sub for tasks? What would the pros / cons be for each including reliability, portability, etc.</p>
| 0debug
|
Mp chart-how to set lable for xaxis ?in left side"amount" lable how to add it programmatically? : [enter image description here][1]
[1]: https://i.stack.imgur.com/tfSEu.png
Mp chart-how to set lable for xaxis ?in left side "amount" lable how to add it programmatically?
Thanks in advance
| 0debug
|
Distingusih between numbers and alphabet in a string : I am trying to build a TCPIP communication between a server and a client in visual studio , the client will accept a string from the keyboard, and he will send the string to the server only if it is numbers not alphabet I tried the below code but it seems there is something wrong
while (rc == SOCKET_ERROR); //try as long till there is connection (no Socket Error)
printf("conected with %s..\n\n", address);
do
{
printf("Please insert the Blood pressure values for further Diagnostic\n ");
gets(data);
char i;
for (i = data[0]; i <= MAX; i++)
{
char n = data[i];
if ((strlen(data) > MAX) || (strlen(data) == 0))
{
printf("argument not allowed!\n\n");
memset(data, '\0', strlen(data));
continue;
}
if ((n >= 'a' && n <= 'z') ||( n >= 'A' && n <= 'Z'))
{
printf("you have to enter a number !\n\n");
memset(data, '\0', strlen(data));
continue;
//next iteration
}
}
| 0debug
|
void yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4],int brightness,int contrast, int saturation)
{
union {
signed short tmp[8] __attribute__ ((aligned(16)));
vector signed short vec;
} buf;
buf.tmp[0] = ( (0xffffLL) * contrast>>8 )>>9;
buf.tmp[1] = -256*brightness;
buf.tmp[2] = (inv_table[0]>>3) *(contrast>>16)*(saturation>>16);
buf.tmp[3] = (inv_table[1]>>3) *(contrast>>16)*(saturation>>16);
buf.tmp[4] = -((inv_table[2]>>1)*(contrast>>16)*(saturation>>16));
buf.tmp[5] = -((inv_table[3]>>1)*(contrast>>16)*(saturation>>16));
c->CSHIFT = (vector unsigned short)vec_splat_u16(2);
c->CY = vec_splat ((vector signed short)buf.vec, 0);
c->OY = vec_splat ((vector signed short)buf.vec, 1);
c->CRV = vec_splat ((vector signed short)buf.vec, 2);
c->CBU = vec_splat ((vector signed short)buf.vec, 3);
c->CGU = vec_splat ((vector signed short)buf.vec, 4);
c->CGV = vec_splat ((vector signed short)buf.vec, 5);
#if 0
{
int i;
char *v[6]={"cy","oy","crv","cbu","cgu","cgv"};
for (i=0; i<6;i++)
printf("%s %d ", v[i],buf.tmp[i] );
printf("\n");
}
#endif
return;
}
| 1threat
|
Query Select in SQL postgree : We need help to use a command in "SELECT" to return the following information from a bank in Postgree SLQ.
"Terminals that had 10 or more occurrences, within 1 hour, with the same user, service, and terminal".
We have the table TB_TRANSACOES:
Id bigserial NOT NULL,
Dh_transaction timestamp NOT NULL,
Nu_account bigint NOT NULL,
Nu_value bigint NOT NULL,
Co_terminal character varying NOT NULL,
Co_service character varying NOT NULL,
Co_user character varying NOT NULL,
CONSTRAINT tb_transacoes_pkey PRIMARY KEY (id)
We have only this part:
SELECT * FROM TB_TRANSACOES WHERE CO_TERMINAL> = 10
I'll be grateful.
| 0debug
|
Php - floor with decimals number bugging normal number : I have that line of code:
$ammount = floor($ammount*100000000) / 100000000;
I want to have number with 8 decimals but with this code above i get, right 8 decimals but before point my number is lower than it could be.
If i putted that number:
"111" it switched to "1.00000000"
i used this code too:
$ammount = number_format($ammount, 8);
But i want too number to be round to lower value
For example:
1.000000009 -> 1.00000000
1.003000001 -> 1.00300000
| 0debug
|
static int ac3_decode_frame(AVCodecContext * avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AC3DecodeContext *s = avctx->priv_data;
int blk, ch, err, ret;
const uint8_t *channel_map;
const float *output[AC3_MAX_CHANNELS];
if (buf_size >= 2 && AV_RB16(buf) == 0x770B) {
int cnt = FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE) >> 1;
s->dsp.bswap16_buf((uint16_t *)s->input_buffer, (const uint16_t *)buf, cnt);
} else
memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));
buf = s->input_buffer;
init_get_bits(&s->gbc, buf, buf_size * 8);
err = parse_frame_header(s);
if (err) {
switch (err) {
case AAC_AC3_PARSE_ERROR_SYNC:
av_log(avctx, AV_LOG_ERROR, "frame sync error\n");
return -1;
case AAC_AC3_PARSE_ERROR_BSID:
av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n");
break;
case AAC_AC3_PARSE_ERROR_SAMPLE_RATE:
av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n");
break;
case AAC_AC3_PARSE_ERROR_FRAME_SIZE:
av_log(avctx, AV_LOG_ERROR, "invalid frame size\n");
break;
case AAC_AC3_PARSE_ERROR_FRAME_TYPE:
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
av_log(avctx, AV_LOG_ERROR, "unsupported frame type : "
"skipping frame\n");
*got_frame_ptr = 0;
return s->frame_size;
} else {
av_log(avctx, AV_LOG_ERROR, "invalid frame type\n");
}
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid header\n");
break;
}
} else {
if (s->frame_size > buf_size) {
av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
err = AAC_AC3_PARSE_ERROR_FRAME_SIZE;
} else if (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL)) {
if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2],
s->frame_size - 2)) {
av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n");
err = AAC_AC3_PARSE_ERROR_CRC;
}
}
}
if (!err) {
avctx->sample_rate = s->sample_rate;
avctx->bit_rate = s->bit_rate;
s->out_channels = s->channels;
s->output_mode = s->channel_mode;
if (s->lfe_on)
s->output_mode |= AC3_OUTPUT_LFEON;
if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
avctx->request_channels < s->channels) {
s->out_channels = avctx->request_channels;
s->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
s->channel_layout = avpriv_ac3_channel_layout_tab[s->output_mode];
}
avctx->channels = s->out_channels;
avctx->channel_layout = s->channel_layout;
s->loro_center_mix_level = gain_levels[s-> center_mix_level];
s->loro_surround_mix_level = gain_levels[s->surround_mix_level];
s->ltrt_center_mix_level = LEVEL_MINUS_3DB;
s->ltrt_surround_mix_level = LEVEL_MINUS_3DB;
if (s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) &&
s->fbw_channels == s->out_channels)) {
set_downmix_coeffs(s);
}
} else if (!s->out_channels) {
s->out_channels = avctx->channels;
if (s->out_channels < s->channels)
s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
}
if (avctx->channels != s->out_channels) {
av_log(avctx, AV_LOG_ERROR, "channel number mismatching on damaged frame\n");
return AVERROR_INVALIDDATA;
}
avctx->audio_service_type = s->bitstream_mode;
if (s->bitstream_mode == 0x7 && s->channels > 1)
avctx->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
avctx->channels = s->out_channels;
s->frame.nb_samples = s->num_blocks * 256;
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];
for (ch = 0; ch < s->channels; ch++) {
if (ch < s->out_channels)
s->outptr[channel_map[ch]] = (float *)s->frame.data[ch];
else
s->outptr[ch] = s->output[ch];
output[ch] = s->output[ch];
}
for (blk = 0; blk < s->num_blocks; blk++) {
if (!err && decode_audio_block(s, blk)) {
av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");
err = 1;
}
if (err)
for (ch = 0; ch < s->out_channels; ch++)
memcpy(s->outptr[channel_map[ch]], output[ch], 1024);
for (ch = 0; ch < s->out_channels; ch++) {
output[ch] = s->outptr[channel_map[ch]];
s->outptr[channel_map[ch]] += AC3_BLOCK_SIZE;
}
}
s->frame.decode_error_flags = err ? FF_DECODE_ERROR_INVALID_BITSTREAM : 0;
for (ch = 0; ch < s->out_channels; ch++)
memcpy(s->output[ch], output[ch], 1024);
*got_frame_ptr = 1;
*(AVFrame *)data = s->frame;
return FFMIN(buf_size, s->frame_size);
}
| 1threat
|
In PyCharm, how do you add a directory from one project as a source to another project? : <p>I have several python projects started from git repos, all related to each other, that are all open in one PyCharm window.</p>
<p>I have python code in one project, call it project B, that imports python packages from project A, but PyCharm can't find the source. </p>
<p>I've marked the directories with python packages in project A as source directories in PyCharm, and indeed other code in project A can lookup these python packages. But these source directories don't appear to be part of the lookup table for other projects in the same window.</p>
<p>Is there any way in PyCharm to make one project recognize directories from another project as a source directory?</p>
| 0debug
|
static int vmdk_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
BDRVVmdkState *s = bs->opaque;
int ret;
uint64_t n, index_in_cluster;
VmdkExtent *extent = NULL;
uint64_t cluster_offset;
while (nb_sectors > 0) {
extent = find_extent(s, sector_num, extent);
if (!extent) {
return -EIO;
}
ret = get_cluster_offset(
bs, extent, NULL,
sector_num << 9, 0, &cluster_offset);
index_in_cluster = sector_num % extent->cluster_sectors;
n = extent->cluster_sectors - index_in_cluster;
if (n > nb_sectors) {
n = nb_sectors;
}
if (ret) {
if (bs->backing_hd) {
if (!vmdk_is_cid_valid(bs)) {
return -EINVAL;
}
ret = bdrv_read(bs->backing_hd, sector_num, buf, n);
if (ret < 0) {
return ret;
}
} else {
memset(buf, 0, 512 * n);
}
} else {
ret = vmdk_read_extent(extent,
cluster_offset, index_in_cluster * 512,
buf, n);
if (ret) {
return ret;
}
}
nb_sectors -= n;
sector_num += n;
buf += n * 512;
}
return 0;
}
| 1threat
|
Need assistance trying to web scrape : <p>Very very new to programming - I am trying to scrape a website in order to find get a quick view of some information on site.</p>
<p>Found this on a tutorial on webscraping linked here: <a href="https://www.pythonforbeginners.com/python-on-the-web/web-scraping-with-beautifulsoup" rel="nofollow noreferrer">https://www.pythonforbeginners.com/python-on-the-web/web-scraping-with-beautifulsoup</a></p>
<pre><code> from bs4 import BeautifulSoup
import requests
url = raw_input("enter a website to extract URL's from")
r = requests.get("http://www.pythonforbeginners.com")
data = r.text
soup = BeautifulSoup(data)
for link in soup.find_all('a'):
print(link.get(href))
</code></pre>
<p>Error message states "href is not defined". I don't know what else to try... Any help would be appreciated.</p>
| 0debug
|
static int query_format(struct vf_instance *vf, unsigned int fmt)
{
switch (fmt) {
case IMGFMT_YV12:
case IMGFMT_IYUV:
case IMGFMT_I420:
return ff_vf_next_query_format(vf, fmt);
}
return 0;
}
| 1threat
|
How to split string in JavaScript with regular expression : <p>I have following html. I want to split it by <code><span></code> tag.</p>
<pre><code>let storyHtml = "<span>People</span> born in different ages are different from each other in various aspects. The world is changing at <span>a</span> rapid pace and thus the difference between <span>people</span> born in different times is inevitable.";
let allSplitPart = storyHtml.split(/<span>.*?<\/span>/gim);
let allMatchPart = storyHtml.match(/<span>.*?<\/span>/gim);
// Output 1: ["", " born in different ages are different from each other in various aspects. The world is changing at ", " rapid pace and thus the difference between ", " born in different times is inevitable."]
//Output 2: ["<span>People</span>", "<span>a</span>", "<span>people</span>"]
</code></pre>
<p><strong>What output I want:</strong></p>
<pre><code>["<span>People</span>", " born in different ages are different from each other in various aspects. The world is changing at ","<span>a</span>"," rapid pace and thus the difference between ","<span>people</span>", " born in different times is inevitable."]
</code></pre>
| 0debug
|
How to get true or false as follows using Symmetry in Python? : If we have to get two values from the user, which we get as
'a' 'p' > True .
How would we get the following:
`'abcd' 'pqrs' > True
'aaa' 'ppp' > True
'acb' 'pqr' > False
'aab' 'pqr' > False`
| 0debug
|
Multiple monads in one do-block : <p>I am currently trying to learn Haskell and I really cannot understand the concept of using just one one monad in do-block. If I have <code>foo :: Int -> Maybe Int</code> and want to use for example function <code>hIsEOF :: Handle -> IO Bool</code> in this function. Can someone please explain me on some basic example how would I use <code>hIsEOF</code> and could somehow work with <code>Bool</code>?</p>
<p>I have been trying to search here and on google, but I always run into some advanced stuff where basically noone explains how, they just give advice on how to fit it right into OP's code. I saw monad transformers mentioned in those threads but even after reading few resources, I cannot seem to find the right way on how to use them.</p>
| 0debug
|
How to chain two GraphQL queries in sequence using Apollo Client : <p>I am using Apollo Client for the frontend and Graphcool for the backend. There are two queries <code>firstQuery</code> and <code>secondQuery</code> that I want them to be called in sequence when the page opens. Here is the sample code (the definition of TestPage component is not listed here):</p>
<pre><code>export default compose(
graphql(firstQuery, {
name: 'firstQuery'
}),
graphql(secondQuery, {
name: 'secondQuery' ,
options: (ownProps) => ({
variables: {
var1: *getValueFromFirstQuery*
}
})
})
)(withRouter(TestPage))
</code></pre>
<p>I need to get <code>var1</code> in <code>secondQuery</code> from the result of <code>firstQuery</code>. How can I do that with Apollo Client and compose? Or is there any other way to do it? Thanks in advance. </p>
| 0debug
|
AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
URLContext *handle, int packet_size)
{
AVFormatContext *rtpctx;
int ret;
AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
if (!rtp_format)
return NULL;
rtpctx = avformat_alloc_context();
if (!rtpctx)
return NULL;
rtpctx->oformat = rtp_format;
if (!av_new_stream(rtpctx, 0)) {
av_free(rtpctx);
return NULL;
}
rtpctx->max_delay = s->max_delay;
rtpctx->streams[0]->sample_aspect_ratio = st->sample_aspect_ratio;
rtpctx->start_time_realtime = s->start_time_realtime;
avcodec_copy_context(rtpctx->streams[0]->codec, st->codec);
if (handle) {
url_fdopen(&rtpctx->pb, handle);
} else
url_open_dyn_packet_buf(&rtpctx->pb, packet_size);
ret = av_write_header(rtpctx);
if (ret) {
if (handle) {
avio_close(rtpctx->pb);
} else {
uint8_t *ptr;
avio_close_dyn_buf(rtpctx->pb, &ptr);
av_free(ptr);
}
avformat_free_context(rtpctx);
return NULL;
}
return rtpctx;
}
| 1threat
|
Linux Map many internal IPs to one external IP : <p>I have one Linux machine with many services which needed to be accessed from outside users, each service has one port, how can i make all these service be accessible by one external public IP?</p>
<p>Thank you.</p>
| 0debug
|
feild seperator in awk script : I am trying to print columns in file which are seperated by "|" using awk.
File content :-
postgres | psql | | 2018-09-17
05:00:45.096491+00 | | active
test_user | PostgreSQL JDBC Driver | ***.**.**.118 | 2018-09-17
03:55:22.310569+00 | | idle in transaction
test_user | PostgreSQL JDBC Driver | ***.**.**.95 | 2018-09-17
03:54:58.638521+00 | | idle in transaction
I am using below awk command to seperate columns in file.
awk 'BEGIN { RS = "|" } ; { print $2 }' vv.txt
Also refer to image attached which gives clear idea about issue.
I am not sure why datais getting messes up? Is it also considering space as separator[![enter image description here][1]][1].
[1]: https://i.stack.imgur.com/lKYGR.jpg
| 0debug
|
What is the recommended directory structure for a Rust project? : <p>Where should one put the sources, examples, documentation, unit tests, integration tests, license, benchmarks <em>etc</em>?</p>
| 0debug
|
static int do_create_others(int type, struct iovec *iovec)
{
dev_t rdev;
int retval = 0;
int offset = PROXY_HDR_SZ;
V9fsString oldpath, path;
int mode, uid, gid, cur_uid, cur_gid;
v9fs_string_init(&path);
v9fs_string_init(&oldpath);
cur_uid = geteuid();
cur_gid = getegid();
retval = proxy_unmarshal(iovec, offset, "dd", &uid, &gid);
if (retval < 0) {
return retval;
}
offset += retval;
retval = setfsugid(uid, gid);
if (retval < 0) {
retval = -errno;
goto err_out;
}
switch (type) {
case T_MKNOD:
retval = proxy_unmarshal(iovec, offset, "sdq", &path, &mode, &rdev);
if (retval < 0) {
goto err_out;
}
retval = mknod(path.data, mode, rdev);
break;
case T_MKDIR:
retval = proxy_unmarshal(iovec, offset, "sd", &path, &mode);
if (retval < 0) {
goto err_out;
}
retval = mkdir(path.data, mode);
break;
case T_SYMLINK:
retval = proxy_unmarshal(iovec, offset, "ss", &oldpath, &path);
if (retval < 0) {
goto err_out;
}
retval = symlink(oldpath.data, path.data);
break;
}
if (retval < 0) {
retval = -errno;
}
err_out:
v9fs_string_free(&path);
v9fs_string_free(&oldpath);
setfsugid(cur_uid, cur_gid);
return retval;
}
| 1threat
|
DateComponentsFormatter returns wrong number of unit count : <p>I've faced issue, when <code>DateComponentsFormatter</code> returns unexpected number of units. Does anyone faced same issue?</p>
<pre><code>import Foundation
let formatter = DateComponentsFormatter()
formatter.unitsStyle = .full;
formatter.maximumUnitCount = 1;
let date = Date(timeIntervalSinceNow: -14.7 * 24 * 60 * 60)
let dateString = formatter.string(from: date, to: Date()) // 2 weeks 1 day
</code></pre>
<p>I expect to receive "2 weeks", but have "2 weeks 1 day".</p>
| 0debug
|
int msi_init(struct PCIDevice *dev, uint8_t offset,
unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask)
{
unsigned int vectors_order;
uint16_t flags;
uint8_t cap_size;
int config_offset;
if (!msi_nonbroken) {
return -ENOTSUP;
}
MSI_DEV_PRINTF(dev,
"init offset: 0x%"PRIx8" vector: %"PRId8
" 64bit %d mask %d\n",
offset, nr_vectors, msi64bit, msi_per_vector_mask);
assert(!(nr_vectors & (nr_vectors - 1)));
assert(nr_vectors > 0);
assert(nr_vectors <= PCI_MSI_VECTORS_MAX);
vectors_order = ctz32(nr_vectors);
flags = vectors_order << ctz32(PCI_MSI_FLAGS_QMASK);
if (msi64bit) {
flags |= PCI_MSI_FLAGS_64BIT;
}
if (msi_per_vector_mask) {
flags |= PCI_MSI_FLAGS_MASKBIT;
}
cap_size = msi_cap_sizeof(flags);
config_offset = pci_add_capability(dev, PCI_CAP_ID_MSI, offset, cap_size);
if (config_offset < 0) {
return config_offset;
}
dev->msi_cap = config_offset;
dev->cap_present |= QEMU_PCI_CAP_MSI;
pci_set_word(dev->config + msi_flags_off(dev), flags);
pci_set_word(dev->wmask + msi_flags_off(dev),
PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE);
pci_set_long(dev->wmask + msi_address_lo_off(dev),
PCI_MSI_ADDRESS_LO_MASK);
if (msi64bit) {
pci_set_long(dev->wmask + msi_address_hi_off(dev), 0xffffffff);
}
pci_set_word(dev->wmask + msi_data_off(dev, msi64bit), 0xffff);
if (msi_per_vector_mask) {
pci_set_long(dev->wmask + msi_mask_off(dev, msi64bit),
0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors));
}
return 0;
}
| 1threat
|
static int curl_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVCURLState *s = bs->opaque;
CURLState *state = NULL;
QemuOpts *opts;
Error *local_err = NULL;
const char *file;
double d;
static int inited = 0;
if (flags & BDRV_O_RDWR) {
error_setg(errp, "curl block device does not support writes");
return -EROFS;
}
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto out_noclean;
}
s->readahead_size = qemu_opt_get_size(opts, CURL_BLOCK_OPT_READAHEAD,
READ_AHEAD_DEFAULT);
if ((s->readahead_size & 0x1ff) != 0) {
error_setg(errp, "HTTP_READAHEAD_SIZE %zd is not a multiple of 512",
s->readahead_size);
goto out_noclean;
}
file = qemu_opt_get(opts, CURL_BLOCK_OPT_URL);
if (file == NULL) {
error_setg(errp, "curl block driver requires an 'url' option");
goto out_noclean;
}
if (!inited) {
curl_global_init(CURL_GLOBAL_ALL);
inited = 1;
}
DPRINTF("CURL: Opening %s\n", file);
s->url = g_strdup(file);
state = curl_init_state(s);
if (!state)
goto out_noclean;
s->accept_range = false;
curl_easy_setopt(state->curl, CURLOPT_NOBODY, 1);
curl_easy_setopt(state->curl, CURLOPT_HEADERFUNCTION,
curl_header_cb);
curl_easy_setopt(state->curl, CURLOPT_HEADERDATA, s);
if (curl_easy_perform(state->curl))
goto out;
curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d);
if (d)
s->len = (size_t)d;
else if(!s->len)
goto out;
if ((!strncasecmp(s->url, "http:
|| !strncasecmp(s->url, "https:
&& !s->accept_range) {
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
"Server does not support 'range' (byte ranges).");
goto out;
}
DPRINTF("CURL: Size = %zd\n", s->len);
curl_clean_state(state);
curl_easy_cleanup(state->curl);
state->curl = NULL;
aio_timer_init(bdrv_get_aio_context(bs), &s->timer,
QEMU_CLOCK_REALTIME, SCALE_NS,
curl_multi_timeout_do, s);
s->multi = curl_multi_init();
curl_multi_setopt(s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb);
#ifdef NEED_CURL_TIMER_CALLBACK
curl_multi_setopt(s->multi, CURLMOPT_TIMERDATA, s);
curl_multi_setopt(s->multi, CURLMOPT_TIMERFUNCTION, curl_timer_cb);
#endif
qemu_opts_del(opts);
return 0;
out:
error_setg(errp, "CURL: Error opening file: %s", state->errmsg);
curl_easy_cleanup(state->curl);
state->curl = NULL;
out_noclean:
g_free(s->url);
qemu_opts_del(opts);
return -EINVAL;
}
| 1threat
|
GoLang - Conversion of type "interface {}" to another interface in a slice of type "interface {}" via reflection : I've been burning neurons for hours and I couldn't solve this question. I have a slice of type People, I need to pass this slice to a function that gets the type "interface {}". The People type "implements" an interface called HasCustomField, but I can't do the type conversion within the function, as I am doing:
type HasCustomField interface {
GetCustomField() map[string]interface{}
}
type People struct {
Name string
customField map[string]interface{}
}
func (c *People) GetCustomField() map[string]interface{} {
if c.customField == nil {
c.customField = make(map[string]interface{})
}
return c.customField
}
func main() {
users := []People{{Name:"Teste"},{Name:"Mizael"}}
ProcessCustomField(&users)
}
func ProcessCustomField(list interface{}) {
if list != nil {
listVal := reflect.ValueOf(list).Elem()
if listVal.Kind() == reflect.Slice {
for i:=0; i<listVal.Len(); i++ {
valueReflect := listVal.Index(i).Interface()
objValueFinal, ok := valueReflect.(HasCustomField)
if ok {
fmt.Println("OK")
} else {
fmt.Println("NAO OK")
}
}
}
The result is always "Not OK", I can not do the conversion, I tried several other ways too, including calling the method "GetCustomField" via reflection, but was unsuccessful.
| 0debug
|
CSS vertical-align paragraph into div : <p>I have a div (with fixed height) with this CSS:</p>
<pre><code>.div {
color: white;
font-family: Bahnschrift;
text-align: justify;
vertical-align: text-top;
}
</code></pre>
<p>As you can see, in this div there are paragraphs vertical aligned at the top. I want to align only the last paragraph (class="lastpar") at the bottom of the div, this is the CSS:</p>
<pre><code>.lastpar {
position: relative;
vertical-align: text-bottom;
}
</code></pre>
<p>But it doesn't work, could you please help me to align it at the bottom of the div? Thanks</p>
| 0debug
|
World map paths data in react high charts : <p>I am looking at the react highmaps documentation and it seems like they have hardcoded/saved the map data:</p>
<p><a href="https://github.com/kirjs/react-highcharts">https://github.com/kirjs/react-highcharts</a>
<a href="https://github.com/kirjs/react-highcharts/tree/master/demo/src/mapdata">https://github.com/kirjs/react-highcharts/tree/master/demo/src/mapdata</a></p>
<p>I see in a lot of little tutorials though that the data comes from high maps itself by just passing a key like this</p>
<pre><code>mapData: Highcharts.maps['custom/world'],
</code></pre>
<p>See example here: <a href="http://jsfiddle.net/gh/get/jquery/3.1.1/highcharts/highcharts/tree/master/samples/maps/tooltip/usehtml/">http://jsfiddle.net/gh/get/jquery/3.1.1/highcharts/highcharts/tree/master/samples/maps/tooltip/usehtml/</a></p>
<p>But given that I am writing a pure reactJS/ nodeJS app, I was wondering if there is a way in pure react to pull in the path data for world maps? Is this deployed to react high maps somewhere?</p>
| 0debug
|
Proper relative imports: "Unable to import module" : <p>I have a project structured like this:</p>
<pre><code>.
└── myapp
├── app.py
├── models
│ ├── hello.py
│ └── world.py
└── requirements.txt
</code></pre>
<p>I have two models, <code>hello</code> and <code>world</code>. Both models are used from <code>app.py</code> where I import them like this:</p>
<pre><code>from models.hello import Hello
from models.world import World
</code></pre>
<p>But <code>world</code> also needs to use <code>hello</code>. I tried this in <code>world.py</code>:</p>
<pre><code>from models.hello import Hello
</code></pre>
<p>The above technically works when I run the app, but VSCode's Python extension gives me the following error:</p>
<pre><code>E0401:Unable to import 'models.hello'.
</code></pre>
<p>What is the proper way of importing a submodule from the same directory? How do I avoid this error in VSCode?</p>
| 0debug
|
static int vhost_user_set_u64(struct vhost_dev *dev, int request, uint64_t u64)
{
VhostUserMsg msg = {
.request = request,
.flags = VHOST_USER_VERSION,
.u64 = u64,
.size = sizeof(m.u64),
};
vhost_user_write(dev, &msg, NULL, 0);
return 0;
}
| 1threat
|
Offsets stored in Zookeeper or Kafka? : <p>I'm a bit confused about where offsets are stored when using Kafka and Zookeeper. It seems like offsets in some cases are stored in Zookeeper, in other cases they are stored in Kafka. </p>
<p>What determines whether the offset is stored in Kafka or in Zookeeper? And what the pros and cons? </p>
<p>NB: Of course I could also store the offset on my own in some different data store but that is not part of the picture for this post.</p>
<p>Some more details about my setup:</p>
<ul>
<li>I run these versions: KAFKA_VERSION="0.10.1.0", SCALA_VERSION="2.11"</li>
<li>I connect to Kafka/Zookeeper using kafka-node from my NodeJS application.</li>
</ul>
| 0debug
|
How to delete everything in node redis? : <p>I want to be able to delete all the keys. Is there a way to flush all in node redis? </p>
<p>Redis client:</p>
<pre><code>client = redis.createClient(REDIS_PORT, REDIS_HOST);
</code></pre>
| 0debug
|
Cordova : Requirements check failed for JDK 1.8 or greater : <p>I am using Cordova 6.4.0 in Windows 7 OS, but I get this error once I tried to build the android version :</p>
<p><a href="https://i.stack.imgur.com/qhpzv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qhpzv.png" alt="Issue description"></a></p>
<p>The Java Home variable is setted correctly to the JDK path, but I don't know why I am getting this issue. Any suggestions please ? </p>
| 0debug
|
Generate two words sentence from full sentence (combinations) : <p>I'm trying to find a solution, where I can generate two words sentences from a full sentence.</p>
<p>Example:
Word: "iPad Mini 32GB White"
I would like that to be splitted up to two words sentences
Example:</p>
<p>"iPad Mini", "iPad 32GB", "iPad White" etc.</p>
<p>The combinations should only be used once, so it doesn't generate the same word, but in the opposite direction.</p>
| 0debug
|
Google maps not showing after uploading the app to playstore : <p>Google maps showing a blank screen after uplaoding the app into playstore. But Map showing when running locally(in emulator).
I tried by changing the SHA1 of google map api by Playstore app signing certificate SHA fingerprint but still showing the blank screen.</p>
| 0debug
|
static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)
{
unsigned int opc, op2, op3, rn, op4;
opc = extract32(insn, 21, 4);
op2 = extract32(insn, 16, 5);
op3 = extract32(insn, 10, 6);
rn = extract32(insn, 5, 5);
op4 = extract32(insn, 0, 5);
if (op4 != 0x0 || op3 != 0x0 || op2 != 0x1f) {
unallocated_encoding(s);
}
switch (opc) {
case 0:
case 2:
break;
case 1:
tcg_gen_movi_i64(cpu_reg(s, 30), s->pc);
break;
case 4:
case 5:
if (rn != 0x1f) {
unallocated_encoding(s);
} else {
unsupported_encoding(s, insn);
}
default:
unallocated_encoding(s);
}
tcg_gen_mov_i64(cpu_pc, cpu_reg(s, rn));
}
| 1threat
|
Django render_to_string() ignores {% csrf_token %} : <p>I am trying to perform unit tests in Django. I have the following form in <code>index.html</code>:</p>
<pre><code><form method=POST>
{% csrf_token %}
<input name=itemT>
</form>
</code></pre>
<p>And I am testing if the view render the template correctly:</p>
<p>views.py</p>
<pre><code>def homePage(request):
return render(request, 'index.html')
</code></pre>
<p>tests.py:</p>
<pre><code>request = HttpRequest()
response = homePage(request)
if response:
response = response.content.decode('UTF-8')
expectedHTML = render_to_string('index.html')
self.assertEqual(response, expectedHTML)
</code></pre>
<p>The <code>response</code> has a hidden input field with a csrf token; however, the <code>expectedHTML</code> does not (there is just a blank line at the place of <code>{% csrf_token %}</code>). So the assertion always fails.</p>
<p>Is it possible to have <code>render_to_string()</code> generate a csrf input field? If so, would the token of <code>response</code> the same as that of <code>expectedHTML</code>?</p>
<p>Or, is there any way to ignore the input field such that the test can be successful?</p>
| 0debug
|
static void virtio_blk_free_request(VirtIOBlockReq *req)
{
if (req) {
g_slice_free(VirtQueueElement, req->elem);
g_slice_free(VirtIOBlockReq, req);
}
}
| 1threat
|
How to change 201509122150 to YYYY-MM-DD hh:mm : Would like to know what is the bext way to change 201509122150 (numeric) to Date class in YYYY-MM-DD hh:mm format.
| 0debug
|
What is the current status of C++ AMP : <p>I am working on high performance code in C++ and have been using both CUDA and OpenCL and more recently C++AMP, which I like very much. I am however a little worried that it is not being developed and extended and will die out.</p>
<p>What leads me to this thought is that even the MS C++AMP blogs have been silent for about a year. Looking at the C++ AMP algorithms library <a href="http://ampalgorithms.codeplex.com/wikipage/history" rel="noreferrer">http://ampalgorithms.codeplex.com/wikipage/history</a> it seems nothing at all has happened for over a year.</p>
<p>The only development I have seen is that now LLVM sort of supports C++AMP, so it is not windows only, but that is all, and not something which has been told far and wide.</p>
<p>What kind of work is going on, if any, that you know of?</p>
| 0debug
|
Passing a string that could several values(not an array) : public class ArithmeticTester
{
public static void main(String[] args)
{
call(3, "+", 4, "7");
call(3, "-", 4, "-1");
call(3, "*", 4, "12");
call(3, "@", 4, "java.lang.IllegalArgumentException");
call(13, "/", 4, "3");
call(13, "/", 0, "java.lang.IllegalArgumentException");
}
public static void call(int a, String op, int b, String expected)
{
try
{
System.out.println(Arithmetic.compute(a, op, b));
}
catch (Throwable ex)
{
System.out.println(ex.getClass().getName());
}
System.out.println("Expected: " + expected);
}
}
This is provided by the book as the testing class
public class Arithmetic
{
/**
Computes the value of an arithmetic expression
@param value1 the first operand
@param operator a string that should contain an operator + - * or /
@param value2 the second operand
@return the result of the operation
*/
public static int compute(int value1, String operator, int value2)
{
int a;
a = 1;
String b;
b = "-";
int c;
c = 3;
return (a, b, c);
}
}
I dont even really know where to begin, i am completely lost at what to even do the book does a shit job of explaining what to do and my teacher is useless at helping students.
Am i supposed to make an if statement that changes operator ever time it loops? Please help.
| 0debug
|
split file extension from an array : <p>I am trying to remove the extension found in every file name in my array.</p>
<p>I have</p>
<pre><code>files = ['file.tsv', 'file2.tsv', 'file3.tsv']
</code></pre>
<p>and want the output to be</p>
<pre><code>files = ['file', 'file2', 'file3']
</code></pre>
<p>How do I perform this function on an array?</p>
| 0debug
|
alert('Hello ' + user_input);
| 1threat
|
static int read_low_coeffs(AVCodecContext *avctx, int16_t *dst, int size, int width, ptrdiff_t stride)
{
PixletContext *ctx = avctx->priv_data;
GetBitContext *b = &ctx->gbit;
unsigned cnt1, nbits, k, j = 0, i = 0;
int64_t value, state = 3;
int rlen, escape, flag = 0;
while (i < size) {
nbits = FFMIN(ff_clz((state >> 8) + 3) ^ 0x1F, 14);
cnt1 = get_unary(b, 0, 8);
if (cnt1 < 8) {
value = show_bits(b, nbits);
if (value <= 1) {
skip_bits(b, nbits - 1);
escape = ((1 << nbits) - 1) * cnt1;
} else {
skip_bits(b, nbits);
escape = value + ((1 << nbits) - 1) * cnt1 - 1;
}
} else {
escape = get_bits(b, 16);
}
value = -((escape + flag) & 1) | 1;
dst[j++] = value * ((escape + flag + 1) >> 1);
i++;
if (j == width) {
j = 0;
dst += stride;
}
state = 120 * (escape + flag) + state - (120 * state >> 8);
flag = 0;
if (state * 4 > 0xFF || i >= size)
continue;
nbits = ((state + 8) >> 5) + (state ? ff_clz(state) : 32) - 24;
escape = av_mod_uintp2(16383, nbits);
cnt1 = get_unary(b, 0, 8);
if (cnt1 > 7) {
rlen = get_bits(b, 16);
} else {
value = show_bits(b, nbits);
if (value > 1) {
skip_bits(b, nbits);
rlen = value + escape * cnt1 - 1;
} else {
skip_bits(b, nbits - 1);
rlen = escape * cnt1;
}
}
if (rlen > size - i)
return AVERROR_INVALIDDATA;
i += rlen;
for (k = 0; k < rlen; k++) {
dst[j++] = 0;
if (j == width) {
j = 0;
dst += stride;
}
}
state = 0;
flag = rlen < 0xFFFF ? 1 : 0;
}
align_get_bits(b);
return get_bits_count(b) >> 3;
}
| 1threat
|
why array variable is getting updated : <p>I wrote this code and a part of this is not written by me and I'm not able to understand how a function is updating my <code>arrayData</code>?</p>
<pre><code>#include <iostream>
using namespace std;
int *insert(int arr[], int size, int elem, int pos);
int main()
{
// Create a array
int arrayData[50] = {0};
// Insert data
for (int i = 0; i < 10; i++)
{
arrayData[i] = i + 1;
}
int elem = 40, pos = 5, size = 10;
// insert the element
insert(arrayData, size, elem, pos);
// show the data
for (int i = 0; i < size + 1; i++)
{
cout << arrayData[i] << " ";
}
return 0;
}
int *insert(int arr[], int size, int elem, int pos)
{
size++;
// shift elements forward
for (int i = size; i >= pos; i--)
arr[i] = arr[i - 1];
// insert x at pos
arr[pos - 1] = elem;
return arr;
}
</code></pre>
<p>OUTPUT:
<code>1 2 3 4 40 5 6 7 8 9 10</code></p>
| 0debug
|
how can we find n sqrt(m) and check whether if answer is a integer in c++ : I have tried it using static<int> and various methods but they are not working in all testcases.so can you provide full code.
| 0debug
|
int get_buffer(ByteIOContext *s, unsigned char *buf, int size)
{
int len, size1;
size1 = size;
while (size > 0) {
len = s->buf_end - s->buf_ptr;
if (len > size)
len = size;
if (len == 0) {
fill_buffer(s);
len = s->buf_end - s->buf_ptr;
if (len == 0)
break;
} else {
memcpy(buf, s->buf_ptr, len);
buf += len;
s->buf_ptr += len;
size -= len;
}
}
return size1 - size;
}
| 1threat
|
How to delete already import certificate/alias by keytool command? : <p>I am trying to delete already import certificate by keytool command </p>
<pre><code> keytool -delete -noprompt -alias "initcert" -keystore keycloak.jks
</code></pre>
<p>But getting below exception</p>
<blockquote>
<p>keytool error: java.lang.Exception: Keystore file does not exist:
keycloak.jks</p>
</blockquote>
<p>Same issue with </p>
<pre><code>keytool -delete -alias "initcert" -keystore keycloak.cer
</code></pre>
<p>issue</p>
<blockquote>
<p>keytool error: java.lang.Exception: Keystore file does not exist:
keycloak.cer</p>
</blockquote>
<p>Now i am trying to import the certificate with same alias name</p>
<pre><code> keytool -import -noprompt -trustcacerts -alias "initcert" -file "C:\Code_Base\keycloak_certificates\keycloak_135.250.138.74_server\keycloak.cer" -keystore "C:\Program Files\Java\jdk1.8.0_152\jre\lib\security\cacerts"
</code></pre>
<p>But again end with </p>
<blockquote>
<p>keytool error: java.lang.Exception: Certificate not imported, alias
already exists</p>
</blockquote>
| 0debug
|
Regex + artificial intelligence : <p>How would it be possible to write software that takes strings from a list and generates regular expressions based on a pattern in each line of the list.</p>
| 0debug
|
static int tight_compress_data(VncState *vs, int stream_id, size_t bytes,
int level, int strategy)
{
z_streamp zstream = &vs->tight.stream[stream_id];
int previous_out;
if (bytes < VNC_TIGHT_MIN_TO_COMPRESS) {
vnc_write(vs, vs->tight.tight.buffer, vs->tight.tight.offset);
return bytes;
}
if (tight_init_stream(vs, stream_id, level, strategy)) {
return -1;
}
buffer_reserve(&vs->tight.zlib, bytes + 64);
zstream->next_in = vs->tight.tight.buffer;
zstream->avail_in = vs->tight.tight.offset;
zstream->next_out = vs->tight.zlib.buffer + vs->tight.zlib.offset;
zstream->avail_out = vs->tight.zlib.capacity - vs->tight.zlib.offset;
zstream->data_type = Z_BINARY;
previous_out = zstream->total_out;
if (deflate(zstream, Z_SYNC_FLUSH) != Z_OK) {
fprintf(stderr, "VNC: error during tight compression\n");
return -1;
}
vs->tight.zlib.offset = vs->tight.zlib.capacity - zstream->avail_out;
bytes = zstream->total_out - previous_out;
tight_send_compact_size(vs, bytes);
vnc_write(vs, vs->tight.zlib.buffer, bytes);
buffer_reset(&vs->tight.zlib);
return bytes;
}
| 1threat
|
static int nbd_co_discard(BlockDriverState *bs, int64_t sector_num,
int nb_sectors)
{
BDRVNBDState *s = bs->opaque;
struct nbd_request request;
struct nbd_reply reply;
if (!(s->nbdflags & NBD_FLAG_SEND_TRIM)) {
return 0;
}
request.type = NBD_CMD_TRIM;
request.from = sector_num * 512;;
request.len = nb_sectors * 512;
nbd_coroutine_start(s, &request);
if (nbd_co_send_request(s, &request, NULL, 0) == -1) {
reply.error = errno;
} else {
nbd_co_receive_reply(s, &request, &reply, NULL, 0);
}
nbd_coroutine_end(s, &request);
return -reply.error;
}
| 1threat
|
If statement wont work : First i run this first function,
it sets paikka3.src to "sapeli.png".
But then when i run the second function, the if statement wont work/run.
Why is this? I have no clue...
code:
var sapeliMäärä = 1;
function tavarat() {
if(sapeliMäärä == 1) {
document.lomake.paikka3.src = "sapeli.png";
}
}
function käytäTavaraa3() {
if(document.lomake.paikka3.src == "sapeli.png") {
OmaHp += 5;
document.lomake.poksi.value = "Söit lohen joka paransi 5 HP";
document.lomake.paikka3.src = "";
lohiMäärä -= 1;
}
}
| 0debug
|
UITextField, text jumps down slightly when editing begins : <p>I'm having an odd issue here. I have UITextFields in my table cells. When I select the field the text jumps very slightly down:</p>
<p><a href="https://i.stack.imgur.com/sNm3N.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/sNm3N.gif" alt="enter image description here"></a></p>
<p>The font is system default 17. I have <code>adjust to fit</code> turned on at size 17. I have tried turning off <code>adjust to fit</code> and there is still a jump. I have tried using different border styles and this also makes no difference. I have tried turning off clip to bounds, it still jumps. I have also tried making the frame taller (much taller) and it still jumps. The only thing that works is if I make the font size much smaller eg 13. What am I doing wrong here? If I can make the font smaller to fix the jump then why doesn't making the frame bigger work? Any pointers on this would be really appreciated. Thanks!</p>
| 0debug
|
void hmp_sendkey(Monitor *mon, const QDict *qdict)
{
const char *keys = qdict_get_str(qdict, "keys");
KeyValueList *keylist, *head = NULL, *tmp = NULL;
int has_hold_time = qdict_haskey(qdict, "hold-time");
int hold_time = qdict_get_try_int(qdict, "hold-time", -1);
Error *err = NULL;
char *separator;
int keyname_len;
while (1) {
separator = strchr(keys, '-');
keyname_len = separator ? separator - keys : strlen(keys);
if (keys[0] == '<' && keyname_len == 1) {
keys = "less";
keyname_len = 4;
}
keylist = g_malloc0(sizeof(*keylist));
keylist->value = g_malloc0(sizeof(*keylist->value));
if (!head) {
head = keylist;
}
if (tmp) {
tmp->next = keylist;
}
tmp = keylist;
if (strstart(keys, "0x", NULL)) {
char *endp;
int value = strtoul(keys, &endp, 0);
assert(endp <= keys + keyname_len);
if (endp != keys + keyname_len) {
goto err_out;
}
keylist->value->type = KEY_VALUE_KIND_NUMBER;
keylist->value->u.number = value;
} else {
int idx = index_from_key(keys, keyname_len);
if (idx == Q_KEY_CODE__MAX) {
goto err_out;
}
keylist->value->type = KEY_VALUE_KIND_QCODE;
keylist->value->u.qcode = idx;
}
if (!separator) {
break;
}
keys = separator + 1;
}
qmp_send_key(head, has_hold_time, hold_time, &err);
hmp_handle_error(mon, &err);
out:
qapi_free_KeyValueList(head);
return;
err_out:
monitor_printf(mon, "invalid parameter: %.*s\n", keyname_len, keys);
goto out;
}
| 1threat
|
Why setText causes my program to fail while Toast doesn't : The setText method when un-commented crashes the Activity/program. However, when it's just the TOAST with the same variable it works perfectly.
int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
int min = Calendar.getInstance().get((Calendar.MINUTE));
int ft = hour + min;
int second = Calendar.getInstance().get(Calendar.SECOND);
if(second<10){
second = second + 10;
}
String sft = Integer.toString(ft);
String ssecond = Integer.toString(second);
fid = sft + ssecond;
Toast.makeText(addRoll.this, fid, Toast.LENGTH_LONG).show();
id.setText(fid);
So this should change the TextView into the 4 digit number created. currently, it is at 0000. I know the variable works because the toast shows the correct variable. Thanks in advance.
| 0debug
|
BlockAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
unsigned long int req, void *buf,
BlockCompletionFunc *cb, void *opaque)
{
BlockDriver *drv = bs->drv;
if (drv && drv->bdrv_aio_ioctl)
return drv->bdrv_aio_ioctl(bs, req, buf, cb, opaque);
return NULL;
}
| 1threat
|
Multiple Datasets in One SSRS : <p>I cannot use First() because I have multiple data to return.</p>
<p>I cannot use Lookup() because I don't know what data to look for.</p>
<p>Any other workaround? or the only way is I have to change my query?</p>
| 0debug
|
static int nut_write_packet(AVFormatContext *s, int stream_index,
const uint8_t *buf, int size, int64_t pts)
{
NUTContext *nut = s->priv_data;
StreamContext *stream= &nut->stream[stream_index];
ByteIOContext *bc = &s->pb;
int key_frame = 0, full_pts=0;
AVCodecContext *enc;
int64_t lsb_pts, delta_pts;
int frame_type, best_length, frame_code, flags, i, size_mul, size_lsb;
const int64_t frame_start= url_ftell(bc);
if (stream_index > s->nb_streams)
return 1;
pts= (av_rescale(pts, stream->rate_num, stream->rate_den) + AV_TIME_BASE/2) / AV_TIME_BASE;
enc = &s->streams[stream_index]->codec;
key_frame = enc->coded_frame->key_frame;
delta_pts= pts - stream->last_pts;
frame_type=0;
if(frame_start + size + 20 - FFMAX(nut->last_frame_start[1], nut->last_frame_start[2]) > MAX_TYPE1_DISTANCE)
frame_type=1;
if(key_frame){
if(frame_type==1 && frame_start + size - nut->last_frame_start[2] > MAX_TYPE2_DISTANCE)
frame_type=2;
if(!stream->last_key_frame)
frame_type=2;
}
if(frame_type>0){
update_packetheader(nut, bc, 0);
reset(s);
full_pts=1;
}
lsb_pts = pts & ((1 << stream->msb_timestamp_shift)-1);
best_length=INT_MAX;
frame_code= -1;
for(i=0; i<256; i++){
int stream_id_plus1= nut->frame_code[i].stream_id_plus1;
int fc_key_frame= stream->last_key_frame;
int length=0;
size_mul= nut->frame_code[i].size_mul;
size_lsb= nut->frame_code[i].size_lsb;
flags= nut->frame_code[i].flags;
if(stream_id_plus1 == 0) length+= get_length(stream_index);
else if(stream_id_plus1 - 1 != stream_index)
continue;
if(flags & FLAG_PRED_KEY_FRAME){
if(flags & FLAG_KEY_FRAME)
fc_key_frame= !fc_key_frame;
}else{
fc_key_frame= !!(flags & FLAG_KEY_FRAME);
}
assert(key_frame==0 || key_frame==1);
if(fc_key_frame != key_frame)
continue;
if((!!(flags & FLAG_FRAME_TYPE)) != (frame_type > 0))
continue;
if(size_mul <= size_lsb){
int p= stream->lru_size[size_lsb - size_mul];
if(p != size)
continue;
}else{
if(size % size_mul != size_lsb)
continue;
if(flags & FLAG_DATA_SIZE)
length += get_length(size / size_mul);
else if(size/size_mul)
continue;
}
if(full_pts != ((flags & FLAG_PTS) && (flags & FLAG_FULL_PTS)))
continue;
if(flags&FLAG_PTS){
if(flags&FLAG_FULL_PTS){
length += get_length(pts);
}else{
length += get_length(lsb_pts);
}
}else{
int delta= stream->lru_pts_delta[(flags & 12)>>2];
if(delta != pts - stream->last_pts)
continue;
assert(frame_type == 0);
}
if(length < best_length){
best_length= length;
frame_code=i;
}
}
assert(frame_code != -1);
flags= nut->frame_code[frame_code].flags;
size_mul= nut->frame_code[frame_code].size_mul;
size_lsb= nut->frame_code[frame_code].size_lsb;
#if 0
best_length /= 7;
best_length ++;
if(frame_type>0){
best_length += 4;
if(frame_type>1)
best_length += 8;
}
av_log(s, AV_LOG_DEBUG, "kf:%d ft:%d pt:%d fc:%2X len:%2d size:%d stream:%d flag:%d mul:%d lsb:%d s+1:%d pts_delta:%d\n", key_frame, frame_type, full_pts ? 2 : ((flags & FLAG_PTS) ? 1 : 0), frame_code, best_length, size, stream_index, flags, size_mul, size_lsb, nut->frame_code[frame_code].stream_id_plus1,(int)(pts - stream->last_pts));
#endif
if (frame_type==2)
put_be64(bc, KEYFRAME_STARTCODE);
put_byte(bc, frame_code);
if(frame_type>0)
put_packetheader(nut, bc, FFMAX(size+20, MAX_TYPE1_DISTANCE));
if(nut->frame_code[frame_code].stream_id_plus1 == 0)
put_v(bc, stream_index);
if (flags & FLAG_PTS){
if (flags & FLAG_FULL_PTS)
put_v(bc, pts);
else
put_v(bc, lsb_pts);
}
if(flags & FLAG_DATA_SIZE)
put_v(bc, size / size_mul);
if(size > MAX_TYPE1_DISTANCE){
assert(frame_type > 0);
update_packetheader(nut, bc, size);
}
put_buffer(bc, buf, size);
update(nut, stream_index, frame_start, frame_type, frame_code, key_frame, size, pts);
return 0;
}
| 1threat
|
Typescript 3 Angular 7 StopPropagation and PreventDefault not working : <p>I have a text input inside a div. Clicking on the input should set it to focus and stop the bubbling of the div click event. I've tried the <code>stopPropagation</code> and <code>preventDefault</code> on the text input event but to no avail. The console logs shows that the div click still executes regardless. How to stop the div click event from executing?</p>
<pre><code>// html
<div (click)="divClick()" >
<mat-card mat-ripple>
<mat-card-header>
<mat-card-title>
<div style="width: 100px">
<input #inputBox matInput (mousedown)="fireEvent($event)" max-width="12" />
</div>
</mat-card-title>
</mat-card-header>
</mat-card>
</div>
// component
@ViewChild('inputBox') inputBox: ElementRef;
divClick() {
console.log('click inside div');
}
fireEvent(e) {
this.inputBox.nativeElement.focus();
e.stopPropagation();
e.preventDefault();
console.log('click inside input');
return false;
}
</code></pre>
| 0debug
|
static void roqvideo_decode_frame(RoqContext *ri)
{
unsigned int chunk_id = 0, chunk_arg = 0;
unsigned long chunk_size = 0;
int i, j, k, nv1, nv2, vqflg = 0, vqflg_pos = -1;
int vqid, bpos, xpos, ypos, xp, yp, x, y, mx, my;
int frame_stats[2][4] = {{0},{0}};
roq_qcell *qcell;
const unsigned char *buf = ri->buf;
const unsigned char *buf_end = ri->buf + ri->size;
while (buf < buf_end) {
chunk_id = bytestream_get_le16(&buf);
chunk_size = bytestream_get_le32(&buf);
chunk_arg = bytestream_get_le16(&buf);
if(chunk_id == RoQ_QUAD_VQ)
break;
if(chunk_id == RoQ_QUAD_CODEBOOK) {
if((nv1 = chunk_arg >> 8) == 0)
nv1 = 256;
if((nv2 = chunk_arg & 0xff) == 0 && nv1 * 6 < chunk_size)
nv2 = 256;
for(i = 0; i < nv1; i++) {
ri->cb2x2[i].y[0] = *buf++;
ri->cb2x2[i].y[1] = *buf++;
ri->cb2x2[i].y[2] = *buf++;
ri->cb2x2[i].y[3] = *buf++;
ri->cb2x2[i].u = *buf++;
ri->cb2x2[i].v = *buf++;
}
for(i = 0; i < nv2; i++)
for(j = 0; j < 4; j++)
ri->cb4x4[i].idx[j] = *buf++;
}
}
bpos = xpos = ypos = 0;
if (chunk_size > buf_end - buf) {
av_log(ri->avctx, AV_LOG_ERROR, "Chunk does not fit in input buffer\n");
chunk_size = buf_end - buf;
}
while(bpos < chunk_size) {
for (yp = ypos; yp < ypos + 16; yp += 8)
for (xp = xpos; xp < xpos + 16; xp += 8) {
if (bpos >= chunk_size) {
av_log(ri->avctx, AV_LOG_ERROR, "Input buffer too small\n");
return;
}
if (vqflg_pos < 0) {
vqflg = buf[bpos++]; vqflg |= (buf[bpos++] << 8);
vqflg_pos = 7;
}
vqid = (vqflg >> (vqflg_pos * 2)) & 0x3;
frame_stats[0][vqid]++;
vqflg_pos--;
switch(vqid) {
case RoQ_ID_MOT:
break;
case RoQ_ID_FCC:
mx = 8 - (buf[bpos] >> 4) - ((signed char) (chunk_arg >> 8));
my = 8 - (buf[bpos++] & 0xf) - ((signed char) chunk_arg);
ff_apply_motion_8x8(ri, xp, yp, mx, my);
break;
case RoQ_ID_SLD:
qcell = ri->cb4x4 + buf[bpos++];
ff_apply_vector_4x4(ri, xp, yp, ri->cb2x2 + qcell->idx[0]);
ff_apply_vector_4x4(ri, xp+4, yp, ri->cb2x2 + qcell->idx[1]);
ff_apply_vector_4x4(ri, xp, yp+4, ri->cb2x2 + qcell->idx[2]);
ff_apply_vector_4x4(ri, xp+4, yp+4, ri->cb2x2 + qcell->idx[3]);
break;
case RoQ_ID_CCC:
for (k = 0; k < 4; k++) {
x = xp; y = yp;
if(k & 0x01) x += 4;
if(k & 0x02) y += 4;
if (bpos >= chunk_size) {
av_log(ri->avctx, AV_LOG_ERROR, "Input buffer too small\n");
return;
}
if (vqflg_pos < 0) {
vqflg = buf[bpos++];
vqflg |= (buf[bpos++] << 8);
vqflg_pos = 7;
}
vqid = (vqflg >> (vqflg_pos * 2)) & 0x3;
frame_stats[1][vqid]++;
vqflg_pos--;
switch(vqid) {
case RoQ_ID_MOT:
break;
case RoQ_ID_FCC:
mx = 8 - (buf[bpos] >> 4) - ((signed char) (chunk_arg >> 8));
my = 8 - (buf[bpos++] & 0xf) - ((signed char) chunk_arg);
ff_apply_motion_4x4(ri, x, y, mx, my);
break;
case RoQ_ID_SLD:
qcell = ri->cb4x4 + buf[bpos++];
ff_apply_vector_2x2(ri, x, y, ri->cb2x2 + qcell->idx[0]);
ff_apply_vector_2x2(ri, x+2, y, ri->cb2x2 + qcell->idx[1]);
ff_apply_vector_2x2(ri, x, y+2, ri->cb2x2 + qcell->idx[2]);
ff_apply_vector_2x2(ri, x+2, y+2, ri->cb2x2 + qcell->idx[3]);
break;
case RoQ_ID_CCC:
ff_apply_vector_2x2(ri, x, y, ri->cb2x2 + buf[bpos]);
ff_apply_vector_2x2(ri, x+2, y, ri->cb2x2 + buf[bpos+1]);
ff_apply_vector_2x2(ri, x, y+2, ri->cb2x2 + buf[bpos+2]);
ff_apply_vector_2x2(ri, x+2, y+2, ri->cb2x2 + buf[bpos+3]);
bpos += 4;
break;
}
}
break;
default:
av_log(ri->avctx, AV_LOG_ERROR, "Unknown vq code: %d\n", vqid);
}
}
xpos += 16;
if (xpos >= ri->width) {
xpos -= ri->width;
ypos += 16;
}
if(ypos >= ri->height)
break;
}
}
| 1threat
|
Parse a single CSV string? : <p>Is there a way that I can parse a single comma delimited string without using anything fancy like a csv.reader(..) ? I can use the <code>split(',')</code> function but that doesn't work when a valid column value contains a comma itself. The csv library has readers for parsing CSV files which correctly handle the aforementioned special case, but I can't use those because I need to parse just a single string. However if the Python CSV allows parsing a single string itself then that's news to me.</p>
| 0debug
|
static void tcg_opt_gen_movi(TCGContext *s, TCGOp *op, TCGArg *args,
TCGArg dst, TCGArg val)
{
TCGOpcode new_op = op_to_movi(op->opc);
tcg_target_ulong mask;
op->opc = new_op;
reset_temp(dst);
temps[dst].state = TCG_TEMP_CONST;
temps[dst].val = val;
mask = val;
if (TCG_TARGET_REG_BITS > 32 && new_op == INDEX_op_mov_i32) {
mask |= ~0xffffffffull;
}
temps[dst].mask = mask;
args[0] = dst;
args[1] = val;
}
| 1threat
|
void pcie_aer_inject_error_print(Monitor *mon, const QObject *data)
{
QDict *qdict;
int devfn;
assert(qobject_type(data) == QTYPE_QDICT);
qdict = qobject_to_qdict(data);
devfn = (int)qdict_get_int(qdict, "devfn");
monitor_printf(mon, "OK id: %s root bus: %s, bus: %x devfn: %x.%x\n",
qdict_get_str(qdict, "id"),
qdict_get_str(qdict, "root_bus"),
(int) qdict_get_int(qdict, "bus"),
PCI_SLOT(devfn), PCI_FUNC(devfn));
}
| 1threat
|
Dependencies Between Workflows on Github Actions : <p>I have a monorepo with two workflows:</p>
<p><code>.github/workflows/test.yml</code></p>
<pre><code>name: test
on: [push, pull_request]
jobs:
test-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: test packages
run: |
yarn install
yarn test
...
</code></pre>
<p><code>.github/workflows/deploy.yml</code></p>
<pre><code> deploy-packages:
runs-on: ubuntu-latest
needs: test-packages
steps:
- uses: actions/checkout@v1
- name: deploy packages
run: |
yarn deploy
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
...
</code></pre>
<p>This doesn't work, I can't reference a job in another workflow:</p>
<pre><code>### ERRORED 19:13:07Z
- Your workflow file was invalid: The pipeline is not valid. The pipeline must contain at least one job with no dependencies.
</code></pre>
<p><strong>Is there a way to create a dependency between workflows?</strong></p>
<p>What I want is to run <code>test.yml</code> then <code>deploy.yml</code> on tags, and <code>test.yml</code> only on push and pull request. I don't want to duplicate jobs between workflows.</p>
| 0debug
|
Visual Studio shows 'Configure settings to improve performance' notification for ReSharper : <p>I am using Visual Studio Professional 2017 15.5.2 along with Resharper 2017.3.1. Every time I open VS, it throws notification</p>
<blockquote>
<p>Configure settings to improve performance.</p>
</blockquote>
<p>I tried ignoring this message but it gets thrown every time I start a new instance.</p>
<p>When this didn't worked, I clicked on message and it took me to Resharper Performance Guide options. I tried changing settings for <code>Source Control plug-in in use.</code>. I changed its value to Ignore but the message still persists.</p>
<blockquote>
<p>2 Questions<br>
1. What is slowing in Resharper for which VS throws this error?<br>
2. Why is this not ignored by VS even though I have asked to ignore this?</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/YSH3q.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/YSH3q.jpg" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/Kl90R.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Kl90R.jpg" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/SJGky.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/SJGky.jpg" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/uJyS5.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/uJyS5.jpg" alt="enter image description here"></a></p>
| 0debug
|
whats the time complexity of my algorithm// plz help me out finding the time complexity of my code : i want to know the time complexity of my code. Plz help me out with my algorithm......
whats the time complexity of my algorithm// plz help me out finding the time complexity of my code
{
int q;
int w;
cout <<"please enter values" <<endl;
cin>>q;
for(w = 0; w<q; w++)
{
int p;
int o;
int sum = 0;
cin>>p;
for(o = 0; o < p; o++)
{
int x;
int y;
int z;
cin>>x ;
cin >>y;
cin>>z;
sum = sum + (x*z);
}
cout<<sum<<endl;
}
_getch();
return 0;
}
| 0debug
|
How to parse Unix timestamp to date string in Kotlin : <p>How can I parse a Unix timestamp to a date string in Kotlin?</p>
<p>For example <code>1532358895</code> to <code>2018-07-23T15:14:55Z</code></p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.