problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
Intend not work in Recycleview.onclicklistener :
This is my Adapter class i need to click the Recycleview list and go to the next page but Intend is not work in this class the app gets crashed how do i work with the intend in this ...
package com.onebook.locationsaver;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.provider.ContactsContract;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static android.content.ContentValues.TAG;
import static androidx.core.content.ContextCompat.startActivity;
public class SaveListAdapter extends androidx.recyclerview.widget.RecyclerView.Adapter<SaveListAdapter.ViewHolder> {
Context context;
public List<DatabseMode> databasemodelist;
private DatabseMode databseMode;
ArrayList<DatabseMode> newlist =new ArrayList<>();
Context a;
public SaveListAdapter(Context context, List<DatabseMode> databasemodelist) {
this.databasemodelist=databasemodelist;
for (int i = databasemodelist.size() - 1; i >= 0; i--) {
newlist.add(databasemodelist.get(i));
this.a=context;
}
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
View listItem= layoutInflater.inflate(R.layout.recycle_view_icon, parent, false);
ViewHolder VH=new ViewHolder(context,listItem) {
@Override
public String toString() {
return super.toString();
}
};
return VH;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
databseMode= (newlist.get(position));
holder.name.setText(databseMode.getname());
holder.detail.setText(databseMode.getdetail());
/*holder.layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(SaveListAdapter.this,"Item is selected",Toast.LENGTH_LONG).show();
*//*
Intent intent=new Intent(a.getApplicationContext(),LocationEdit.class);
intent.putExtra("potition",getItemId(position ));
a.startActivity(intent);*//*
}
});*/
}
@Override
public int getItemCount() {
return databasemodelist.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView name,detail;
public LinearLayout layout;
private Context context;
List<DatabseMode> databasemodelist;
public ViewHolder(Context context,View itemView) {
super(itemView);
this.name = (TextView) itemView.findViewById(R.id.textView);
this.detail=itemView.findViewById(R.id.textview00);
this.context=context;
itemView.setOnClickListener(this);
//layout= (LinearLayout) itemView;
}
@Override
public void onClick(View v) {
int position=getLayoutPosition();
DatabseMode databseMode=databasemodelist.get(position);
Intent intent=new Intent(context,LocationEdit.class);
intent.putExtra("id",databseMode.getname());
context.startActivity(intent);
Toast.makeText(context,"this the text",Toast.LENGTH_SHORT).show();
}
}
}
The above is the adapter for recycleview
package com.onebook.locationsaver;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
public class LocationList extends AppCompatActivity {
private RecyclerView recyclerViewsavedata;
private RecyclerView.Adapter getdataadapter;
private List<DatabseMode> databasemodelist;
private DatabaseHelper databaseHelper ;
ListView listView;
private Context context;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.locationlist);
databasemodelist =new ArrayList<>();
databaseHelper =new DatabaseHelper(this);
recyclerViewsavedata=findViewById(R.id.recyclerView);
recyclerViewsavedata.setHasFixedSize(true);
recyclerViewsavedata.setLayoutManager(new LinearLayoutManager(this));
databasemodelist=databaseHelper.getAllCotacts();
//listView.setAdapter(new Listviewadapter(LocationList.this,databasemodelist));
getdataadapter=new SaveListAdapter((Activity) context,databasemodelist);
recyclerViewsavedata.setAdapter(getdataadapter);
recyclerViewsavedata.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(LocationList.this,"This item is selecton",Toast.LENGTH_SHORT).show();
}
});
}
}
The above is the Recycleview class ane one help me please i'm struggle on this for 4 days onclick in the recycle view is not working in my applilation
| 0debug
|
static int mov_get_mpeg2_xdcam_codec_tag(AVFormatContext *s, MOVTrack *track)
{
int tag = track->par->codec_tag;
int interlaced = track->par->field_order > AV_FIELD_PROGRESSIVE;
AVStream *st = track->st;
int rate = av_q2d(find_fps(s, st));
if (!tag)
tag = MKTAG('m', '2', 'v', '1');
if (track->par->format == AV_PIX_FMT_YUV420P) {
if (track->par->width == 1280 && track->par->height == 720) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('x','d','v','4');
else if (rate == 25) tag = MKTAG('x','d','v','5');
else if (rate == 30) tag = MKTAG('x','d','v','1');
else if (rate == 50) tag = MKTAG('x','d','v','a');
else if (rate == 60) tag = MKTAG('x','d','v','9');
}
} else if (track->par->width == 1440 && track->par->height == 1080) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('x','d','v','6');
else if (rate == 25) tag = MKTAG('x','d','v','7');
else if (rate == 30) tag = MKTAG('x','d','v','8');
} else {
if (rate == 25) tag = MKTAG('x','d','v','3');
else if (rate == 30) tag = MKTAG('x','d','v','2');
}
} else if (track->par->width == 1920 && track->par->height == 1080) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('x','d','v','d');
else if (rate == 25) tag = MKTAG('x','d','v','e');
else if (rate == 30) tag = MKTAG('x','d','v','f');
} else {
if (rate == 25) tag = MKTAG('x','d','v','c');
else if (rate == 30) tag = MKTAG('x','d','v','b');
}
}
} else if (track->par->format == AV_PIX_FMT_YUV422P) {
if (track->par->width == 1280 && track->par->height == 720) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('x','d','5','4');
else if (rate == 25) tag = MKTAG('x','d','5','5');
else if (rate == 30) tag = MKTAG('x','d','5','1');
else if (rate == 50) tag = MKTAG('x','d','5','a');
else if (rate == 60) tag = MKTAG('x','d','5','9');
}
} else if (track->par->width == 1920 && track->par->height == 1080) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('x','d','5','d');
else if (rate == 25) tag = MKTAG('x','d','5','e');
else if (rate == 30) tag = MKTAG('x','d','5','f');
} else {
if (rate == 25) tag = MKTAG('x','d','5','c');
else if (rate == 30) tag = MKTAG('x','d','5','b');
}
}
}
return tag;
}
| 1threat
|
Create Agent Job : <p>How to Create Agent Job In SQL Server</p>
| 0debug
|
aws-amplify Authentication...how to access tokens on successful Auth.signIn? : <p>I'm trying to figure out how to access the accessToken, refreshToken, and idToken that I receive back from aws-amplify using the Auth library. </p>
<p>example in docs: <a href="https://aws.github.io/aws-amplify/media/authentication_guide.html" rel="noreferrer">https://aws.github.io/aws-amplify/media/authentication_guide.html</a></p>
<p>example of my usage:</p>
<p><code>const user = await Auth.signIn(email, password);</code></p>
<p><code>user</code> has a bunch of properties that are inaccessible including everything I need. In the docs, it's unclear how to get to these properties because the examples all log the result. Any ideas?</p>
| 0debug
|
void address_space_init(AddressSpace *as, MemoryRegion *root)
{
memory_region_transaction_begin();
as->root = root;
as->current_map = g_new(FlatView, 1);
flatview_init(as->current_map);
as->ioeventfd_nb = 0;
as->ioeventfds = NULL;
QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link);
as->name = NULL;
memory_region_transaction_commit();
address_space_init_dispatch(as);
}
| 1threat
|
Laravel validation pdf mime : <p>I have tried below mime types for validating PDF files.but none of them doesnt pass the validation .</p>
<pre><code> $rules = [
....
"file" => "required|mimes:application/pdf, application/x-pdf,application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf|max:10000"
....
]
</code></pre>
| 0debug
|
Draw rotated rectangle in opencv c++ : <p>I want to draw a rotated rectangle in opencv with c++. I use <code>"rectangle"</code> function like bellow:</p>
<pre><code>rectangle(RGBsrc, vertices[0], vertices[2], Scalar(0, 0, 0), CV_FILLED, 8, 0);
</code></pre>
<p>but this function draw an rectangle with 0 angle. How can i draw rotated rectangle with special angle in opencv with c++?</p>
| 0debug
|
void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap,
int64_t cur_sector, int64_t nr_sectors)
{
assert(bdrv_dirty_bitmap_enabled(bitmap));
hbitmap_set(bitmap->bitmap, cur_sector, nr_sectors);
}
| 1threat
|
static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
int n, i, ch, st, pkt_size, ret;
const int16_t *samples;
int16_t **samples_p;
uint8_t *dst;
ADPCMEncodeContext *c = avctx->priv_data;
uint8_t *buf;
samples = (const int16_t *)frame->data[0];
samples_p = (int16_t **)frame->extended_data;
st = avctx->channels == 2;
if (avctx->codec_id == AV_CODEC_ID_ADPCM_SWF)
pkt_size = (2 + avctx->channels * (22 + 4 * (frame->nb_samples - 1)) + 7) / 8;
else
pkt_size = avctx->block_align;
if ((ret = ff_alloc_packet2(avctx, avpkt, pkt_size)))
return ret;
dst = avpkt->data;
switch(avctx->codec->id) {
case AV_CODEC_ID_ADPCM_IMA_WAV:
{
int blocks, j;
blocks = (frame->nb_samples - 1) / 8;
for (ch = 0; ch < avctx->channels; ch++) {
ADPCMChannelStatus *status = &c->status[ch];
status->prev_sample = samples_p[ch][0];
bytestream_put_le16(&dst, status->prev_sample);
*dst++ = status->step_index;
*dst++ = 0;
}
if (avctx->trellis > 0) {
FF_ALLOC_OR_GOTO(avctx, buf, avctx->channels * blocks * 8, error);
for (ch = 0; ch < avctx->channels; ch++) {
adpcm_compress_trellis(avctx, &samples_p[ch][1],
buf + ch * blocks * 8, &c->status[ch],
blocks * 8, 1);
}
for (i = 0; i < blocks; i++) {
for (ch = 0; ch < avctx->channels; ch++) {
uint8_t *buf1 = buf + ch * blocks * 8 + i * 8;
for (j = 0; j < 8; j += 2)
*dst++ = buf1[j] | (buf1[j + 1] << 4);
}
}
av_free(buf);
} else {
for (i = 0; i < blocks; i++) {
for (ch = 0; ch < avctx->channels; ch++) {
ADPCMChannelStatus *status = &c->status[ch];
const int16_t *smp = &samples_p[ch][1 + i * 8];
for (j = 0; j < 8; j += 2) {
uint8_t v = adpcm_ima_compress_sample(status, smp[j ]);
v |= adpcm_ima_compress_sample(status, smp[j + 1]) << 4;
*dst++ = v;
}
}
}
}
break;
}
case AV_CODEC_ID_ADPCM_IMA_QT:
{
PutBitContext pb;
init_put_bits(&pb, dst, pkt_size * 8);
for (ch = 0; ch < avctx->channels; ch++) {
ADPCMChannelStatus *status = &c->status[ch];
put_bits(&pb, 9, (status->prev_sample & 0xFFFF) >> 7);
put_bits(&pb, 7, status->step_index);
if (avctx->trellis > 0) {
uint8_t buf[64];
adpcm_compress_trellis(avctx, &samples_p[ch][1], buf, status,
64, 1);
for (i = 0; i < 64; i++)
put_bits(&pb, 4, buf[i ^ 1]);
} else {
for (i = 0; i < 64; i += 2) {
int t1, t2;
t1 = adpcm_ima_qt_compress_sample(status, samples_p[ch][i ]);
t2 = adpcm_ima_qt_compress_sample(status, samples_p[ch][i + 1]);
put_bits(&pb, 4, t2);
put_bits(&pb, 4, t1);
}
}
}
flush_put_bits(&pb);
break;
}
case AV_CODEC_ID_ADPCM_SWF:
{
PutBitContext pb;
init_put_bits(&pb, dst, pkt_size * 8);
n = frame->nb_samples - 1;
put_bits(&pb, 2, 2);
for (i = 0; i < avctx->channels; i++) {
c->status[i].step_index = av_clip(c->status[i].step_index, 0, 63);
put_sbits(&pb, 16, samples[i]);
put_bits(&pb, 6, c->status[i].step_index);
c->status[i].prev_sample = samples[i];
}
if (avctx->trellis > 0) {
FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error);
adpcm_compress_trellis(avctx, samples + avctx->channels, buf,
&c->status[0], n, avctx->channels);
if (avctx->channels == 2)
adpcm_compress_trellis(avctx, samples + avctx->channels + 1,
buf + n, &c->status[1], n,
avctx->channels);
for (i = 0; i < n; i++) {
put_bits(&pb, 4, buf[i]);
if (avctx->channels == 2)
put_bits(&pb, 4, buf[n + i]);
}
av_free(buf);
} else {
for (i = 1; i < frame->nb_samples; i++) {
put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0],
samples[avctx->channels * i]));
if (avctx->channels == 2)
put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1],
samples[2 * i + 1]));
}
}
flush_put_bits(&pb);
break;
}
case AV_CODEC_ID_ADPCM_MS:
for (i = 0; i < avctx->channels; i++) {
int predictor = 0;
*dst++ = predictor;
c->status[i].coeff1 = ff_adpcm_AdaptCoeff1[predictor];
c->status[i].coeff2 = ff_adpcm_AdaptCoeff2[predictor];
}
for (i = 0; i < avctx->channels; i++) {
if (c->status[i].idelta < 16)
c->status[i].idelta = 16;
bytestream_put_le16(&dst, c->status[i].idelta);
}
for (i = 0; i < avctx->channels; i++)
c->status[i].sample2= *samples++;
for (i = 0; i < avctx->channels; i++) {
c->status[i].sample1 = *samples++;
bytestream_put_le16(&dst, c->status[i].sample1);
}
for (i = 0; i < avctx->channels; i++)
bytestream_put_le16(&dst, c->status[i].sample2);
if (avctx->trellis > 0) {
n = avctx->block_align - 7 * avctx->channels;
FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error);
if (avctx->channels == 1) {
adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
avctx->channels);
for (i = 0; i < n; i += 2)
*dst++ = (buf[i] << 4) | buf[i + 1];
} else {
adpcm_compress_trellis(avctx, samples, buf,
&c->status[0], n, avctx->channels);
adpcm_compress_trellis(avctx, samples + 1, buf + n,
&c->status[1], n, avctx->channels);
for (i = 0; i < n; i++)
*dst++ = (buf[i] << 4) | buf[n + i];
}
av_free(buf);
} else {
for (i = 7 * avctx->channels; i < avctx->block_align; i++) {
int nibble;
nibble = adpcm_ms_compress_sample(&c->status[ 0], *samples++) << 4;
nibble |= adpcm_ms_compress_sample(&c->status[st], *samples++);
*dst++ = nibble;
}
}
break;
case AV_CODEC_ID_ADPCM_YAMAHA:
n = frame->nb_samples / 2;
if (avctx->trellis > 0) {
FF_ALLOC_OR_GOTO(avctx, buf, 2 * n * 2, error);
n *= 2;
if (avctx->channels == 1) {
adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
avctx->channels);
for (i = 0; i < n; i += 2)
*dst++ = buf[i] | (buf[i + 1] << 4);
} else {
adpcm_compress_trellis(avctx, samples, buf,
&c->status[0], n, avctx->channels);
adpcm_compress_trellis(avctx, samples + 1, buf + n,
&c->status[1], n, avctx->channels);
for (i = 0; i < n; i++)
*dst++ = buf[i] | (buf[n + i] << 4);
}
av_free(buf);
} else
for (n *= avctx->channels; n > 0; n--) {
int nibble;
nibble = adpcm_yamaha_compress_sample(&c->status[ 0], *samples++);
nibble |= adpcm_yamaha_compress_sample(&c->status[st], *samples++) << 4;
*dst++ = nibble;
}
break;
default:
return AVERROR(EINVAL);
}
avpkt->size = pkt_size;
*got_packet_ptr = 1;
return 0;
error:
return AVERROR(ENOMEM);
}
| 1threat
|
image not show in recyclerview from server : i follow this tutorial but i get some problem (https://www.simplifiedcoding.net/android-recyclerview-and-cardview-tutorial/) . I have one table named images with coloums id and images.
this is my getData.php
<?php
$sql = "SELECT * FROM images";
require_once('dbConnect.php');
$r = mysqli_query($con,$sql);
$result = array();
while($row = mysqli_fetch_array($r)){
array_push($result,array(
'name'=>$row['name'],
'url'=>$row['image']
));
}
echo json_encode(array('result'=>$result));
mysqli_close($con);
this is my config.java
package com.example.mdesigntemp;
import android.graphics.Bitmap;
public class ConfigChildItem {
public static String[] names;
public static String[] urls;
public static Bitmap[] bitmaps;
public static final String GET_URL = "http://www.kinandayu.com/image_content/getAllImage.php";
public static final String TAG_IMAGE_URL = "url";
public static final String TAG_IMAGE_NAME = "name";
public static final String TAG_JSON_ARRAY="result";
public ConfigChildItem(int i){
names = new String[i];
urls = new String[i];
bitmaps = new Bitmap[i];
}
}
this is my recyclerviewAdapter :
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ViewHolder> {
List<ListItem> items;
public RecyclerAdapter(String[] names, String[] urls, Bitmap[] images){
super();
items = new ArrayList<ListItem>();
for(int i =0; i<names.length; i++){
ListItem item = new ListItem();
item.setName(names[i]);
item.setUrl(urls[i]);
item.setImage(images[i]);
items.add(item);
}
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View layoutView = LayoutInflater.from(parent.getContext()).
inflate(R.layout.item_list, parent, false);
ViewHolder viewHolder = new ViewHolder(layoutView);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
ListItem list = items.get(position);
holder.imageView.setImageBitmap(list.getImage());
holder.textViewName.setText(list.getName());
holder.textViewUrl.setText(list.getUrl());
}
@Override
public int getItemCount() {
return items.size();
}
class ViewHolder extends RecyclerView.ViewHolder {
public ImageView imageView;
public TextView textViewName;
public TextView textViewUrl;
public ViewHolder(View itemView) {
super(itemView);
imageView = (ImageView) itemView.findViewById(R.id.items);
textViewName = (TextView) itemView.findViewById(R.id.textViewTitle);
textViewUrl = (TextView) itemView.findViewById(R.id.SimpleDescCardSub1);
}
}
}
this is my childtab1 activity :
public class Child_Tab1 extends Activity{
private RecyclerView rvView;
private RecyclerView.Adapter adapter;
private RecyclerView.LayoutManager layoutManager;
private ArrayList<String> dataSet;
private ConfigChildItem configchilditem;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.child_tab_1);
ActionBarTitleGravity();
rvView = (RecyclerView) findViewById(R.id.rv1);
rvView.setAdapter(adapter);
rvView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
SpacesItemsDecoration decoration = new SpacesItemsDecoration(4);
rvView.addItemDecoration(decoration);
getData();
}
private void ActionBarTitleGravity() {
ActionBar actionbar = getActionBar();
TextView textview = new TextView(getApplicationContext());
LayoutParams layoutparams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
textview.setLayoutParams(layoutparams);
textview.setText("Kinandayu");
textview.setTextColor(Color.parseColor("#00acc1"));
textview.setGravity(Gravity.START);
textview.setTextSize(20);
actionbar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionbar.setCustomView(textview);
}
private void getData(){
class GetData extends AsyncTask<Void,Void,String>{
ProgressDialog progressDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = ProgressDialog.show(Child_Tab1.this, "Fetching Data", "Please wait...",false,false);
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
progressDialog.dismiss();
parseJSON(s);
}
@Override
protected String doInBackground(Void... params) {
BufferedReader bufferedReader = null;
try {
URL url = new URL(ConfigChildItem.GET_URL);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
StringBuilder sb = new StringBuilder();
bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
String json;
while((json = bufferedReader.readLine())!= null){
sb.append(json+"\n");
}
return sb.toString().trim();
}catch(Exception e){
return null;
}
}
}
GetData gd = new GetData();
gd.execute();
}
public void showData() {
adapter = new RecyclerAdapter(ConfigChildItem.names,ConfigChildItem.urls, ConfigChildItem.bitmaps);
rvView.setAdapter(adapter);
}
private void parseJSON(String json){
try {
JSONObject jsonObject = new JSONObject(json);
JSONArray array = jsonObject.getJSONArray(ConfigChildItem.TAG_JSON_ARRAY);
configchilditem = new ConfigChildItem(array.length());
for(int i=0; i<array.length(); i++){
JSONObject j = array.getJSONObject(i);
ConfigChildItem.names[i] = getName(j);
ConfigChildItem.urls[i] = getURL(j);
}
} catch (JSONException e) {
e.printStackTrace();
}
ChildItemListJSON gb = new ChildItemListJSON(this,this, ConfigChildItem.urls);
gb.execute();
}
private String getName(JSONObject j){
String name = null;
try {
name = j.getString(ConfigChildItem.TAG_IMAGE_NAME);
} catch (JSONException e) {
e.printStackTrace();
}
return name;
}
private String getURL(JSONObject j){
String url = null;
try {
url = j.getString(ConfigChildItem.TAG_IMAGE_URL);
} catch (JSONException e) {
e.printStackTrace();
}
return url;
}
}
this is my getbitmap :
public class ChildItemListJSON extends AsyncTask<Void,Void,Void> {
private Context context;
private String[] urls;
private ProgressDialog loading;
private Child_Tab1 child_Tab1;
public ChildItemListJSON(Context context, Child_Tab1 child_Tab1, String[] urls){
this.context = context;
this.urls = urls;
this.child_Tab1 = child_Tab1;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
loading = ProgressDialog.show(context,"Downloading Image","Please wait...",false,false);
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
loading.dismiss();
child_Tab1.showData();
}
@Override
protected Void doInBackground(Void... params) {
for(int i=0; i<urls.length; i++){
ConfigChildItem.bitmaps[i] = getImage(urls[i]);
}
return null;
}
private Bitmap getImage(String bitmapUrl){
URL url;
Bitmap image = null;
try {
url = new URL(bitmapUrl);
image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
}catch(Exception e){}
return image;
}
}
and this is my listitem.java :
public class ListItem {
private String name;
private String url;
private Bitmap image;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Bitmap getImage() {
return image;
}
public void setImage(Bitmap image) {
this.image = image;
}
}
i have one table with coloums id and image(varchar300) [![my table][1]][1]
[1]: https://i.stack.imgur.com/vPtt7.png
my big problem is :
1. why the picture in my database is not loaded to my recylerview
2. do i do wrong with my php script? my image was store in folder uploads in my file manager in cpanel
any answer is very helpfull for me. thanks before
| 0debug
|
TypeError: Class extends value undefined is not a function or null : <p>I am getting the following error when trying to create these entities.</p>
<p><code>TypeError: Class extends value undefined is not a function or null</code></p>
<p>I am assuming this has something to do with circular dependencies, but how is that supposed to be avoided when using table inheritance and one to many relationships?</p>
<p>It is complaining about the following javascript at <code>BaseComic_1.BaseComic</code>.</p>
<p><strong><code>let Variant = class Variant extends BaseComic_1.BaseComic {</code></strong></p>
<p>Here is the complete file.</p>
<pre><code>"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
const typeorm_1 = require("typeorm");
const Comic_1 = require("./Comic");
const BaseComic_1 = require("./BaseComic");
let Variant = class Variant extends BaseComic_1.BaseComic {
};
__decorate([
typeorm_1.ManyToOne(type => Comic_1.Comic, comic => comic.variants),
__metadata("design:type", Comic_1.Comic)
], Variant.prototype, "comic", void 0);
Variant = __decorate([
typeorm_1.ClassEntityChild()
], Variant);
exports.Variant = Variant;
//# sourceMappingURL=Variant.js.map
</code></pre>
<hr>
<pre><code>import {Entity, Column, PrimaryGeneratedColumn, OneToMany} from "typeorm";
import {Comic} from "./Comic";
@Entity()
export class Series {
@PrimaryGeneratedColumn()
public id: number;
@Column("text", {
length: 30
})
public copyright: string;
@Column("text", {
length: 100
})
public attributionText: string;
@Column("text", {
length: 150
})
public attributionHTML: string;
@Column("text", {
length: 50
})
public etag: string;
@Column("text", {
length: 200
})
public title: string;
@Column("text")
public description: string;
@Column("number", {
length: 4
})
public startYear: number;
@Column("number", {
length: 4
})
public endYear: number;
@Column("text", {
length: 20
})
public rating: string;
@Column("text", {
length: 20
})
public type: string;
@Column("text")
public thumbnail: string;
@OneToMany(type => Comic, comic => comic.series)
public comics: Array<Comic>;
}
</code></pre>
<hr>
<pre><code>import {Entity, TableInheritance, PrimaryGeneratedColumn, Column, ManyToOne, DiscriminatorColumn} from "typeorm";
import {Series} from "./Series";
@Entity()
@TableInheritance("class-table")
@DiscriminatorColumn({ name: "type", type: "string"})
export class BaseComic {
@PrimaryGeneratedColumn()
public id: number;
@Column("text", {
length: 30
})
public copyright: string;
@Column("text", {
length: 100
})
public attributionText: string;
@Column("text", {
length: 150
})
public attributionHTML: string;
@Column("text", {
length: 50
})
public etag: string;
@Column("text", {
length: 200
})
public title: string;
@Column("int")
public issue: number;
@Column("text")
public variantDescription: string;
@Column("boolean")
public variant: boolean;
@Column("text")
public description: string;
@Column("int")
public pageCount: number;
@Column("date")
public onSaleDate: Date;
@Column("date")
public unlimitedDate: Date;
@Column("text")
public thumbnail: string;
@ManyToOne(type => Series, series => series.comics)
public series: Series;
}
</code></pre>
<hr>
<pre><code>import {OneToMany, ClassEntityChild} from "typeorm";
import {Variant} from "./Variant";
import {BaseComic} from "./BaseComic";
@ClassEntityChild()
export class Comic extends BaseComic {
@OneToMany(type => Variant, variant => variant.comic)
public variants: Variant[];
}
</code></pre>
<hr>
<pre><code>import {ManyToOne, ClassEntityChild} from "typeorm";
import {Comic} from "./Comic";
import {BaseComic} from "./BaseComic";
@ClassEntityChild()
export class Variant extends BaseComic {
@ManyToOne(type => Comic, comic => comic.variants)
public comic: Comic;
}
</code></pre>
| 0debug
|
Sort object with keys (JS) : <p>Have Object. look like this</p>
<p><a href="https://i.stack.imgur.com/OBxaT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OBxaT.png" alt="enter image description here"></a></p>
<p>need to sort it, in result: mo,tu,we,th,fr,st,su</p>
<p>try do this but not working</p>
<pre><code>const sortOrder = {'mo': 1, 'tu': 2, 'we': 3, 'th':4,'fr':5, 'sa':6, 'su':7}
const res = result.map(o => Object.assign({}, ...Object.keys(o).sort((a, b) => sortOrder[a] - sortOrder[b]).map(x => { return { [x]: o[x]}})))
</code></pre>
| 0debug
|
static inline void RENAME(rgb24ToUV_half)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused)
{
int i;
assert(src1==src2);
for (i=0; i<width; i++) {
int r= src1[6*i + 0] + src1[6*i + 3];
int g= src1[6*i + 1] + src1[6*i + 4];
int b= src1[6*i + 2] + src1[6*i + 5];
dstU[i]= (RU*r + GU*g + BU*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1);
dstV[i]= (RV*r + GV*g + BV*b + (257<<RGB2YUV_SHIFT))>>(RGB2YUV_SHIFT+1);
}
}
| 1threat
|
How to tell between undefined array elements and empty slots? : <p>Suppose I am a user script developer and I don't have control over the on-page javascript. The page creates arrays with random lengths, filling them with random values (including falsy ones, such as <code>undefined</code>). Not every element has to be assigned a value, so there may be empty slots.</p>
<p>A simplified example (Firefox console):</p>
<pre><code>var arr = new Array(3);
arr[0] = null;
arr[1] = undefined;
console.log(arr); \\ Array [ null, undefined, <1 empty slot> ]
console.log(arr[1]); \\ undefined
console.log(arr[2]); \\ undefined
console.log(arr[1] === arr[2]); \\ true
console.log(typeof arr[1]); \\ undefined
console.log(typeof arr[2]); \\ undefined
</code></pre>
<p>As we can see, Firefox displays <code>undefined</code> and empty slots differently, whereas for javascript they seem to be identical.</p>
<p>Now suppose I want to clean such an array, removing all empty slots but leaving <code>undefined</code> elements intact. How do I do that?</p>
| 0debug
|
Tensorflow Object Detection API no train.py file : <p>I've correctly installed Tensorflow Object Detection API according to the provided documentation. However, when I need to train my network there is no train.py file in the research/object_detection directory.
Is there anything I can do to fix this?</p>
<p>Link: <a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md" rel="noreferrer">https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md</a></p>
| 0debug
|
Unable to Execute Rails console command Ruby : <pre><code>/Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/completion.rb:10:in `require': dlopen(/Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
Referenced from: /Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
Reason: image not found - /Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
from /Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/completion.rb:10:in `<top (required)>'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:3:in `require'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:3:in `<top (required)>'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:138:in `require'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
</code></pre>
<p>This is my error screen after trying to execute the command. I've tried to uninstall and reinstall readline and that did not help. I am just learning rails and do not 100% know what I am doing (just following a guide) so this type of error is past my understanding. Thanks!</p>
| 0debug
|
cut a string after a dot in R : <p>All my column names start with</p>
<pre><code>A.ABC.test1
A.ABC.test2
A.ABC.test3
A.ABC.test4
A.ABC.test5
</code></pre>
<p>I would like to keep only <code>test1</code> , <code>test2</code> ...</p>
<p>Any ideas?</p>
| 0debug
|
kotlin logging with lambda parameters : <p>In log4j2 we have a handy feature which is described as</p>
<pre><code>// Java-8 style optimization: no need to explicitly check the log level:
// the lambda expression is not evaluated if the TRACE level is not enabled
logger.trace("Some long-running operation returned {}", () -> expensiveOperation());
</code></pre>
<p>my attempt to use this in kotlin</p>
<pre><code>log.debug("random {}", { UUID.randomUUID() })
</code></pre>
<p>which will print</p>
<pre><code>random Function0<java.util.UUID>
</code></pre>
<p><strong>How do we use lambda argument logging with kotlin? Or how do we explicitly tell kotlin what method to call?</strong></p>
| 0debug
|
static int mov_read_glbl(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
{
AVStream *st = c->fc->streams[c->fc->nb_streams-1];
if((uint64_t)atom.size > (1<<30))
return -1;
av_free(st->codec->extradata);
st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size;
get_buffer(pb, st->codec->extradata, atom.size);
return 0;
}
| 1threat
|
int do_subchannel_work_passthrough(SubchDev *sch)
{
int ret = 0;
SCSW *s = &sch->curr_status.scsw;
if (s->ctrl & SCSW_FCTL_CLEAR_FUNC) {
sch_handle_clear_func(sch);
} else if (s->ctrl & SCSW_FCTL_HALT_FUNC) {
sch_handle_halt_func(sch);
} else if (s->ctrl & SCSW_FCTL_START_FUNC) {
ret = sch_handle_start_func_passthrough(sch);
}
return ret;
}
| 1threat
|
def even_bit_toggle_number(n) :
res = 0; count = 0; temp = n
while (temp > 0) :
if (count % 2 == 1) :
res = res | (1 << count)
count = count + 1
temp >>= 1
return n ^ res
| 0debug
|
Android context.getResources.updateConfiguration() deprecated : <p>Just recently context.getResources().<a href="https://developer.android.com/reference/android/content/res/Resources.html#updateConfiguration(android.content.res.Configuration,%20android.util.DisplayMetrics)">updateConfiguration()</a> has been deprecated in Android API 25 and it is advised to use context.<a href="https://developer.android.com/reference/android/content/Context.html#createConfigurationContext(android.content.res.Configuration)">createConfigurationContext()</a> instead.</p>
<p>Does anyone know how <strong>createConfigurationContext</strong> can be used to override android system locale?</p>
<p>before this would be done by:</p>
<pre><code>Configuration config = getBaseContext().getResources().getConfiguration();
config.setLocale(locale);
context.getResources().updateConfiguration(config,
context.getResources().getDisplayMetrics());
</code></pre>
| 0debug
|
Flutter: ListView not scrollable, not bouncing : <p>I have the following example (tested on an iPhone X, iOS 11):</p>
<pre><code>import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new ListView(
children: <Widget>[
new Container(
height: 40.0,
color: Colors.blue,
),
new Container(
height: 40.0,
color: Colors.red,
),
new Container(
height: 40.0,
color: Colors.green,
),
]
);
}
}
</code></pre>
<p>In this case the ListView acts like expected. I can scroll beyond the viewport and the ListView bounces back again (typical iOS behavior). But when I add a ScrollController to track the offset, the behavior of the scrolling changes:</p>
<pre><code>import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
ScrollController _controller = new ScrollController();
@override
Widget build(BuildContext context) {
return new ListView(
controller: _controller,
children: <Widget>[
new Container(
height: 40.0,
color: Colors.blue,
),
new Container(
height: 40.0,
color: Colors.red,
),
new Container(
height: 40.0,
color: Colors.green,
),
]
);
}
}
</code></pre>
<p>In this case the scrolling is not possible anymore. Why is it that when I add a ScrollController, that the scrolling is not possible anymore? Also adding <code>physics: new BouncingScrollPhysics(),</code> to the ListView does not help.</p>
<p>Thanks for any help :)</p>
| 0debug
|
static void vnc_connect(VncDisplay *vd, int csock,
bool skipauth, bool websocket)
{
VncState *vs = g_malloc0(sizeof(VncState));
int i;
vs->csock = csock;
vs->vd = vd;
if (skipauth) {
vs->auth = VNC_AUTH_NONE;
vs->subauth = VNC_AUTH_INVALID;
} else {
if (websocket) {
vs->auth = vd->ws_auth;
vs->subauth = VNC_AUTH_INVALID;
} else {
vs->auth = vd->auth;
vs->subauth = vd->subauth;
}
}
VNC_DEBUG("Client sock=%d ws=%d auth=%d subauth=%d\n",
csock, websocket, vs->auth, vs->subauth);
vs->lossy_rect = g_malloc0(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));
for (i = 0; i < VNC_STAT_ROWS; ++i) {
vs->lossy_rect[i] = g_malloc0(VNC_STAT_COLS * sizeof (uint8_t));
}
VNC_DEBUG("New client on socket %d\n", csock);
update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE);
qemu_set_nonblock(vs->csock);
#ifdef CONFIG_VNC_WS
if (websocket) {
vs->websocket = 1;
#ifdef CONFIG_VNC_TLS
if (vd->ws_tls) {
qemu_set_fd_handler(vs->csock, vncws_tls_handshake_io, NULL, vs);
} else
#endif
{
qemu_set_fd_handler(vs->csock, vncws_handshake_read, NULL, vs);
}
} else
#endif
{
qemu_set_fd_handler(vs->csock, vnc_client_read, NULL, vs);
}
vnc_client_cache_addr(vs);
vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED);
vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING);
#ifdef CONFIG_VNC_WS
if (!vs->websocket)
#endif
{
vnc_init_state(vs);
}
if (vd->num_connecting > vd->connections_limit) {
QTAILQ_FOREACH(vs, &vd->clients, next) {
if (vs->share_mode == VNC_SHARE_MODE_CONNECTING) {
vnc_disconnect_start(vs);
return;
}
}
}
}
| 1threat
|
static void ppc_heathrow_init(QEMUMachineInitArgs *args)
{
ram_addr_t ram_size = args->ram_size;
const char *cpu_model = args->cpu_model;
const char *kernel_filename = args->kernel_filename;
const char *kernel_cmdline = args->kernel_cmdline;
const char *initrd_filename = args->initrd_filename;
const char *boot_device = args->boot_device;
MemoryRegion *sysmem = get_system_memory();
PowerPCCPU *cpu = NULL;
CPUPPCState *env = NULL;
char *filename;
qemu_irq *pic, **heathrow_irqs;
int linux_boot, i;
MemoryRegion *ram = g_new(MemoryRegion, 1);
MemoryRegion *bios = g_new(MemoryRegion, 1);
MemoryRegion *isa = g_new(MemoryRegion, 1);
uint32_t kernel_base, initrd_base, cmdline_base = 0;
int32_t kernel_size, initrd_size;
PCIBus *pci_bus;
PCIDevice *macio;
MACIOIDEState *macio_ide;
DeviceState *dev;
BusState *adb_bus;
int bios_size;
MemoryRegion *pic_mem;
MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1);
uint16_t ppc_boot_device;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
void *fw_cfg;
linux_boot = (kernel_filename != NULL);
if (cpu_model == NULL)
cpu_model = "G3";
for (i = 0; i < smp_cpus; i++) {
cpu = cpu_ppc_init(cpu_model);
if (cpu == NULL) {
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
exit(1);
}
env = &cpu->env;
cpu_ppc_tb_init(env, TBFREQ);
qemu_register_reset(ppc_heathrow_reset, cpu);
}
if (ram_size > (2047 << 20)) {
fprintf(stderr,
"qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
((unsigned int)ram_size / (1 << 20)));
exit(1);
}
memory_region_init_ram(ram, NULL, "ppc_heathrow.ram", ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(sysmem, 0, ram);
memory_region_init_ram(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE);
vmstate_register_ram_global(bios);
if (bios_name == NULL)
bios_name = PROM_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
memory_region_set_readonly(bios, true);
memory_region_add_subregion(sysmem, PROM_ADDR, bios);
if (filename) {
bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL,
1, ELF_MACHINE, 0);
g_free(filename);
} else {
bios_size = -1;
}
if (bios_size < 0 || bios_size > BIOS_SIZE) {
hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name);
exit(1);
}
if (linux_boot) {
uint64_t lowaddr = 0;
int bswap_needed;
#ifdef BSWAP_NEEDED
bswap_needed = 1;
#else
bswap_needed = 0;
#endif
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0);
if (kernel_size < 0)
kernel_size = load_aout(kernel_filename, kernel_base,
ram_size - kernel_base, bswap_needed,
TARGET_PAGE_SIZE);
if (kernel_size < 0)
kernel_size = load_image_targphys(kernel_filename,
kernel_base,
ram_size - kernel_base);
if (kernel_size < 0) {
hw_error("qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
if (initrd_filename) {
initrd_base = round_page(kernel_base + kernel_size + KERNEL_GAP);
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
hw_error("qemu: could not load initial ram disk '%s'\n",
initrd_filename);
exit(1);
}
cmdline_base = round_page(initrd_base + initrd_size);
} else {
initrd_base = 0;
initrd_size = 0;
cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP);
}
ppc_boot_device = 'm';
} else {
kernel_base = 0;
kernel_size = 0;
initrd_base = 0;
initrd_size = 0;
ppc_boot_device = '\0';
for (i = 0; boot_device[i] != '\0'; i++) {
#if 0
if (boot_device[i] >= 'a' && boot_device[i] <= 'f') {
ppc_boot_device = boot_device[i];
break;
}
#else
if (boot_device[i] >= 'c' && boot_device[i] <= 'd') {
ppc_boot_device = boot_device[i];
break;
}
#endif
}
if (ppc_boot_device == '\0') {
fprintf(stderr, "No valid boot device for G3 Beige machine\n");
exit(1);
}
}
memory_region_init_alias(isa, NULL, "isa_mmio",
get_system_io(), 0, 0x00200000);
memory_region_add_subregion(sysmem, 0xfe000000, isa);
heathrow_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
heathrow_irqs[0] =
g_malloc0(smp_cpus * sizeof(qemu_irq) * 1);
for (i = 0; i < smp_cpus; i++) {
switch (PPC_INPUT(env)) {
case PPC_FLAGS_INPUT_6xx:
heathrow_irqs[i] = heathrow_irqs[0] + (i * 1);
heathrow_irqs[i][0] =
((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT];
break;
default:
hw_error("Bus model not supported on OldWorld Mac machine\n");
}
}
if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
hw_error("Only 6xx bus is supported on heathrow machine\n");
}
pic = heathrow_pic_init(&pic_mem, 1, heathrow_irqs);
pci_bus = pci_grackle_init(0xfec00000, pic,
get_system_memory(),
get_system_io());
pci_vga_init(pci_bus);
escc_mem = escc_init(0, pic[0x0f], pic[0x10], serial_hds[0],
serial_hds[1], ESCC_CLOCK, 4);
memory_region_init_alias(escc_bar, NULL, "escc-bar",
escc_mem, 0, memory_region_size(escc_mem));
for(i = 0; i < nb_nics; i++)
pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL);
ide_drive_get(hd, MAX_IDE_BUS);
macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO);
dev = DEVICE(macio);
qdev_connect_gpio_out(dev, 0, pic[0x12]);
qdev_connect_gpio_out(dev, 1, pic[0x0D]);
qdev_connect_gpio_out(dev, 2, pic[0x02]);
qdev_connect_gpio_out(dev, 3, pic[0x0E]);
qdev_connect_gpio_out(dev, 4, pic[0x03]);
macio_init(macio, pic_mem, escc_bar);
macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),
"ide[0]"));
macio_ide_init_drives(macio_ide, hd);
macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),
"ide[1]"));
macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]);
dev = DEVICE(object_resolve_path_component(OBJECT(macio), "cuda"));
adb_bus = qdev_get_child_bus(dev, "adb.0");
dev = qdev_create(adb_bus, TYPE_ADB_KEYBOARD);
qdev_init_nofail(dev);
dev = qdev_create(adb_bus, TYPE_ADB_MOUSE);
qdev_init_nofail(dev);
if (usb_enabled(false)) {
pci_create_simple(pci_bus, -1, "pci-ohci");
}
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
graphic_depth = 15;
fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
if (kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base);
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel_cmdline);
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
if (kvm_enabled()) {
#ifdef CONFIG_KVM
uint8_t *hypercall;
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
hypercall = g_malloc(16);
kvmppc_get_hypercall(env, hypercall, 16);
fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
#endif
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, TBFREQ);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_CLOCKFREQ, 266000000);
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
}
| 1threat
|
static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
const float *la, int channel, int prev_type)
{
AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data;
AacPsyChannel *pch = &pctx->ch[channel];
int grouping = 0;
int uselongblock = 1;
int attacks[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
float clippings[AAC_NUM_BLOCKS_SHORT];
int i;
FFPsyWindowInfo wi = { { 0 } };
if (la) {
float hpfsmpl[AAC_BLOCK_SIZE_LONG];
float const *pf = hpfsmpl;
float attack_intensity[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
float energy_subshort[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
float energy_short[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
const float *firbuf = la + (AAC_BLOCK_SIZE_SHORT/4 - PSY_LAME_FIR_LEN);
int att_sum = 0;
psy_hp_filter(firbuf, hpfsmpl, psy_fir_coeffs);
for (i = 0; i < PSY_LAME_NUM_SUBBLOCKS; i++) {
energy_subshort[i] = pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 1) * PSY_LAME_NUM_SUBBLOCKS)];
assert(pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)] > 0);
attack_intensity[i] = energy_subshort[i] / pch->prev_energy_subshort[i + ((AAC_NUM_BLOCKS_SHORT - 2) * PSY_LAME_NUM_SUBBLOCKS + 1)];
energy_short[0] += energy_subshort[i];
}
for (i = 0; i < AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS; i++) {
float const *const pfe = pf + AAC_BLOCK_SIZE_LONG / (AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS);
float p = 1.0f;
for (; pf < pfe; pf++)
p = FFMAX(p, fabsf(*pf));
pch->prev_energy_subshort[i] = energy_subshort[i + PSY_LAME_NUM_SUBBLOCKS] = p;
energy_short[1 + i / PSY_LAME_NUM_SUBBLOCKS] += p;
if (p > energy_subshort[i + 1])
p = p / energy_subshort[i + 1];
else if (energy_subshort[i + 1] > p * 10.0f)
p = energy_subshort[i + 1] / (p * 10.0f);
else
p = 0.0;
attack_intensity[i + PSY_LAME_NUM_SUBBLOCKS] = p;
}
for (i = 0; i < (AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS; i++)
if (!attacks[i / PSY_LAME_NUM_SUBBLOCKS])
if (attack_intensity[i] > pch->attack_threshold)
attacks[i / PSY_LAME_NUM_SUBBLOCKS] = (i % PSY_LAME_NUM_SUBBLOCKS) + 1;
for (i = 1; i < AAC_NUM_BLOCKS_SHORT + 1; i++) {
float const u = energy_short[i - 1];
float const v = energy_short[i];
float const m = FFMAX(u, v);
if (m < 40000) {
if (u < 1.7f * v && v < 1.7f * u) {
if (i == 1 && attacks[0] < attacks[i])
attacks[0] = 0;
attacks[i] = 0;
}
}
att_sum += attacks[i];
}
if (attacks[0] <= pch->prev_attack)
attacks[0] = 0;
att_sum += attacks[0];
if (pch->prev_attack == 3 || att_sum) {
uselongblock = 0;
for (i = 1; i < AAC_NUM_BLOCKS_SHORT + 1; i++)
if (attacks[i] && attacks[i-1])
attacks[i] = 0;
}
} else {
uselongblock = !(prev_type == EIGHT_SHORT_SEQUENCE);
}
lame_apply_block_type(pch, &wi, uselongblock);
if (audio) {
for (i = 0; i < AAC_NUM_BLOCKS_SHORT; i++) {
const float *wbuf = audio + i * AAC_BLOCK_SIZE_SHORT;
float max = 0;
int j;
for (j = 0; j < AAC_BLOCK_SIZE_SHORT; j++)
max = FFMAX(max, fabsf(wbuf[j]));
clippings[i] = max;
}
} else {
for (i = 0; i < 8; i++)
clippings[i] = 0;
}
wi.window_type[1] = prev_type;
if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) {
float clipping = 0.0f;
wi.num_windows = 1;
wi.grouping[0] = 1;
if (wi.window_type[0] == LONG_START_SEQUENCE)
wi.window_shape = 0;
else
wi.window_shape = 1;
for (i = 0; i < 8; i++)
clipping = FFMAX(clipping, clippings[i]);
wi.clipping[0] = clipping;
} else {
int lastgrp = 0;
wi.num_windows = 8;
wi.window_shape = 0;
for (i = 0; i < 8; i++) {
if (!((pch->next_grouping >> i) & 1))
lastgrp = i;
wi.grouping[lastgrp]++;
}
for (i = 0; i < 8; i += wi.grouping[i]) {
int w;
float clipping = 0.0f;
for (w = 0; w < wi.grouping[i]; w++)
clipping = FFMAX(clipping, clippings[i+w]);
for (w = 0; w < wi.grouping[i]; w++)
wi.clipping[i+w] = clipping;
}
}
for (i = 0; i < 9; i++) {
if (attacks[i]) {
grouping = i;
break;
}
}
pch->next_grouping = window_grouping[grouping];
pch->prev_attack = attacks[8];
return wi;
}
| 1threat
|
vb.net . Incorrect syntax near ')'. Dim temp As Integer = Convert.ToInt32(cmd.ExecuteScalar().ToString()) : Incorrect syntax near ')'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near ')'.
Source Error:
Line 26: Dim cmd As SqlCommand = New SqlCommand(checkuser, con)
Line 27:
Line 28: Dim temp As Integer = Convert.ToInt32(cmd.ExecuteScalar().ToString())
Line 29: con.Close()
Line 30:
| 0debug
|
How to convert an image into a matrix in opencv : <p>As it is said in the title, i want to convert an image into a matrix to be able to do some calculation i have used this declaration but it show me an error : no matching function for call to c::Mat::Mat(IplImage*&)</p>
<pre><code>IplImage* image1 = cvLoadImage("C://images//PolarImage300915163358.bmp", 1);
Mat mtx(image1); // convert IplImage* -> Mat
</code></pre>
<p>is there something wrong with this declaration </p>
| 0debug
|
SVG transform-origin in Firefox : So I have this blueprint that I've recreated as an SVG.
Everything works fine in Chrome, but in Firefox, once the rotation animation on the doors finishes, the doors themselves (the rotated elements) shift from their original positions either horizontally to the right or vertically to the bottom.
I know the issue **seemingly** has something to do with the `transform-origin` values, since initially the doors are lined up perfectly. However, I've tried adjusting the `transform-origin` coordinates, which makes me believe this issue is unrelated to the `transform-origin` values. For instance, for a door that shifts vertically to the bottom, try adjusting the `y` value by either increasing or decreasing it. It obviously has an effect, but the effect doesn't correspond to the shifting.
The issue is most noticeable after refreshing the browser once the animation has completed.
**Is this simply a bug in Firefox?**
Here is the [codepen][1]!
[1]: https://codepen.io/tOkyO1/pen/GrzmGM
| 0debug
|
static int verify_expr(AVExpr *e)
{
if (!e) return 0;
switch (e->type) {
case e_value:
case e_const: return 1;
case e_func0:
case e_func1:
case e_squish:
case e_ld:
case e_gauss:
case e_isnan:
case e_floor:
case e_ceil:
case e_trunc:
case e_sqrt:
case e_not:
case e_random:
return verify_expr(e->param[0]) && !e->param[2];
case e_taylor:
return verify_expr(e->param[0]) && verify_expr(e->param[1])
&& (!e->param[2] || verify_expr(e->param[2]));
default: return verify_expr(e->param[0]) && verify_expr(e->param[1]) && !e->param[2];
}
}
| 1threat
|
PROGRAM SOS: ARRAYS AND FILES : <p>Please help. I don't know what I'm doing. I need to pass a text file containing a string and two doubles and I can't get this to work at all. I am super lost</p>
| 0debug
|
How do I use the python continue keyword as a string literal in a python script? : <p>I'm writing a python script wherein I need to use the <em>continue</em> word.</p>
<p>I know that it is a python keyword.</p>
<p>So how should I write my script so that python will not complain that I am using a keyword as a string literal.</p>
<p>Thanks in advance for your time.</p>
| 0debug
|
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
{
AVFilterContext *ctx = inlink->dst;
AudioEchoContext *s = ctx->priv;
AVFrame *out_frame;
if (av_frame_is_writable(frame)) {
out_frame = frame;
} else {
out_frame = ff_get_audio_buffer(inlink, frame->nb_samples);
if (!out_frame)
return AVERROR(ENOMEM);
av_frame_copy_props(out_frame, frame);
}
s->echo_samples(s, s->delayptrs, frame->extended_data, out_frame->extended_data,
frame->nb_samples, inlink->channels);
s->next_pts = frame->pts + av_rescale_q(frame->nb_samples, (AVRational){1, inlink->sample_rate}, inlink->time_base);
if (frame != out_frame)
av_frame_free(&frame);
return ff_filter_frame(ctx->outputs[0], out_frame);
}
| 1threat
|
Import .data file in Python : <p>I have .data file contains tab separated list. I want to import this .data file into Python, I've seen there are so many libraries offer this feature, but can't really find one that easily to implement. Can you guys tell me how to load it, or any kind of library(best library) that could help me and how to use it? Thanks.</p>
| 0debug
|
int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset,
int *num, uint64_t *host_offset, QCowL2Meta **m)
{
BDRVQcowState *s = bs->opaque;
uint64_t start, remaining;
uint64_t cluster_offset;
uint64_t cur_bytes;
int ret;
trace_qcow2_alloc_clusters_offset(qemu_coroutine_self(), offset, *num);
assert((offset & ~BDRV_SECTOR_MASK) == 0);
again:
start = offset;
remaining = *num << BDRV_SECTOR_BITS;
cluster_offset = 0;
*host_offset = 0;
cur_bytes = 0;
*m = NULL;
while (true) {
if (!*host_offset) {
*host_offset = start_of_cluster(s, cluster_offset);
}
assert(remaining >= cur_bytes);
start += cur_bytes;
remaining -= cur_bytes;
cluster_offset += cur_bytes;
if (remaining == 0) {
break;
}
cur_bytes = remaining;
ret = handle_dependencies(bs, start, &cur_bytes, m);
if (ret == -EAGAIN) {
assert(*m == NULL);
goto again;
} else if (ret < 0) {
return ret;
} else if (cur_bytes == 0) {
break;
} else {
}
ret = handle_copied(bs, start, &cluster_offset, &cur_bytes, m);
if (ret < 0) {
return ret;
} else if (ret) {
continue;
} else if (cur_bytes == 0) {
break;
}
ret = handle_alloc(bs, start, &cluster_offset, &cur_bytes, m);
if (ret < 0) {
return ret;
} else if (ret) {
continue;
} else {
assert(cur_bytes == 0);
break;
}
}
*num -= remaining >> BDRV_SECTOR_BITS;
assert(*num > 0);
assert(*host_offset != 0);
return 0;
}
| 1threat
|
Combine char to get char* : <p>Really dumb c++ question, but I don't see it covered in the way I need it to be. I have a const char* that I want to pull various values out of and into their own char*. For example</p>
<pre><code>const char* atr;
//
//Data is placed in atr
//
//Here's what I want to do, but obviously this doesn't compile
char* _ts = atr[0] + atr[1];
char* _t0 = atr[2] + atr[3];
</code></pre>
<p>Thanks a ton in advance. I'm a day to day C++ dev who was basically raised on C++11 and beyond, so dealing with character pointers is a bit strange to me.</p>
| 0debug
|
What are projectable nodes in angular2 : <p>On reading the documentation of <a href="https://angular.io/docs/ts/latest/api/core/index/ViewContainerRef-class.html#!#createEmbeddedView-anchor" rel="noreferrer">ViewContainerRef</a> and <a href="https://angular.io/docs/ts/latest/api/core/index/ComponentFactory-class.html#!#create-anchor" rel="noreferrer">ComponentFactory</a>, where , for example we have the method </p>
<p><a href="https://angular.io/docs/ts/latest/api/core/index/ViewContainerRef-class.html#!#createEmbeddedView-anchor" rel="noreferrer">ViewContainerRef#createComponent</a> which takes 3 arguments : <code>componentFactory</code> , <code>injector</code> and <code>projectableNodes</code>. </p>
<p>I have tried looking up what <code>projectableNodes</code> mean and how they are used in blogs, tutorials and source code but could not find much. </p>
<p>On looking up the <a href="https://github.com/angular/angular/pull/11235/files#r77220989" rel="noreferrer">diff for for ngComponentOutlet directive</a>, All I could gather was that the string in projectableNodes is "projected" or rendered on to the created components view ( like ng-content may be). If so that is confusing as we have <a href="https://angular.io/docs/ts/latest/api/core/index/ViewContainerRef-class.html#!#createEmbeddedView-anchor" rel="noreferrer">ViewContainerRef#createEmbeddedView</a> for the same. </p>
<p>I would like to know as to what are these <code>projectedNodes</code> and have an example of their usage.</p>
| 0debug
|
How can I create a program, where the user inputs an integer and it outputs a 90 degree number pyramid? : <p>I already have a bit, however I have no idea what to do from where I am.
This is what I am trying to do. </p>
<p>ex.</p>
<p>Input: 5</p>
<p>Output:</p>
<p>5</p>
<p>44</p>
<p>333</p>
<p>2222</p>
<p>11111</p>
<p>This is my current code:</p>
<pre><code> #include<iostream>
using namespace std;
int main(){
int a;
int counter = 1;
int counter4;
int counter5;
cout << "Enter an integer, any integer" << endl;
cin >> a;
cout << a << endl;
cout << endl;
while(a >= counter){
counter5 = a--;
counter4 = a;
while(counter4 > counter5){
cout << counter5;
cout << " " << endl;
counter4--;
}
}
}
</code></pre>
<p>I know that I have a lot more I have to do but I just don't know how. Thanks for any support and help you guys can give me. </p>
| 0debug
|
SQLiteConnection databases leak when running emulator : <p>I was running the emulator and received the following errors about memory leak. It was interesting that the leaking database seems to be of the Google gms instead of a user database. Does anyone know how to fix it? Thanks!</p>
<pre><code>09-27 15:55:07.252 2058-2068/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/metrics.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
09-27 15:55:07.255 2058-2068/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/help_responses.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
09-27 15:55:07.259 2058-2068/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/auto_complete_suggestions.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
</code></pre>
| 0debug
|
Kotlin val difference getter override vs assignment : <p>I started playing arround with Kotlin and read something about mutable val with custom getter. As refered in e.g <a href="http://blog.danlew.net/2017/05/30/mutable-vals-in-kotlin/" rel="noreferrer">here</a> or in the <a href="https://kotlinlang.org/docs/reference/coding-conventions.html#functions-vs-properties" rel="noreferrer">Kotlin Coding Convention</a> one should not override the getter if the result can change.</p>
<pre><code>class SampleArray(val size: Int) {
val isEmpty get() = size == 0 // size is set at the beginning and does not change so this is ok
}
class SampleArray(var size: Int) {
fun isEmpty() { return size == 0 } // size is set at the beginning but can also change over time so function is prefered
}
</code></pre>
<p>But just from the perspective of usage as in the guidelines where is the difference between the following two</p>
<pre><code>class SampleArray(val size: Int) {
val isEmpty get() = size == 0 // size can not change so this can be used instad of function
val isEmpty = size == 0 // isEmpty is assigned at the beginning ad will keep this value also if size could change
}
</code></pre>
<p>From <a href="https://stackoverflow.com/a/36366900/3883569">this</a> answer I could see that for getter override the value is not stored. Is there something else where the getter override is different form the assignment? Maybe with delegates or latinit?</p>
| 0debug
|
Calculate averages for each country, from a data frame : <p>I'm working on a dataframe called 'df'. Two of the columns in 'df' are 'country' and 'dissent'. I need to calculate the average dissent per country. What is the most effective way to iterate through the data frame and calculate the averages by country? </p>
<p>I tried for loops but it does not work and also I don't think it is the most effective way.</p>
| 0debug
|
void curses_display_init(DisplayState *ds, int full_screen)
{
#ifndef _WIN32
if (!isatty(1)) {
fprintf(stderr, "We need a terminal output\n");
exit(1);
}
#endif
curses_setup();
curses_keyboard_setup();
atexit(curses_atexit);
curses_winch_init();
dcl = (DisplayChangeListener *) g_malloc0(sizeof(DisplayChangeListener));
dcl->ops = &dcl_ops;
register_displaychangelistener(dcl);
invalidate = 1;
}
| 1threat
|
How to put validation to date : [![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/exKZ1.png
Student can select any number of CourseBatchCode,
in Case 3 CourseBatchCode is selected
This is my Table I want to put validation on the table that
1)ENDTIME should not be between following Start time and end time
2)EndTime should be less than following Start Time and End time
Plz Help with Cursor Query thank u
| 0debug
|
What is Travis recommended language when you need Docker only? : The whole project is build inside docker. And it runs so far with any language I tried. But which is the minimal one with just a docker?
As any of these https://docs.travis-ci.com/user/languages/ doesn't really fit.
| 0debug
|
Difference in applying codes in elements : <p>I would like to ask what is the difference between <code>*{}</code> and <code>body,html{}</code>. It changes the view in the html and I want to have a broad knowledge about this. Thanks.</p>
| 0debug
|
How to control the font size of quoted text in Markdown : <p>The font of quoted text on Markdown is often too large in contrast to the rest of the (unquoted) text. This is an example:
<a href="https://i.stack.imgur.com/gfj8z.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gfj8z.png" alt="enter image description here"></a></p>
<p>generated with RStudio as</p>
<pre><code>#####Intution:
> **[Identification of an MA model is often best done with the ACF rather
> than the PACF]((https://onlinecourses.science.psu.edu/stat510/node/62))**.
>
> For an MA model, the theoretical PACF does not shut off, but instead
> tapers toward 0 in some manner. A clearer pattern for an MA model is
> in the ACF. The ACF will have non-zero autocorrelations only at lags
> involved in the model.
>
> A moving average term in a time series model is a past error (multiplied by a coefficient).
The $q^{\text{th}}$-order moving average model, denoted by MA(q) is
</code></pre>
| 0debug
|
update filed in query access with duplicate filed : i have table like this
UserName tel Active
-----------------------------------------------
michael 12345678 t
michael 23441606 t
nabil 32564189 t
nabil 54655526 t
mic 5 1233333 t
mic 12121212 t
mic 12131313 t
i need to make update to field Active to be like this
UserName tel Active
-----------------------------------------------
michael 12345678 t1
michael 23441606 t2
nabil 32564189 t1
nabil 54655526 t2
mic 5 1233333 t1
mic 12121212 t2
mic 12131313 t3
| 0debug
|
Android Application connecting to an existing database : <p>I am working on an android application for my institute. I have to connect my app to the existing database of the college, although there is no API written. When I contacted the administration for help then they only handed me a SQL connection string and told me to write the API myself. I want to focus on the application only. Is there any way I can skip the API writing and still connect to the database easily and quickly??</p>
| 0debug
|
static void vmxnet3_update_features(VMXNET3State *s)
{
uint32_t guest_features;
int rxcso_supported;
guest_features = VMXNET3_READ_DRV_SHARED32(s->drv_shmem,
devRead.misc.uptFeatures);
rxcso_supported = VMXNET_FLAG_IS_SET(guest_features, UPT1_F_RXCSUM);
s->rx_vlan_stripping = VMXNET_FLAG_IS_SET(guest_features, UPT1_F_RXVLAN);
s->lro_supported = VMXNET_FLAG_IS_SET(guest_features, UPT1_F_LRO);
VMW_CFPRN("Features configuration: LRO: %d, RXCSUM: %d, VLANSTRIP: %d",
s->lro_supported, rxcso_supported,
s->rx_vlan_stripping);
if (s->peer_has_vhdr) {
qemu_set_offload(qemu_get_queue(s->nic)->peer,
rxcso_supported,
s->lro_supported,
s->lro_supported,
0,
0);
}
}
| 1threat
|
Firebase onAuthStateChanged callback takes 20+ seconds sometimes : <p>We've been using Firebase on our applications after moving away from our own NodeJS backend running express and during this transition we've noticed one major drawback. The amount of time it takes for the initial auth state to be received by the client.</p>
<p>When my application is opened I <strong>immediately</strong> register the <code>onAuthStateChanged</code> callback to start listening for changes in authentication state, that way I can route the user to either their personal hub or the authentication screen. </p>
<p>The problem is that while sometimes this only takes a few milliseconds, at other times (Independant of internet connection) it takes anywhere from 20+ seconds, causing an extremely poor user experience. </p>
<p>We're using the Firebase WEB API on a UIWebView component.</p>
<p>I've tested this on 3G, 4G, LTE and Wifi and it's completely random. Sometimes it loads like lightning. Sometimes it's so slow that I question the reliability of the service. </p>
<p>Some may argue that this is due to the user data we have to download, but the 20-30 seconds that we're waiting is before we even attempt to pull data from the server. This is just to get the initial authorization state. We're only using email providers.</p>
<p>Does anyone know what we could do to improve this? On average the <code>onAuthStateChanged</code> callback is defined <code>562ms</code> after the applications execution. After this sometimes it can take <code>20-200ms</code> (Average latency) and sometimes it takes 20000ms+</p>
| 0debug
|
Change file name while generate cvs from java project : in this post (https://stackoverflow.com/questions/13159272/how-to-export-data-in-csv-format-using-java) I found out solution to write date to csv file and this work fine (TOP Answer).
I need change file name to anything with .csv extention. Now I get WebServlet name as a file name without any extention.
Have any of You idea how to set a file name ?
| 0debug
|
C++ How do you call a method for all members of a class? : <p>I have a class will many members and I want to
call a method for ALL membersof that class rather than
just an individual member</p>
<p>I could link all members of class via linked lists but is there a better way?</p>
| 0debug
|
int ff_slice_thread_init(AVCodecContext *avctx)
{
int i;
SliceThreadContext *c;
int thread_count = avctx->thread_count;
#if HAVE_W32THREADS
w32thread_init();
#endif
if (av_codec_is_encoder(avctx->codec) &&
avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO &&
avctx->height > 2800)
thread_count = avctx->thread_count = 1;
if (!thread_count) {
int nb_cpus = av_cpu_count();
if (avctx->height)
nb_cpus = FFMIN(nb_cpus, (avctx->height+15)/16);
if (nb_cpus > 1)
thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
else
thread_count = avctx->thread_count = 1;
}
if (thread_count <= 1) {
avctx->active_thread_type = 0;
return 0;
}
c = av_mallocz(sizeof(SliceThreadContext));
if (!c)
return -1;
c->workers = av_mallocz_array(thread_count, sizeof(pthread_t));
if (!c->workers) {
av_free(c);
return -1;
}
avctx->internal->thread_ctx = c;
c->current_job = 0;
c->job_count = 0;
c->job_size = 0;
c->done = 0;
pthread_cond_init(&c->current_job_cond, NULL);
pthread_cond_init(&c->last_job_cond, NULL);
pthread_mutex_init(&c->current_job_lock, NULL);
pthread_mutex_lock(&c->current_job_lock);
for (i=0; i<thread_count; i++) {
if(pthread_create(&c->workers[i], NULL, worker, avctx)) {
avctx->thread_count = i;
pthread_mutex_unlock(&c->current_job_lock);
ff_thread_free(avctx);
return -1;
}
}
thread_park_workers(c, thread_count);
avctx->execute = thread_execute;
avctx->execute2 = thread_execute2;
return 0;
}
| 1threat
|
Java script number format change : <p>I've number i.e. 12345678 and I want to change it to the following format
[12,34,56,78]. How can I do that?</p>
| 0debug
|
How can I display single list value in 2 different columns of jsp according to ID's? : <div id="mappedORg">
<table width="100%" id="myTable" class="sortable">
<tr>
<h1>Mapped Organization</h1>
<thead>
<tr><th><strong><s:property value="getText('global.univeristy')" /></strong></th>
<th ><strong><s:property value="getText('global.college')" /></strong></th>
</tr>
</thead>
<tbody>
<s:iterator value="userOrgMappedList" var="quesvar" status="questat">
<tr>
<td valign="top" class="style11" style="width: 20%;"><s:property value="userOrgMappedList[#questat.index].OrgName"/></td>
</s:iterator>
</tr>
here is my query for fetching university and college
SELECT UOM.Organization_ID, OM.Organization_Name, OM.Organization_Type_ID, UOM.Is_Active,OM.Organization_Parent_Id FROM T_User_Organization_Map UOM
INNER JOIN M_Organization_Master OM ON UOM.Organization_ID = OM.Organization_ID
INNER JOIN M_Organization_Type_Master OTM ON OM.Organization_Type_ID=OTM.Organization_Type_ID
LEFT OUTER JOIN M_Organization_Master LOM ON OM.Organization_Parent_Id = LOM.Organization_ID WHERE UOM.User_ID IN (' 1 ') AND OM.Is_Active = 1 ORDER BY OM.Organization_Name
Query is returing organization_parent_id as whose organization_id is university for that particular organization.
I want to display university and college in different column as different university has different college and all are fetching from same list
usrOrgMapping . How can I display all College with respect to university.
How can I perform this operation in jsp page?
| 0debug
|
JavaScript charAt problem that I can’t seem to answer correctly : <p>Write a function called charAt which accepts a string and an index (number) and returns the character at that index.</p>
<p>The function should return an empty string if the number is greater than the length of the string.</p>
<p>Do not use the built in charAt method - the tests will fail if you do!</p>
| 0debug
|
static void *nbd_client_thread(void *arg)
{
int fd = *(int *)arg;
off_t size;
size_t blocksize;
uint32_t nbdflags;
int sock;
int ret;
pthread_t show_parts_thread;
do {
sock = unix_socket_outgoing(sockpath);
if (sock == -1) {
goto out;
}
} while (sock == -1);
ret = nbd_receive_negotiate(sock, NULL, &nbdflags,
&size, &blocksize);
if (ret == -1) {
goto out;
}
ret = nbd_init(fd, sock, nbdflags, size, blocksize);
if (ret == -1) {
goto out;
}
pthread_create(&show_parts_thread, NULL, show_parts, NULL);
if (verbose) {
fprintf(stderr, "NBD device %s is now connected to %s\n",
device, srcpath);
} else {
dup2(STDOUT_FILENO, STDERR_FILENO);
}
ret = nbd_client(fd);
if (ret) {
goto out;
}
close(fd);
kill(getpid(), SIGTERM);
return (void *) EXIT_SUCCESS;
out:
kill(getpid(), SIGTERM);
return (void *) EXIT_FAILURE;
}
| 1threat
|
Float vs Integer | Which is more efficient? : <p>Good morning,</p>
<p>I am starting to learn Python in my computer science class. Is there any benefit to using a integer over a float number? </p>
<p>Thanks.</p>
| 0debug
|
Using OpenGL, given a hypothesis of the pose of an object, how to get a list the visible vertices and segments : I work on pose estimation of a 3d objects. I am using CAD model of that object to generate all the possible hypothesis. I am using pyopengl to render the view of the object from a specific POV. Can anyone explain how to get a list of all the visible vertices?
So I use face culling to eliminate the occluded faces, but I don't know how to pass the visible vertices to other python functions
Thanks
| 0debug
|
How to get rid of Function calls are not supported in decorators in Angular aot compiling? : <p>I am testing a <a href="https://www.highcharts.com/" rel="noreferrer">Highcharts</a> Angular2x <a href="https://github.com/gevgeny/angular2-highcharts" rel="noreferrer">Wrapper</a>. At first, I had no problem using Angular CLI (1.6.1) "ng serve" and profiling performance with Chrome. Then, i tried to use ahead-of-time compiling to see how that affects the performance.</p>
<p>So, using:</p>
<pre><code>ng serve --aot
</code></pre>
<p>I get the following error:</p>
<pre><code>ERROR in Error during template compile of 'AppModule'
Function calls are not supported in decorators but 'ChartModule' was called.
</code></pre>
<p>Now, i know that aot generates factory code for modules and somehow "transformes" templates to VanillaJS, things get a bit tricky here and i couldn't understand how ngc is going to generate factory code for a module that requires an external library.</p>
<p>I got this App.Module.ts:</p>
<pre><code>import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { ChartModule } from 'angular2-highcharts';
import { AppComponent } from './app.component';
declare var require: any;
export function getHighchartsModule() {
return require('highcharts');
}
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
ChartModule.forRoot(getHighchartsModule) // This causes the error
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
</code></pre>
<p>My Package.json dependencies : </p>
<pre><code>"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"angular2-highcharts": "^0.5.5",
"core-js": "^2.4.1",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
}
</code></pre>
<p>My questions are :
Is there anything i can do here to avoid the mentioned compiling error ?
Can anyone explain why does this happen ? (optional)</p>
| 0debug
|
Apply CSS upon query string - My code does not work, but why? : <p>I have a popup message "Your invitation has been sent" on this page: <a href="https://idio.ai/thank-you-webinar-testing-ground/?referralsent=true" rel="nofollow noreferrer">https://idio.ai/thank-you-webinar-testing-ground/?referralsent=true</a></p>
<p>What I'd like to achieve to only show this message when the URL has this query string on it</p>
<blockquote>
<p>?referralsent=true</p>
</blockquote>
<p>On the class ".message" there is a <strong>display: none</strong> by default which needs to be changed to <strong>display: block</strong> in case the query string is there.</p>
<p>Here is my script so far but it does not work and I can't figure out why.</p>
<pre><code>function getParameterByName(referralsent, url) {
if (!url) url = window.location.href;
referralsent = referralsent.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + referralsent + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
if (getParameterByName('referralsent')) {
var referralsent = getParameterByName('referralsent');
// replace only if available
jQuery('message').css('display', 'block');
}
</code></pre>
<p>What is wrong here why is it not showing? Any ideas?</p>
| 0debug
|
Python - What is the process to create pdf reports with charts from a DB? : <p>I have a database generated by a survey to evaluate university professors. What I want is a python script that takes the information from that database, generates a graphing table for each user, creates graphs for each user, and then renders it in a template to export it to a pdf.</p>
<p><strong>What does the database look like?</strong></p>
<pre><code>User Professor_evaluated Category Question Answer
_________________________________________________________________
Mike Professor Criss respect 1 3
Mike Professor Criss respect 2 4
Mike Professor Criss wisdom 3 5
Mike Professor Criss wisdom 4 3
Charles Professor Criss respect 1 3
Charles Professor Criss respect 2 4
Charles Professor Criss wisdom 3 5
Charles Professor Criss wisdom 4 3
</code></pre>
<p>Each teacher has several categories assigned to be evaluated (respect, wisdom, etc.) and in turn each category has associated questions. In other words, a category has several questions. Each row of the DB is the answer to a question from a student evaluating a teacher</p>
<p><strong>What do I need?</strong></p>
<p>I need to create a script for automatically generate pdf reports that summarizes this information through charts, for example a chart with the overall score of each teacher, another chart with the score of each teacher by category, another chart with the average of each student, etc..Finally, every teacher would have a report.I want a report like this<a href="https://i.stack.imgur.com/Vi8Yp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Vi8Yp.png" alt="Example"></a></p>
<p><strong>What is my question?</strong></p>
<p>my question is about which python packages and modules I would need to do this task. And what would be the general process of doing so. I don't need the code, because I know the answer is very general, but the knowledge of how I could do it.</p>
<p><em>For example: you would first need to process the information with pandas, to create a table that summarizes the information you want to graph, then plot it, then create a template of your report with XYZ module and then export it to pdf with XYZ module.</em></p>
| 0debug
|
Install Cuda without root : <p>I know that I can install Cuda with the following:</p>
<pre>
wget http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run
chmod +x cuda_7.0.28_linux.run
./cuda_7.0.28_linux.run -extract=`pwd`/nvidia_installers
cd nvidia_installers
sudo ./NVIDIA-Linux-x86_64-346.46.run
sudo modprobe nvidia
sudo ./cuda-linux64-rel-7.0.28-19326674.run
</pre>
<p>Just wondering if I can install Cuda without root?</p>
<p>Thanks,</p>
| 0debug
|
What is squeeze testing? : <p>In the talk "<a href="http://www.infoq.com/presentations/netflix-operations-devops" rel="noreferrer">Beyond DevOps: How Netflix Bridges the Gap</a>," around 29:10 Josh Evans mentions squeeze testing as something that can help them understand system drift. What is squeeze testing and how is it implemented?</p>
| 0debug
|
How can set the default spark logging level? : <p>I launch pyspark applications from pycharm on my own workstation, to a 8 node cluster. This cluster also has settings encoded in spark-defaults.conf and spark-env.sh </p>
<p>This is how I obtain my spark context variable.</p>
<pre><code>spark = SparkSession \
.builder \
.master("spark://stcpgrnlp06p.options-it.com:7087") \
.appName(__SPARK_APP_NAME__) \
.config("spark.executor.memory", "50g") \
.config("spark.eventlog.enabled", "true") \
.config("spark.eventlog.dir", r"/net/share/grid/bin/spark/UAT/SparkLogs/") \
.config("spark.cores.max", 128) \
.config("spark.sql.crossJoin.enabled", "True") \
.config("spark.executor.extraLibraryPath","/net/share/grid/bin/spark/UAT/bin/vertica-jdbc-8.0.0-0.jar") \
.config("spark.serializer", "org.apache.spark.serializer.KryoSerializer") \
.config("spark.logConf", "true") \
.getOrCreate()
sc = spark.sparkContext
sc.setLogLevel("INFO")
</code></pre>
<p>I want to see the effective config that is being used in my log. This line</p>
<pre><code> .config("spark.logConf", "true") \
</code></pre>
<p>should cause the spark api to log its effective config to the log as INFO, but the default log level is set to WARN, and as such I don't see any messages. </p>
<p>setting this line </p>
<pre><code>sc.setLogLevel("INFO")
</code></pre>
<p>shows INFO messages going forward, but its too late by then.</p>
<p>How can I set the default logging level that spark starts with?</p>
| 0debug
|
Java Equivalent of c# this.GetType().Namespace : <p>Which is the java equivalent of c# </p>
<p><code>this.GetType().Namespace</code> </p>
<p>to get the package name in which the class is contained?</p>
| 0debug
|
float128 float128_scalbn( float128 a, int n STATUS_PARAM )
{
flag aSign;
int32 aExp;
uint64_t aSig0, aSig1;
aSig1 = extractFloat128Frac1( a );
aSig0 = extractFloat128Frac0( a );
aExp = extractFloat128Exp( a );
aSign = extractFloat128Sign( a );
if ( aExp == 0x7FFF ) {
return a;
}
if ( aExp != 0 )
aSig0 |= LIT64( 0x0001000000000000 );
else if ( aSig0 == 0 && aSig1 == 0 )
return a;
aExp += n - 1;
return normalizeRoundAndPackFloat128( aSign, aExp, aSig0, aSig1
STATUS_VAR );
}
| 1threat
|
def remove_empty(list1):
remove_empty = [x for x in list1 if x]
return remove_empty
| 0debug
|
How can i Modify the following JSON object structure using javascript or Jquery? : I have Json Object Like Following.
var jsonObj = [{'Id':'1','Username':'Ray','FatherName':'Thompson'},
{'Id':'2','Username':'Steve','FatherName':'Johnson'},
{'Id':'3','Username':'Albert','FatherName':'Einstein'}]
But i want to convert this json format to following.
var jsonObj = [['Id':'1','Username':'Ray','FatherName':'Thompson'],
['Id':'2','Username':'Steve','FatherName':'Johnson'],
['Id':'3','Username':'Albert','FatherName':'Einstein']]
how can i do it using Jquary or javascript please Help.
| 0debug
|
I used the set location relative method to set the jframe to the center still appearing to the up left of the screen here is the code : enter code here
`
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
new megui().setVisible(true);
new megui().setLocationRelativeTo(null);
} catch (Exception e) {
e.printStackTrace();
}`enter code here`
}
});
}
| 0debug
|
How to reverse a string using python using for loop? Ex- "Hello World" to "world hello" : How to reverse a string in python using for loop?
EX- "HELLO WORLD" to "WORLD HELLO"
str="HELLO WORLD"
| 0debug
|
How to get parent's data when its own data is null? : <p>I've a list like this:</p>
<pre><code>+ID+--+ParentID+--+Name+--+Code
+1-----NULL--------A-------Aa
+2-----NULL--------B-------Bb
+3-----2-----------B1------NULL
+4-----2-----------B2------NULL
+5-----1-----------A2------NULL
</code></pre>
<p>I get 'Code' values to another list by a linq query.</p>
<pre><code>var newList = new List<string>();
list.ForEach(x=>newList.Add(x.Code))
</code></pre>
<p>However, if the <strong>Code</strong> is null or empty, I want to get its parent's 'Code'. So, my new list should contains</p>
<pre><code>+Aa
+Bb
+Bb
+Bb
+Aa
</code></pre>
<p>How can I do this with linq?</p>
| 0debug
|
Do view creat new rows and store data on every request? : I just wanna know do view create rows (with existing view query) every time data was requested or it just stores existing data on it and keep updating with new changes? (mysql).
| 0debug
|
static void gem_write(void *opaque, hwaddr offset, uint64_t val,
unsigned size)
{
GemState *s = (GemState *)opaque;
uint32_t readonly;
DB_PRINT("offset: 0x%04x write: 0x%08x ", (unsigned)offset, (unsigned)val);
offset >>= 2;
val &= ~(s->regs_ro[offset]);
readonly = s->regs[offset] & (s->regs_ro[offset] | s->regs_w1c[offset]);
s->regs[offset] = (val & ~s->regs_w1c[offset]) | readonly;
s->regs[offset] &= ~(s->regs_w1c[offset] & val);
switch (offset) {
case GEM_NWCTRL:
if (val & GEM_NWCTRL_RXENA) {
gem_get_rx_desc(s);
}
if (val & GEM_NWCTRL_TXSTART) {
gem_transmit(s);
}
if (!(val & GEM_NWCTRL_TXENA)) {
s->tx_desc_addr = s->regs[GEM_TXQBASE];
}
if (val & GEM_NWCTRL_RXENA) {
qemu_flush_queued_packets(qemu_get_queue(s->nic));
}
break;
case GEM_TXSTATUS:
gem_update_int_status(s);
break;
case GEM_RXQBASE:
s->rx_desc_addr = val;
break;
case GEM_TXQBASE:
s->tx_desc_addr = val;
break;
case GEM_RXSTATUS:
gem_update_int_status(s);
break;
case GEM_IER:
s->regs[GEM_IMR] &= ~val;
gem_update_int_status(s);
break;
case GEM_IDR:
s->regs[GEM_IMR] |= val;
gem_update_int_status(s);
break;
case GEM_SPADDR1LO:
case GEM_SPADDR2LO:
case GEM_SPADDR3LO:
case GEM_SPADDR4LO:
s->sar_active[(offset - GEM_SPADDR1LO) / 2] = false;
break;
case GEM_SPADDR1HI:
case GEM_SPADDR2HI:
case GEM_SPADDR3HI:
case GEM_SPADDR4HI:
s->sar_active[(offset - GEM_SPADDR1HI) / 2] = true;
break;
case GEM_PHYMNTNC:
if (val & GEM_PHYMNTNC_OP_W) {
uint32_t phy_addr, reg_num;
phy_addr = (val & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;
if (phy_addr == BOARD_PHY_ADDRESS) {
reg_num = (val & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;
gem_phy_write(s, reg_num, val);
}
}
break;
}
DB_PRINT("newval: 0x%08x\n", s->regs[offset]);
}
| 1threat
|
JavaScript onChange not working using DOM element : <p>I got a problem when trying to make onchange listener for input in JavaScript:</p>
<pre><code>var apple = document.getElementById("apple");
apple.addEventListener("change", validate("apple"));
function validate(fruitName){
var qty = parseInt(document.getElementById(fruitName).value);
console.log(qty);
}
</code></pre>
<p>I am trying to check everytime when the user input something for 'apple' input, I will print the quantity at console. But by doing this, It only ran the first time when I refreshed the browser by printing out a NaN and does not work even when I changed the input for 'apple'.</p>
<p>Any ideas?</p>
<p>Thanks in advance.</p>
| 0debug
|
size_t av_cpu_max_align(void)
{
int flags = av_get_cpu_flags();
if (flags & AV_CPU_FLAG_AVX)
return 32;
if (flags & (AV_CPU_FLAG_ALTIVEC | AV_CPU_FLAG_SSE | AV_CPU_FLAG_NEON))
return 16;
return 8;
}
| 1threat
|
static TCGArg do_constant_folding(int op, TCGArg x, TCGArg y)
{
TCGArg res = do_constant_folding_2(op, x, y);
#if TCG_TARGET_REG_BITS == 64
if (op_bits(op) == 32) {
res &= 0xffffffff;
}
#endif
return res;
}
| 1threat
|
static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov)
{
int max_track_id = 1, i;
int64_t max_track_len_temp, max_track_len = 0;
int version;
for (i = 0; i < mov->nb_streams; i++) {
if (mov->tracks[i].entry > 0) {
max_track_len_temp = av_rescale_rnd(mov->tracks[i].track_duration,
MOV_TIMESCALE,
mov->tracks[i].timescale,
AV_ROUND_UP);
if (max_track_len < max_track_len_temp)
max_track_len = max_track_len_temp;
if (max_track_id < mov->tracks[i].track_id)
max_track_id = mov->tracks[i].track_id;
}
}
version = max_track_len < UINT32_MAX ? 0 : 1;
(version == 1) ? avio_wb32(pb, 120) : avio_wb32(pb, 108);
ffio_wfourcc(pb, "mvhd");
avio_w8(pb, version);
avio_wb24(pb, 0);
if (version == 1) {
avio_wb64(pb, mov->time);
avio_wb64(pb, mov->time);
} else {
avio_wb32(pb, mov->time);
avio_wb32(pb, mov->time);
}
avio_wb32(pb, MOV_TIMESCALE);
(version == 1) ? avio_wb64(pb, max_track_len) : avio_wb32(pb, max_track_len);
avio_wb32(pb, 0x00010000);
avio_wb16(pb, 0x0100);
avio_wb16(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 0x00010000);
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x00010000);
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x40000000);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, 0);
avio_wb32(pb, max_track_id + 1);
return 0x6c;
}
| 1threat
|
how to code to get current location name based on longitude and latitude in javascript? : i m using this code to get the current location of the user through google maps api and i am getting the location in the form of latitude and longitudes and getting the location in LatLng variable. But after that when i am converting the latitude and longitude to an address then its not working . Kindly help....
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(function (p)
{
var LatLng = new google.maps.LatLng(p.coords.latitude,p.coords.longitude);
alert(LatLng);
alert(p.coords.latitude);
alert(p.coords.longitude);
var mapOptions = {
center: LatLng,
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'LatLng': LatLng }, function (results, status)
{
alert(geocoder);
if (status == google.maps.GeocoderStatus.OK)
{
if (results[1])
{
alert("Location: " + results[1].formatted_address);
}
}
});
| 0debug
|
static void do_video_out(AVFormatContext *s,
AVOutputStream *ost,
AVInputStream *ist,
AVFrame *in_picture,
int *frame_size, AVOutputStream *audio_sync)
{
int nb_frames, i, ret;
AVFrame *final_picture, *formatted_picture;
AVFrame picture_format_temp, picture_crop_temp;
static uint8_t *video_buffer= NULL;
uint8_t *buf = NULL, *buf1 = NULL;
AVCodecContext *enc, *dec;
enum PixelFormat target_pixfmt;
#define VIDEO_BUFFER_SIZE (1024*1024)
avcodec_get_frame_defaults(&picture_format_temp);
avcodec_get_frame_defaults(&picture_crop_temp);
enc = &ost->st->codec;
dec = &ist->st->codec;
nb_frames = 1;
*frame_size = 0;
if(sync_method){
double vdelta;
vdelta = ost->sync_ipts * enc->frame_rate / enc->frame_rate_base - ost->sync_opts;
if (vdelta < -1.1)
nb_frames = 0;
else if (vdelta > 1.1)
nb_frames = 2;
}
ost->sync_opts+= nb_frames;
if (nb_frames <= 0)
return;
if (!video_buffer)
video_buffer = av_malloc(VIDEO_BUFFER_SIZE);
if (!video_buffer)
return;
target_pixfmt = ost->video_resample || ost->video_pad
? PIX_FMT_YUV420P : enc->pix_fmt;
if (dec->pix_fmt != target_pixfmt) {
int size;
size = avpicture_get_size(target_pixfmt, dec->width, dec->height);
buf = av_malloc(size);
if (!buf)
return;
formatted_picture = &picture_format_temp;
avpicture_fill((AVPicture*)formatted_picture, buf, target_pixfmt, dec->width, dec->height);
if (img_convert((AVPicture*)formatted_picture, target_pixfmt,
(AVPicture *)in_picture, dec->pix_fmt,
dec->width, dec->height) < 0) {
if (verbose >= 0)
fprintf(stderr, "pixel format conversion not handled\n");
goto the_end;
}
} else {
formatted_picture = in_picture;
}
if (ost->video_resample) {
final_picture = &ost->pict_tmp;
img_resample(ost->img_resample_ctx, (AVPicture*)final_picture, (AVPicture*)formatted_picture);
if (ost->padtop || ost->padbottom || ost->padleft || ost->padright) {
fill_pad_region((AVPicture*)final_picture, enc->height, enc->width,
ost->padtop, ost->padbottom, ost->padleft, ost->padright,
padcolor);
}
if (enc->pix_fmt != PIX_FMT_YUV420P) {
int size;
av_free(buf);
size = avpicture_get_size(enc->pix_fmt, enc->width, enc->height);
buf = av_malloc(size);
if (!buf)
return;
final_picture = &picture_format_temp;
avpicture_fill((AVPicture*)final_picture, buf, enc->pix_fmt, enc->width, enc->height);
if (img_convert((AVPicture*)final_picture, enc->pix_fmt,
(AVPicture*)&ost->pict_tmp, PIX_FMT_YUV420P,
enc->width, enc->height) < 0) {
if (verbose >= 0)
fprintf(stderr, "pixel format conversion not handled\n");
goto the_end;
}
}
} else if (ost->video_crop) {
picture_crop_temp.data[0] = formatted_picture->data[0] +
(ost->topBand * formatted_picture->linesize[0]) + ost->leftBand;
picture_crop_temp.data[1] = formatted_picture->data[1] +
((ost->topBand >> 1) * formatted_picture->linesize[1]) +
(ost->leftBand >> 1);
picture_crop_temp.data[2] = formatted_picture->data[2] +
((ost->topBand >> 1) * formatted_picture->linesize[2]) +
(ost->leftBand >> 1);
picture_crop_temp.linesize[0] = formatted_picture->linesize[0];
picture_crop_temp.linesize[1] = formatted_picture->linesize[1];
picture_crop_temp.linesize[2] = formatted_picture->linesize[2];
final_picture = &picture_crop_temp;
} else if (ost->video_pad) {
final_picture = &ost->pict_tmp;
for (i = 0; i < 3; i++) {
uint8_t *optr, *iptr;
int shift = (i == 0) ? 0 : 1;
int y, yheight;
optr = final_picture->data[i] + (((final_picture->linesize[i] *
ost->padtop) + ost->padleft) >> shift);
iptr = formatted_picture->data[i];
yheight = (enc->height - ost->padtop - ost->padbottom) >> shift;
for (y = 0; y < yheight; y++) {
memcpy(optr, iptr, formatted_picture->linesize[i]);
optr += final_picture->linesize[i];
iptr += formatted_picture->linesize[i];
}
}
fill_pad_region((AVPicture*)final_picture, enc->height, enc->width,
ost->padtop, ost->padbottom, ost->padleft, ost->padright,
padcolor);
if (enc->pix_fmt != PIX_FMT_YUV420P) {
int size;
av_free(buf);
size = avpicture_get_size(enc->pix_fmt, enc->width, enc->height);
buf = av_malloc(size);
if (!buf)
return;
final_picture = &picture_format_temp;
avpicture_fill((AVPicture*)final_picture, buf, enc->pix_fmt, enc->width, enc->height);
if (img_convert((AVPicture*)final_picture, enc->pix_fmt,
(AVPicture*)&ost->pict_tmp, PIX_FMT_YUV420P,
enc->width, enc->height) < 0) {
if (verbose >= 0)
fprintf(stderr, "pixel format conversion not handled\n");
goto the_end;
}
}
} else {
final_picture = formatted_picture;
}
for(i=0;i<nb_frames;i++) {
AVPacket pkt;
av_init_packet(&pkt);
pkt.stream_index= ost->index;
if (s->oformat->flags & AVFMT_RAWPICTURE) {
AVFrame* old_frame = enc->coded_frame;
enc->coded_frame = dec->coded_frame;
pkt.data= (uint8_t *)final_picture;
pkt.size= sizeof(AVPicture);
if(dec->coded_frame)
pkt.pts= dec->coded_frame->pts;
if(dec->coded_frame && dec->coded_frame->key_frame)
pkt.flags |= PKT_FLAG_KEY;
av_write_frame(s, &pkt);
enc->coded_frame = old_frame;
} else {
AVFrame big_picture;
big_picture= *final_picture;
big_picture.interlaced_frame = in_picture->interlaced_frame;
if(do_interlace_me || do_interlace_dct){
if(top_field_first == -1)
big_picture.top_field_first = in_picture->top_field_first;
else
big_picture.top_field_first = 1;
}
if (same_quality) {
big_picture.quality = ist->st->quality;
}else
big_picture.quality = ost->st->quality;
if(!me_threshold)
big_picture.pict_type = 0;
big_picture.pts = AV_NOPTS_VALUE;
ret = avcodec_encode_video(enc,
video_buffer, VIDEO_BUFFER_SIZE,
&big_picture);
if(ret){
pkt.data= video_buffer;
pkt.size= ret;
if(enc->coded_frame)
pkt.pts= enc->coded_frame->pts;
if(enc->coded_frame && enc->coded_frame->key_frame)
pkt.flags |= PKT_FLAG_KEY;
av_write_frame(s, &pkt);
*frame_size = ret;
if (ost->logfile && enc->stats_out) {
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->frame_number++;
}
the_end:
av_free(buf);
av_free(buf1);
}
| 1threat
|
PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin)
{
PCIBus *bus;
do {
bus = dev->bus;
pin = bus->map_irq(dev, pin);
dev = bus->parent_dev;
} while (dev);
assert(bus->route_intx_to_irq);
return bus->route_intx_to_irq(bus->irq_opaque, pin);
}
| 1threat
|
DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
{
const char *value;
DriveInfo *dinfo = NULL;
QDict *bs_opts;
QemuOpts *legacy_opts;
DriveMediaType media = MEDIA_DISK;
BlockInterfaceType type;
int cyls, heads, secs, translation;
int max_devs, bus_id, unit_id, index;
const char *devaddr;
bool read_only = false;
bool copy_on_read;
const char *filename;
Error *local_err = NULL;
qemu_opt_rename(all_opts, "iops", "throttling.iops-total");
qemu_opt_rename(all_opts, "iops_rd", "throttling.iops-read");
qemu_opt_rename(all_opts, "iops_wr", "throttling.iops-write");
qemu_opt_rename(all_opts, "bps", "throttling.bps-total");
qemu_opt_rename(all_opts, "bps_rd", "throttling.bps-read");
qemu_opt_rename(all_opts, "bps_wr", "throttling.bps-write");
qemu_opt_rename(all_opts, "iops_max", "throttling.iops-total-max");
qemu_opt_rename(all_opts, "iops_rd_max", "throttling.iops-read-max");
qemu_opt_rename(all_opts, "iops_wr_max", "throttling.iops-write-max");
qemu_opt_rename(all_opts, "bps_max", "throttling.bps-total-max");
qemu_opt_rename(all_opts, "bps_rd_max", "throttling.bps-read-max");
qemu_opt_rename(all_opts, "bps_wr_max", "throttling.bps-write-max");
qemu_opt_rename(all_opts,
"iops_size", "throttling.iops-size");
qemu_opt_rename(all_opts, "readonly", "read-only");
value = qemu_opt_get(all_opts, "cache");
if (value) {
int flags = 0;
if (bdrv_parse_cache_flags(value, &flags) != 0) {
error_report("invalid cache option");
return NULL;
}
if (!qemu_opt_get(all_opts, "cache.writeback")) {
qemu_opt_set_bool(all_opts, "cache.writeback",
!!(flags & BDRV_O_CACHE_WB));
}
if (!qemu_opt_get(all_opts, "cache.direct")) {
qemu_opt_set_bool(all_opts, "cache.direct",
!!(flags & BDRV_O_NOCACHE));
}
if (!qemu_opt_get(all_opts, "cache.no-flush")) {
qemu_opt_set_bool(all_opts, "cache.no-flush",
!!(flags & BDRV_O_NO_FLUSH));
}
qemu_opt_unset(all_opts, "cache");
}
bs_opts = qdict_new();
qemu_opts_to_qdict(all_opts, bs_opts);
legacy_opts = qemu_opts_create(&qemu_legacy_drive_opts, NULL, 0,
&error_abort);
qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err);
if (error_is_set(&local_err)) {
qerror_report_err(local_err);
error_free(local_err);
goto fail;
}
if (qemu_opt_get(legacy_opts, "boot") != NULL) {
fprintf(stderr, "qemu-kvm: boot=on|off is deprecated and will be "
"ignored. Future versions will reject this parameter. Please "
"update your scripts.\n");
}
value = qemu_opt_get(legacy_opts, "media");
if (value) {
if (!strcmp(value, "disk")) {
media = MEDIA_DISK;
} else if (!strcmp(value, "cdrom")) {
media = MEDIA_CDROM;
read_only = true;
} else {
error_report("'%s' invalid media", value);
goto fail;
}
}
read_only |= qemu_opt_get_bool(legacy_opts, "read-only", false);
copy_on_read = qemu_opt_get_bool(legacy_opts, "copy-on-read", false);
if (read_only && copy_on_read) {
error_report("warning: disabling copy-on-read on read-only drive");
copy_on_read = false;
}
qdict_put(bs_opts, "read-only",
qstring_from_str(read_only ? "on" : "off"));
qdict_put(bs_opts, "copy-on-read",
qstring_from_str(copy_on_read ? "on" :"off"));
value = qemu_opt_get(legacy_opts, "if");
if (value) {
for (type = 0;
type < IF_COUNT && strcmp(value, if_name[type]);
type++) {
}
if (type == IF_COUNT) {
error_report("unsupported bus type '%s'", value);
goto fail;
}
} else {
type = block_default_type;
}
cyls = qemu_opt_get_number(legacy_opts, "cyls", 0);
heads = qemu_opt_get_number(legacy_opts, "heads", 0);
secs = qemu_opt_get_number(legacy_opts, "secs", 0);
if (cyls || heads || secs) {
if (cyls < 1) {
error_report("invalid physical cyls number");
goto fail;
}
if (heads < 1) {
error_report("invalid physical heads number");
goto fail;
}
if (secs < 1) {
error_report("invalid physical secs number");
goto fail;
}
}
translation = BIOS_ATA_TRANSLATION_AUTO;
value = qemu_opt_get(legacy_opts, "trans");
if (value != NULL) {
if (!cyls) {
error_report("'%s' trans must be used with cyls, heads and secs",
value);
goto fail;
}
if (!strcmp(value, "none")) {
translation = BIOS_ATA_TRANSLATION_NONE;
} else if (!strcmp(value, "lba")) {
translation = BIOS_ATA_TRANSLATION_LBA;
} else if (!strcmp(value, "auto")) {
translation = BIOS_ATA_TRANSLATION_AUTO;
} else {
error_report("'%s' invalid translation type", value);
goto fail;
}
}
if (media == MEDIA_CDROM) {
if (cyls || secs || heads) {
error_report("CHS can't be set with media=cdrom");
goto fail;
}
}
bus_id = qemu_opt_get_number(legacy_opts, "bus", 0);
unit_id = qemu_opt_get_number(legacy_opts, "unit", -1);
index = qemu_opt_get_number(legacy_opts, "index", -1);
max_devs = if_max_devs[type];
if (index != -1) {
if (bus_id != 0 || unit_id != -1) {
error_report("index cannot be used with bus and unit");
goto fail;
}
bus_id = drive_index_to_bus_id(type, index);
unit_id = drive_index_to_unit_id(type, index);
}
if (unit_id == -1) {
unit_id = 0;
while (drive_get(type, bus_id, unit_id) != NULL) {
unit_id++;
if (max_devs && unit_id >= max_devs) {
unit_id -= max_devs;
bus_id++;
}
}
}
if (max_devs && unit_id >= max_devs) {
error_report("unit %d too big (max is %d)", unit_id, max_devs - 1);
goto fail;
}
if (drive_get(type, bus_id, unit_id) != NULL) {
error_report("drive with bus=%d, unit=%d (index=%d) exists",
bus_id, unit_id, index);
goto fail;
}
if (qemu_opts_id(all_opts) == NULL) {
char *new_id;
const char *mediastr = "";
if (type == IF_IDE || type == IF_SCSI) {
mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd";
}
if (max_devs) {
new_id = g_strdup_printf("%s%i%s%i", if_name[type], bus_id,
mediastr, unit_id);
} else {
new_id = g_strdup_printf("%s%s%i", if_name[type],
mediastr, unit_id);
}
qdict_put(bs_opts, "id", qstring_from_str(new_id));
g_free(new_id);
}
devaddr = qemu_opt_get(legacy_opts, "addr");
if (devaddr && type != IF_VIRTIO) {
error_report("addr is not supported by this bus type");
goto fail;
}
if (type == IF_VIRTIO) {
QemuOpts *devopts;
devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
&error_abort);
if (arch_type == QEMU_ARCH_S390X) {
qemu_opt_set(devopts, "driver", "virtio-blk-s390");
} else {
qemu_opt_set(devopts, "driver", "virtio-blk-pci");
}
qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"));
if (devaddr) {
qemu_opt_set(devopts, "addr", devaddr);
}
}
filename = qemu_opt_get(legacy_opts, "file");
dinfo = blockdev_init(filename, bs_opts, type, &local_err);
if (dinfo == NULL) {
if (error_is_set(&local_err)) {
qerror_report_err(local_err);
error_free(local_err);
}
goto fail;
} else {
assert(!error_is_set(&local_err));
}
dinfo->enable_auto_del = true;
dinfo->opts = all_opts;
dinfo->cyls = cyls;
dinfo->heads = heads;
dinfo->secs = secs;
dinfo->trans = translation;
dinfo->bus = bus_id;
dinfo->unit = unit_id;
dinfo->devaddr = devaddr;
switch(type) {
case IF_IDE:
case IF_SCSI:
case IF_XEN:
case IF_NONE:
dinfo->media_cd = media == MEDIA_CDROM;
break;
default:
break;
}
fail:
qemu_opts_del(legacy_opts);
return dinfo;
}
| 1threat
|
static void change_qscale(MpegEncContext * s, int dquant)
{
s->qscale += dquant;
if (s->qscale < 1)
s->qscale = 1;
else if (s->qscale > 31)
s->qscale = 31;
s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
s->c_dc_scale= s->c_dc_scale_table[ s->qscale ];
}
| 1threat
|
static int xan_huffman_decode(unsigned char *dest, const unsigned char *src,
int dest_len)
{
unsigned char byte = *src++;
unsigned char ival = byte + 0x16;
const unsigned char * ptr = src + byte*2;
unsigned char val = ival;
unsigned char *dest_end = dest + dest_len;
GetBitContext gb;
init_get_bits(&gb, ptr, 0);
while ( val != 0x16 ) {
val = src[val - 0x17 + get_bits1(&gb) * byte];
if ( val < 0x16 ) {
if (dest + 1 > dest_end)
return 0;
*dest++ = val;
val = ival;
}
}
return 0;
}
| 1threat
|
PHP variable inside a javascript "text change onclick" : Hi I have this javascript code inside a PHP echo
function change_text()
{
if(document.getElementById(\"toggle_button\").innerHTML==\"Ver respuesta\")
{
document.getElementById(\"toggle_button\").innerHTML=\"$PHP_VARIABLE\";
}
else
{
document.getElementById(\"toggle_button\").innerHTML=\"Ver respuesta\";
}
}
I need to insert the text of $PHP_VARIABLE at $PHP_VARIABLE, but it is not working...
I think this will work with this javascript code who obtain the variable, but I don't know how to insert this in the code.
var php_var = "<?php echo $php_var; ?>";
| 0debug
|
static void decode_32Bit_opc(CPUTriCoreState *env, DisasContext *ctx)
{
int op1;
int32_t r1, r2, r3;
int32_t address, const16;
int8_t b, const4;
int32_t bpos;
TCGv temp, temp2, temp3;
op1 = MASK_OP_MAJOR(ctx->opcode);
if (unlikely((op1 & 0x3f) == OPCM_32_BRN_JTT)) {
op1 = OPCM_32_BRN_JTT;
}
switch (op1) {
case OPCM_32_ABS_LDW:
decode_abs_ldw(env, ctx);
break;
case OPCM_32_ABS_LDB:
decode_abs_ldb(env, ctx);
break;
case OPCM_32_ABS_LDMST_SWAP:
decode_abs_ldst_swap(env, ctx);
break;
case OPCM_32_ABS_LDST_CONTEXT:
decode_abs_ldst_context(env, ctx);
break;
case OPCM_32_ABS_STORE:
decode_abs_store(env, ctx);
break;
case OPCM_32_ABS_STOREB_H:
decode_abs_storeb_h(env, ctx);
break;
case OPC1_32_ABS_STOREQ:
address = MASK_OP_ABS_OFF18(ctx->opcode);
r1 = MASK_OP_ABS_S1D(ctx->opcode);
temp = tcg_const_i32(EA_ABS_FORMAT(address));
temp2 = tcg_temp_new();
tcg_gen_shri_tl(temp2, cpu_gpr_d[r1], 16);
tcg_gen_qemu_st_tl(temp2, temp, ctx->mem_idx, MO_LEUW);
tcg_temp_free(temp2);
tcg_temp_free(temp);
break;
case OPC1_32_ABS_LD_Q:
address = MASK_OP_ABS_OFF18(ctx->opcode);
r1 = MASK_OP_ABS_S1D(ctx->opcode);
temp = tcg_const_i32(EA_ABS_FORMAT(address));
tcg_gen_qemu_ld_tl(cpu_gpr_d[r1], temp, ctx->mem_idx, MO_LEUW);
tcg_gen_shli_tl(cpu_gpr_d[r1], cpu_gpr_d[r1], 16);
tcg_temp_free(temp);
break;
case OPC1_32_ABS_LEA:
address = MASK_OP_ABS_OFF18(ctx->opcode);
r1 = MASK_OP_ABS_S1D(ctx->opcode);
tcg_gen_movi_tl(cpu_gpr_a[r1], EA_ABS_FORMAT(address));
break;
case OPC1_32_ABSB_ST_T:
address = MASK_OP_ABS_OFF18(ctx->opcode);
b = MASK_OP_ABSB_B(ctx->opcode);
bpos = MASK_OP_ABSB_BPOS(ctx->opcode);
temp = tcg_const_i32(EA_ABS_FORMAT(address));
temp2 = tcg_temp_new();
tcg_gen_qemu_ld_tl(temp2, temp, ctx->mem_idx, MO_UB);
tcg_gen_andi_tl(temp2, temp2, ~(0x1u << bpos));
tcg_gen_ori_tl(temp2, temp2, (b << bpos));
tcg_gen_qemu_st_tl(temp2, temp, ctx->mem_idx, MO_UB);
tcg_temp_free(temp);
tcg_temp_free(temp2);
break;
case OPC1_32_B_CALL:
case OPC1_32_B_CALLA:
case OPC1_32_B_J:
case OPC1_32_B_JA:
case OPC1_32_B_JL:
case OPC1_32_B_JLA:
address = MASK_OP_B_DISP24(ctx->opcode);
gen_compute_branch(ctx, op1, 0, 0, 0, address);
break;
case OPCM_32_BIT_ANDACC:
decode_bit_andacc(env, ctx);
break;
case OPCM_32_BIT_LOGICAL_T1:
decode_bit_logical_t(env, ctx);
break;
case OPCM_32_BIT_INSERT:
decode_bit_insert(env, ctx);
break;
case OPCM_32_BIT_LOGICAL_T2:
decode_bit_logical_t2(env, ctx);
break;
case OPCM_32_BIT_ORAND:
decode_bit_orand(env, ctx);
break;
case OPCM_32_BIT_SH_LOGIC1:
decode_bit_sh_logic1(env, ctx);
break;
case OPCM_32_BIT_SH_LOGIC2:
decode_bit_sh_logic2(env, ctx);
break;
case OPCM_32_BO_ADDRMODE_POST_PRE_BASE:
decode_bo_addrmode_post_pre_base(env, ctx);
break;
case OPCM_32_BO_ADDRMODE_BITREVERSE_CIRCULAR:
decode_bo_addrmode_bitreverse_circular(env, ctx);
break;
case OPCM_32_BO_ADDRMODE_LD_POST_PRE_BASE:
decode_bo_addrmode_ld_post_pre_base(env, ctx);
break;
case OPCM_32_BO_ADDRMODE_LD_BITREVERSE_CIRCULAR:
decode_bo_addrmode_ld_bitreverse_circular(env, ctx);
break;
case OPCM_32_BO_ADDRMODE_STCTX_POST_PRE_BASE:
decode_bo_addrmode_stctx_post_pre_base(env, ctx);
break;
case OPCM_32_BO_ADDRMODE_LDMST_BITREVERSE_CIRCULAR:
decode_bo_addrmode_ldmst_bitreverse_circular(env, ctx);
break;
case OPC1_32_BOL_LD_A_LONGOFF:
case OPC1_32_BOL_LD_W_LONGOFF:
case OPC1_32_BOL_LEA_LONGOFF:
case OPC1_32_BOL_ST_W_LONGOFF:
case OPC1_32_BOL_ST_A_LONGOFF:
decode_bol_opc(env, ctx, op1);
break;
case OPCM_32_BRC_EQ_NEQ:
case OPCM_32_BRC_GE:
case OPCM_32_BRC_JLT:
case OPCM_32_BRC_JNE:
const4 = MASK_OP_BRC_CONST4_SEXT(ctx->opcode);
address = MASK_OP_BRC_DISP15_SEXT(ctx->opcode);
r1 = MASK_OP_BRC_S1(ctx->opcode);
gen_compute_branch(ctx, op1, r1, 0, const4, address);
break;
case OPCM_32_BRN_JTT:
address = MASK_OP_BRN_DISP15_SEXT(ctx->opcode);
r1 = MASK_OP_BRN_S1(ctx->opcode);
gen_compute_branch(ctx, op1, r1, 0, 0, address);
break;
case OPCM_32_BRR_EQ_NEQ:
case OPCM_32_BRR_ADDR_EQ_NEQ:
case OPCM_32_BRR_GE:
case OPCM_32_BRR_JLT:
case OPCM_32_BRR_JNE:
case OPCM_32_BRR_JNZ:
case OPCM_32_BRR_LOOP:
address = MASK_OP_BRR_DISP15_SEXT(ctx->opcode);
r2 = MASK_OP_BRR_S2(ctx->opcode);
r1 = MASK_OP_BRR_S1(ctx->opcode);
gen_compute_branch(ctx, op1, r1, r2, 0, address);
break;
case OPCM_32_RC_LOGICAL_SHIFT:
decode_rc_logical_shift(env, ctx);
break;
case OPCM_32_RC_ACCUMULATOR:
decode_rc_accumulator(env, ctx);
break;
case OPCM_32_RC_SERVICEROUTINE:
decode_rc_serviceroutine(env, ctx);
break;
case OPCM_32_RC_MUL:
decode_rc_mul(env, ctx);
break;
case OPCM_32_RCPW_MASK_INSERT:
decode_rcpw_insert(env, ctx);
break;
case OPC1_32_RCRR_INSERT:
r1 = MASK_OP_RCRR_S1(ctx->opcode);
r2 = MASK_OP_RCRR_S3(ctx->opcode);
r3 = MASK_OP_RCRR_D(ctx->opcode);
const16 = MASK_OP_RCRR_CONST4(ctx->opcode);
temp = tcg_const_i32(const16);
temp2 = tcg_temp_new();
temp3 = tcg_temp_new();
tcg_gen_andi_tl(temp2, cpu_gpr_d[r3+1], 0x1f);
tcg_gen_andi_tl(temp3, cpu_gpr_d[r3], 0x1f);
gen_insert(cpu_gpr_d[r2], cpu_gpr_d[r1], temp, temp2, temp3);
tcg_temp_free(temp);
tcg_temp_free(temp2);
tcg_temp_free(temp3);
break;
case OPCM_32_RCRW_MASK_INSERT:
decode_rcrw_insert(env, ctx);
break;
case OPCM_32_RCR_COND_SELECT:
decode_rcr_cond_select(env, ctx);
break;
case OPCM_32_RCR_MADD:
decode_rcr_madd(env, ctx);
break;
case OPCM_32_RCR_MSUB:
decode_rcr_msub(env, ctx);
break;
case OPC1_32_RLC_ADDI:
case OPC1_32_RLC_ADDIH:
case OPC1_32_RLC_ADDIH_A:
case OPC1_32_RLC_MFCR:
case OPC1_32_RLC_MOV:
case OPC1_32_RLC_MOV_64:
case OPC1_32_RLC_MOV_U:
case OPC1_32_RLC_MOV_H:
case OPC1_32_RLC_MOVH_A:
case OPC1_32_RLC_MTCR:
decode_rlc_opc(env, ctx, op1);
break;
}
}
| 1threat
|
Hi I want to write a piece of code to disable drag event of notification bar in android app : <p>Hi I want to write a piece of code to disable drag event of notification bar in android app.</p>
<p>can some body help in this.</p>
| 0debug
|
document.getElementById(); returns null on an id that definitely exists : <p>Does anyone know why document.getElementById("closebtn"); returns null? I have tried console.logging it, and i just get null. I am using node.js and Electron</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="home.css" />
<script>
console.log(document.getElementById("closebtn"));</script>
</head>
<body>
<div id="menubar">
<button id="closebtn" onclick=""></button>
</div>
</body>
</html>
</code></pre>
| 0debug
|
static void block_job_completed_single(BlockJob *job)
{
if (!job->ret) {
if (job->driver->commit) {
job->driver->commit(job);
} else {
if (job->driver->abort) {
job->driver->abort(job);
if (job->cb) {
job->cb(job->opaque, job->ret);
if (block_job_is_cancelled(job)) {
block_job_event_cancelled(job);
} else {
const char *msg = NULL;
if (job->ret < 0) {
msg = strerror(-job->ret);
block_job_event_completed(job, msg);
if (job->txn) {
QLIST_REMOVE(job, txn_list);
block_job_txn_unref(job->txn);
block_job_unref(job);
| 1threat
|
how do i click all href javascript links with javascript or jquery :
I have multiple codes on my website like these below, I'm trying to make a small javascript piece of code or jquery that will automatically click all of these hrefs and do the deleteXY functions with the correct numbers.
<li><a href="javascript:deleteXY(4)">Delete</a></li>
<li><a href="javascript:deleteXY(6)">Delete</a></li>
| 0debug
|
def all_Bits_Set_In_The_Given_Range(n,l,r):
num = ((1 << r) - 1) ^ ((1 << (l - 1)) - 1)
new_num = n & num
if (num == new_num):
return True
return False
| 0debug
|
AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
enum AVFrameSideDataType type,
int size)
{
AVFrameSideData *ret, **tmp;
if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1)
return NULL;
tmp = av_realloc(frame->side_data,
(frame->nb_side_data + 1) * sizeof(*frame->side_data));
if (!tmp)
return NULL;
frame->side_data = tmp;
ret = av_mallocz(sizeof(*ret));
if (!ret)
return NULL;
if (size > 0) {
ret->buf = av_buffer_alloc(size);
if (!ret->buf) {
av_freep(&ret);
return NULL;
}
ret->data = ret->buf->data;
ret->size = size;
}
ret->type = type;
frame->side_data[frame->nb_side_data++] = ret;
return ret;
}
| 1threat
|
Get the percentage of a number with javascript : <p>So I am creating a web app and I get some data.</p>
<p>There are points you have now (now=284), and total points (total=1000). So, The difference between them is dif=716.</p>
<p>How do I use javascript to turn the difference in to a percentage value , for example 32% or whatever?</p>
<p>Thanks</p>
| 0debug
|
Can anyone see a mistake in this code? : <p>I'm trying to make some plots of distributions in R and i have the code but it just won't run, it says there's an unexpected symbol. </p>
<pre><code>curve(dexp(x, rate=3) xlim=c(0,40), main="exp(rate=3) population
distribution", xlab="X", ylab="f(x)")
</code></pre>
<p>Im trying to plot an exponential random variable with rate 3.</p>
| 0debug
|
static int interleave_new_audio_packet(AVFormatContext *s, AVPacket *pkt,
int stream_index, int flush)
{
AVStream *st = s->streams[stream_index];
AudioInterleaveContext *aic = st->priv_data;
int size = FFMIN(av_fifo_size(aic->fifo), *aic->samples * aic->sample_size);
if (!size || (!flush && size == av_fifo_size(aic->fifo)))
return 0;
av_new_packet(pkt, size);
av_fifo_generic_read(aic->fifo, pkt->data, size, NULL);
pkt->dts = pkt->pts = aic->dts;
pkt->duration = av_rescale_q(*aic->samples, st->time_base, aic->time_base);
pkt->stream_index = stream_index;
aic->dts += pkt->duration;
aic->samples++;
if (!*aic->samples)
aic->samples = aic->samples_per_frame;
return size;
}
| 1threat
|
why and when construct to copy object? : i am new to programming c# i saw an example in one of textbooks that i read
this example is about abstract class explanation but i did not understand one part of the code :
// Create an abstract class.
using System;
abstract class TwoDShape {
double pri_width;
double pri_height;
// A default constructor.
public TwoDShape() {
Width = Height = 0.0;
name = "null";
}
// Parameterized constructor.
public TwoDShape(double w, double h, string n) {
Width = w;
Height = h;
name = n;
}
// Construct object with equal width and height.
public TwoDShape(double x, string n) {
Width = Height = x;
name = n;
}
// Construct a copy of a TwoDShape object.
public TwoDShape(TwoDShape ob) {
Width = ob.Width;
Height = ob.Height;
name = ob.name;
}
why and when i construct a copy of object this case??
| 0debug
|
Scipy.optimize Inequality Constraint - Which side of the inequality is considered? : <p>I am using the scipy.optimize module to find optimal input weights that would minimize my output. From the examples I've seen, we define the constraint with a one-sided equation; then we create a variable that's of the type 'inequality'. My question is how does the optimization package know whether the sum of the variables in my constraint need to be smaller than 1 or larger than 1?</p>
<p>...</p>
<pre><code>def constraint1(x):
return x[0]+x[1]+x[2]+x[3]-1
</code></pre>
<p>....</p>
<pre><code>con1 = {'type': 'ineq', 'fun': constraint1}
</code></pre>
<p>link to full solution I'm using in my example:
<a href="http://apmonitor.com/che263/index.php/Main/PythonOptimization" rel="noreferrer">http://apmonitor.com/che263/index.php/Main/PythonOptimization</a></p>
<p>Thank you.</p>
| 0debug
|
I want to run a stopwatch program in the background of my main program , and print the time at the end of th emain programe : <p>I am new to programming ,and i want to know how to run a stopwatch program in the background without displaying the time constantly and at the end i want it to print how long the user took to go through the program </p>
| 0debug
|
static void raw_reopen_commit(BDRVReopenState *state)
{
BDRVRawState *new_s = state->opaque;
BDRVRawState *s = state->bs->opaque;
memcpy(s, new_s, sizeof(BDRVRawState));
g_free(state->opaque);
state->opaque = NULL;
}
| 1threat
|
Some one can help me to fix this function code? : <p>i want to use a function for each row in a vector.</p>
<p>when I try my code I receive this message:
the condition has length > 1 and only the first element will be used</p>
<pre><code>function(Inn, x, y, z, xx, b, i, Dp){
if (Inn == 0) {
if (runif(1) <= x) { # success.probability.imitation
absorptive.capacity <- max(y, z)
}
else{
absorptive.capacity <- min(x, x + b/sqrt(i) - Dp)
}
} else{
if (runif(1) <= xx) { # sucess innovation
absorptive.capacity <- y + b / sqrt(i)
} else{
absorptive.capacity <- y + b / sqrt(i) - Dp
}
}
if (absorptive.capacity > 1) {
absorptive.capacity = 1
}
return(absorptive.capacity)
}
absorptive.capacity(c(0, 1), c(0.5, 0), c(0.7, 0.8), 0.7, c(0, 06), 0.5, c(64, 94), 0.06)
</code></pre>
<p>I want return each value after that transformation, this is the purpose for my function. Some one can help me?</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.