problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
{
int len, nb_components, i, width, height, pix_fmt_id;
s->cur_scan = 0;
s->upscale_h = s->upscale_v = 0;
len = get_bits(&s->gb, 16);
s->bits = get_bits(&s->gb, 8);
if (s->pegasus_rct)
s->bits = 9;
if (s->bits == 9 && !s->pegasus_rct)
s->rct = 1;
if (s->bits != 8 && !s->lossless) {
av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
return -1;
}
if(s->lossless && s->avctx->lowres){
av_log(s->avctx, AV_LOG_ERROR, "lowres is not possible with lossless jpeg\n");
return -1;
}
height = get_bits(&s->gb, 16);
width = get_bits(&s->gb, 16);
if (s->interlaced && s->width == width && s->height == height + 1)
height= s->height;
av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height);
if (av_image_check_size(width, height, 0, s->avctx))
return AVERROR_INVALIDDATA;
nb_components = get_bits(&s->gb, 8);
if (nb_components <= 0 ||
nb_components > MAX_COMPONENTS)
return -1;
if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
if (nb_components != s->nb_components) {
av_log(s->avctx, AV_LOG_ERROR, "nb_components changing in interlaced picture\n");
return AVERROR_INVALIDDATA;
}
}
if (s->ls && !(s->bits <= 8 || nb_components == 1)) {
av_log_missing_feature(s->avctx,
"For JPEG-LS anything except <= 8 bits/component"
" or 16-bit gray", 0);
return AVERROR_PATCHWELCOME;
}
s->nb_components = nb_components;
s->h_max = 1;
s->v_max = 1;
memset(s->h_count, 0, sizeof(s->h_count));
memset(s->v_count, 0, sizeof(s->v_count));
for (i = 0; i < nb_components; i++) {
s->component_id[i] = get_bits(&s->gb, 8) - 1;
s->h_count[i] = get_bits(&s->gb, 4);
s->v_count[i] = get_bits(&s->gb, 4);
if (s->h_count[i] > s->h_max)
s->h_max = s->h_count[i];
if (s->v_count[i] > s->v_max)
s->v_max = s->v_count[i];
if (!s->h_count[i] || !s->v_count[i]) {
av_log(s->avctx, AV_LOG_ERROR, "h/v_count is 0\n");
return -1;
}
s->quant_index[i] = get_bits(&s->gb, 8);
if (s->quant_index[i] >= 4)
return AVERROR_INVALIDDATA;
av_log(s->avctx, AV_LOG_DEBUG, "component %d %d:%d id: %d quant:%d\n",
i, s->h_count[i], s->v_count[i],
s->component_id[i], s->quant_index[i]);
}
if (s->ls && (s->h_max > 1 || s->v_max > 1)) {
av_log_missing_feature(s->avctx, "Subsampling in JPEG-LS", 0);
return AVERROR_PATCHWELCOME;
}
if (s->v_max == 1 && s->h_max == 1 && s->lossless==1 && nb_components==3)
s->rgb = 1;
if (width != s->width || height != s->height) {
av_freep(&s->qscale_table);
s->width = width;
s->height = height;
s->interlaced = 0;
if (s->first_picture &&
s->org_height != 0 &&
s->height < ((s->org_height * 3) / 4)) {
s->interlaced = 1;
s->bottom_field = s->interlace_polarity;
s->picture_ptr->interlaced_frame = 1;
s->picture_ptr->top_field_first = !s->interlace_polarity;
height *= 2;
}
avcodec_set_dimensions(s->avctx, width, height);
s->qscale_table = av_mallocz((s->width + 15) / 16);
s->first_picture = 0;
}
if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
if (s->progressive) {
av_log_ask_for_sample(s->avctx, "progressively coded interlaced pictures not supported\n");
return AVERROR_INVALIDDATA;
}
} else{
pix_fmt_id = (s->h_count[0] << 28) | (s->v_count[0] << 24) |
(s->h_count[1] << 20) | (s->v_count[1] << 16) |
(s->h_count[2] << 12) | (s->v_count[2] << 8) |
(s->h_count[3] << 4) | s->v_count[3];
av_log(s->avctx, AV_LOG_DEBUG, "pix fmt id %x\n", pix_fmt_id);
if (!(pix_fmt_id & 0xD0D0D0D0))
pix_fmt_id -= (pix_fmt_id & 0xF0F0F0F0) >> 1;
if (!(pix_fmt_id & 0x0D0D0D0D))
pix_fmt_id -= (pix_fmt_id & 0x0F0F0F0F) >> 1;
switch (pix_fmt_id) {
case 0x11111100:
if (s->rgb)
s->avctx->pix_fmt = AV_PIX_FMT_BGR24;
else {
if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A') {
s->avctx->pix_fmt = AV_PIX_FMT_GBR24P;
} else {
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
}
}
av_assert0(s->nb_components == 3);
break;
case 0x12121100:
case 0x22122100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_v = 2;
s->upscale_h = (pix_fmt_id == 0x22122100);
s->chroma_height = s->height;
break;
case 0x21211100:
case 0x22211200:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_v = (pix_fmt_id == 0x22211200);
s->upscale_h = 2;
s->chroma_height = s->height;
break;
case 0x22221100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_v = 2;
s->upscale_h = 2;
s->chroma_height = s->height / 2;
break;
case 0x11000000:
if(s->bits <= 8)
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
else
s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
break;
case 0x12111100:
case 0x22211100:
case 0x22112100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_h = (pix_fmt_id == 0x22211100) * 2 + (pix_fmt_id == 0x22112100);
s->chroma_height = s->height / 2;
break;
case 0x21111100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
break;
case 0x22121100:
case 0x22111200:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
s->upscale_v = (pix_fmt_id == 0x22121100) + 1;
break;
case 0x22111100:
s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUVJ420P;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unhandled pixel format 0x%x\n", pix_fmt_id);
return AVERROR_PATCHWELCOME;
}
if ((s->upscale_h || s->upscale_v) && s->avctx->lowres) {
av_log(s->avctx, AV_LOG_ERROR, "lowres not supported for weird subsampling\n");
return AVERROR_PATCHWELCOME;
}
if (s->ls) {
s->upscale_h = s->upscale_v = 0;
if (s->nb_components > 1)
s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
else if (s->bits <= 8)
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
else
s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
}
if (s->picture_ptr->data[0])
s->avctx->release_buffer(s->avctx, s->picture_ptr);
if (s->avctx->get_buffer(s->avctx, s->picture_ptr) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
s->picture_ptr->pict_type = AV_PICTURE_TYPE_I;
s->picture_ptr->key_frame = 1;
s->got_picture = 1;
for (i = 0; i < 3; i++)
s->linesize[i] = s->picture_ptr->linesize[i] << s->interlaced;
av_dlog(s->avctx, "%d %d %d %d %d %d\n",
s->width, s->height, s->linesize[0], s->linesize[1],
s->interlaced, s->avctx->height);
if (len != (8 + (3 * nb_components)))
av_log(s->avctx, AV_LOG_DEBUG, "decode_sof0: error, len(%d) mismatch\n", len);
}
if (s->progressive) {
int bw = (width + s->h_max * 8 - 1) / (s->h_max * 8);
int bh = (height + s->v_max * 8 - 1) / (s->v_max * 8);
for (i = 0; i < s->nb_components; i++) {
int size = bw * bh * s->h_count[i] * s->v_count[i];
av_freep(&s->blocks[i]);
av_freep(&s->last_nnz[i]);
s->blocks[i] = av_malloc(size * sizeof(**s->blocks));
s->last_nnz[i] = av_mallocz(size * sizeof(**s->last_nnz));
s->block_stride[i] = bw * s->h_count[i];
}
memset(s->coefs_finished, 0, sizeof(s->coefs_finished));
}
return 0;
}
| 1threat |
How to Pick files and Images for upload with flutter web : <p>I would like to know how to pick an Image from the users computer into my flutter web app for upload</p>
| 0debug |
RestAssured: How to check the length of json array response? : <p>I have an endpoint that returns a JSON like:</p>
<pre><code>[
{"id" : 4, "name" : "Name4"},
{"id" : 5, "name" : "Name5"}
]
</code></pre>
<p>and a DTO class:</p>
<pre><code>public class FooDto {
public int id;
public String name;
}
</code></pre>
<p>Now, I'm testing the length of the returned json array this way:</p>
<pre><code>@Test
public void test() {
FooDto[] foos = RestAssured.get("/foos").as(FooDto[].class);
assertThat(foos.length, is(2));
}
</code></pre>
<p>But, is there any way to do it without cast to FooDto array? Something like this:</p>
<pre><code>@Test
public void test() {
RestAssured.get("/foos").then().assertThat()
.length(2);
}
</code></pre>
| 0debug |
In Fragment how change the " This " To ACCESS_FINE_LOCATION : case R.id.gps:
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
mgoogleMap.setMyLocationEnabled(true);
the probleme in the this in normal classe was work but in fragment not working | 0debug |
Visitor *qmp_output_get_visitor(QmpOutputVisitor *v)
{
return &v->visitor;
}
| 1threat |
"No valid url specified" when trying to install Kibana's Sense plugin : <p>I'm trying to install the Sense plugin as specified in ElasticSearch getting started guide, like this:</p>
<pre><code>./bin/kibana plugin --install elastic/sense
</code></pre>
<p>However that command seems outdated and the only one that seems possible is this:</p>
<pre><code>./bin/kibana-plugin install elastic/sense
</code></pre>
<p>But it doesn't work:</p>
<pre><code>Attempting to transfer from elastic/sense
Attempting to transfer from https://artifacts.elastic.co/downloads/kibana-plugins/elastic/sense/elastic/sense-5.0.1.zip
Plugin installation was unsuccessful due to error "No valid url specified."
</code></pre>
<p>I tried to install it by downloading it locally from here: <a href="https://download.elasticsearch.org/elasticsearch/sense/sense-2.0.0-beta7.tar.gz" rel="noreferrer">https://download.elasticsearch.org/elasticsearch/sense/sense-2.0.0-beta7.tar.gz</a></p>
<p>And then running:</p>
<pre><code>./bin/kibana-plugin install file:<PATH_TO_sense-2.0.0-beta7.tar>
</code></pre>
<p>But I get this error:</p>
<pre><code>Attempting to transfer from file:/Users/raquelalegre/workspace/ORACC/p4-search-tool/kibana-5.0.1-darwin-x86_64/sense-2.0.0-beta7.tar
Transferring 6363648 bytes....................
Transfer complete
Retrieving metadata from plugin archive
Error: Could not find the End of Central Directory Record
Plugin installation was unsuccessful due to error "Error retrieving metadata from plugin archive"
</code></pre>
<p>I'm stuck and can't find how to install this :( Any help would be really appreciated!</p>
| 0debug |
static int local_mknod(FsContext *fs_ctx, const char *path, FsCred *credp)
{
int err = -1;
int serrno = 0;
if (fs_ctx->fs_sm == SM_MAPPED) {
err = mknod(rpath(fs_ctx, path), SM_LOCAL_MODE_BITS|S_IFREG, 0);
if (err == -1) {
return err;
}
local_set_xattr(rpath(fs_ctx, path), credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
err = mknod(rpath(fs_ctx, path), credp->fc_mode, credp->fc_rdev);
if (err == -1) {
return err;
}
err = local_post_create_passthrough(fs_ctx, path, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
}
return err;
err_end:
remove(rpath(fs_ctx, path));
errno = serrno;
return err;
}
| 1threat |
static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
MpegEncContext * const s = &h->s;
AVCodecContext * const avctx= s->avctx;
int buf_index=0;
#if 0
int i;
for(i=0; i<50; i++){
av_log(NULL, AV_LOG_ERROR,"%02X ", buf[i]);
}
#endif
h->slice_num = 0;
s->current_picture_ptr= NULL;
for(;;){
int consumed;
int dst_length;
int bit_length;
uint8_t *ptr;
int i, nalsize = 0;
if(h->is_avc) {
if(buf_index >= buf_size) break;
nalsize = 0;
for(i = 0; i < h->nal_length_size; i++)
nalsize = (nalsize << 8) | buf[buf_index++];
if(nalsize <= 1){
if(nalsize == 1){
buf_index++;
continue;
}else{
av_log(h->s.avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize);
break;
}
}
} else {
for(; buf_index + 3 < buf_size; buf_index++){
if(buf[buf_index] == 0 && buf[buf_index+1] == 0 && buf[buf_index+2] == 1)
break;
}
if(buf_index+3 >= buf_size) break;
buf_index+=3;
}
ptr= decode_nal(h, buf + buf_index, &dst_length, &consumed, h->is_avc ? nalsize : buf_size - buf_index);
while(ptr[dst_length - 1] == 0 && dst_length > 1)
dst_length--;
bit_length= 8*dst_length - decode_rbsp_trailing(ptr + dst_length - 1);
if(s->avctx->debug&FF_DEBUG_STARTCODE){
av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d/%d length %d\n", h->nal_unit_type, buf_index, buf_size, dst_length);
}
if (h->is_avc && (nalsize != consumed))
av_log(h->s.avctx, AV_LOG_ERROR, "AVC: Consumed only %d bytes instead of %d\n", consumed, nalsize);
buf_index += consumed;
if( (s->hurry_up == 1 && h->nal_ref_idc == 0)
||(avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0))
continue;
switch(h->nal_unit_type){
case NAL_IDR_SLICE:
idr(h);
case NAL_SLICE:
init_get_bits(&s->gb, ptr, bit_length);
h->intra_gb_ptr=
h->inter_gb_ptr= &s->gb;
s->data_partitioning = 0;
if(decode_slice_header(h) < 0){
av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
break;
}
s->current_picture_ptr->key_frame= (h->nal_unit_type == NAL_IDR_SLICE);
if(h->redundant_pic_count==0 && s->hurry_up < 5
&& (avctx->skip_frame < AVDISCARD_NONREF || h->nal_ref_idc)
&& (avctx->skip_frame < AVDISCARD_BIDIR || h->slice_type!=B_TYPE)
&& (avctx->skip_frame < AVDISCARD_NONKEY || h->slice_type==I_TYPE)
&& avctx->skip_frame < AVDISCARD_ALL)
decode_slice(h);
break;
case NAL_DPA:
init_get_bits(&s->gb, ptr, bit_length);
h->intra_gb_ptr=
h->inter_gb_ptr= NULL;
s->data_partitioning = 1;
if(decode_slice_header(h) < 0){
av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
}
break;
case NAL_DPB:
init_get_bits(&h->intra_gb, ptr, bit_length);
h->intra_gb_ptr= &h->intra_gb;
break;
case NAL_DPC:
init_get_bits(&h->inter_gb, ptr, bit_length);
h->inter_gb_ptr= &h->inter_gb;
if(h->redundant_pic_count==0 && h->intra_gb_ptr && s->data_partitioning
&& s->context_initialized
&& s->hurry_up < 5
&& (avctx->skip_frame < AVDISCARD_NONREF || h->nal_ref_idc)
&& (avctx->skip_frame < AVDISCARD_BIDIR || h->slice_type!=B_TYPE)
&& (avctx->skip_frame < AVDISCARD_NONKEY || h->slice_type==I_TYPE)
&& avctx->skip_frame < AVDISCARD_ALL)
decode_slice(h);
break;
case NAL_SEI:
init_get_bits(&s->gb, ptr, bit_length);
decode_sei(h);
break;
case NAL_SPS:
init_get_bits(&s->gb, ptr, bit_length);
decode_seq_parameter_set(h);
if(s->flags& CODEC_FLAG_LOW_DELAY)
s->low_delay=1;
if(avctx->has_b_frames < 2)
avctx->has_b_frames= !s->low_delay;
break;
case NAL_PPS:
init_get_bits(&s->gb, ptr, bit_length);
decode_picture_parameter_set(h, bit_length);
break;
case NAL_AUD:
case NAL_END_SEQUENCE:
case NAL_END_STREAM:
case NAL_FILLER_DATA:
case NAL_SPS_EXT:
case NAL_AUXILIARY_SLICE:
break;
default:
av_log(avctx, AV_LOG_ERROR, "Unknown NAL code: %d\n", h->nal_unit_type);
}
}
if(!s->current_picture_ptr) return buf_index;
s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264;
s->current_picture_ptr->pict_type= s->pict_type;
h->prev_frame_num_offset= h->frame_num_offset;
h->prev_frame_num= h->frame_num;
if(s->current_picture_ptr->reference){
h->prev_poc_msb= h->poc_msb;
h->prev_poc_lsb= h->poc_lsb;
}
if(s->current_picture_ptr->reference)
execute_ref_pic_marking(h, h->mmco, h->mmco_index);
ff_er_frame_end(s);
MPV_frame_end(s);
return buf_index;
}
| 1threat |
Overwrite a File in Node.js : <p>Im trying to write into a text file in node.js.
Im doing this the following way:</p>
<pre><code>fs.writeFile("persistence\\announce.txt", string, function (err) {
if (err) {
return console.log("Error writing file: " + err);
}
});
</code></pre>
<p>whereas string is a variable. </p>
<p>This function will begin it`s writing always at the beginning of a file, so it will overwrite previous content. </p>
<p>I have a problem in the following case:</p>
<p>old content:</p>
<pre><code>Hello Stackoverflow
</code></pre>
<p>new write:</p>
<pre><code>Hi Stackoverflow
</code></pre>
<p>Now the following content will be in the file:</p>
<pre><code>Hi stackoverflowlow
</code></pre>
<p>The new write was shorter then the previous content, so part of the old content is still persistent.</p>
<p><strong>My question:</strong></p>
<p>What do I need to do, so that the old content of a file will be completely removed before the new write is made?</p>
| 0debug |
how do i write login form in android studio : <p>I am trying to login with this code after
entering credentials is gives an error in MainActivity.java at<br>
"setContentView(R.layout.main_activity)"<br>
so whole application get crashed.<br>
please give me a solution to do this.</p>
<p>Login.java</p>
<pre><code>package com.example.user.mangoair11;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
/**
* Created by User on 6/29/2016.
*/
public class Login extends Activity {
private EditText editTextEmail;
private EditText editTextPassword;
public static final String EMAIL_NAME = "EMAIL";
String email;
String password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_activity);
editTextEmail = (EditText) findViewById(R.id.editTextEmail);
editTextPassword = (EditText) findViewById(R.id.editTextPassword);
}
public void invokeLogin(View view){
email = editTextEmail.getText().toString();
password = editTextPassword.getText().toString();
login(email,password);
}
private void login(final String username, String password) {
class LoginAsync extends AsyncTask<String, Void, String> {
private Dialog loadingDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
loadingDialog = ProgressDialog.show(Login.this, "Please wait", "Loading...");
}
@Override
protected String doInBackground(String... params) {
String email = params[0];
String pass = params[1];
InputStream is = null;
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("email", email));
nameValuePairs.add(new BasicNameValuePair("password", pass));
String result = null;
try{
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(
"http://hostogen.com/mangoair10/login.php");
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
result = sb.toString();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
@Override
protected void onPostExecute(String result) {
String s = result.trim();
loadingDialog.dismiss();
if (s.equalsIgnoreCase("success")) {
Intent intent = new Intent(Login.this, UserProfile.class);
intent.putExtra(EMAIL_NAME, email);
finish();
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(), "Invalid User Name or Password", Toast.LENGTH_LONG).show();
}
}
}
LoginAsync la = new LoginAsync();
la.execute(username, password);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
MainActivity.java
package com.example.user.mangoair11;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
Button register,login;
TextView privacy, contact, about;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
register=(Button)findViewById(R.id.button_register);
login=(Button)findViewById(R.id.button_login);
privacy=(TextView)findViewById(R.id.textView2_privacy);
contact=(TextView)findViewById(R.id.textView3_contact);
about=(TextView)findViewById(R.id.textView_about);
register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this, Register.class);
startActivity(i);
}
});
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i=new Intent(MainActivity.this,Login.class);
startActivity(i);
}
});
privacy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,Privacy.class);
startActivity(i);
}
});
contact.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,Contact.class);
startActivity(i);
}
});
about.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,About.class);
startActivity(i);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}[it give error at page shown in image][1]
return super.onOptionsItemSelected(item);
}
}
</code></pre>
| 0debug |
static int process_tns_coeffs(TemporalNoiseShaping *tns, float *tns_coefs_raw,
int order, int w, int filt)
{
int i, j;
int *idx = tns->coef_idx[w][filt];
float *lpc = tns->coef[w][filt];
const int iqfac_p = ((1 << (MAX_LPC_PRECISION-1)) - 0.5)/(M_PI/2.0);
const int iqfac_m = ((1 << (MAX_LPC_PRECISION-1)) + 0.5)/(M_PI/2.0);
float temp[TNS_MAX_ORDER] = {0.0f}, out[TNS_MAX_ORDER] = {0.0f};
for (i = 0; i < order; i++) {
idx[i] = ceilf(asin(tns_coefs_raw[i])*((tns_coefs_raw[i] >= 0) ? iqfac_p : iqfac_m));
lpc[i] = 2*sin(idx[i]/((idx[i] >= 0) ? iqfac_p : iqfac_m));
}
for (i = order; i > -1; i--) {
lpc[i] = (fabs(lpc[i]) > 0.1f) ? lpc[i] : 0.0f;
if (lpc[i] != 0.0 ) {
order = i;
break;
}
}
if (!order)
return 0;
out[0] = 1.0f;
for (i = 1; i <= order; i++) {
for (j = 1; j < i; j++) {
temp[j] = out[j] + lpc[i]*out[i-j];
}
for (j = 1; j <= i; j++) {
out[j] = temp[j];
}
out[i] = lpc[i-1];
}
memcpy(lpc, out, TNS_MAX_ORDER*sizeof(float));
return order;
}
| 1threat |
File encryption ionic 3 : I am looking for file encryption in ionic 3. I am using "libsodium-wrappers" for encrypting my files. I want to encrypt and save files irrespective of their file type. but getting errors each time. I have read a file as the string and encrypted it. But I am not able to get that file again as original one. I have tried readAsText and readAsArraybuffer from file plugin of ionic 3.
is there any other way to get a file in string format and then again in file format with corresponding string? | 0debug |
"already defined in .obj error" or "function template has already been define" : I have this header file:
**Utility.h:**
#pragma once
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <Windows.h>
using namespace std;
template<std::size_t> struct int_ {};
void writeToCSV(string fileName, string value);
struct Timer {
public:
Timer();
void start();
double getMilliSec();
private:
LARGE_INTEGER frequency; // ticks per second
LARGE_INTEGER t1, t2; // ticks
};
//...
#include "Utility.cpp"
And this implementation file:
**Utility.cpp:**
#include "Utility.h"
void writeToCSV(string fileName, string value) {
//...
}
Timer::Timer() {
// get ticks per second
QueryPerformanceFrequency(&frequency);
}
void Timer::start() {
QueryPerformanceCounter(&t1);
}
double Timer::getMilliSec() {
QueryPerformanceCounter(&t2);
return (t2.QuadPart - t1.QuadPart) * 1000.0 / frequency.QuadPart;
}
Which returns this error:
error C2084: function 'void writeToCSV(std::string,std::string)' already has a body
The problem is not about guards (as suggested in [this][1] question) since I use `#pragma once`
I`ve read about of [implementing .tpp files][2] for template class implementation, but I find it an horrible solution, since Visual Studio will format nothing from this file.
[1]: http://stackoverflow.com/questions/4988593/function-already-has-a-body
[2]: http://stackoverflow.com/a/495056/4480180 | 0debug |
In Spring, @Async is working better when we don't define an manual executor : What is the use of defining manual thread executor inside the @Async annotation in spring? When we don't define executor, the @Async is working better.
Use case:
I have created a manual thread pool with max pool size is 50. If we pass 200 requests it process only up to 50 requests. But if we don't define manual thread executor for @Async, it is working fine.
@Async("manualThreadExecutor") - Stops after max pool size
@Async - works fine | 0debug |
static int tgq_decode_mb(TgqContext *s, AVFrame *frame, int mb_y, int mb_x)
{
int mode;
int i;
int8_t dc[6];
mode = bytestream2_get_byte(&s->gb);
if (mode > 12) {
GetBitContext gb;
init_get_bits8(&gb, s->gb.buffer, FFMIN(bytestream2_get_bytes_left(&s->gb), mode));
for (i = 0; i < 6; i++)
tgq_decode_block(s, s->block[i], &gb);
tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y);
bytestream2_skip(&s->gb, mode);
} else {
if (mode == 3) {
memset(dc, bytestream2_get_byte(&s->gb), 4);
dc[4] = bytestream2_get_byte(&s->gb);
dc[5] = bytestream2_get_byte(&s->gb);
} else if (mode == 6) {
bytestream2_get_buffer(&s->gb, dc, 6);
} else if (mode == 12) {
for (i = 0; i < 6; i++) {
dc[i] = bytestream2_get_byte(&s->gb);
bytestream2_skip(&s->gb, 1);
}
} else {
av_log(s->avctx, AV_LOG_ERROR, "unsupported mb mode %i\n", mode);
return -1;
}
tgq_idct_put_mb_dconly(s, frame, mb_x, mb_y, dc);
}
return 0;
}
| 1threat |
static int preallocate(BlockDriverState *bs)
{
uint64_t nb_sectors;
uint64_t offset;
uint64_t host_offset = 0;
int num;
int ret;
QCowL2Meta *meta;
nb_sectors = bdrv_getlength(bs) >> 9;
offset = 0;
while (nb_sectors) {
num = MIN(nb_sectors, INT_MAX >> 9);
ret = qcow2_alloc_cluster_offset(bs, offset, &num,
&host_offset, &meta);
if (ret < 0) {
return ret;
}
ret = qcow2_alloc_cluster_link_l2(bs, meta);
if (ret < 0) {
qcow2_free_any_clusters(bs, meta->alloc_offset, meta->nb_clusters,
QCOW2_DISCARD_NEVER);
return ret;
}
if (meta != NULL) {
QLIST_REMOVE(meta, next_in_flight);
}
nb_sectors -= num;
offset += num << 9;
}
if (host_offset != 0) {
uint8_t buf[512];
memset(buf, 0, 512);
ret = bdrv_write(bs->file, (host_offset >> 9) + num - 1, buf, 1);
if (ret < 0) {
return ret;
}
}
return 0;
}
| 1threat |
void cpu_physical_memory_write_rom(hwaddr addr,
const uint8_t *buf, int len)
{
hwaddr l;
uint8_t *ptr;
hwaddr addr1;
MemoryRegion *mr;
while (len > 0) {
l = len;
mr = address_space_translate(&address_space_memory,
addr, &addr1, &l, true);
if (!(memory_region_is_ram(mr) ||
memory_region_is_romd(mr))) {
} else {
addr1 += memory_region_get_ram_addr(mr);
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
invalidate_and_set_dirty(addr1, l);
}
len -= l;
buf += l;
addr += l;
}
}
| 1threat |
SQL Server, convert an alphanumeric string to upper case alphanumeric : <p>I need code to convert '1a234grh7eg79ef' to '1A234GRH7EG79EF' in sql server.</p>
| 0debug |
How to replace one substring with different substrings in R? : <p>I have a vector of strings and I want to replace one common substring in all the strings with different substrings. I'm doing this in R. For example:</p>
<pre><code>input=c("I like fruits","I like you","I like dudes")
# I need to do something like this
newStrings=c("You","We","She")
gsub("I",newStrings,input)
</code></pre>
<p>so that the output should look like:</p>
<pre><code>"You like fruits"
"We like you"
"She like dudes"
</code></pre>
<p>However, gsub uses only the first string in newStrings. Any suggestions?
Thanks</p>
| 0debug |
Download Android APK file from Fabric Beta : <p>Is it possible to download the Android APK file from Fabric Beta? We have multiple releases uploaded.</p>
| 0debug |
Golang equivalent of npm install -g : <p>If I had a compiled Golang program that I wanted to install such that I could run it with a bash command from anywhere on my computer, how would I do that? For example, in nodejs</p>
<pre><code>npm install -g express
</code></pre>
<p>Installs express such that I can run the command</p>
<pre><code>express myapp
</code></pre>
<p>and express will generate a file directory for a node application called "myapp" in whatever my current directory is. Is there an equivalent command for go? I believe now with the "go install" command you have to be in the directory that contains the executable in order to run it</p>
<p>Thanks in advance!</p>
| 0debug |
can store strings in python array? : from array import *
val=array('u',["thili","gfgfdg"])
print(val)
when I compiled above python code, compiler showed an array.[enter image description here][1]
[1]: https://i.stack.imgur.com/W88gM.png
what is the problem in my code.can not store strings in python array?? | 0debug |
def zigzag(n, k):
if (n == 0 and k == 0):
return 1
if (k == 0):
return 0
return zigzag(n, k - 1) + zigzag(n - 1, n - k) | 0debug |
tortoisegit Commands to Overwrite Local Files : I've installed tortoisegit on windows. I want to fetch all code from origin/master and all local files may be overwritten.
How can we do this with right clicking on the folder and which tortoisegit method we should use with parameters ?
or do we always need to open a command prompt and do a
git fetch --all
get reset --hard origin/master
? | 0debug |
AddTemporarySigningCredential vs AddSigningCredential in IdentityServer4 : <p>According to the docs, IdentityServer uses an asymmetric key pair to sign and validate JWTs.
One could either use <code>AddTemporarySigningCredential()</code> in the configuration which creates a fresh RSA every startup or use <code>AddSigningCredential(..)</code> with an RSA key or a certificate.</p>
<p>The document mentions the Temporary version is useful for Development situations but it does not tell what is the disadvantage of this when used in a production environment. </p>
<p>I have a aspnetcore web api in which the clients are authenticated using the IdentityServer4. The system works fine at the moment with the temporarysigningcredential but I wonder whether there is any benefit in using the other variant.</p>
<p>Thanks,</p>
| 0debug |
How to generate JPA Metamodel with Gradle 5.x : <p>I am currently trying to upgrade from gradle 4.8.1 to 5.1.1 but fail with generating the hibernate metamodel for our code.</p>
<p>The problem is that gradle 5 ignores the annotation processor passed with the compile classpath, but all plugins I found are using this (i.e <code>"-proc:only"</code>).</p>
<p>I tried to specify the annotation processor explicitly as pointed out by gradle (<a href="https://docs.gradle.org/4.6/release-notes.html#convenient-declaration-of-annotation-processor-dependencies" rel="noreferrer">https://docs.gradle.org/4.6/release-notes.html#convenient-declaration-of-annotation-processor-dependencies</a>)
<code>annotationProcessor 'org.hibernate:hibernate-jpamodelgen'</code></p>
<p>But this does not help and I still get the following error:</p>
<blockquote>
<p>warning: Annotation processing without compilation requested but no processors were found.</p>
</blockquote>
<p>Maybe also the plugins need to be updated, but as I said all plugins which I found are passing the annotation processor with the classpath. We are currently using this one: <a href="https://github.com/Catalysts/cat-gradle-plugins/tree/master/cat-gradle-hibernate-plugin" rel="noreferrer">https://github.com/Catalysts/cat-gradle-plugins/tree/master/cat-gradle-hibernate-plugin</a></p>
| 0debug |
Scroll view is scrolling when content is fully visible : <p>I have a problem: my scroll view scrollable, when content is fully visible. What should i do, to enable scrolling, when some part of content is hidden?</p>
| 0debug |
SQL Server - Get last week and next week number from week number : I would like to get last week and next week number from week number.
How to get the next week number if its december or the last week if it's january ?
| 0debug |
Dependency Injection and JavaFX : <p>Since JavaFX runtime wants to instantiate my Application object and all of my controller objects, how do I inject dependencies into these objects?</p>
<p>If objects were instantiated by a DI framework, like Spring, the framework would wire up all the dependencies. If I was instantiating the objects manually, I would provide the dependencies through constructor parameters. But what do I do in a JavaFX application?</p>
<p>Thanks!</p>
| 0debug |
int tpm_register_model(enum TpmModel model)
{
int i;
for (i = 0; i < TPM_MAX_MODELS; i++) {
if (tpm_models[i] == -1) {
tpm_models[i] = model;
return 0;
}
}
error_report("Could not register TPM model");
return 1;
}
| 1threat |
static uint32_t ppc_hash64_pte_size_decode(uint64_t pte1, uint32_t slb_pshift)
{
switch (slb_pshift) {
case 12:
return 12;
case 16:
if ((pte1 & 0xf000) == 0x1000) {
return 16;
}
return 0;
case 24:
if ((pte1 & 0xff000) == 0) {
return 24;
}
return 0;
}
return 0;
}
| 1threat |
static int apply_param_change(AVCodecContext *avctx, AVPacket *avpkt)
{
int size = 0, ret;
const uint8_t *data;
uint32_t flags;
data = av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, &size);
if (!data)
return 0;
if (!(avctx->codec->capabilities & CODEC_CAP_PARAM_CHANGE)) {
av_log(avctx, AV_LOG_ERROR, "This decoder does not support parameter "
"changes, but PARAM_CHANGE side data was sent to it.\n");
return AVERROR(EINVAL);
}
if (size < 4)
goto fail;
flags = bytestream_get_le32(&data);
size -= 4;
if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) {
if (size < 4)
goto fail;
avctx->channels = bytestream_get_le32(&data);
size -= 4;
}
if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) {
if (size < 8)
goto fail;
avctx->channel_layout = bytestream_get_le64(&data);
size -= 8;
}
if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
if (size < 4)
goto fail;
avctx->sample_rate = bytestream_get_le32(&data);
size -= 4;
}
if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) {
if (size < 8)
goto fail;
avctx->width = bytestream_get_le32(&data);
avctx->height = bytestream_get_le32(&data);
size -= 8;
ret = ff_set_dimensions(avctx, avctx->width, avctx->height);
if (ret < 0)
return ret;
}
return 0;
fail:
av_log(avctx, AV_LOG_ERROR, "PARAM_CHANGE side data too small.\n");
return AVERROR_INVALIDDATA;
}
| 1threat |
how to fix Unable to start activity ComponentInfo{.....}: java.lang.NullPointerException : <p>i.m new in android.
its app to direction of qibla. actually i have 3 classes: main, GPS servive, and RoseGPS (to rotate needle).from that main activity class i want to call a functions of other class. error appear when i add RoseGPS. help me to fix it.</p>
<p>MainActivity</p>
<pre><code>public class GPSMainActivity extends Activity implements SensorListener{
//public class GPSMainActivity extends Activity{
TextView textView1,textView2,textView3,textView4;
AppService appService;
Context context;
double latMasjid, lonMasjid;
public static double degree;
private RelativeLayout direcCantainer;
SensorManager sensorManager;
static final int sensor=SensorManager.SENSOR_ORIENTATION;
private RoseGPS rose;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gpsmain);
textView1=(TextView) findViewById(R.id.tvAddress);
textView2=(TextView) findViewById(R.id.tvDegree);
textView3=(TextView)findViewById(R.id.tvLat);
textView4=(TextView) findViewById(R.id.tvLong);
appService=new AppService(GPSMainActivity.this);
Location gpsLocation = appService.getLocation();
if (gpsLocation != null) {
latMasjid=gpsLocation.getLatitude();
lonMasjid = gpsLocation.getLongitude();
String resultLat = "Latitude: " + gpsLocation.getLatitude() +
" Longitude: " + gpsLocation.getLongitude();
textView4.setText(resultLat);
} else {
textView3.setText("gagal");
}
degree=bearing(latMasjid,lonMasjid,21.42243,39.82624);
textView2.setText(String.format("%.2f", degree)+(char)0x00B0);
direcCantainer=(RelativeLayout)findViewById(R.id.cantainer_layout);
rose = new RoseGPS(context);
direcCantainer.addView(rose);
rose.invalidate();
sensorManager=(SensorManager)getSystemService(context.SENSOR_SERVICE);
}
protected double bearing(double startLat, double startLng, double endLat, double endLng){
double longitude1 = startLng;
double longitude2 = endLng;
double latitude1 = Math.toRadians(startLat);
double latitude2 = Math.toRadians(endLat);
double longDiff= Math.toRadians(longitude2 - longitude1);
double y= Math.sin(longDiff)* Math.cos(latitude2);
double x= Math.cos(latitude1)* Math.sin(latitude2)- Math.sin(latitude1)* Math.cos(latitude2)* Math.cos(longDiff);
return (Math.toDegrees(Math.atan2(y, x))+360)%360;
}
public void onSensorChanged(int sensor, float[] values){
if(sensor != GPSMainActivity.sensor)
return;
int orientation = (int)values[0];
rose.setDirections(orientation, orientation);
}
public void onAccuracyChanged(int sensor, int accuracy){
}
</code></pre>
<p>RoseGPS</p>
<pre><code>public class RoseGPS extends View{
GPSMainActivity fragment1GPSMainActivity = new GPSMainActivity();
private float directionNorth=0;
private float directionQibla=0;
private TextView bearingNorth, bearingQibla;
private String bearingNorthString, bearingQiblaString;
private DecimalFormat df = new DecimalFormat("0.000");
private Bitmap compassBackground, compassNeedle;
private Matrix rotateNeedle=new Matrix();
private int width=240;
private int height=240;
private float centre_x=width*0.5f;
private float centre_y=height*0.5f;
public RoseGPS(Context context){
super(context);
initCompassView();
}
public RoseGPS(Context context, AttributeSet attrs, int defStyle){
super(context,attrs,defStyle);
initCompassView();
}
public RoseGPS(Context context, AttributeSet attrs){
super(context, attrs);
initCompassView();
}
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
setMeasuredDimension(width,height);
}
private void initCompassView(){
compassNeedle=BitmapFactory.decodeResource(getResources(), R.drawable.panah_36);
compassBackground=BitmapFactory.decodeResource(getResources(), R.drawable.kompas_72);
width=compassBackground.getWidth()*2;
height=compassBackground.getHeight()*2;
centre_x=width*0.5f;
centre_y=height*0.5f;
rotateNeedle.postTranslate(centre_x - compassNeedle.getWidth()/2, centre_y - compassNeedle.getHeight()/2);
invalidate();
}
public void setConstants(TextView bearingNorth, CharSequence bearingNorthString, TextView bearingQibla, CharSequence bearingQiblaString){
this.bearingNorth=bearingNorth;
this.bearingNorthString=bearingNorthString.toString();
this.bearingQibla=bearingQibla;
this.bearingQiblaString=bearingQiblaString.toString();
}
public void setDirections(float directionsNorth, float directionsQibla){
this.directionNorth=directionsNorth;
this.directionQibla=directionsQibla;
rotateNeedle=new Matrix();
float degree=(float) GPSMainActivity.degree;
rotateNeedle.postRotate(degree, compassNeedle.getWidth()/2, compassNeedle.getHeight()/2);
rotateNeedle.postTranslate(centre_x - compassNeedle.getWidth()/2, centre_y - compassNeedle.getHeight()/2);
invalidate();
}
protected void onDraw(Canvas canvas){
bearingNorth.setText(bearingNorthString.replace("(1)", df.format(directionNorth)));
bearingQibla.setText(bearingQiblaString.replace("(+/-)", directionQibla>=0 ? "+" : "-").replace("(2)", df.format(Math.abs(directionQibla))).replace("(3)", df.format(directionNorth+directionQibla)));
Paint p=new Paint();
canvas.rotate(-directionNorth, centre_x, centre_y);
canvas.drawBitmap(compassBackground, compassBackground.getWidth()/2, compassBackground.getHeight()/2, p);
canvas.drawBitmap(compassNeedle, rotateNeedle, p);
}
</code></pre>
<p>my xml</p>
<pre><code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.gpsaja.GPSMainActivity" >
<TextView
android:id="@+id/tvAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:layout_gravity="center"
android:textStyle="bold"/>
<RelativeLayout
android:id="@+id/cantainer_layout"
android:layout_width="match_parent"
android:layout_height="260dp"
android:background="#ffffff"
android:layout_gravity="center">
</RelativeLayout>
<TextView
android:id="@+id/tvDegree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/idDegree"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
>
<TextView
android:id="@+id/tvLat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/idLat"
android:gravity="center"/>
<TextView
android:id="@+id/tvLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/idLon" />
</LinearLayout>
</code></pre>
<p></p>
<p>my Logcat</p>
<pre><code> 11-24 02:04:51.663: E/AndroidRuntime(2177): FATAL EXCEPTION: main
11-24 02:04:51.663: E/AndroidRuntime(2177): Process: com.gpsaja, PID: 2177
11-24 02:04:51.663: E/AndroidRuntime(2177): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gpsaja/com.gpsaja.GPSMainActivity}: java.lang.NullPointerException
11-24 02:04:51.663: E/AndroidRuntime(2177): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
11-24 02:04:51.663: E/AndroidRuntime(2177): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
11-24 02:04:51.663: E/AndroidRuntime(2177): at android.app.ActivityThread.access$800(ActivityThread.java:135)
11-24 02:04:51.663: E/AndroidRuntime(2177): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
11-24 02:04:51.663: E/AndroidRuntime(2177): at android.os.Handler.dispatchMessage(Handler.java:102)
11-24 02:04:51.663: E/AndroidRuntime(2177): at android.os.Looper.loop(Looper.java:136)
11-24 02:04:51.663: E/AndroidRuntime(2177): at android.app.ActivityThread.main(ActivityThread.java:5001)
11-24 02:04:51.663: E/AndroidRuntime(2177): at java.lang.reflect.Method.invokeNative(Native Method)
11-24 02:04:51.663: E/AndroidRuntime(2177): at java.lang.reflect.Method.invoke(Method.java:515)
11-24 02:04:51.663: E/AndroidRuntime(2177): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
11-24 02:04:51.663: E/AndroidRuntime(2177): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
11-24 02:04:51.663: E/AndroidRuntime(2177): at dalvik.system.NativeStart.main(Native Method)
11-24 02:04:51.663: E/AndroidRuntime(2177): Caused by: java.lang.NullPointerException
11-24 02:04:51.663: E/AndroidRuntime(2177): at android.view.ViewConfiguration.get(ViewConfiguration.java:352)
11-24 02:04:51.663: E/AndroidRuntime(2177): at android.view.View.<init>(View.java:3448)
11-24 02:04:51.663: E/AndroidRuntime(2177): at com.gpsaja.RoseGPS.<init>(RoseGPS.java:33)
11-24 02:04:51.663: E/AndroidRuntime(2177): at com.gpsaja.GPSMainActivity.onCreate(GPSMainActivity.java:64)
11-24 02:04:51.663: E/AndroidRuntime(2177): at android.app.Activity.performCreate(Activity.java:5231)
11-24 02:04:51.663: E/AndroidRuntime(2177): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-24 02:04:51.663: E/AndroidRuntime(2177): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
11-24 02:04:51.663: E/AndroidRuntime(2177): ... 11 more
</code></pre>
| 0debug |
Why doesn't this ruby code do anything? : <p>I am running the following ruby code in my local environment:</p>
<pre><code>def multiples(max)
array = []
(0...max).each do |n|
if (n % 3 == 0) || (n % 5 == 0)
array << n
end
end
array.inject(:+)
end
multiples(1000)
</code></pre>
<p>and nothing happens at all. My code looks good to me. What's the issue here?</p>
| 0debug |
__org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_qemu_x_EnumList *a,
__org_qemu_x_StructList *b,
__org_qemu_x_Union2 *c,
__org_qemu_x_Alt *d,
Error **errp)
{
__org_qemu_x_Union1 *ret = g_new0(__org_qemu_x_Union1, 1);
ret->type = ORG_QEMU_X_UNION1_KIND___ORG_QEMU_X_BRANCH;
ret->u.__org_qemu_x_branch = strdup("blah1");
return ret;
| 1threat |
static int send_invoke_response(URLContext *s, RTMPPacket *pkt)
{
RTMPContext *rt = s->priv_data;
double seqnum;
char filename[64];
char command[64];
int stringlen;
char *pchar;
const uint8_t *p = pkt->data;
uint8_t *pp = NULL;
RTMPPacket spkt = { 0 };
GetByteContext gbc;
int ret;
bytestream2_init(&gbc, p, pkt->size);
if (ff_amf_read_string(&gbc, command, sizeof(command),
&stringlen)) {
av_log(s, AV_LOG_ERROR, "Error in PT_INVOKE\n");
return AVERROR_INVALIDDATA;
}
ret = ff_amf_read_number(&gbc, &seqnum);
if (ret)
return ret;
ret = ff_amf_read_null(&gbc);
if (ret)
return ret;
if (!strcmp(command, "FCPublish") ||
!strcmp(command, "publish")) {
ret = ff_amf_read_string(&gbc, filename,
sizeof(filename), &stringlen);
if (ret) {
if (ret == AVERROR(EINVAL))
av_log(s, AV_LOG_ERROR, "Unable to parse stream name - name too long?\n");
else
av_log(s, AV_LOG_ERROR, "Unable to parse stream name\n");
return ret;
}
if (s->filename) {
pchar = strrchr(s->filename, '/');
if (!pchar) {
av_log(s, AV_LOG_WARNING,
"Unable to find / in url %s, bad format\n",
s->filename);
pchar = s->filename;
}
pchar++;
if (strcmp(pchar, filename))
av_log(s, AV_LOG_WARNING, "Unexpected stream %s, expecting"
" %s\n", filename, pchar);
}
rt->state = STATE_RECEIVING;
}
if (!strcmp(command, "FCPublish")) {
if ((ret = ff_rtmp_packet_create(&spkt, RTMP_SYSTEM_CHANNEL,
RTMP_PT_INVOKE, 0,
RTMP_PKTDATA_DEFAULT_SIZE)) < 0) {
av_log(s, AV_LOG_ERROR, "Unable to create response packet\n");
return ret;
}
pp = spkt.data;
ff_amf_write_string(&pp, "onFCPublish");
} else if (!strcmp(command, "publish")) {
ret = write_begin(s);
if (ret < 0)
return ret;
return write_status(s, pkt, "NetStream.Publish.Start",
filename);
} else if (!strcmp(command, "play")) {
ret = write_begin(s);
if (ret < 0)
return ret;
rt->state = STATE_SENDING;
return write_status(s, pkt, "NetStream.Play.Start",
filename);
} else {
if ((ret = ff_rtmp_packet_create(&spkt, RTMP_SYSTEM_CHANNEL,
RTMP_PT_INVOKE, 0,
RTMP_PKTDATA_DEFAULT_SIZE)) < 0) {
av_log(s, AV_LOG_ERROR, "Unable to create response packet\n");
return ret;
}
pp = spkt.data;
ff_amf_write_string(&pp, "_result");
ff_amf_write_number(&pp, seqnum);
ff_amf_write_null(&pp);
if (!strcmp(command, "createStream")) {
rt->nb_streamid++;
if (rt->nb_streamid == 0 || rt->nb_streamid == 2)
rt->nb_streamid++;
ff_amf_write_number(&pp, rt->nb_streamid);
}
}
spkt.size = pp - spkt.data;
ret = ff_rtmp_packet_write(rt->stream, &spkt, rt->out_chunk_size,
&rt->prev_pkt[1], &rt->nb_prev_pkt[1]);
ff_rtmp_packet_destroy(&spkt);
return ret;
}
| 1threat |
Kotlin Annotation IntDef : <p>I have this code sample:</p>
<pre><code>class MeasureTextView: TextView {
constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
companion object{
val UNIT_NONE = -1
val UNIT_KG = 1
val UNIT_LB = 0
}
fun setMeasureText(number: Float, unitType: Int){
val suffix = when(unitType){
UNIT_NONE -> {
EMPTY_STRING
}
UNIT_KG -> {
KG_SUFIX
}
UNIT_LB -> {
LB_SUFIX
}
else -> throw IllegalArgumentException("Wrong unitType passed to formatter: MeasureTextView.setMeasureText")
}
// set the final text
text = "$number $suffix"
}
}
</code></pre>
<p>I want to be able to use, at compile time, the auto complete feature in conjunction with IntDef annotation, so when i invoke <code>setMeasureText(...)</code>,
the static variables are shown as options to the argument of this method.</p>
<p>I have searched about this, and i couldn't find if Kotlin supported this java-style annotations (intdef for example). So i have tried it, and made an annotation for this, but it won't show in autocompletion.</p>
<p>My question:
- Is Java annotation IntDef supported in Kotlin (latest version)</p>
<ul>
<li><p>If it is, how can i turn in ON in the Android Studio IDE (if it works, i can't get the compiler to suggest it).</p></li>
<li><p>If it is not, is there any Kotlin-way of make this compile time checks</p></li>
</ul>
| 0debug |
static void put_ebml_utf8(ByteIOContext *pb, unsigned int elementid, char *str)
{
put_ebml_binary(pb, elementid, str, strlen(str));
}
| 1threat |
static int mpegps_read_pes_header(AVFormatContext *s,
int64_t *ppos, int *pstart_code,
int64_t *ppts, int64_t *pdts)
{
MpegDemuxContext *m = s->priv_data;
int len, size, startcode, c, flags, header_len;
int64_t pts, dts, last_pos;
last_pos = -1;
redo:
m->header_state = 0xff;
size = MAX_SYNC_SIZE;
startcode = find_next_start_code(&s->pb, &size, &m->header_state);
if (startcode < 0)
return AVERROR_IO;
if (startcode == PACK_START_CODE)
goto redo;
if (startcode == SYSTEM_HEADER_START_CODE)
goto redo;
if (startcode == PADDING_STREAM ||
startcode == PRIVATE_STREAM_2) {
len = get_be16(&s->pb);
url_fskip(&s->pb, len);
goto redo;
}
if (startcode == PROGRAM_STREAM_MAP) {
mpegps_psm_parse(m, &s->pb);
goto redo;
}
if (!((startcode >= 0x1c0 && startcode <= 0x1df) ||
(startcode >= 0x1e0 && startcode <= 0x1ef) ||
(startcode == 0x1bd)))
goto redo;
if (ppos) {
*ppos = url_ftell(&s->pb) - 4;
}
len = get_be16(&s->pb);
pts = AV_NOPTS_VALUE;
dts = AV_NOPTS_VALUE;
for(;;) {
if (len < 1)
goto redo;
c = get_byte(&s->pb);
len--;
if (c != 0xff)
break;
}
if ((c & 0xc0) == 0x40) {
if (len < 2)
goto redo;
get_byte(&s->pb);
c = get_byte(&s->pb);
len -= 2;
}
if ((c & 0xf0) == 0x20) {
if (len < 4)
goto redo;
dts = pts = get_pts(&s->pb, c);
len -= 4;
} else if ((c & 0xf0) == 0x30) {
if (len < 9)
goto redo;
pts = get_pts(&s->pb, c);
dts = get_pts(&s->pb, -1);
len -= 9;
} else if ((c & 0xc0) == 0x80) {
#if 0
if ((c & 0x30) != 0) {
goto redo;
}
#endif
flags = get_byte(&s->pb);
header_len = get_byte(&s->pb);
len -= 2;
if (header_len > len)
goto redo;
if ((flags & 0xc0) == 0x80) {
dts = pts = get_pts(&s->pb, -1);
if (header_len < 5)
goto redo;
header_len -= 5;
len -= 5;
} if ((flags & 0xc0) == 0xc0) {
pts = get_pts(&s->pb, -1);
dts = get_pts(&s->pb, -1);
if (header_len < 10)
goto redo;
header_len -= 10;
len -= 10;
}
len -= header_len;
while (header_len > 0) {
get_byte(&s->pb);
header_len--;
}
}
else if( c!= 0xf )
goto redo;
if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) {
if (len < 1)
goto redo;
startcode = get_byte(&s->pb);
len--;
if (startcode >= 0x80 && startcode <= 0xbf) {
if (len < 3)
goto redo;
get_byte(&s->pb);
get_byte(&s->pb);
get_byte(&s->pb);
len -= 3;
}
}
if(dts != AV_NOPTS_VALUE && ppos){
int i;
for(i=0; i<s->nb_streams; i++){
if(startcode == s->streams[i]->id) {
av_add_index_entry(s->streams[i], *ppos, dts, 0, 0, AVINDEX_KEYFRAME );
}
}
}
*pstart_code = startcode;
*ppts = pts;
*pdts = dts;
return len;
}
| 1threat |
Replacement for sql query with storedProcedure : public DataTable GetRandomQuestionByCateId(string id, int z)
{
string sql = "SELECT * FROM tblQuestions where CategoryId=@a ORDER BY QId OFFSET @z ROWS FETCH NEXT 1 ROWS ONLY";
SqlParameter[] param = new SqlParameter[]
{
new SqlParameter("@a",id),
new SqlParameter("@z",z),
};
return DAO.GetTable(sql, param);
}
I have this code segment and want to execute a stored procedure as:
create PROCEDURE GetRandomQuest
(
@a int,
@b int
)
AS
BEGIN
SET NOCOUNT ON;
sELECT *
FROM tblQuestions where CategoryId=@a
ORDER BY QId
OFFSET @b ROWS
FETCH NEXT 1 ROWS ONLY;
END
EXEC dbo.GetRandomQuest @a=2, @b=1
how can i replace it in above case? | 0debug |
static int calc_bit_demand(AacPsyContext *ctx, float pe, int bits, int size,
int short_window)
{
const float bitsave_slope = short_window ? PSY_3GPP_SAVE_SLOPE_S : PSY_3GPP_SAVE_SLOPE_L;
const float bitsave_add = short_window ? PSY_3GPP_SAVE_ADD_S : PSY_3GPP_SAVE_ADD_L;
const float bitspend_slope = short_window ? PSY_3GPP_SPEND_SLOPE_S : PSY_3GPP_SPEND_SLOPE_L;
const float bitspend_add = short_window ? PSY_3GPP_SPEND_ADD_S : PSY_3GPP_SPEND_ADD_L;
const float clip_low = short_window ? PSY_3GPP_CLIP_LO_S : PSY_3GPP_CLIP_LO_L;
const float clip_high = short_window ? PSY_3GPP_CLIP_HI_S : PSY_3GPP_CLIP_HI_L;
float clipped_pe, bit_save, bit_spend, bit_factor, fill_level;
ctx->fill_level += ctx->frame_bits - bits;
ctx->fill_level = av_clip(ctx->fill_level, 0, size);
fill_level = av_clipf((float)ctx->fill_level / size, clip_low, clip_high);
clipped_pe = av_clipf(pe, ctx->pe.min, ctx->pe.max);
bit_save = (fill_level + bitsave_add) * bitsave_slope;
assert(bit_save <= 0.3f && bit_save >= -0.05000001f);
bit_spend = (fill_level + bitspend_add) * bitspend_slope;
assert(bit_spend <= 0.5f && bit_spend >= -0.1f);
bit_factor = 1.0f - bit_save + ((bit_spend - bit_save) / (ctx->pe.max - ctx->pe.min)) * (clipped_pe - ctx->pe.min);
ctx->pe.max = FFMAX(pe, ctx->pe.max);
ctx->pe.min = FFMIN(pe, ctx->pe.min);
return FFMIN(ctx->frame_bits * bit_factor, ctx->frame_bits + size - bits);
}
| 1threat |
void tlb_set_page(CPUState *cpu, target_ulong vaddr,
hwaddr paddr, int prot,
int mmu_idx, target_ulong size)
{
CPUArchState *env = cpu->env_ptr;
MemoryRegionSection *section;
unsigned int index;
target_ulong address;
target_ulong code_address;
uintptr_t addend;
CPUTLBEntry *te;
hwaddr iotlb, xlat, sz;
assert(size >= TARGET_PAGE_SIZE);
if (size != TARGET_PAGE_SIZE) {
tlb_add_large_page(env, vaddr, size);
}
sz = size;
section = address_space_translate_for_iotlb(cpu->as, paddr,
&xlat, &sz);
assert(sz >= TARGET_PAGE_SIZE);
#if defined(DEBUG_TLB)
printf("tlb_set_page: vaddr=" TARGET_FMT_lx " paddr=0x" TARGET_FMT_plx
" prot=%x idx=%d\n",
vaddr, paddr, prot, mmu_idx);
#endif
address = vaddr;
if (!memory_region_is_ram(section->mr) && !memory_region_is_romd(section->mr)) {
address |= TLB_MMIO;
addend = 0;
} else {
addend = (uintptr_t)memory_region_get_ram_ptr(section->mr) + xlat;
}
code_address = address;
iotlb = memory_region_section_get_iotlb(cpu, section, vaddr, paddr, xlat,
prot, &address);
index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
env->iotlb[mmu_idx][index] = iotlb - vaddr;
te = &env->tlb_table[mmu_idx][index];
te->addend = addend - vaddr;
if (prot & PAGE_READ) {
te->addr_read = address;
} else {
te->addr_read = -1;
}
if (prot & PAGE_EXEC) {
te->addr_code = code_address;
} else {
te->addr_code = -1;
}
if (prot & PAGE_WRITE) {
if ((memory_region_is_ram(section->mr) && section->readonly)
|| memory_region_is_romd(section->mr)) {
te->addr_write = address | TLB_MMIO;
} else if (memory_region_is_ram(section->mr)
&& cpu_physical_memory_is_clean(section->mr->ram_addr
+ xlat)) {
te->addr_write = address | TLB_NOTDIRTY;
} else {
te->addr_write = address;
}
} else {
te->addr_write = -1;
}
}
| 1threat |
VS Code - Code Formatting space before curly braces : <p>When I use autoformat function in VS Code editor it insert spaces before curly brackets like this:</p>
<p>From:</p>
<pre><code><Button onClick={this.callMyFunc.bind(this, screenSet.index)}>Add</Button>
</code></pre>
<p>To: </p>
<pre><code><Button onClick={this.callMyFunc.bind(this, screenSet.index) }>Add</Button>
</code></pre>
<p>From: </p>
<pre><code>))}
</code></pre>
<p>To: </p>
<pre><code>)) }
</code></pre>
<p>I can't find option what settings this... Can anyone help me, please?</p>
| 0debug |
C / gcc / underscore in "#define"s : I am testing (*with gcc version 4.9.2 / Linux no parameters*) two versions of the same code.
Both have a #define directive, followed by an #ifdef/#endif pair further down.
Now, it turns out that the combination works properly **only if the label after the initial #define starts with an underscore**. Without the underscore, it works.... in a very weird way, like every third time.
In other words,
#define _whatever
works, while
#define whatever
doesn't.
Even though I know how to make the directive work, just curious - does that behavior follow any standard?
Thanks.
| 0debug |
C# how to pass an array as a ref parameter : I appreciate some help translating the VB code below, to C#.
I am stucked in obSMS.GetEstado(vMessages). I am invoking an external service that is supposed to retun me vMessages,
an array like the one described at the bottom. Each row of the array has 4 elements (0, 1 ,2 3).
Please I need a int in how to traslate obSMS.GetEstado(vMessages) to C#.
Thanks a lot
Dim obSMS As SMSEmpresarial.clsSMS
Dim vMessages As Object
Dim i As Integer
obSMS = New SMSEmpresarial.clsSMS
obSMS.GetEstado(vMessages)
For i = 0 To UBound(vMessages, 1) - 1
Me.ListBox1.Items.Add("Cod:" & CStr(vMessages(i, 0)) &
":Tel:" & CStr(vMessages(i, 1)) & ":Est:" & CStr(vMessages(i, 2)) &
":Obs:" & CStr(vMessages(i, 3)))
Next
obSMS = Nothing
Exit Sub
How vMessages array looks like:
row 0 AAAAA BBBBB CCCCC DDDD
row 1 KKKKK PPPPP GGGGG HHHH
row 2 MMMMM FFFFF XXXXX ZZZZ | 0debug |
What is the difference between managed-schema and schema.xml : <p>I have below questions in solr 6.</p>
<ol>
<li>What is the main difference between managed-schema and schema.xml</li>
<li>What are the benefits and disadvantages while using managed-schema and schema.xml(classic).</li>
</ol>
<p>And could you please help me in understanding what is recommended in solr6?</p>
<p>Regards,</p>
<p>Shaffic</p>
| 0debug |
how to change the wallpaper using OC or Swift on mac : <p>how to change the wallpaper using OC or Swift on mac?</p>
<p>Use OC or swift to set wallpaper,Who knows how to do it?</p>
| 0debug |
static void query_facilities(void)
{
struct sigaction sa_old, sa_new;
register int r0 __asm__("0");
register void *r1 __asm__("1");
int fail;
memset(&sa_new, 0, sizeof(sa_new));
sa_new.sa_handler = sigill_handler;
sigaction(SIGILL, &sa_new, &sa_old);
r1 = &facilities;
asm volatile(".word 0xb2b0,0x1000"
: "=r"(r0) : "0"(0), "r"(r1) : "memory", "cc");
if (got_sigill) {
got_sigill = 0;
asm volatile(".word 0xb908,0x0000" : "=r"(r0) : : "cc");
if (!got_sigill) {
facilities |= FACILITY_ZARCH_ACTIVE;
}
got_sigill = 0;
r1 = &facilities;
asm volatile(".word 0xe300,0x1000,0x0058"
: "=r"(r0) : "r"(r1) : "cc");
if (!got_sigill) {
facilities |= FACILITY_LONG_DISP;
}
got_sigill = 0;
asm volatile(".word 0xc209,0x0000,0x0000" : : : "cc");
if (!got_sigill) {
facilities |= FACILITY_EXT_IMM;
}
got_sigill = 0;
asm volatile(".word 0xc201,0x0000,0x0001");
if (!got_sigill) {
facilities |= FACILITY_GEN_INST_EXT;
}
}
sigaction(SIGILL, &sa_old, NULL);
fail = 0;
if ((facilities & FACILITY_ZARCH_ACTIVE) == 0) {
fprintf(stderr, "TCG: z/Arch facility is required.\n");
fprintf(stderr, "TCG: Boot with a 64-bit enabled kernel.\n");
fail = 1;
}
if ((facilities & FACILITY_LONG_DISP) == 0) {
fprintf(stderr, "TCG: long-displacement facility is required.\n");
fail = 1;
}
if (sizeof(void *) != 8) {
fprintf(stderr, "TCG: 31-bit mode is not supported.\n");
fail = 1;
}
if (fail) {
exit(-1);
}
}
| 1threat |
static int cng_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
CNGContext *p = avctx->priv_data;
int buf_size = avpkt->size;
int ret, i;
int16_t *buf_out;
float e = 1.0;
float scaling;
if (avpkt->size) {
int dbov = -avpkt->data[0];
p->target_energy = 1081109975 * ff_exp10(dbov / 10.0) * 0.75;
memset(p->target_refl_coef, 0, p->order * sizeof(*p->target_refl_coef));
for (i = 0; i < FFMIN(avpkt->size - 1, p->order); i++) {
p->target_refl_coef[i] = (avpkt->data[1 + i] - 127) / 128.0;
}
}
if (avctx->internal->skip_samples > 10 * avctx->frame_size) {
avctx->internal->skip_samples = 0;
return AVERROR_INVALIDDATA;
}
if (p->inited) {
p->energy = p->energy / 2 + p->target_energy / 2;
for (i = 0; i < p->order; i++)
p->refl_coef[i] = 0.6 *p->refl_coef[i] + 0.4 * p->target_refl_coef[i];
} else {
p->energy = p->target_energy;
memcpy(p->refl_coef, p->target_refl_coef, p->order * sizeof(*p->refl_coef));
p->inited = 1;
}
make_lpc_coefs(p->lpc_coef, p->refl_coef, p->order);
for (i = 0; i < p->order; i++)
e *= 1.0 - p->refl_coef[i]*p->refl_coef[i];
scaling = sqrt(e * p->energy / 1081109975);
for (i = 0; i < avctx->frame_size; i++) {
int r = (av_lfg_get(&p->lfg) & 0xffff) - 0x8000;
p->excitation[i] = scaling * r;
}
ff_celp_lp_synthesis_filterf(p->filter_out + p->order, p->lpc_coef,
p->excitation, avctx->frame_size, p->order);
frame->nb_samples = avctx->frame_size;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
buf_out = (int16_t *)frame->data[0];
for (i = 0; i < avctx->frame_size; i++)
buf_out[i] = p->filter_out[i + p->order];
memcpy(p->filter_out, p->filter_out + avctx->frame_size,
p->order * sizeof(*p->filter_out));
*got_frame_ptr = 1;
return buf_size;
}
| 1threat |
Why data frame column names different using = and <- in R : <p>Can any body explain why the below two data frames <code>df1</code> and <code>df2</code> are differing in their column names</p>
<pre><code> df1 <- data.frame(a = 1:5, b = 11:15)
df1
# a b
# 1 1 11
# 2 2 12
# 3 3 13
# 4 4 14
# 5 5 15
df2 <- data.frame(a <- 1:5, b <- 11:15)
df2
# a....1.5 b....11.15
# 1 1 11
# 2 2 12
# 3 3 13
# 4 4 14
# 5 5 15
</code></pre>
| 0debug |
Set textview from json url android? : Hello so i am currently making an app that gets json data from url and i want to get the "points" from the json set to textView7. I have some code but i do not know if its correct. I want to be able to pull 2 diffrent from the url https://www.lurkinator.net/api/data?username=bobtheshoplifter_
"points": 3,
"username": "bobtheshoplifter_"
I wanna set them both in the textView's i have
Here is how my text views look like [Image][1] Both the username and points are seperate and the string of the username is @string/userid and points @string/points
Thanks for the help!
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
public class AddProfile extends Activity {
// All xml labels
TextView txtPoints;
// Progress Dialog
private ProgressDialog pDialog;
// Profile json object
JSONArray points;
JSONObject hay;
// Profile JSON url
private static final String POINTS_URL = "https://www.lurkinator.net/api/data?username=bobtheshoplifter_";
// ALL JSON node names
private static final String TAG_POINTS = "points";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtPoints = (TextView) findViewById(R.id.textView7);
<!-- end snippet -->
[1]: https://i.stack.imgur.com/vxoFI.png | 0debug |
How do I code an image generator that will generate every 64 x 64 picture ever? : <p>So I want to make a website where I can generate EVERY SINGLE Minecraft skin (which are 64 px by 64 px) possible (And put it up on a web page), by using many different combinations of many different coloured pixels in many different positions. (Or in fact, ALL of them.)</p>
<p>Similar to a generator which generates every black/white pixel combination in a 1x2 grid (I made a gif on that here, <a href="https://gyazo.com/071a5d482852fc8eea9963e841f5dbc1" rel="nofollow">https://gyazo.com/071a5d482852fc8eea9963e841f5dbc1</a>, but it's very small so you'll have to look at your screen closely), except using all colours and on a much larger scale.</p>
<p>But the problem is, I don't know what coding language to code it in.</p>
<p>And there are many different coding languages, like PHP, SQL, JavaScript, Ruby, Python, and others, but I just don't know which one to use to create a generator like this. (And I also don't know how to actually get it onto the web page so it can generate onto the web page real-time.)</p>
<p>If anyone could help me on this then that would be greatly appreciated.</p>
<p>Thanks.</p>
| 0debug |
How to get this type of array from string.xml file to an android activity : <p><a href="https://i.stack.imgur.com/rLz2S.png" rel="nofollow noreferrer">photo of the integer array in string.xml </a></p>
<p>I want to access this integer array into an arraylist in activity.</p>
| 0debug |
static int compat_read(AVFilterContext *ctx, AVFilterBufferRef **pbuf, int nb_samples, int flags)
{
AVFilterBufferRef *buf;
AVFrame *frame;
int ret;
if (!pbuf)
return ff_poll_frame(ctx->inputs[0]);
frame = av_frame_alloc();
if (!frame)
return AVERROR(ENOMEM);
if (!nb_samples)
ret = av_buffersink_get_frame_flags(ctx, frame, flags);
else
ret = av_buffersink_get_samples(ctx, frame, nb_samples);
if (ret < 0)
goto fail;
if (ctx->inputs[0]->type == AVMEDIA_TYPE_VIDEO) {
buf = avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize,
AV_PERM_READ,
frame->width, frame->height,
frame->format);
} else {
buf = avfilter_get_audio_buffer_ref_from_arrays(frame->extended_data,
frame->linesize[0], AV_PERM_READ,
frame->nb_samples,
frame->format,
frame->channel_layout);
}
if (!buf) {
ret = AVERROR(ENOMEM);
goto fail;
}
avfilter_copy_frame_props(buf, frame);
buf->buf->priv = frame;
buf->buf->free = compat_free_buffer;
*pbuf = buf;
return 0;
fail:
av_frame_free(&frame);
return ret;
}
| 1threat |
static int link_filter_inouts(AVFilterContext *filt_ctx,
AVFilterInOut **curr_inputs,
AVFilterInOut **open_inputs, void *log_ctx)
{
int pad, ret;
for (pad = 0; pad < filt_ctx->input_count; pad++) {
AVFilterInOut *p = *curr_inputs;
if (p)
*curr_inputs = (*curr_inputs)->next;
else if (!(p = av_mallocz(sizeof(*p))))
return AVERROR(ENOMEM);
if (p->filter_ctx) {
if ((ret = link_filter(p->filter_ctx, p->pad_idx, filt_ctx, pad, log_ctx)) < 0)
return ret;
av_free(p->name);
av_free(p);
} else {
p->filter_ctx = filt_ctx;
p->pad_idx = pad;
append_inout(open_inputs, &p);
}
}
if (*curr_inputs) {
av_log(log_ctx, AV_LOG_ERROR,
"Too many inputs specified for the \"%s\" filter.\n",
filt_ctx->filter->name);
return AVERROR(EINVAL);
}
pad = filt_ctx->output_count;
while (pad--) {
AVFilterInOut *currlinkn = av_mallocz(sizeof(AVFilterInOut));
if (!currlinkn)
return AVERROR(ENOMEM);
currlinkn->filter_ctx = filt_ctx;
currlinkn->pad_idx = pad;
insert_inout(curr_inputs, currlinkn);
}
return 0;
}
| 1threat |
How to preprocess text for embedding? : <p>In the traditional "one-hot" representation of words as vectors you have a vector of the same dimension as the cardinality of your vocabulary. To reduce dimensionality usually stopwords are removed, as well as applying stemming, lemmatizing, etc. to normalize the features you want to perform some NLP task on.</p>
<p>I'm having trouble understanding whether/how to preprocess text to be embedded (e.g. word2vec). My goal is to use these word embeddings as features for a NN to classify texts into topic A, not topic A, and then perform event extraction on them on documents of topic A (using a second NN).</p>
<p>My first instinct is to preprocess removing stopwords, lemmatizing stemming, etc. But as I learn about NN a bit more I realize that applied to natural language, the CBOW and skip-gram models would in fact require the whole set of words to be present --to be able to predict a word from context one would need to know the actual context, not a reduced form of the context after normalizing... right?). The actual sequence of POS tags seems to be key for a human-feeling prediction of words.</p>
<p>I've found <a href="https://groups.google.com/forum/#!topic/word2vec-toolkit/TI-TQC-b53w" rel="noreferrer">some guidance online</a> but I'm still curious to know what the community here thinks:</p>
<ol>
<li>Are there any recent commonly accepted best practices regarding punctuation, stemming, lemmatizing, stopwords, numbers, lowercase etc?</li>
<li>If so, what are they? Is it better in general to process as little as possible, or more on the heavier side to normalize the text? Is there a trade-off?</li>
</ol>
<p>My thoughts: </p>
<p>It is better to remove punctuation (but e.g. in Spanish don't remove the accents because the do convey contextual information), change written numbers to numeric, do not lowercase everything (useful for entity extraction), no stemming, no lemmatizing. </p>
<p>Does this sound right?</p>
| 0debug |
translate jquery in js : I have a conflict with jQuery on my site. And my script on jQuery don't work correctly.
Please help me translate this jQuery code in JavaScript. Thank you!
$('.row').each(function(){
boxes = $(this).find('.product .ic>a');
maxHeight = Math.max.apply(
Math, boxes.map(function() {
return $(this).height();
}).get());
boxes.height(maxHeight); | 0debug |
static uint32_t ide_ioport_read(void *opaque, uint32_t addr1)
{
IDEState *ide_if = opaque;
IDEState *s = ide_if->cur_drive;
uint32_t addr;
int ret, hob;
addr = addr1 & 7;
hob = 0;
switch(addr) {
case 0:
ret = 0xff;
break;
case 1:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->error;
else
ret = s->hob_feature;
break;
case 2:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->nsector & 0xff;
else
ret = s->hob_nsector;
break;
case 3:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->sector;
else
ret = s->hob_sector;
break;
case 4:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->lcyl;
else
ret = s->hob_lcyl;
break;
case 5:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else if (!hob)
ret = s->hcyl;
else
ret = s->hob_hcyl;
break;
case 6:
if (!ide_if[0].bs && !ide_if[1].bs)
ret = 0;
else
ret = s->select;
break;
default:
case 7:
if ((!ide_if[0].bs && !ide_if[1].bs) ||
(s != ide_if && !s->bs))
ret = 0;
else
ret = s->status;
qemu_irq_lower(s->irq);
break;
}
#ifdef DEBUG_IDE
printf("ide: read addr=0x%x val=%02x\n", addr1, ret);
#endif
return ret;
}
| 1threat |
Jackson JSON mapper by Spring Boot : <p>My question is very simple, Jackson2ObjectMapperBuilder works only in the serialization of a response and not in the serialization of a request?</p>
<p>Thanks!</p>
| 0debug |
C# Linq unique not work on lists : <p>I am trying with the following code to check if a list contains duplicated data:</p>
<pre><code> internal class Program
{
private static void Main(string[] args)
{
var list = new List<Obj>() { new Obj() { id = "1", name = "1" }, new Obj() { id = "1", name = "1" } };
Console.WriteLine(AllItemsAreUnique(list));
}
public static bool AllItemsAreUnique<T>(IEnumerable<T> items)
{
return items.Distinct().Count() == items.Count();
}
}
internal class Obj
{
public string id;
public string name;
}
</code></pre>
<p>And the result is true! Why?</p>
| 0debug |
ERROR: (gcloud.beta.functions.deploy) ... message=[The caller does not have permission] : <p>I am trying to deploy code from this repo:</p>
<p><a href="https://github.com/anishkny/puppeteer-on-cloud-functions" rel="noreferrer">https://github.com/anishkny/puppeteer-on-cloud-functions</a></p>
<p>in Google Cloud Build. My cloudbuild.yaml file contents are:</p>
<pre><code>steps:
- name: 'gcr.io/cloud-builders/gcloud'
args: ['beta', 'functions', 'deploy', 'screenshot', '--trigger-http', '--runtime', 'nodejs8', '--memory', '1024MB']
</code></pre>
<p>I have given the following roles to my Cloud Build Service account (****@cloudbuild.gserviceaccount.com):</p>
<ul>
<li><strong>Cloud Build Service Account</strong></li>
<li><strong>Cloud Functions Developer</strong></li>
</ul>
<p>Yet, in my Cloud Build log I see the following error:</p>
<pre><code>starting build "1f04522c-fe60-4a25-a4a8-d70e496e2821"
FETCHSOURCE
Fetching storage object: gs://628906418368.cloudbuild-source.googleusercontent.com/94762cc396ed1bb46e8c5dbfa3fa42550140c2eb-b3cfa476-cb21-45ba-849c-c28423982a0f.tar.gz#1534532794239047
Copying gs://628906418368.cloudbuild-source.googleusercontent.com/94762cc396ed1bb46e8c5dbfa3fa42550140c2eb-b3cfa476-cb21-45ba-849c-c28423982a0f.tar.gz#1534532794239047...
/ [0 files][ 0.0 B/ 835.0 B]
/ [1 files][ 835.0 B/ 835.0 B]
Operation completed over 1 objects/835.0 B.
tar: Substituting `.' for empty member name
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
ERROR: (gcloud.beta.functions.deploy) ResponseError: status=[403], code=[Forbidden], message=[The caller does not have permission]
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/gcloud" failed: exit status 1
</code></pre>
<p>What am I missing?</p>
| 0debug |
static void ide_dev_set_bootindex(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
IDEDevice *d = IDE_DEVICE(obj);
int32_t boot_index;
Error *local_err = NULL;
visit_type_int32(v, name, &boot_index, &local_err);
if (local_err) {
goto out;
}
check_boot_index(boot_index, &local_err);
if (local_err) {
goto out;
}
d->conf.bootindex = boot_index;
if (d->unit != -1) {
add_boot_device_path(d->conf.bootindex, &d->qdev,
d->unit ? "/disk@1" : "/disk@0");
}
out:
if (local_err) {
error_propagate(errp, local_err);
}
}
| 1threat |
How to disable eslint on vue-cli 3? : <p>I recently update the laster version <a href="https://github.com/vuejs/vue-cli" rel="noreferrer">vue-cli 3</a></p>
<p>After creating a project and run it,
it will show the message </p>
<ul>
<li>You may use special comments to disable some warnings.</li>
<li>Use <code>//eslint-disable-next-line</code> to ignore the next line.</li>
<li>Use <code>/* eslint-disable */</code> to ignore all warnings in a file.</li>
</ul>
<p>but in Which file should I put those comments? </p>
<p>I only have a package.json / package-lock.json and .gitignore on my root folder</p>
<p>Do I have to create a .eslintrc?</p>
| 0debug |
int ff_load_image(uint8_t *data[4], int linesize[4],
int *w, int *h, enum PixelFormat *pix_fmt,
const char *filename, void *log_ctx)
{
AVInputFormat *iformat = NULL;
AVFormatContext *format_ctx;
AVCodec *codec;
AVCodecContext *codec_ctx;
AVFrame *frame;
int frame_decoded, ret = 0;
AVPacket pkt;
av_register_all();
iformat = av_find_input_format("image2");
if ((ret = avformat_open_input(&format_ctx, filename, iformat, NULL)) < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Failed to open input file '%s'\n", filename);
return ret;
}
codec_ctx = format_ctx->streams[0]->codec;
codec = avcodec_find_decoder(codec_ctx->codec_id);
if (!codec) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to find codec\n");
ret = AVERROR(EINVAL);
goto end;
}
if ((ret = avcodec_open2(codec_ctx, codec, NULL)) < 0) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to open codec\n");
goto end;
}
if (!(frame = avcodec_alloc_frame()) ) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to alloc frame\n");
ret = AVERROR(ENOMEM);
goto end;
}
ret = av_read_frame(format_ctx, &pkt);
if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to read frame from file\n");
goto end;
}
ret = avcodec_decode_video2(codec_ctx, frame, &frame_decoded, &pkt);
if (ret < 0 || !frame_decoded) {
av_log(log_ctx, AV_LOG_ERROR, "Failed to decode image from file\n");
goto end;
}
ret = 0;
*w = frame->width;
*h = frame->height;
*pix_fmt = frame->format;
if ((ret = av_image_alloc(data, linesize, *w, *h, *pix_fmt, 16)) < 0)
goto end;
ret = 0;
av_image_copy(data, linesize, frame->data, frame->linesize, *pix_fmt, *w, *h);
end:
if (codec_ctx)
avcodec_close(codec_ctx);
if (format_ctx)
avformat_close_input(&format_ctx);
av_freep(&frame);
if (ret < 0)
av_log(log_ctx, AV_LOG_ERROR, "Error loading image file '%s'\n", filename);
return ret;
}
| 1threat |
Undefined variable codeigniter model : guys i need to understand why the country_id variable isn't defined in
**Model :**
public function getCountry($country_id) {
$this->db->select()->where('country_id', $country_id);
$this->db->from('country');
$query = $this->db->get();
return $query->result();
}
**Controller :**
$country_info = $this->country->getCountry($country_id);
Result :
Message: Undefined variable: country_id
Filename: localisation/Countries.php
Line Number: 12 | 0debug |
gitlab runner The requested URL returned error: 403 : <p>I'm currently using gitlab.com (not local installation) with their multi-runner for CI integration. This works great on one of my projects but fails for another.</p>
<p>I'm using 2012R2 for my host with MSBuild version 14.0.23107.0. I know the error below shows 403 which is an access denied message. My problem is finding the permission setting to change.</p>
<p>Error message:</p>
<blockquote>
<p>Running with gitlab-ci-multi-runner 1.5.3 (fb49c47) Using Shell
executor... Running on WIN-E0ORPCQUFHS...</p>
<p>Fetching changes...</p>
<p>HEAD is now at 6a70d96 update runner file remote: Access denied fatal:
unable to access
'<a href="https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.com/##REDACTED##/ADInactiveObjectCleanup.git/" rel="noreferrer">https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.com/##REDACTED##/ADInactiveObjectCleanup.git/</a>':
The requested URL returned error: 403 Checking out 60ea1410 as
Production...</p>
<p>fatal: reference is not a tree:
60ea1410dd7586f6ed9535d058f07c5bea2ba9c7 ERROR: Build failed: exit
status 128</p>
</blockquote>
<p>gitlab-ci.yml file:</p>
<pre><code>variables:
Solution: ADInactiveObjectCleanup.sln
before_script:
#- "echo off"
#- 'call "%VS120COMNTOOLS%\vsvars32.bat"'
## output environment variables (usefull for debugging, propably not what you want to do if your ci server is public)
#- echo.
#- set
#- echo.
stages:
- build
#- test
#- deploy
build:
stage: build
script:
- echo building...
- '"%ProgramFiles(x86)%\MSBuild\14.0\Bin\msbuild.exe" "%Solution%" /p:Configuration=Release'
except:
#- tags
</code></pre>
| 0debug |
I found this code and i try to use it on python 3 and it doesn't work pls help me : list=input('racecar:')
if (list==list[::-1]):
print ("It is a palindrome")
else:
print("it is not palindrome") | 0debug |
static inline void RENAME(yuv2bgr24_2)(SwsContext *c, const uint16_t *buf0,
const uint16_t *buf1, const uint16_t *ubuf0,
const uint16_t *ubuf1, const uint16_t *vbuf0,
const uint16_t *vbuf1, const uint16_t *abuf0,
const uint16_t *abuf1, uint8_t *dest,
int dstW, int yalpha, int uvalpha, int y)
{
x86_reg uv_off = c->uv_off << 1;
__asm__ volatile(
"mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
"mov %4, %%"REG_b" \n\t"
"push %%"REG_BP" \n\t"
YSCALEYUV2RGB(%%REGBP, %5, %6)
"pxor %%mm7, %%mm7 \n\t"
WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
"pop %%"REG_BP" \n\t"
"mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
:: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
"a" (&c->redDither), "m"(uv_off)
);
}
| 1threat |
Function pointer expression : <p>So I've got the following expression:</p>
<pre><code>int (*f1(int(*a)(int, int))) (int, int);
</code></pre>
<p>and I'm trying to make sense out of it, but it's confusing. I figured out that "a" is a pointer to a function which takes 2 arguments(int, int).
Then f1 seems to be a pointer to another function that takes 2 int arguments.
But what's confusing me is how f1 relates to a. </p>
<p>Can someone give me some hints or properly explain what the above expression is doing?</p>
| 0debug |
Produce a function that receives the die value and the total number of rolls and prints a single line of the histogram based on the values passed. : "You will need to call the function once per possible die value."
I'm a programming noob and have spent about seven hours trying to figure this out. My code is just a conglomeration of ideas and hopes that I'm headed in the right direction. I desperately need help and want to understand this stuff. I've scoured the message boards for my specific issue in vain. Please assist...
I realize my code is spitting out the result for every possible roll. When I need a program that I.E. when someone chooses to roll 50 times and designates 2 as the die value they desire to single out. The histogram would display how many times 2 was randomly rolled out of 50 rolls as asterisks on a single line of histogram.
My code thus far:
import random
def dice_sum(rolls):
results = 0
dice_sum = 0
for i in range(0, rolls):
results = random.randint(1, 6)
print("Die %d rolled %d." % (i+1, results))
dice_sum += results
print("Total of %d dice rolls is: %d" % (rolls, dice_sum))
return dice_sum
def hist_gram():
hist_gram='*'
dievalue= int(input('Which specific value between 1 and 6 are you requesting? [enter a #]'))
# get user input
rolls = int(input('How many times would you like to roll the 6 sided die? [enter a #]'))
dievalue= int(input('Which specific value between 1 and 6 are you requesting? [enter a #]'))
# pass input values to function and print result
result = dice_sum(rolls=rolls)
print(result)
| 0debug |
How do i do decrements in C language? : If an example , i set a value of :
a = 50
How do i do a decrement whereby a always decreases by 2 ? An example :
48
46
44
42
40
Whereby the return results , i can use as a variable. Example in the case below , this method is to get temperature at random. But i would like it to decrease so that i can call this get temperature method even below for it to loop.
/* Retrieves current temperature. */
static int32_t get_temperature_sample(void)
{
/* For the sake of example, random data is used */
return rand() % 10 + 25;
}
/* Periodically called by Kaa SDK. */
static void example_callback(void *context)
{
time_t current_time = time(NULL);
/* Respect sample period */
if (difftime(current_time, last_sample_time) >= sample_period) {
int32_t temperature = get_temperature_sample();
printf("Sampled temperature: %i\n", temperature);
last_sample_time = current_time;
kaa_user_log_record_t *log_record = kaa_logging_data_collection_create();
log_record->temperature = temperature;
kaa_logging_add_record(kaa_client_get_context(context)->log_collector, log_record, NULL);
}
}
Like if the above codes , if i were to say that for my temperature. I wouldnt want it to be random as you can see it uses random. I want to set a value for my temperature and decrease like a constant until it reaches 0 in my print function shown below.
printf("Sampled temperature: %i\n", temperature);
last_sample_time = current_time; | 0debug |
void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number)
{
int time_incr;
int time_div, time_mod;
if (s->pict_type == AV_PICTURE_TYPE_I) {
if (!(s->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) {
if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT)
mpeg4_encode_visual_object_header(s);
if (s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || picture_number == 0)
mpeg4_encode_vol_header(s, 0, 0);
}
if (!(s->workaround_bugs & FF_BUG_MS))
mpeg4_encode_gop_header(s);
}
s->partitioned_frame = s->data_partitioning && s->pict_type != AV_PICTURE_TYPE_B;
put_bits(&s->pb, 16, 0);
put_bits(&s->pb, 16, VOP_STARTCODE);
put_bits(&s->pb, 2, s->pict_type - 1);
time_div = FFUDIV(s->time, s->avctx->time_base.den);
time_mod = FFUMOD(s->time, s->avctx->time_base.den);
time_incr = time_div - s->last_time_base;
av_assert0(time_incr >= 0);
while (time_incr--)
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 1, 0);
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, s->time_increment_bits, time_mod);
put_bits(&s->pb, 1, 1);
put_bits(&s->pb, 1, 1);
if (s->pict_type == AV_PICTURE_TYPE_P) {
put_bits(&s->pb, 1, s->no_rounding);
}
put_bits(&s->pb, 3, 0);
if (!s->progressive_sequence) {
put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first);
put_bits(&s->pb, 1, s->alternate_scan);
}
put_bits(&s->pb, 5, s->qscale);
if (s->pict_type != AV_PICTURE_TYPE_I)
put_bits(&s->pb, 3, s->f_code);
if (s->pict_type == AV_PICTURE_TYPE_B)
put_bits(&s->pb, 3, s->b_code);
}
| 1threat |
Maximum execution time of 120 seconds exceeded in yii2 : <p>I upload an excel file with 1000 rows, by default I have just 2 min in execution time, with that time I can upload 400 records.
I get this error <code>Maximum execution time of 120 seconds exceeded</code></p>
<p>How i can modify this period in yii2 framework ?</p>
| 0debug |
void helper_dcbz(CPUPPCState *env, target_ulong addr, uint32_t is_dcbzl)
{
int dcbz_size = env->dcache_line_size;
#if !defined(CONFIG_USER_ONLY) && defined(TARGET_PPC64)
if (!is_dcbzl &&
(env->excp_model == POWERPC_EXCP_970) &&
((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) {
dcbz_size = 32;
}
#endif
do_dcbz(env, addr, dcbz_size);
}
| 1threat |
PHP/Maths Percentage of Percentage : <p>I am working out what the changes of a horse winning a race is from the previous records of each horses.</p>
<p>Horse 1 has won 5% of his races</p>
<p>Horse 2 has won 7% of his races</p>
<p>Horse 3 has won 12% of his races</p>
<p>Now if 3 horses are running in this final race, how do I split 100% between these 3 horses?</p>
| 0debug |
static void filter_mb_edgech( H264Context *h, uint8_t *pix, int stride, int bS[4], int qp ) {
int i, d;
const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 );
const int alpha = alpha_table[index_a];
const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )];
const int pix_next = stride;
for( i = 0; i < 4; i++ )
{
if( bS[i] == 0 ) {
pix += 2;
continue;
}
for( d = 0; d < 2; d++ ) {
const uint8_t p0 = pix[-1*pix_next];
const uint8_t p1 = pix[-2*pix_next];
const uint8_t q0 = pix[0];
const uint8_t q1 = pix[1*pix_next];
if( abs( p0 - q0 ) >= alpha ||
abs( p1 - p0 ) >= beta ||
abs( q1 - q0 ) >= beta ) {
pix++;
continue;
}
if( bS[i] < 4 ) {
int tc = tc0_table[index_a][bS[i] - 1] + 1;
int i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
pix[-pix_next] = clip( p0 + i_delta, 0, 255 );
pix[0] = clip( q0 - i_delta, 0, 255 );
}
else
{
pix[-pix_next] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
}
pix++;
}
}
}
| 1threat |
What happens when an executor is lost? : <p>I get these messages:</p>
<pre><code>16/05/22 13:33:53 ERROR YarnScheduler: Lost executor 61 on <host>: Executor heartbeat timed out after 134828 ms
16/05/22 13:33:53 WARN TaskSetManager: Lost task 25.0 in stage 12.0 (TID 2214, <host>): ExecutorLostFailure (executor 61 lost)
</code></pre>
<p>Will a replacement executor be spawned?</p>
| 0debug |
Creating Random Numbers in C# using a unique ID : <p>How do i write a code in C# which generates a set of random numbers and each set created should have a unique ID .So if that range and unique number is given again the same random numbers should be generated.</p>
<p>Eg Range is 1 - 100
Random Numbers generated by system is 5, 10 ,15 and for this range a unique ID is created 123,432,876.</p>
<p>Now if i enter the same range 1-100 and the same unique ID 123,432,876. My output should be 5,10 and 15 only.</p>
| 0debug |
Why this code doesn't print some value? : i don't understand why when i try to print values in "archivio[]" with "stampa" function,this program prints "studente","matricola","nome","cognome" correctly, but doesn't print values from "stampaEsami".
#include <stdio.h>
#include <stdlib.h>
#define MAXSTUDENTI 20
#define MAXSTRINGA 100
#define MAXESAMI 25
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
typedef char Stringa[MAXSTRINGA];
typedef enum { uno, due, tre, FC
} AnnoCorso;
typedef struct {
Stringa nomeEsame;
int voto;
} Esame;
typedef struct {
Esame listaEsami[MAXESAMI];
int numeroEsami;
}ListaEsame;
typedef struct {
int matricola;
Stringa nome;
Stringa cognome;
AnnoCorso anno;
ListaEsame esami;
} Studente;
void init(Studente[], int);
void acquisisciEsami(Studente, int);
void stampa(Studente[], int);
void stampaEsami(ListaEsame);
void init(Studente archivio[], int n){
int i;
int nEsami;
for(i = 0; i < n; i++){
printf("Studente n. %d\n", i+1);
printf("Inserire matricola: ");
scanf("%d", &archivio[i].matricola);
printf("Inserire nome: ");
scanf("%s", &archivio[i].nome);
printf("Inserire cognome: ");
scanf("%s", &archivio[i].cognome);
printf("Inserire il numero di esami svolti: ");
scanf("%d", &archivio[i].esami.numeroEsami);
nEsami = archivio[i].esami.numeroEsami;
if(nEsami != 0) {
acquisisciEsami(archivio[i], nEsami);
}
}
}
void acquisisciEsami(Studente studente, int n){
int i;
for(i = 0; i < n; i++) {
printf("Inserire nome esame:");
scanf("%s", studente.esami.listaEsami[i].nomeEsame);
printf("Inserire voto esame:");
scanf("%d", &studente.esami.listaEsami[i].voto);
}
}
void stampa(Studente archivio[], int n){
printf("\nGli studenti presenti in archivio sono:\n");
int i;
for(i = 0; i < n; i++){
printf("Studente n. %d:\n", i+1);
printf("Matricola: %d\n", archivio[i].matricola);
printf("Nome: %s\n", archivio[i].nome);
printf("Cognome: %s\n", archivio[i].cognome);
stampaEsami(archivio[i].esami);
}
}
void stampaEsami(ListaEsame esami){
int i = 0;
int n = esami.numeroEsami;
for(i = 0; i < n; i++){
printf("Nome esame: %s\n", esami.listaEsami[i].nomeEsame );
printf("Voto esame: %d\n", esami.listaEsami[i].voto);
}
}
int main(int argc, char *argv[]) {
Studente studenti[MAXSTUDENTI] ;
int n;
printf("Inserire il numero di studenti da memorizzare in archivio:\n ");
scanf("%d", &n);
init(studenti, n);
stampa(studenti, n);
return 0;
} | 0debug |
Moshi ignore field : <p>Is there a simple way to ignore a field when using moshi to serialize to a json string? I can only think about is a custom adapter - but I have the feeling that there is a better way</p>
| 0debug |
What is wrong with this C program : <p>I am trying to write a usb mass storage driver. I don't have a storage device, so I am trying to allocate some memory. below is the program I wrote to emulate
a 512*2048 (1 MB) size usb drive</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
char ** called_func(char **mem, char start_sec, char num_of_sec)
{
char **read_mem, row, column;
read_mem = (char **)malloc(sizeof(char *) * 512 * num_of_sec);
for(row = 0 ; row < num_of_sec ; row++)
for(column = 0 ; column < 512 ; column++ )
read_mem[row][column] = mem[row + start_sec][column];
return read_mem;
}
int main()
{
char **mem, row , column, i, j;
char **ret;
mem = (char **)malloc(sizeof(char *) * 512 * 2048);
if(mem == NULL)
printf("allocation failed\n");
for(row = 0; row < 2048 ; row++)
for(column = 0 ; column < 512 ; column++)
mem[row][column] = 'a';
ret = called_func(mem, 2, 6);//start sec, num of sectors this time I am going to read from the second sector, and total 6 sectors
for(i=0;i<2;i++)
{
for(j=0;j<6;j++)
{
printf("ret[i][j] = %c",i, j, ret[i][j]);
}
printf("\n");
}
return 0;
}
</code></pre>
<p>I haven't wrote a C program in many months. Please tell where I am wrong as I keep getting segmentation fault.</p>
| 0debug |
def adjacent_num_product(list_nums):
return max(a*b for a, b in zip(list_nums, list_nums[1:])) | 0debug |
static void adx_decode_stereo(short *out,const unsigned char *in,PREV *prev)
{
short tmp[32*2];
int i;
adx_decode(tmp ,in ,prev);
adx_decode(tmp+32,in+18,prev+1);
for(i=0;i<32;i++) {
out[i*2] = tmp[i];
out[i*2+1] = tmp[i+32];
}
}
| 1threat |
What is Facades and how it works? (Specially for Laravel) : <p>Can you please describe elaborately about <strong>Facade</strong>?</p>
| 0debug |
static int idcin_read_seek(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags)
{
IdcinDemuxContext *idcin = s->priv_data;
if (idcin->first_pkt_pos > 0) {
int ret = avio_seek(s->pb, idcin->first_pkt_pos, SEEK_SET);
if (ret < 0)
return ret;
ff_update_cur_dts(s, s->streams[idcin->video_stream_index], 0);
idcin->next_chunk_is_video = 1;
idcin->current_audio_chunk = 0;
return 0;
}
return -1;
}
| 1threat |
static int get_int32(QEMUFile *f, void *pv, size_t size)
{
int32_t *v = pv;
qemu_get_sbe32s(f, v);
return 0;
}
| 1threat |
How to disable underline to Material UI's datepicker in React? : <p>How can I disable showing underline to material-ui-pickers? </p>
<p><strong>sandbox</strong>
<a href="https://codesandbox.io/s/l2ykr7kwvz?from-embed" rel="noreferrer">https://codesandbox.io/s/l2ykr7kwvz?from-embed</a></p>
<p>I want to removing underline to its <code>TextField</code>. </p>
<p>I tried </p>
<p><code>disableUnderline={true}</code></p>
<p><code>underlineStyle={{display: 'non'}}</code></p>
<p><code>showingUnderline={false}</code></p>
<p>But nothing works, How can I hide underline?</p>
<pre><code><DatePicker
underlineStyle={{display: 'none'}}
value={selectedDate}
onChange={this.handleDateChange}
animateYearScrolling={false}
/>
</code></pre>
| 0debug |
Laravel cache store does not support tagging : <p>I am getting this error since I installed <strong>Zizaco\Entrust</strong> on my Authentication Routes.</p>
<pre><code>BadMethodCallException: This cache store does not support tagging.
</code></pre>
<p>I had few known issues and I had to change some config options and that is the reason I am getting this error.</p>
<p>What does this error relate to so that I can find the problem and fix it instead of finding the code I modified?</p>
<p>Thanks</p>
| 0debug |
Adobe Air application has black bars on iPhone 6 plus : <p>I am having problem with my ios air app, shown in picture bellow. I can not get rid of black bars. Despite I added all launching images:</p>
<p>Any advice would be great help!</p>
<p>Images:</p>
<p><img src="https://i.imgur.com/bT1cOt2.png" alt="launching images"> [1]</p>
<p>Iphone6 plus screen</p>
<p><img src="https://i.imgur.com/11bTbxI.png" alt="screen from iphone"> [2]</p>
| 0debug |
static void sysbus_esp_mem_write(void *opaque, target_phys_addr_t addr,
uint64_t val, unsigned int size)
{
SysBusESPState *sysbus = opaque;
uint32_t saddr;
saddr = addr >> sysbus->it_shift;
esp_reg_write(&sysbus->esp, saddr, val);
}
| 1threat |
def find_longest_repeating_subseq(str):
n = len(str)
dp = [[0 for k in range(n+1)] for l in range(n+1)]
for i in range(1, n+1):
for j in range(1, n+1):
if (str[i-1] == str[j-1] and i != j):
dp[i][j] = 1 + dp[i-1][j-1]
else:
dp[i][j] = max(dp[i][j-1], dp[i-1][j])
return dp[n][n] | 0debug |
int qemu_chr_fe_write_all(CharDriverState *s, const uint8_t *buf, int len)
{
int offset = 0;
int res;
qemu_mutex_lock(&s->chr_write_lock);
while (offset < len) {
do {
res = s->chr_write(s, buf + offset, len - offset);
if (res == -1 && errno == EAGAIN) {
g_usleep(100);
}
} while (res == -1 && errno == EAGAIN);
if (res <= 0) {
break;
}
offset += res;
}
qemu_mutex_unlock(&s->chr_write_lock);
if (res < 0) {
return res;
}
return offset;
}
| 1threat |
How to get key and value of json array object in javascript? : I have below json array structure.. How can i get the key and value of each of the `records` json object?
{
"records": [{
"cfsub_2": "1",
"cf_7": "1/3/2016",
"cf_1": "Clinic San",
"cf_2": "Fever",
"cf_3": "56.60",
"cfe_8": "dsf4334"
}, {
"cfsub_2": "2",
"cf_7": "3/3/2016",
"cf_1": "Clinic Raju",
"cf_2": "braces",
"cf_3": "183.50",
"cfe_8": "fresr4"
}]
} | 0debug |
static int proxy_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name,
int flags, FsCred *credp, V9fsFidOpenState *fs)
{
V9fsString fullname;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
fs->fd = v9fs_request(fs_ctx->private, T_CREATE, NULL, "sdddd",
&fullname, flags, credp->fc_mode,
credp->fc_uid, credp->fc_gid);
v9fs_string_free(&fullname);
if (fs->fd < 0) {
errno = -fs->fd;
fs->fd = -1;
}
return fs->fd;
}
| 1threat |
static int thp_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
ThpDemuxContext *thp = s->priv_data;
AVIOContext *pb = s->pb;
unsigned int size;
int ret;
if (thp->audiosize == 0) {
if (thp->frame >= thp->framecnt)
return AVERROR_EOF;
avio_seek(pb, thp->next_frame, SEEK_SET);
thp->next_frame += FFMAX(thp->next_framesz, 1);
thp->next_framesz = avio_rb32(pb);
avio_rb32(pb);
size = avio_rb32(pb);
if (thp->has_audio)
thp->audiosize = avio_rb32(pb);
else
thp->frame++;
ret = av_get_packet(pb, pkt, size);
if (ret != size) {
av_free_packet(pkt);
return AVERROR(EIO);
}
pkt->stream_index = thp->video_stream_index;
} else {
ret = av_get_packet(pb, pkt, thp->audiosize);
if (ret != thp->audiosize) {
av_free_packet(pkt);
return AVERROR(EIO);
}
pkt->stream_index = thp->audio_stream_index;
if (thp->audiosize >= 8)
pkt->duration = AV_RB32(&pkt->data[4]);
thp->audiosize = 0;
thp->frame++;
}
return 0;
} | 1threat |
Java error message array in other method : <p>My code isn't compiling the error that is given to me is "non-static method sumArray(double[]) cannot be referenced from a static context". I have tried to figure this out but I'm not sure what I need to change. Please help and let me know what the error is.</p>
<p>import java.util.*;
public class Homework5
{</p>
<pre><code>public static void main( String[] args )
{
Scanner key = new Scanner(System.in);
System.out.println("How many numbers would you like in the array?");
int arrayLength = key.nextInt();
Homework5 inst1 = new Homework5();
double[] numbers = new double[arrayLength];
System.out.println("Enter " + arrayLength + " numbers:");
for( int i=0; i < arrayLength; i++ )
{
numbers[i] = key.nextDouble();
}
System.out.println( "The sum is "+sumArray(numbers));
}
public double sumArray( double[] newArray )
{
double total=0;
for( int index = 0; index < newArray.length ; index++ )
{
total = total+newArray[index];
}
return total;
}
</code></pre>
<p>}</p>
| 0debug |
net_checksum_add_iov(const struct iovec *iov, const unsigned int iov_cnt,
uint32_t iov_off, uint32_t size)
{
size_t iovec_off, buf_off;
unsigned int i;
uint32_t res = 0;
uint32_t seq = 0;
iovec_off = 0;
buf_off = 0;
for (i = 0; i < iov_cnt && size; i++) {
if (iov_off < (iovec_off + iov[i].iov_len)) {
size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off , size);
void *chunk_buf = iov[i].iov_base + (iov_off - iovec_off);
res += net_checksum_add_cont(len, chunk_buf, seq);
seq += len;
buf_off += len;
iov_off += len;
size -= len;
}
iovec_off += iov[i].iov_len;
}
return res;
}
| 1threat |
read in string of unknown length : I have the following simple fortran program:
program quotes
implicit none
character*1000 quote
integer*4 i
open(13,file='d:\sp500.new',status='unknown')
close(13,status='delete')
open(12,file='d:\sp500.dat')
open(13,file='d:\sp500.new', status='new')
do 100 i = 1,61113
read(12,'(A)') quote
if(quote[1] .eq. 'I')write(13,'(A)')quote
100 continue
end
I'm trying to read in the entire string, check to see if the first character in the string = 'I' and if true write out the entire string. I have some other testing I have to do so I need to read the input string character by character
the error message is:
D:\quotes.f90(18): error FOR3852: syntax error detected between QUOTE and [1]
Error executing fl32.exe.
quotes.obj - 1 error(s), 0 warning(s)
| 0debug |
Why doesn't sumBy(selector) return Long? : <p><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/sum-by.html" rel="noreferrer">sumBy(selector)</a> returns Int</p>
<p><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/sum-by-double.html" rel="noreferrer">sumByDouble(selector)</a> returns Double</p>
<p>Why doesn't sumBy return Long? Is there a workaround for this?</p>
| 0debug |
static int kvm_mips_put_fpu_registers(CPUState *cs, int level)
{
MIPSCPU *cpu = MIPS_CPU(cs);
CPUMIPSState *env = &cpu->env;
int err, ret = 0;
unsigned int i;
if (env->CP0_Config1 & (1 << CP0C1_FP)) {
if (level == KVM_PUT_FULL_STATE) {
err = kvm_mips_put_one_ureg(cs, KVM_REG_MIPS_FCR_IR,
&env->active_fpu.fcr0);
if (err < 0) {
DPRINTF("%s: Failed to put FCR_IR (%d)\n", __func__, err);
ret = err;
}
}
err = kvm_mips_put_one_ureg(cs, KVM_REG_MIPS_FCR_CSR,
&env->active_fpu.fcr31);
if (err < 0) {
DPRINTF("%s: Failed to put FCR_CSR (%d)\n", __func__, err);
ret = err;
}
for (i = 0; i < 32; ++i) {
if (env->CP0_Status & (1 << CP0St_FR)) {
err = kvm_mips_put_one_ureg64(cs, KVM_REG_MIPS_FPR_64(i),
&env->active_fpu.fpr[i].d);
} else {
err = kvm_mips_get_one_ureg(cs, KVM_REG_MIPS_FPR_32(i),
&env->active_fpu.fpr[i].w[FP_ENDIAN_IDX]);
}
if (err < 0) {
DPRINTF("%s: Failed to put FPR%u (%d)\n", __func__, i, err);
ret = err;
}
}
}
return ret;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.