problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static int virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy)
{
int n, r;
if (!(proxy->flags & VIRTIO_PCI_FLAG_USE_IOEVENTFD) ||
proxy->ioeventfd_disabled ||
proxy->ioeventfd_started) {
return 0;
}
for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
if (!virtio_queue_get_num(proxy->vdev, n)) {
continue;
}
r = virtio_pci_set_host_notifier_internal(proxy, n, true);
if (r < 0) {
goto assign_error;
}
virtio_pci_set_host_notifier_fd_handler(proxy, n, true);
}
proxy->ioeventfd_started = true;
return 0;
assign_error:
while (--n >= 0) {
if (!virtio_queue_get_num(proxy->vdev, n)) {
continue;
}
virtio_pci_set_host_notifier_fd_handler(proxy, n, false);
virtio_pci_set_host_notifier_internal(proxy, n, false);
}
proxy->ioeventfd_started = false;
proxy->ioeventfd_disabled = true;
return r;
}
| 1threat |
int qcrypto_init(Error **errp G_GNUC_UNUSED)
{
return 0;
}
| 1threat |
I want to remove this image : <p>How can i remove this image:
<a href="https://i.stack.imgur.com/kBQcH.png" rel="nofollow noreferrer">Image <--</a></p>
<p>Link: <a href="http://infinitefun20.blogspot.gr" rel="nofollow noreferrer">infinitefun20.blogspot.gr</a></p>
| 0debug |
Spark Implicit $ for DataFrame : <p>Where in the <code>sqlContext.implicits._</code> does it define the $"string" to represent a dataframe call to the parent dataframe's column? Specifically I was confused on seeing something like the following:</p>
<pre><code>import sqlContext.implicits._
df.where($"type".isin("type1","type2") and $"status".isin("completed","inprogress"))
</code></pre>
| 0debug |
static bool use_exit_tb(DisasContext *s)
{
return (s->singlestep_enabled ||
(s->tb->cflags & CF_LAST_IO) ||
(s->tb->flags & FLAG_MASK_PER));
}
| 1threat |
Webpack: Unknown argument: mode / configuration has an unknown property 'mode' : <p>getting crazy with this, really missing something....</p>
<p>I have webpack 4.6.0, webpack-cli ^2.1.2, so the latest. </p>
<p>Following the docs (<a href="https://webpack.js.org/concepts/mode/" rel="noreferrer">https://webpack.js.org/concepts/mode/</a>), want to use the mode to have to configs, one for production and one for development, but I get:</p>
<p>configuration[0] has an unknown property 'mode'. These properties are valid:
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }</p>
<p>What am I missing :O????? </p>
<pre><code>module.exports = [
merge(base, {
mode: 'development',
output: {
path: path.resolve(__dirname, './public/assets/development'),
},
}),
merge(base, {
mode: 'production',
output: {
path: path.resolve(__dirname, './public/assets/production'),
filename: '[name].bundle.js',
},
}),
]
</code></pre>
| 0debug |
Why the imageView which is in "userProfilePic" id, changes quickly to the old one stored in database, after selecting a new picture : <p>I want to change the picture in the imageView id "userProfilePic" to the new one selected by the user, and update that picture to the database. But once I choose a new picture, the image under "userProfilePic" id quickly changes to the new one and again it changes to the old one( which is already in the database) so I am unable to upload new pictures for the "userProfilePic" id. I am a beginner to Android development and I know only small amount of android, So please help me to solve this issue. This is my <code>EditUserProfile.java file</code></p>
<pre><code> package com.example.kasun.timetable;
import android.app.DatePickerDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v7.app.ActionBarActivity;
import android.util.Base64;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
public class EditYourProfile extends ActionBarActivity implements View.OnClickListener {
private static final int Result_Load_Image=1;
private Button bSave2,bBack2,bImageUpload;
private EditText etUsernameEdit,etFirstNameEdit,etLastNameEdit,etPasswordEdit,etPositionEdit,etBirthDateEdit,etQualificationEdit,etEmailEdit;
private Calendar myCalendar = Calendar.getInstance();
private UserLocalDatabase userLocalDatabase;
private ImageView userProfilePic;
private static final String SERVER_ADDRESS="http://172.21.18.170/Timetable/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_your_profile);
bBack2=(Button)findViewById(R.id.bBack2);
bSave2=(Button)findViewById(R.id.bSave2);
etUsernameEdit=(EditText)findViewById(R.id.etUserNameEdit);
etFirstNameEdit=(EditText)findViewById(R.id.etFirstNameEdit);
etLastNameEdit=(EditText)findViewById(R.id.etLastNameEdit);
etPasswordEdit=(EditText)findViewById(R.id.etPasswordEdit);
etEmailEdit=(EditText)findViewById(R.id.etEmailEdit);
etQualificationEdit=(EditText)findViewById(R.id.etQualificationEdit);
etPositionEdit=(EditText)findViewById(R.id.etPositionEdit);
etBirthDateEdit=(EditText)findViewById(R.id.etBirthDateEdit);
userProfilePic=(ImageView)findViewById(R.id.userProfilePic);
bImageUpload=(Button)findViewById(R.id.bImageUpload);
bSave2.setOnClickListener(this);
bBack2.setOnClickListener(this);
userProfilePic.setOnClickListener(this);
bImageUpload.setOnClickListener(this);
userLocalDatabase = new UserLocalDatabase(this);
final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateLabel();
}
};
etBirthDateEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new DatePickerDialog(EditYourProfile.this, date, myCalendar
.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
myCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
});
}
private void updateLabel() {
String myFormat = "MM/dd/yy";
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
etBirthDateEdit.setText(sdf.format(myCalendar.getTime()));
}
@Override
protected void onStart() {
super.onStart();
if(authenticate()==true){
showDetails();
}
else {
startActivity(new Intent(this, MainActivity.class));
finish();
}
}
public boolean authenticate(){
return userLocalDatabase.getUserStatus();
}
public void showDetails(){
User user=userLocalDatabase.getLoggedInUser();
etFirstNameEdit.setText(user.firstName);
etLastNameEdit.setText(user.lastName);
etUsernameEdit.setText(user.userName);
etQualificationEdit.setText(user.qualification);
etPositionEdit.setText(user.position);
etPasswordEdit.setText(user.password);
etEmailEdit.setText(user.email);
new downloadImage(etUsernameEdit.getText().toString()).execute();
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.bSave2:
break;
case R.id.bBack2:
startActivity(new Intent(this,SelectTask.class));
break;
case R.id.userProfilePic:
Intent galleryIntent= new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent,Result_Load_Image);
break;
case R.id.bImageUpload:
Bitmap image=((BitmapDrawable) userProfilePic.getDrawable()).getBitmap();
new uploadImage(image,etUsernameEdit.getText().toString()).execute();
break;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==Result_Load_Image && resultCode==RESULT_OK && data!=null){
Uri selectedImage= data.getData();
userProfilePic.setImageURI(selectedImage);
}
}
public class uploadImage extends AsyncTask<Void,Void,Void> {
private Bitmap image;
private String name;
public uploadImage(Bitmap image,String name){
this.image=image;
this.name=name;
}
@Override
protected Void doInBackground(Void... params) {
ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG,100,byteArrayOutputStream);
String encodedImage= Base64.encodeToString(byteArrayOutputStream.toByteArray(),Base64.DEFAULT);
ArrayList<NameValuePair> dataToSend1= new ArrayList<>();
dataToSend1.add(new BasicNameValuePair("image",encodedImage));
dataToSend1.add(new BasicNameValuePair("name",name));
HttpParams httpRequestParams= getHttpRequestParams();
HttpClient httpClient = new DefaultHttpClient(httpRequestParams);
HttpPost post= new HttpPost(SERVER_ADDRESS + "savePicture.php");
try{
post.setEntity(new UrlEncodedFormEntity(dataToSend1));
httpClient.execute(post);
}
catch(Exception e){
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
Toast.makeText(getApplicationContext(),"Image is uploaded",Toast.LENGTH_SHORT).show();
}
}
//----------------------------------------------------------------------------------------------
private HttpParams getHttpRequestParams(){
HttpParams httpRequestParams= new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpRequestParams, 1000 * 30);
HttpConnectionParams.setSoTimeout(httpRequestParams,1000 * 30);
return httpRequestParams;
}
public class downloadImage extends AsyncTask<Void,Void,Bitmap>{
private String name;
public downloadImage(String name){
this.name=name;
}
@Override
protected Bitmap doInBackground(Void... params) {
String url= SERVER_ADDRESS+"proPictures/"+name+".JPG";
try{
URLConnection connection= new URL(url).openConnection();
connection.setConnectTimeout(1000*30);
connection.setReadTimeout(1000 * 30);
return BitmapFactory.decodeStream((InputStream) connection.getContent(), null, null);
}catch(Exception e){
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Bitmap bitmap) {
super.onPostExecute(bitmap);
if(bitmap!=null){
userProfilePic.setImageBitmap(bitmap);
}
}
}
}
</code></pre>
<p>here is my relavant xml file</p>
<pre><code> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.kasun.timetable.EditYourProfile"
android:background="#303030">
<ScrollView
android:layout_width="match_parent"
android:layout_height="1000dp"
android:id="@+id/scroll">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="110dp"
android:layout_height="100dp"
android:id="@+id/userProfilePic"
android:layout_marginTop="34dp"
android:background="#c6c4c4"
android:layout_marginBottom="10dp"/>
<Button
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="Upload "
android:id="@+id/bImageUpload"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/userNameText"
android:id="@+id/textView18"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/etUserNameEdit"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/FirstNameText"
android:id="@+id/textView19"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/etFirstNameEdit"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/LastNameText"
android:id="@+id/textView20"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/etLastNameEdit"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/Password"
android:id="@+id/textView21"
android:layout_marginTop="16dp"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="@+id/etPasswordEdit"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/Position"
android:id="@+id/textView23"
android:layout_marginTop="12dp"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/etPositionEdit"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/Email"
android:id="@+id/textView24"
android:layout_marginTop="12dp"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/etEmailEdit"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/Telephone"
android:id="@+id/textView25"
android:layout_marginTop="12dp"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/etTelephoneEdit"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/BDate"
android:id="@+id/textView26"
android:layout_marginTop="16dp"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etBirthDateEdit"
android:textColor="#ffffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/qualification"
android:id="@+id/textView26"
android:layout_marginTop="16dp"
android:layout_marginBottom="10dp"
android:textColor="#ffffffff" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etQualificationEdit"/>
<!--<DatePicker-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:id="@+id/datePicker"-->
<!--android:layout_alignBottom="@+id/scroll"-->
<!--android:layout_centerHorizontal="true"-->
<!--android:layout_marginBottom="85dp" />-->
</LinearLayout>
</ScrollView>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/LogoutButtonText"
android:id="@+id/bLogout2"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:gravity="center" />
<!--android:layout_alignParentRight="@+id/bBack2"-->
<!--android:layout_alignBottom="@+id/scroll"-->
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/BackButtonText"
android:id="@+id/bBack2"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:gravity="center" />
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/SaveButtonText"
android:id="@+id/bSave2"
android:layout_alignTop="@+id/bBack2"
android:layout_centerHorizontal="true"
android:gravity="center" />
</RelativeLayout>
</code></pre>
| 0debug |
Vue Trigger watch on mounted : <p>I have a vue component below that I want to watch to trigger on when it's getting mounted. How do I do that?</p>
<pre><code>Vue.component('check-mark', {
name: 'check-mark',
template: `
<input :value="value">
`,
props: {
value: {
type: String,
required: true,
},
},
mounted: async function () {
//trigger this.value watch() here
},
watch: {
value: function (value) {
if (value == 'Y') {
this.class = 'checked';
} else {
this.class = 'unchecked';
}
},
},
});
</code></pre>
| 0debug |
Generate random number with jinja2 : <p>I need to generate a random number between 1 and 50. Aparently the random filter needs a <a href="http://jinja.pocoo.org/docs/dev/templates/#random" rel="noreferrer">sequence</a>. How can I create a list with numbers from 1 to 50 in Jinja? </p>
<pre><code>{{ [1,n,50]|random() }}
</code></pre>
| 0debug |
Using a function in mysql function and passing into database query : <p>I have a funnction called <strong>time_elapsed_string</strong> which converts the mysql function <strong>NOW()</strong> to another format.</p>
<p>How do I pass the function to the mysql function and use in a pdo statement.</p>
<pre><code>$lastseen = time_elapsed_string(NOW());
$query = $pdo->prepare("UPDATE users SET lastseen =
:lastseen WHERE id=:id");
$query->bindParam(':id', $userid, PDO::PARAM_INT);
$query->bindParam(':lastseen', $lastseen);
$query->execute();
</code></pre>
<p>I get this error - <strong>Fatal error: Uncaught Error: Call to undefined function NOW()</strong></p>
| 0debug |
$_session[] in the function PHP : how to add $_session[] in function
function get_cart_list(){
global $_SESSION['items'];
if (isset($_SESSION['items'])) {
foreach ($_SESSION['items'] as $key => $val){
$gete = $key;
$total = 0;
include ('gc-cache-product.php');
$jumlah_harga = ( $skupricenew ) * $val;
$total += $jumlah_harga;
include ($themeid."/content/part/cart/cart_list_item.php");
}
}
}
syntax error, unexpected '[', expecting ',' or ';' in <b>/home/clients/xxx/html/website/template/shadows/gc-cart.php</b> on line 2
thank you | 0debug |
Unable to parse json and set it to recyclerview : <p>Hi I am learning Android App Development. For this, I wanted to make myself a simple wallpaper app. Hence, I wrote something roughly which is presented here. I want to get wallpaper urls from json. Unfortunately, I am unable to get data from my server. <code>java.lang.NullPointerException: Attempt to read from null array</code>
How do I get the data correctly from the jsonParse asynctask?
I am stuck on this the whole day. What could have gone wrong here?
Here is my code:</p>
<p>myjson.json:</p>
<pre><code>{
"walls":[
{"ourUrl":"http://www.hdbloggers.net/wp-content/uploads/2016/01/Wallpapers-for-Android.jpg"},
{"ourUrl":"http://androidwallpape.rs/content/02-wallpapers/131-night-sky/wallpaper-2707591.jpg"},
{"ourUrl":"http://androidwallpape.rs/content/02-wallpapers/155-starrynight/starry-night-sky-star-galaxy-space-dark-9-wallpaper.jpg"}
]
}
</code></pre>
<p>MainActivity.java:</p>
<pre><code>package regalstreak.me.wallpapers;
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public class MainActivity extends Activity {
RecyclerView recyclerView;
RecyclerView.LayoutManager layoutManager;
RecyclerView.Adapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView)findViewById(R.id.recycler_view);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
adapter = new RecyclerAdapter(this);
recyclerView.setAdapter(adapter);
}
}
</code></pre>
<p>RecyclerAdapter.java:</p>
<pre><code>package regalstreak.me.wallpapers;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import org.apache.commons.io.IOUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
// This is a recycleradapter which will set the correct images to the correct position in the recyclerview.
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ViewHolder> {
private Context myCtx1;
String[] arr;
String[] arrurl;
String jsonURL = "http://dev.regalstreak.me/myjson.json";
public RecyclerAdapter(Context ctx) {
this.myCtx1 = ctx;
}
public ImageView Image;
private String[] mText = {
"Text 1",
"Text 2",
"Text 3"
};
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView Text;
public ViewHolder(View itemView) {
super(itemView);
Image = (ImageView) itemView.findViewById(R.id.image_view);
Text = (TextView) itemView.findViewById(R.id.text_view);
}
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View v = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.wallpapers_list, viewGroup, false);
ViewHolder viewHolder = new ViewHolder(v);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder viewHolder, int i) {
viewHolder.Text.setText(mText[i]);
new jsonParse().execute();
new DownloadImageTask(Image).execute(arrurl[i]);
}
@Override
public int getItemCount() {
return mText.length;
}
class jsonParse extends AsyncTask<String, Void, String[]> {
protected String[] doInBackground(String[] urls) {
String myText = null;
String url = urls[0];
String ourUrl;
try {
InputStream in = new java.net.URL(jsonURL).openStream();
myText = IOUtils.toString(in, "utf-8");
in.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
// Parse the json
List<String> allUrls = new ArrayList<String>();
JSONObject jsonObjectRoot = new JSONObject(myText);
JSONArray jsonArray = jsonObjectRoot.getJSONArray("walls");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
ourUrl = jsonObject.getString("ourUrl");
allUrls.add(ourUrl);
}
arr = allUrls.toArray(new String[allUrls.size()]);
} catch (JSONException e) {
e.printStackTrace();
}
return arr;
}
protected void onPostExecute(String[] result){
arrurl = result;
}
}
}
</code></pre>
<p>DownloadImageTask.java:</p>
<pre><code>package regalstreak.me.wallpapers;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.ImageView;
import java.io.InputStream;
// Here, we will download the wallpapers obtained from jsonData with an asynctask.
public class DownloadImageTask extends AsyncTask<String, Void, Bitmap>{
ImageView bmImage;
public DownloadImageTask(ImageView bmImage){
this.bmImage = bmImage;
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
in.close();
} catch (Exception e) {
Log.e("Error getting images.", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
protected void onPostExecute(Bitmap result){
bmImage.setImageBitmap(result);
}
}
</code></pre>
<p>activity_main.xml:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="regalstreak.me.wallpapers.MainActivity">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recycler_view" />
</RelativeLayout>
</code></pre>
<p>wallpaper_list.xml:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relative"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp">
<ImageView
android:id="@+id/image_view"
android:layout_width="match_parent"
android:layout_height="150dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/image_view"
android:alpha="0.6"
android:background="@color/colorDivider"
android:padding="9dp">
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/colorPrimaryText" />
</RelativeLayout>
</RelativeLayout>
</code></pre>
| 0debug |
static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id,
Error **errp)
{
X86CPU *cpu = NULL;
Error *local_err = NULL;
cpu = cpu_x86_create(cpu_model, &local_err);
if (local_err != NULL) {
goto out;
}
object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err);
object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
out:
if (local_err) {
error_propagate(errp, local_err);
object_unref(OBJECT(cpu));
cpu = NULL;
}
return cpu;
}
| 1threat |
static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,
long search_pc)
{
int opc, op_index, macro_op_index;
const TCGOpDef *def;
unsigned int dead_iargs;
const TCGArg *args;
#ifdef DEBUG_DISAS
if (unlikely(loglevel & CPU_LOG_TB_OP)) {
fprintf(logfile, "OP:\n");
tcg_dump_ops(s, logfile);
fprintf(logfile, "\n");
}
#endif
tcg_liveness_analysis(s);
#ifdef DEBUG_DISAS
if (unlikely(loglevel & CPU_LOG_TB_OP_OPT)) {
fprintf(logfile, "OP after la:\n");
tcg_dump_ops(s, logfile);
fprintf(logfile, "\n");
}
#endif
tcg_reg_alloc_start(s);
s->code_buf = gen_code_buf;
s->code_ptr = gen_code_buf;
macro_op_index = -1;
args = gen_opparam_buf;
op_index = 0;
for(;;) {
opc = gen_opc_buf[op_index];
#ifdef CONFIG_PROFILER
dyngen_table_op_count[opc]++;
#endif
def = &tcg_op_defs[opc];
#if 0
printf("%s: %d %d %d\n", def->name,
def->nb_oargs, def->nb_iargs, def->nb_cargs);
#endif
switch(opc) {
case INDEX_op_mov_i32:
#if TCG_TARGET_REG_BITS == 64
case INDEX_op_mov_i64:
#endif
dead_iargs = s->op_dead_iargs[op_index];
tcg_reg_alloc_mov(s, def, args, dead_iargs);
break;
case INDEX_op_nop:
case INDEX_op_nop1:
case INDEX_op_nop2:
case INDEX_op_nop3:
break;
case INDEX_op_nopn:
args += args[0];
goto next;
case INDEX_op_discard:
{
TCGTemp *ts;
ts = &s->temps[args[0]];
if (ts->val_type != TEMP_VAL_CONST && !ts->fixed_reg) {
if (ts->val_type == TEMP_VAL_REG)
s->reg_to_temp[ts->reg] = -1;
ts->val_type = TEMP_VAL_DEAD;
}
}
break;
case INDEX_op_macro_goto:
macro_op_index = op_index;
op_index = args[0] - 1;
args = gen_opparam_buf + args[1];
goto next;
case INDEX_op_macro_end:
macro_op_index = -1;
op_index = args[0] - 1;
args = gen_opparam_buf + args[1];
goto next;
case INDEX_op_macro_start:
tcg_abort();
case INDEX_op_set_label:
tcg_reg_alloc_bb_end(s);
tcg_out_label(s, args[0], (long)s->code_ptr);
break;
case INDEX_op_call:
dead_iargs = s->op_dead_iargs[op_index];
args += tcg_reg_alloc_call(s, def, opc, args, dead_iargs);
goto next;
case INDEX_op_end:
goto the_end;
#ifndef CONFIG_NO_DYNGEN_OP
case 0 ... INDEX_op_end - 1:
#ifdef CONFIG_PROFILER
{
extern int64_t dyngen_old_op_count;
dyngen_old_op_count++;
}
#endif
tcg_reg_alloc_bb_end(s);
if (search_pc >= 0) {
s->code_ptr += def->copy_size;
args += def->nb_args;
} else {
args = dyngen_op(s, opc, args);
}
goto next;
#endif
default:
dead_iargs = s->op_dead_iargs[op_index];
tcg_reg_alloc_op(s, def, opc, args, dead_iargs);
break;
}
args += def->nb_args;
next: ;
if (search_pc >= 0 && search_pc < s->code_ptr - gen_code_buf) {
if (macro_op_index >= 0)
return macro_op_index;
else
return op_index;
}
op_index++;
#ifndef NDEBUG
check_regs(s);
#endif
}
the_end:
return -1;
}
| 1threat |
can you help me with LINQ query : I got this MySQL querry and I would like to change this to LINQ query.
MySQL: SELECT id,cas_poziadavky,nazov_linky,stanica,cas_prichodu,meno_udrzbara,pricina_problemu,riesenie_problemu,cas_odchodu,bol_prestoj,poznamka, TIMESTAMPDIFF(MINUTE, cas_poziadavky, cas_odchodu) AS 'rozdiel',TIMESTAMPDIFF(MINUTE, cas_poziadavky, cas_prichodu) AS 'reakcia',TIMESTAMPDIFF(MINUTE, cas_prichodu, cas_odchodu) AS 'vyriesenie' FROM monitor_linky
Can you help me please.
| 0debug |
how to print this type of array? : Array
(
[0] => Array
(
[0] => 1
)
[1] => Array
(
[0] => 2
)
[2] => Array
(
[0] => 3
)
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
[11] =>
[12] =>
[13] =>
[14] =>
)
How to print above array using foreach?I tried by using foreach like this:
$i = 0;
foreach($array as $arr)
{
echo $arr[$i];
$i++;
}
But the result is empty.Please help me to solve this. | 0debug |
static inline void RENAME(rgb24ToY)(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused)
{
#if COMPILE_TEMPLATE_MMX
RENAME(bgr24ToY_mmx)(dst, src, width, PIX_FMT_RGB24);
#else
int i;
for (i=0; i<width; i++) {
int r= src[i*3+0];
int g= src[i*3+1];
int b= src[i*3+2];
dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);
}
#endif
}
| 1threat |
void helper_slbie(CPUPPCState *env, target_ulong addr)
{
PowerPCCPU *cpu = ppc_env_get_cpu(env);
ppc_slb_t *slb;
slb = slb_lookup(cpu, addr);
if (!slb) {
return;
}
if (slb->esid & SLB_ESID_V) {
slb->esid &= ~SLB_ESID_V;
tlb_flush(CPU(cpu), 1);
}
}
| 1threat |
What does the .dtbcache file do? : <p>I have a C# WinForms project, which I am working on in Visual Studio 2017 (although it was originally created in the 2015 version). </p>
<p>I don't recall having done anything special, but it has added a file called <code>.dtbcache</code>, that it wants to add to git. The file has no extension, and a Google search doesn't show any results.</p>
<p>The file is located in <code>..\repos\myprject\.vs\MyProject\DesignTimeBuild</code>. Which means that the "dtb" part of the file name probably means <strong>d</strong>esign <strong>t</strong>ime <strong>b</strong>uild, but that doesn't really make it that much better.</p>
<p><a href="https://i.stack.imgur.com/AvwwV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AvwwV.png" alt="enter image description here"></a></p>
<p>Can I delete it or add it to .gitignore? I would prefer not to include it in our git repository, unless it is required.</p>
| 0debug |
static void m5206_mbar_writeb(void *opaque, target_phys_addr_t offset,
uint32_t value)
{
m5206_mbar_state *s = (m5206_mbar_state *)opaque;
int width;
offset &= 0x3ff;
if (offset > 0x200) {
hw_error("Bad MBAR write offset 0x%x", (int)offset);
}
width = m5206_mbar_width[offset >> 2];
if (width > 1) {
uint32_t tmp;
tmp = m5206_mbar_readw(opaque, offset & ~1);
if (offset & 1) {
tmp = (tmp & 0xff00) | value;
} else {
tmp = (tmp & 0x00ff) | (value << 8);
}
m5206_mbar_writew(opaque, offset & ~1, tmp);
return;
}
m5206_mbar_write(s, offset, value, 1);
}
| 1threat |
void do_compare_and_swap32(void *cpu_env, int num)
{
#ifdef TARGET_I386
uint32_t old = ((CPUX86State*)cpu_env)->regs[R_EAX];
uint32_t *value = (uint32_t*)((CPUX86State*)cpu_env)->regs[R_ECX];
DPRINTF("commpage: compare_and_swap32(%x,new,%p)\n", old, value);
if(value && old == tswap32(*value))
{
uint32_t new = ((CPUX86State*)cpu_env)->regs[R_EDX];
*value = tswap32(new);
((CPUX86State*)cpu_env)->eflags |= 0x40;
}
else
{
((CPUX86State*)cpu_env)->regs[R_EAX] = tswap32(*value);
((CPUX86State*)cpu_env)->eflags &= ~0x40;
}
#else
qerror("do_compare_and_swap32 unimplemented");
#endif
}
| 1threat |
static void hmp_mouse_move(Monitor *mon, const QDict *qdict)
{
int dx, dy, dz, button;
const char *dx_str = qdict_get_str(qdict, "dx_str");
const char *dy_str = qdict_get_str(qdict, "dy_str");
const char *dz_str = qdict_get_try_str(qdict, "dz_str");
dx = strtol(dx_str, NULL, 0);
dy = strtol(dy_str, NULL, 0);
qemu_input_queue_rel(NULL, INPUT_AXIS_X, dx);
qemu_input_queue_rel(NULL, INPUT_AXIS_Y, dy);
if (dz_str) {
dz = strtol(dz_str, NULL, 0);
if (dz != 0) {
button = (dz > 0) ? INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN;
qemu_input_queue_btn(NULL, button, true);
qemu_input_event_sync();
qemu_input_queue_btn(NULL, button, false);
}
}
qemu_input_event_sync();
}
| 1threat |
PHP Get BIC from IBAN : <p>I'm creating an application where I need to have the IBAN and BIC number of the users so I can make payments to them.</p>
<p>How can I generate/get BIC from IBAN Bank account in PHP? Does someone knows?
Country: Germany, and free if it's possible.</p>
<p>Tried this one: <a href="http://www.iban-bic.com/soap0.html?L=2" rel="nofollow noreferrer">http://www.iban-bic.com/soap0.html?L=2</a>
But, you need to pay for it.</p>
<p>Thank you.</p>
| 0debug |
How to verify if a IP address is valid on Java? : <p>I want to verify an IP address in java, how can I do that?
The IP Address needs to be in this format: xxx.xxx.xxx.xxx
Each octet range must be 0 ~ 255.</p>
<p>Since the IP is verified, the code must show a message telling that the IP is valid or not. If not, the user must type the IP again.</p>
<p>I've done the method to convert an IP string to an array of integers so far...</p>
<pre class="lang-java prettyprint-override"><code>
public static void verify() {
Scanner input = new Scanner(System.in);
System.out.println("IP: (xxx.xxx.xxx.xxx)");
String ipAddress = input.nextLine();
int[] arrayIpAddress = Arrays.stream(ipAddress.split("\\.")).mapToInt(Integer::parseInt).toArray();
}
</code></pre>
| 0debug |
static inline int target_to_host_errno(int err)
{
if (target_to_host_errno_table[err])
return target_to_host_errno_table[err];
return err;
}
| 1threat |
how to find out whether a number is equal to any element of a vector : <p>I am trying to write a if with two conditions. The first condition is k > h, and the second condition is k not equal to any element in m[1,]. Can anyone tell me how to do it?
Thank you a lot!</p>
| 0debug |
NO_OF_CHARS = 256
def str_to_list(string):
temp = []
for x in string:
temp.append(x)
return temp
def lst_to_string(List):
return ''.join(List)
def get_char_count_array(string):
count = [0] * NO_OF_CHARS
for i in string:
count[ord(i)] += 1
return count
def remove_dirty_chars(string, second_string):
count = get_char_count_array(second_string)
ip_ind = 0
res_ind = 0
temp = ''
str_list = str_to_list(string)
while ip_ind != len(str_list):
temp = str_list[ip_ind]
if count[ord(temp)] == 0:
str_list[res_ind] = str_list[ip_ind]
res_ind += 1
ip_ind+=1
return lst_to_string(str_list[0:res_ind]) | 0debug |
why my css code is not working in vuejs? : <p>I've got problem with css in VueJs. Sorry for poor description, but I have no idea what I'm doing wrong. </p>
<p>My css in style scoped works generally fine in vuejs, I can normally address idis and classes. </p>
<p>The problem is when I want to change for example value of internal css of an element of vuetify framework, or wysiwyg editor. I don't understand, because on codepen everything works fine. For example here I'm setting padding of wysiwig editor to 0 and it simply works (in codepen):</p>
<p>template:</p>
<pre><code><div class="container">
<div id="editor-container">
</div>
</div>
</code></pre>
<p>script</p>
<pre><code>var quill = new Quill('#editor-container', {
modules: {
toolbar: [
[{ header: [1, 2, false] }],
['bold', 'italic', 'underline'],
['image', 'code-block']
]
},
placeholder: 'Compose the most wonderful and amazing epic you could ever imagine!',
theme: 'snow' // or 'bubble'
});
</code></pre>
<p>style</p>
<pre><code>.ql-editor {
padding: 0!important;
}
</code></pre>
<p>On my vuejs SPA I'm pasting the exactly the same css code and it does nothing. I'm in the right component, adressing right element. In my console, when I'm doing inspect - I see properties of .q1-editor as padding 12px etc. So nothing is changing in my website :(
I'm sorry for poor explanation - css is not my primary language. </p>
<p>Maybe someone who have more experience with css will have an idea what I'm doing wrong.</p>
| 0debug |
set label text in navigation title when scrolling : in srotyboard, i have label and many other object in UIScrollView (UIScrollView is in view).
i want when i scrolling, when label past from navigation bar, title of label set in navigation title.
i try this code but it is not my need.
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if(self.lbl.frame.origin.x==60) {
self.navigationController!.navigationBar.topItem!.title = "First"
}
}
what should i do???
where should i write my code?
(i am new in swift)
thank you | 0debug |
Parse error: syntax error, unexpected '{' in /path/to/the/website/file.php on line 18 : <p>The issue says unexpected {..... I dont understand why this is hapenning i remove it and i still ahve issues. Please reply with th right code.</p>
<p>Kevin Andrews / Auth</p>
<pre><code><?php
$shortenedlink = mt_rand(10000,99999);
$longlink = $_POST['longlink'];
if(!isset($longlink) || trim($longlink) == '')
{
echo "The link field is empty. Redirecting you in 3 seconds.";
header ( "refresh:3;url=http://auth.kenygamer.com" );
exit;
$shortenedlinkpath = "$shortenedlink.asp";
if (file_exists($shortenedlinkpath))
{
echo "An error occurred creating the shortened link, because the assigned number already exists. However, you can retry. Copy the link and paste it again on the main page:<br><br>$longlink<br><br>Redirecting you in 15 seconds.";
header( "refresh:15;url=http://auth.kenygamer.com" );
exit;
}
else
{
echo "";
}
$shortenedfilecontent = '<title>Outgoing link</title><meta http-equiv="refresh" content="5; url=$longlink">';
$fp = fopen("$shortenedlink.asp", "w");
fwrite($fp, $shortenedfilecontent).'&nbsp;';
fclose($fp);
echo ("The shortened URL has been successfully created. The shortened number #$shortenedlink has been assigned to your long URL $longlink. Therefore, it is accessible at https://auth.kenygamer.com/$shortenedlink at any time. Remember that you can always create new shortened URLs.<br><br>Long link: $longlink<br>Shortened link: $shortenedlink<br><br>Redirecting you in 20 seconds.");
header( "refresh:20;url=https://auth.kenygamer.com/$shortenedlink" );
?>
</code></pre>
| 0debug |
Overriding Equals/GetHashCode for class in order to use hashset Contains/ExceptWith/UnionWith : <p>I currently have a C# class that appears as follows:</p>
<pre><code> namespace DBModel
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;
public partial class ConnSrv
{
public int ID { get; set; }
[Required]
[StringLength(14)]
public string Service { get; set; }
[Required]
[StringLength(14)]
public string ConnectsToService { get; set; }
public virtual Service Service1 { get; set; }
public virtual Service Service2 { get; set; }
}
}
</code></pre>
<p>In my main program, I'm creating hashsets to work with these objects. The problem I'm encountering is that I would like to be able to use operators such as Contains, Except, ExceptWith, UnionWith, and so on on these hashsets.</p>
<p>For an object of the ConnSrv to be considered "equal", the Service and ConnectsToService values have to be equal. As such, I realize that in some way, I will have to override the Equals and GetHashCode operators for the class. I'm just not sure how to do so, whether it's through a straight override of the object class, by implementing IEquatable or IEquatable, or through some other method. Below are a couple simple examples of what I would expect the end result to be once implemented. If I'm way out in left field, please let me know. Thanks in advance for your time.</p>
<pre><code> var testHS1 = new HashSet<ConnectingService>();
testHS1.Add(test1);
testHS1.Contains(test2); // Returns true
var testHS2 = new HashSet<ConnectingService>();
testHS2.Add(test1);
testHS2.Add(test2);
testHS2.Add(test3);
testHS2.Except(testHS1); // Expect end result to only contain test3
</code></pre>
| 0debug |
ruby creating hash for array.each : <p>This is my code: </p>
<pre><code>@games.each do |game| #@games is an array
#definitely working
game = Hash.new 0
end
</code></pre>
<p>And as you can guess... it's not working. No errors. Just variables like that don't exist. I want my hashes be called by a title of games. Plenty of this, because there are 240titles. </p>
<p>I am pretty sure I have to take this "game = Hash.new 0" out of block, but to be honest I don't have any ideas.</p>
<p>Regards.</p>
| 0debug |
C# - Access - Problems with double queries : I'm trying to execute 2 query in one button click.. It doesn't seem to work and just closes automatically.. Does anyone can help me or explain to me why my code doesn't work? Here's the code:
test = 1;
{
connection.Open();
string strTemp = " [StudentNum] Text, [StudentName] Text, [Section] Text, [TimeIn] Text, [TimeOut] Text, [Status] Text";
OleDbCommand myCommand = new OleDbCommand();
myCommand.Connection = connection;
myCommand.CommandText = "CREATE TABLE [" + date + "](" + strTemp + ")";
myCommand.ExecuteNonQuery();
if (test == 1)
{
OleDbCommand commandl = new OleDbCommand();
commandl.Connection = connection;
commandl.CommandText = "INSERT INTO ['" + date + "']([StudentNum],[StudentName],[Section]) select [StudentNo],[Name],[Section] from StudInfo";
commandl.ExecuteNonQuery();
} | 0debug |
static int uhci_handle_td(UHCIState *s, UHCIQueue *q,
UHCI_TD *td, uint32_t td_addr, uint32_t *int_mask)
{
UHCIAsync *async;
int len = 0, max_len;
bool spd;
bool queuing = (q != NULL);
uint8_t pid = td->token & 0xff;
if (!(td->ctrl & TD_CTRL_ACTIVE)) {
if (td->ctrl & TD_CTRL_IOC) {
*int_mask |= 0x01;
}
return TD_RESULT_NEXT_QH;
}
async = uhci_async_find_td(s, td_addr, td);
if (async) {
async->queue->valid = 32;
if (!async->done)
return TD_RESULT_ASYNC_CONT;
if (queuing) {
return TD_RESULT_ASYNC_CONT;
}
uhci_async_unlink(async);
goto done;
}
if (q == NULL) {
USBDevice *dev = uhci_find_device(s, (td->token >> 8) & 0x7f);
USBEndpoint *ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf);
q = uhci_queue_get(s, td, ep);
}
async = uhci_async_alloc(q, td_addr);
async->queue->valid = 32;
max_len = ((td->token >> 21) + 1) & 0x7ff;
spd = (pid == USB_TOKEN_IN && (td->ctrl & TD_CTRL_SPD) != 0);
usb_packet_setup(&async->packet, pid, q->ep, td_addr, spd,
(td->ctrl & TD_CTRL_IOC) != 0);
qemu_sglist_add(&async->sgl, td->buffer, max_len);
usb_packet_map(&async->packet, &async->sgl);
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
len = usb_handle_packet(q->ep->dev, &async->packet);
if (len >= 0)
len = max_len;
break;
case USB_TOKEN_IN:
len = usb_handle_packet(q->ep->dev, &async->packet);
break;
default:
usb_packet_unmap(&async->packet, &async->sgl);
uhci_async_free(async);
s->status |= UHCI_STS_HCPERR;
uhci_update_irq(s);
return TD_RESULT_STOP_FRAME;
}
if (len == USB_RET_ASYNC) {
uhci_async_link(async);
if (!queuing) {
uhci_queue_fill(q, td);
}
return TD_RESULT_ASYNC_START;
}
async->packet.result = len;
done:
len = uhci_complete_td(s, td, async, int_mask);
usb_packet_unmap(&async->packet, &async->sgl);
uhci_async_free(async);
return len;
}
| 1threat |
how can add javascript class data into php varible :
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
function net_total(){
var net_total = 0;
$('.qty').each(function(){
var row = $(this).parent().parent();
var price = row.find('.price').val();
var total = price * $(this).val()-0;
row.find('.total').val(total);
})
$('.total').each(function(){
net_total += ($(this).val()-0);
})
$('.net_total').html("Total : $ " +net_total);
}
<!-- language: lang-html -->
<div class="col-md-4">
<b class="net_total" style="font-size:20px;"> </b>
</div>
<!-- end snippet -->
We want net_total class data add in to another php varible like,how can insert dnet_total class data in to data base by php | 0debug |
Kafka connect to MSSQL no topics created : I have connected Kafka with MSSQl using JDBC connector. The connector has been successfully connected and the status is running. But when i curled port `http://ip:8083/topics` I am getting 404 not found error `"error_code":404,"message":"HTTP 404 Not Found"}`. What could be the reason for this please help.
This is the connector configuration.
{"name":"test-mssql-source","config":{"connector.class":"io.confluent.connect.jdbc.JdbcSourceConnector","mode":"incrementing","incrementing.column.name":"id","topic.prefix":"test-mssql-","tasks.max":"1","poll.interval.ms":"100","name":"test-mssql-source","connection.url":"jdbc:sqlserver://ip;Database=TEST_KAFKA;user=user;password=root","value.converter":"org.apache.kafka.connect.json.JsonConverter"},"tasks":[{"connector":"test-mssql-source","task":0}],"type":"source"} | 0debug |
assigment with OR statement : So i came across this code when i was reading source in git hub.
addr2int = ( (uint32_t)paddr[2] ) | ( (uint32_t)paddr[3] << 8 ) | ( (uint32_t)paddr[4] << 16 ) | ( (uint32_t)paddr[5] << 24 )
Can some one explain to me what happens here, i tried to google it but i don't know the keywords to search this because i keep getting wrong results.
As far as i can tell this is an assignment but i don't understand why their are or operators and if this is an multiple assignment? | 0debug |
c++ , can we cast a child class object into parent class type or vise versa.? : <p>I tried this code but getting this compilation error </p>
<pre><code>class A{
};
class B : public A{
};
int main()
{
A a = new B(); // ERROR: "No suitable constructor exists to convert from "B*" to "A".
B b = new A(); // ERROR: "No suitable constructor exists to convert from "A*" to "B".
}
</code></pre>
<p>I am new to C++ and trying to learn . Can someone help me to understand this.</p>
| 0debug |
static int set_params(AVFilterContext *ctx, const char *params)
{
Frei0rContext *s = ctx->priv;
int i;
if (!params)
return 0;
for (i = 0; i < s->plugin_info.num_params; i++) {
f0r_param_info_t info;
char *param;
int ret;
s->get_param_info(&info, i);
if (*params) {
if (!(param = av_get_token(¶ms, "|")))
return AVERROR(ENOMEM);
params++;
ret = set_param(ctx, info, i, param);
av_free(param);
if (ret < 0)
return ret;
}
av_log(ctx, AV_LOG_VERBOSE,
"idx:%d name:'%s' type:%s explanation:'%s' ",
i, info.name,
info.type == F0R_PARAM_BOOL ? "bool" :
info.type == F0R_PARAM_DOUBLE ? "double" :
info.type == F0R_PARAM_COLOR ? "color" :
info.type == F0R_PARAM_POSITION ? "position" :
info.type == F0R_PARAM_STRING ? "string" : "unknown",
info.explanation);
#ifdef DEBUG
av_log(ctx, AV_LOG_DEBUG, "value:");
switch (info.type) {
void *v;
double d;
char s[128];
f0r_param_color_t col;
f0r_param_position_t pos;
case F0R_PARAM_BOOL:
v = &d;
s->get_param_value(s->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "%s", d >= 0.5 && d <= 1.0 ? "y" : "n");
break;
case F0R_PARAM_DOUBLE:
v = &d;
s->get_param_value(s->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "%f", d);
break;
case F0R_PARAM_COLOR:
v = &col;
s->get_param_value(s->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "%f/%f/%f", col.r, col.g, col.b);
break;
case F0R_PARAM_POSITION:
v = &pos;
s->get_param_value(s->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "%f/%f", pos.x, pos.y);
break;
default:
v = s;
s->get_param_value(s->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "'%s'\n", s);
break;
}
#endif
av_log(ctx, AV_LOG_VERBOSE, "\n");
}
return 0;
}
| 1threat |
How to use printf "%q " in bash? : <p>I would like to print out augments of a function to a file.
I was told a command printf "%q ", whose instruction is following,</p>
<pre><code># man printf
%q ARGUMENT is printed in a format that can be reused as shell input, escaping non-print‐
able characters with the proposed POSIX $'' syntax.
</code></pre>
<p>On the basis of instruction above, I tried following code.</p>
<pre><code>#!/bin/bash
# file name : print_out_function_augs.sh
output_file='output.txt'
function print_augs() {
printf "%q " "$@" >> "${output_file}"
echo >> "${output_file}"
}
print_augs a 'b c'
cat "${output_file}"
rm "${output_file}"
</code></pre>
<p>and run</p>
<pre><code>bash print_out_function_augs.sh
</code></pre>
<p>The results are following,</p>
<pre><code>a b\ c
</code></pre>
<p>I expected the results as</p>
<pre><code>a 'b c'
</code></pre>
<p>which is the original augments to print_augs function.</p>
<p>Why does the output and the original augments are different?
Or can I print out the original augments as they are?</p>
<p>Thank you very much.</p>
| 0debug |
static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
ptrdiff_t pitch)
{
uint32_t bit_cache;
uint8_t *list[63];
uint32_t *dst;
const uint32_t *codebook;
int entries[6];
int i, j, m, n;
int stages;
unsigned mean;
unsigned x, y, width, height, level;
uint32_t n1, n2, n3, n4;
list[0] = pixels;
for (i = 0, m = 1, n = 1, level = 5; i < n; i++) {
SVQ1_PROCESS_VECTOR();
dst = (uint32_t *)list[i];
width = 1 << ((4 + level) / 2);
height = 1 << ((3 + level) / 2);
stages = get_vlc2(bitbuf, svq1_intra_multistage[level].table, 3, 3) - 1;
if (stages == -1) {
for (y = 0; y < height; y++)
memset(&dst[y * (pitch / 4)], 0, width);
continue;
}
if ((stages > 0 && level >= 4)) {
ff_dlog(NULL,
"Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",
stages, level);
return AVERROR_INVALIDDATA;
}
av_assert0(stages >= 0);
mean = get_vlc2(bitbuf, svq1_intra_mean.table, 8, 3);
if (stages == 0) {
for (y = 0; y < height; y++)
memset(&dst[y * (pitch / 4)], mean, width);
} else {
SVQ1_CALC_CODEBOOK_ENTRIES(ff_svq1_intra_codebooks);
for (y = 0; y < height; y++) {
for (x = 0; x < width / 4; x++, codebook++) {
n1 = n4;
n2 = n4;
SVQ1_ADD_CODEBOOK()
dst[x] = n1 << 8 | n2;
}
dst += pitch / 4;
}
}
}
return 0;
}
| 1threat |
how to display results from a javascript function to an html element : I am having trouble figuring out how to display values from a JavaScript to a table in HTML. I have very little coding experience so please bare with me. I am trying to display just the even numbers between a starting number and a ending number. I believe my functions are correct but for some reason the values do not display on the page when submitted. Any help would be awesome. Thanks
In HTML:
<!DOCTYPE html>
<html>
<head>
<script type="text/JavaScript" src="displayEvens.js"></script>
<link
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
<h1>Display Evens</h1>
<form name="displayEvens" onsubmit="return validateItems();"
onreset="resetForm();">
<div class="form-group row">
<label for="startingNumber" class="col-sm-2 col-form-
label">Starting Number</label>
<div class="col-sm-10">
<input type="number" class="form-control" `
id="startingNumber"`
placeholder="Enter a number"/>
</div>
</div>
<div class="form-group row">
<label for="endingNumber" class="col-sm-2 col-form-`
label">Ending`
Number</label>
<div class="col-sm-10">
<input type="number" class="form-control" id="endingNumber"
placeholder="Enter a number"/>
</div>
</div>
<div class="form-group row">
<label for="step" class="col-sm-2 col-form-
label">Step</label>
<div class="col-sm-10">
<input type="number" class="form-control" id="step"
placeholder="Enter a number"/>
</div>
</div>
<button type="submit" id="submitButton" class="btn btn-
default">Display Evens</button>
<button type="reset" id="resetButton" class="btn">Reset</button>
</form></br>
<table id="results" class="table table-striped">
<thead>
<tr>
<td>Even numbers between <span id="startingNum"></span> and
<span id="endingNum"></span>
by <span id="stepNum"></span></td>
<th>Result</th>
</tr>
</thead>
<tbody>
<tr>
<td><span id="evens"></span></td>
</tbody>
</table>
</div>
<!--<div id="results" style="display:none;">
<h3>Results:</h3>
<span id="evens"></span>
<h3>Your Starting Number:</h3>
<span id="start"></span></br>
<h3>Your Ending Number:</h3>
<span id="end"></span></br>
<h3>Your Step Number:</h3>
<span id="step"></span>
</div>-->
</body>
</html>
In JavaScript:
function clearErrors() {
for (var loopCounter = 0;
loopCounter < document.forms["displayEvens"].elements.length;
loopCounter++) {
if (document.forms["displayEvens"].elements[loopCounter]
.parentElement.className.indexOf("has-") != -1) {
document.forms["displayEvens"].elements[loopCounter]
.parentElement.className = "form-group";
}
}
}
function resetForm() {
clearErrors();
document.forms["displayEvens"]["startingNumber"].value = "";
document.forms["displayEvens"]["endingNumber"].value = "";
document.forms["displayEvens"]["step"].value = "";
document.getElementById("results").style.display = "none";
document.getElementById("submitButton").innerText = "DisplayEvens";
document.forms["displayEvens"]["startingNumber"].focus();
}
function displayEvens(startingNumber, endingNumber, step) {
var startingNumber =
parseInt(document.getElementById("startingNum").value);
var endingNumber = parseInt(document.getElementById("endingNum").value);
var step = parseInt(document.getElementById("stepNum").value);
var evenNums = [];
for (var i = startingNumber; i < endingNumber; i += step) {
if (i % 2 == 0) {
evenNums.push(i);
}
}
document.getElementById("evens").innerText = evenNums;
}
function validateItems() {
clearErrors();
displayEvens(startingNumber, endingNumber, step);
console.trace("got here!");
//var startingNumber = document.forms["displayEvens"]
["startingNumber"].value;
//var endingNumber = document.forms["displayEvens"]
["endingNumber"].value;
//var step = document.forms["displayEvens"]["step"].value;
if (startingNumber == "" || isNaN(startingNumber)) {
alert("Starting Number must be filled in with a number.");
document.forms["displayEvens"]["startingNumber"]
.parentElement.className = "form-group has-error";
document.forms["displayEvens"]["startingNumber"].focus();
return false;
}
if (endingNumber == "" || isNaN(endingNumber)) {
alert("Ending Number must be filled in with a number.");
document.forms["displayEvens"]["endingNumber"]
.parentElement.className = "form-group has-error"
document.forms["displayEvens"]["endingNumber"].focus();
return false;
}
if (endingNumber <= startingNumber) {
alert("Ending Number must be greater than the Starting number.");
document.forms["displayEvens"]["endingNumber"]
.parentElement.className = "form-group has-error"
document.forms["displayEvens"]["endingNumber"].focus();
return false;
}
if (step == "" || isNaN(step)) {
alert("Step Number must be filled in with a number.");
document.forms["displayEvens"]["step"]
.parentElement.className = "form-group has-error"
document.forms["displayEvens"]["step"].focus();
return false;
}
if (step < 0) {
alert("Step Number must be filled in with a positive number.");
document.forms["displayEvens"]["step"]
.parentElement.className = "form-group has-error"
document.forms["displayEvens"]["step"].focus();
return false;
}
//document.getElementById("results").style.display = "block";
//document.getElementById("submitButton").innerText = "Recalculate";
document.getElementById("startingNum").innerText =
Number(startingNumber);
document.getElementById("endingNum").innerText = Number(endingNumber);
document.getElementById("stepNum").innerText = Number(step);
document.getElementById("evens").innerText = Number(evenNums);
return false;
} | 0debug |
Location of PHP error logs in Laravel Homestead : <p>I'm currently experiencing routing issues, where various pages of my application are returning white pages.</p>
<p>Where are the PHP logs located within Homestead Vagrant so I can diagnose what's the issue?</p>
<p>I've checked <code>/var/log/</code> and I can only see a <code>php7.0-fpm.log</code> that relates to PHP, but nothing is generated within here when I read it.</p>
| 0debug |
How to merge multiple images like snapchat in iOS in swift : I wanted to add imoticons, images in single image like we do in snapchat and save the image with all the images added. I have done with adding, rotating, pinch, zoom functionality, but how to save the image with all the images added with their position is the point where i m stucked, can anyone please help me. | 0debug |
How to add a typescript definition file to a npm package? : <p>Is there a way to add typescript definitions (<code>.d.ts</code> files) to a pure javascript project directly (e.g. in <code>package.json</code>). I can't find any documentation on that.</p>
| 0debug |
how to know the name of a frame to be used in selenium - python : I am on a very simple python script (which I don't know how to start), regarding selenium, so I wanna know how would you know the 'name'/'ID' of the frame, the one that you can use to Identify that specific frame. I would like to ask where can I get that
I don't know if you understand that but, I wanna know if how would I recognize that specific frame?
SOrry
and also how could I click on that
ty | 0debug |
static void build_udp_url(char *buf, int buf_size,
const char *hostname, int port,
int local_port, int ttl)
{
snprintf(buf, buf_size, "udp:
if (local_port >= 0)
url_add_option(buf, buf_size, "localport=%d", local_port);
if (ttl >= 0)
url_add_option(buf, buf_size, "ttl=%d", ttl);
}
| 1threat |
document.getElementById('input').innerHTML = user_input; | 1threat |
Select query does not complete when using offset-fetching : I have implemented pagination in a web application using Linq, the query generated by Linq looks similar to this one:
SELECT
[Extent1].[ID_PLAZO] AS [ID_PLAZO],
LTRIM(RTRIM([Extent1].[ID_EXPEDIENTE])) AS [ID_EXPEDIENTE],
[Extent1].[ID_TIPO_PLAZO] AS [ID_TIPO_PLAZO],
[Extent1].[FECHA_INICIO] AS [FECHA_INICIO],
[Extent1].[FECHA_FIN] AS [FECHA_FIN],
[Extent1].[FECHA_EJECUCION_INICIO] AS [FECHA_EJECUCION_INICIO],
[Extent1].[FECHA_EJECUCION_FIN] AS [FECHA_EJECUCION_FIN]
FROM [dbo].[AESEG_PLAZO] AS [Extent1]
INNER JOIN [dbo].[AESEG_EXPEDIENTE] AS [Extent2] ON [Extent1].[ID_EXPEDIENTE] = [Extent2].[ID_EXPEDIENTE]
INNER JOIN [dbo].[SAS_CONVOCATORIA] AS [Extent3] ON [Extent2].[ID_CONVOCATORIA] = [Extent3].[CONV_ID_CONVOCATORIA]
WHERE ([Extent3].[CONV_PREFIJO_EXP] LIKE '%AC15%' ESCAPE '~') OR ([Extent3].[CONV_DESCRIPCION] LIKE '%AC15%' ESCAPE '~')
ORDER BY [Extent1].[ID_PLAZO] ASC
OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY
The query does work and returns 10 results in less than a second, but if I fetch 5 rows it does not end.
I have noticed that the execution plan is a bit different in those cases but I am not an SQL expert. Do you know how to solve this or why is this happening?
[Screenshot: fetch 10 Rows][1]
[Screenshot: fetch 5 Rows][2]
[1]: https://i.stack.imgur.com/GKEA5.jpg
[2]: https://i.stack.imgur.com/Rssj7.jpg | 0debug |
How to mine twitter API with respect to time using Tweepy? : I have access to Twitter's API, and I'm using the Tweepy module to mine through tweets. However, I can't figure out how to search tweets in a specific time slot, like march 1st - july 20th.
Any ideas?
Thanks! | 0debug |
I'm learning Curiously recurring template pattern. What's wrong with this template? : Thanks to [this post][1], I'm trying to learning [Curiously recurring template pattern][2].
[This][3] is the code I wrote:
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
template<class EnvelopeType>
class Envelope
{
public:
double mSingle = 1.0;
void SetValue(double value) { mValue = value; }
inline double GetValue() { return mValue; }
private:
static double mValue;
};
class Volume : public Envelope<Volume>
{
};
class Pitch : public Envelope<Pitch>
{
};
template<EnvelopeType T>
double Envelope<T>::mValue;
int main()
{
Envelope<Volume> mVolume;
Envelope<Pitch> mPitch;
mVolume.SetValue(0.5);
mPitch.SetValue(1.0);
}
What's wrong? It says *unknown type name "EnvelopeType"*. Of course it doesnt know: that's the T type of the template.
[1]: http://stackoverflow.com/questions/12796580/static-variable-for-each-derived-class
[2]: https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
[3]: http://coliru.stacked-crooked.com/a/267f9771385752d2 | 0debug |
static void test_visitor_in_list(TestInputVisitorData *data,
const void *unused)
{
UserDefOneList *item, *head = NULL;
Error *err = NULL;
Visitor *v;
int i;
v = visitor_input_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44 } ]");
visit_type_UserDefOneList(v, &head, NULL, &err);
g_assert(!err);
g_assert(head != NULL);
for (i = 0, item = head; item; item = item->next, i++) {
char string[12];
snprintf(string, sizeof(string), "string%d", i);
g_assert_cmpstr(item->value->string, ==, string);
g_assert_cmpint(item->value->base->integer, ==, 42 + i);
}
qapi_free_UserDefOneList(head);
}
| 1threat |
Mysql: Order an SQL Querry by fastest response Time : So i have a SQL-Querry
```
SELECT number, ResponseTime, TicketCreateTime, round(time_to_sec(timediff(ResponseTime, TicketCreateTime))/60,2) AS FRMins FROM (SELECT TE.id, T.number, T.ticket_id, TE.thread_id, TE.pid, T.created AS TicketCreateTime, TE.created AS ResponseTime, TE.type, TE.staff_id FROM ost_ticket T INNER JOIN ost_thread_entry TE ON T.ticket_id = TE.thread_id WHERE TE.type = 'N' OR TE.type = 'R' AND TE.id IN (SELECT min(id) FROM ost_thread_entry WHERE type = 'N' OR type = 'R' GROUP BY thread_id)) AS FTRT_tbl;
```
[Table][1]
But my goal ist to have only one of the number and it should be this one with the lowest FRMins. I tried it in many diffrent ways, but i don't get it right.
I'm sorry if this is written a little weird. This is my first post and I honestly have no idea how to ask the question well.
[1]: https://i.stack.imgur.com/Z7lM9.png | 0debug |
Wrapping a HTML tag that currently is in a string? : <p>I have HTML as a string, something like:</p>
<pre><code><p>some text</p><p>some more text</p><table><th>....</table>
</code></pre>
<p>I wish to wrap table in a div tag - table could be anywhere.</p>
<p>I've thought about using <code>replace</code> but I would have to replace both the opening table tag and the closing table tag.</p>
<p>Is there a way to just wrap the table element?</p>
<p>Vanilla JS only.</p>
| 0debug |
On button tapping how to back on previous app IOS (Swift)? : On tapping push notification my app launched, now i want go back on previous app on tapping button from my app in (Swift). How do i achieve?
Thanks,
Sanjay | 0debug |
static uint32_t pmac_ide_readw (void *opaque,target_phys_addr_t addr)
{
uint16_t retval;
MACIOIDEState *d = opaque;
addr = (addr & 0xFFF) >> 4;
if (addr == 0) {
retval = ide_data_readw(&d->bus, 0);
} else {
retval = 0xFFFF;
}
retval = bswap16(retval);
return retval;
}
| 1threat |
void err (const char *s)
{
perror (s);
abort ();
}
| 1threat |
VBA macro : find button by location and 'click' them : <p>I'm trying to du a macro. From a row index and a column index detect if there is one or more button on this cell and execute the code attached to this button.</p>
<p>I have not found a 'find_button_by_location' method nor a 'button.execute_as_clicked'</p>
<p>I wonder if anyone can help me with some suggestion.</p>
<p>Thank you</p>
| 0debug |
static void hypercall_init(void)
{
spapr_register_hypercall(H_ENTER, h_enter);
spapr_register_hypercall(H_REMOVE, h_remove);
spapr_register_hypercall(H_PROTECT, h_protect);
spapr_register_hypercall(KVMPPC_H_RTAS, h_rtas);
} | 1threat |
Vue Router hosting on apache2 : <p>I am hosting my vuejs project on apache server.</p>
<ol>
<li>init project</li>
<li>setup router</li>
<li>Build and hosted to apache server </li>
</ol>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const router = new VueRouter({
routes: Routes,
// relative: true,
mode: 'history'
});</code></pre>
</div>
</div>
</p>
<p>This runs fine in local, but vue router breaks on server.
Example</p>
<p>If I run <a href="http://example.com" rel="noreferrer">http://example.com</a> and go to <a href="http://exmaple.com/sub" rel="noreferrer">http://exmaple.com/sub</a>
It works fine</p>
<p>but if I refresh the page It will throw 404 Error.</p>
<p>Error:
<a href="https://i.stack.imgur.com/YCH98.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YCH98.png" alt="enter image description here"></a></p>
| 0debug |
Pycharm: How to focus on Editor when hit a debug point : <p>I am using a mac, with Pycharm version 2018.2.4 Community version.</p>
<p>When I run a debugging session using the debugger and hit a debug point, I have to click on my editor using my mouse to be able to type code on the editor. If I don't do this and hit my keyboard directly, Mac will complain with some "bing" sound, signaling the keyboard input is not valid to any application (my opinion).</p>
<p>How to make my Pycharm auto focus on the editor when hitting the debug point? Or at least focus on the debugger so that I can hit ESC to focus on the editor?</p>
<p>I have selected "Focus application on breakpoint" in the setting.
<a href="https://i.stack.imgur.com/yKOjy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yKOjy.png" alt="enter image description here"></a></p>
| 0debug |
Convert DataFrame into dict : <p><a href="https://i.stack.imgur.com/kErXL.png" rel="nofollow">I use pandas to read df.csv, so I have a Dataframe Like this, </a></p>
<p><a href="https://i.stack.imgur.com/DlogA.png" rel="nofollow">I want to convert it to dict like this</a></p>
| 0debug |
static void filter_mirror_setup(NetFilterState *nf, Error **errp)
{
MirrorState *s = FILTER_MIRROR(nf);
if (!s->outdev) {
error_setg(errp, "filter filter mirror needs 'outdev' "
"property set");
return;
}
s->chr_out = qemu_chr_find(s->outdev);
if (s->chr_out == NULL) {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", s->outdev);
return;
}
if (qemu_chr_fe_claim(s->chr_out) != 0) {
error_setg(errp, QERR_DEVICE_IN_USE, s->outdev);
return;
}
}
| 1threat |
User accessible xml files used in iOS application : <p>I'm building an iOS application which will read in XML files and generate various reports from them. The application must read them from the local device (in this case an iPad Mini 4). Users later may upload new XML files to the device (via non-developer type means and not changing the app's source code in any way). What is a good method for users to upload files to the iPad in a way that my application will have read access to them? Also, any pointers for XML reading in Swift would be beneficial. </p>
<p>I'm using Swift 4.0.3 and XCode 9.2 and while I've been a software developer for a long time, I'm relatively new to iOS development.</p>
| 0debug |
static void do_test_equality(bool expected, int _, ...)
{
va_list ap_count, ap_extract;
QObject **args;
int arg_count = 0;
int i, j;
va_start(ap_count, _);
va_copy(ap_extract, ap_count);
while (va_arg(ap_count, QObject *) != &test_equality_end_of_arguments) {
arg_count++;
}
va_end(ap_count);
args = g_new(QObject *, arg_count);
for (i = 0; i < arg_count; i++) {
args[i] = va_arg(ap_extract, QObject *);
}
va_end(ap_extract);
for (i = 0; i < arg_count; i++) {
g_assert(qobject_is_equal(args[i], args[i]) == true);
for (j = i + 1; j < arg_count; j++) {
g_assert(qobject_is_equal(args[i], args[j]) == expected);
}
}
} | 1threat |
static enum AVHWDeviceType hw_device_match_type_in_name(const char *codec_name)
{
const char *type_name;
enum AVHWDeviceType type;
for (type = av_hwdevice_iterate_types(AV_HWDEVICE_TYPE_NONE);
type != AV_HWDEVICE_TYPE_NONE;
type = av_hwdevice_iterate_types(type)) {
type_name = av_hwdevice_get_type_name(type);
if (strstr(codec_name, type_name))
return type;
}
return AV_HWDEVICE_TYPE_NONE;
}
| 1threat |
String overlapping when a struct : <p>I write a code to enter student information as follows. The problem occurs when the student ID append Lastname.I know that the error lies in entering id and Lastname but I can not understand and fix it</p>
<pre><code>#include "stdio.h"
#include "string.h"
typedef struct Fullname_s{
char Lastname[20];
char Fistname[10];
}Fullname;
typedef struct Birthday_s{
int Day,Month,Year;
}Birthday;
typedef struct Mark_s{
float mark[10];
}Mark;
typedef struct SV{
char ID[8];
Fullname F_name;
Birthday B_day;
char Sex[5];
Mark _Mark;
}sv;
sv s[100];
void inputsv(sv s[],int *n);
void printinfo(int i);
void output(sv s[],int n);
int main(){
int n;
inputsv(s,&n);
output(s,n);
}
void inputsv(sv s[],int *n){
printf("--------Enter Students information--------\n");
printf("Enter number of students \n");
scanf("%d",n);
int i=0;
while(i<*n){
int x;
printf("-------------------------Student %d-------------------------- \n",i+1);
printf("ID Student : ");
fflush(stdin);
scanf("%s",&s[i].ID);
gets();
printf(" Lastname : ");
fgets(s[i].F_name.Lastname,20,stdin);
printf(" Fistname : ");
gets(s[i].F_name.Fistname);
do{
puts("Enter 0 :MALE");
puts("Enter 1 :FEMALE");
scanf("%d",&x);
if(x==0)
strcpy(s[i].Sex,"MALE");
else
strcpy(s[i].Sex,"FEMALE");
}while(x!=0&&x!=1);
printf(" Birthday : ");
scanf("%d%d%d",&s[i].B_day.Day,&s[i].B_day.Month,&s[i].B_day.Year);
for(int j=0;j<10;j++){
printf(" Mark %2d:",j+1);
scanf("%f",&s[i]._Mark.mark[j]);
}
i++;
gets();
}
}
void output(sv s[],int n){
printf("STUDENTS INFORMATION \n");
for(int i=0;i<n;i++){
printf("--------------------\n");
printf(" STUDENT %2d\n",i+1);
printinfo(i);
printf("-------------\n");
}
printf("------------------------\n");
}
void printinfo(int i){
printf(" ID STUDENT :%s\n",s[i].ID);
printf(" FULLNAME :%s %s \n",s[i].F_name.Lastname,s[i].F_name.Fistname);
printf(" BIRTHDAY :%2d-%2d-%4d \n",s[i].B_day.Day,s[i].B_day.Month,s[i].B_day.Year);
printf(" SEX :%s\n",s[i].Sex);
for(int j=0;j<10;j++){
printf(" MARK %2d : %0.2f \n",j+1,s[i]._Mark.mark[j]);
}
}
</code></pre>
<p>Error as in the picture.Thanks all
<a href="https://i.stack.imgur.com/THxZP.jpg" rel="nofollow noreferrer">enter image description here</a></p>
| 0debug |
Powershell parsing json : Hi I am trying to parse this json through powershell
gc .\release.json | ConvertFrom-Json
release.json will have similar content as below
{
"source": 2,
"id": 3487,
"environments": [
{
"id": 11985,
"variables": {
"Var1": { "value": "val1" },
"Var2": { "value": "val2" },
"var3": { "value": "val3" }
}
},
{
"id": 13797,
"variables": {
"Var1": { "value": "val1" },
"Var2": { "value": "val2" },
"var3": { "value": "val3" },
"var4": { "value": "val4" }
}
}
]
}
To get an output like below, I can have many variable in each environment and can have multiple environment. eventually I need to take this to excel and analyse.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/ChrlQ.png
| 0debug |
About embedded firmware development : <p>In the past few days I found how important is RTOS layer on the top of the embedded hardware.
My question is :
Is there any bifurcation between device driver (written in C directly burned over the microcontroller)
And the Linux Device driver ? </p>
| 0debug |
static void acpi_build_update(void *build_opaque)
{
AcpiBuildState *build_state = build_opaque;
AcpiBuildTables tables;
if (!build_state || build_state->patched) {
return;
}
build_state->patched = 1;
acpi_build_tables_init(&tables);
acpi_build(&tables, MACHINE(qdev_get_machine()));
acpi_ram_update(build_state->table_mr, tables.table_data);
if (build_state->rsdp) {
memcpy(build_state->rsdp, tables.rsdp->data, acpi_data_len(tables.rsdp));
} else {
acpi_ram_update(build_state->rsdp_mr, tables.rsdp);
}
acpi_ram_update(build_state->linker_mr, tables.linker);
acpi_build_tables_cleanup(&tables, true);
}
| 1threat |
void helper_fcmpu (uint64_t arg1, uint64_t arg2, uint32_t crfD)
{
CPU_DoubleU farg1, farg2;
uint32_t ret = 0;
farg1.ll = arg1;
farg2.ll = arg2;
if (unlikely(float64_is_nan(farg1.d) ||
float64_is_nan(farg2.d))) {
ret = 0x01UL;
} else if (float64_lt(farg1.d, farg2.d, &env->fp_status)) {
ret = 0x08UL;
} else if (!float64_le(farg1.d, farg2.d, &env->fp_status)) {
ret = 0x04UL;
} else {
ret = 0x02UL;
}
env->fpscr &= ~(0x0F << FPSCR_FPRF);
env->fpscr |= ret << FPSCR_FPRF;
env->crf[crfD] = ret;
if (unlikely(ret == 0x01UL
&& (float64_is_signaling_nan(farg1.d) ||
float64_is_signaling_nan(farg2.d)))) {
fload_invalid_op_excp(POWERPC_EXCP_FP_VXSNAN);
}
}
| 1threat |
static void dwt_encode97_float(DWTContext *s, float *t)
{
int lev,
w = s->linelen[s->ndeclevels-1][0];
float *line = s->f_linebuf;
line += 5;
for (lev = s->ndeclevels-1; lev >= 0; lev--){
int lh = s->linelen[lev][0],
lv = s->linelen[lev][1],
mh = s->mod[lev][0],
mv = s->mod[lev][1],
lp;
float *l;
l = line + mh;
for (lp = 0; lp < lv; lp++){
int i, j = 0;
for (i = 0; i < lh; i++)
l[i] = t[w*lp + i];
sd_1d97_float(line, mh, mh + lh);
for (i = mh; i < lh; i+=2, j++)
t[w*lp + j] = F_LFTG_X * l[i] / 2;
for (i = 1-mh; i < lh; i+=2, j++)
t[w*lp + j] = F_LFTG_K * l[i] / 2;
}
l = line + mv;
for (lp = 0; lp < lh; lp++) {
int i, j = 0;
for (i = 0; i < lv; i++)
l[i] = t[w*i + lp];
sd_1d97_float(line, mv, mv + lv);
for (i = mv; i < lv; i+=2, j++)
t[w*j + lp] = F_LFTG_X * l[i] / 2;
for (i = 1-mv; i < lv; i+=2, j++)
t[w*j + lp] = F_LFTG_K * l[i] / 2;
}
}
}
| 1threat |
which version mariadb can replace mysql 5.7? : <p>I know mariadb 5.3 can replace mysql5.3 with same functions.<br>
Which version mariadb can replace mysql5.7 with same <a href="https://dev.mysql.com/doc/refman/5.7/en/json-function-reference.html" rel="nofollow noreferrer">JSON process functions</a>?</p>
| 0debug |
Controller can't receive model data : <p>Hi I want to grab all user modify data. </p>
<p>My question is why controller can't receive the model data from View in my project.</p>
<p>Please explain why this error was caused and how to solve it.</p>
<p>Models:</p>
<pre><code> public class ShoppingCart
{
public List<ShoppingCartItemModel> items = new List<ShoppingCartItemModel>();
public IEnumerable<ShoppingCartItemModel> Items
{
get { return items; }
}
}
public class ShoppingCartItemModel
{
public Product Product
{
get;
set;
}
public int Quantity { get; set; }
}
</code></pre>
<p>Controller </p>
<pre><code> [HttpPost]
public RedirectToRouteResult EditFromCart(ShoppingCart MyModel)
{
ShoppingCart cart = GetCart();
foreach (var CartItem in cart.items)
{
foreach (var ReceiveModelItem in MyModel.items)
{
if (CartItem.Product.ProductID == ReceiveModelItem.Product.ProductID)
{
CartItem.Quantity = ReceiveModelItem.Quantity;
}
}
}
return RedirectToAction("Index", "ShoppingCart");
}
</code></pre>
<p>View</p>
<pre><code>@model ShoppingCart
@{
ViewBag.Title = "購物車內容";
}
<h2>Index</h2>
<table class="table">
<thead>
<tr>
<th>
Quantity
</th>
<th>
Item
</th>
<th class="text-right">
Price
</th>
<th class="text-right">
Subtotal
</th>
</tr>
</thead>
<tbody>
@using (Html.BeginForm("EditFromCart", "ShoppingCart", FormMethod.Post))
{
foreach (var item in Model.items)
{
<tr>
<td class="text-center">
@item.Product.ProductName
</td>
<td class="text-center">
@item.Product.Price.ToString("c")
</td>
<td class="text-center">
@( (item.Quantity * item.Product.Price).ToString("c"))
</td>
<td class="text-left">
@Html.EditorFor(model => item.Quantity, null, "UserInputQuantity")
@Html.Hidden("ProductId", item.Product.ProductID)
</td>
</tr>
}
<tr>
<td colspan="3">
<input class="btn btn-warning" type="submit" value="Edit">
</td>
</tr>
}
</tbody>
</table>
</code></pre>
| 0debug |
static int mxf_read_source_clip(MXFStructuralComponent *source_clip, ByteIOContext *pb, int tag)
{
switch(tag) {
case 0x0202:
source_clip->duration = get_be64(pb);
break;
case 0x1201:
source_clip->start_position = get_be64(pb);
break;
case 0x1101:
url_fskip(pb, 16);
get_buffer(pb, source_clip->source_package_uid, 16);
break;
case 0x1102:
source_clip->source_track_id = get_be32(pb);
break;
}
return 0;
}
| 1threat |
static void mxf_write_preface(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
mxf_write_metadata_key(pb, 0x012f00);
PRINT_KEY(s, "preface key", pb->buf_ptr - 16);
klv_encode_ber_length(pb, 130 + 16 * mxf->essence_container_count);
mxf_write_local_tag(pb, 16, 0x3C0A);
mxf_write_uuid(pb, Preface, 0);
PRINT_KEY(s, "preface uid", pb->buf_ptr - 16);
mxf_write_local_tag(pb, 8, 0x3B02);
avio_wb64(pb, mxf->timestamp);
mxf_write_local_tag(pb, 2, 0x3B05);
avio_wb16(pb, 258);
mxf_write_local_tag(pb, 16 + 8, 0x3B06);
mxf_write_refs_count(pb, 1);
mxf_write_uuid(pb, Identification, 0);
mxf_write_local_tag(pb, 16, 0x3B03);
mxf_write_uuid(pb, ContentStorage, 0);
mxf_write_local_tag(pb, 16, 0x3B09);
avio_write(pb, op1a_ul, 16);
mxf_write_local_tag(pb, 8 + 16 * mxf->essence_container_count, 0x3B0A);
mxf_write_essence_container_refs(s);
mxf_write_local_tag(pb, 8, 0x3B0B);
avio_wb64(pb, 0);
}
| 1threat |
Jquery clear form after submission success : <p>Let's say we have a code like this:</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
$("#signup").click(function(e) {
e.preventDefault();
var email = $("#email").val();
var fname = $("#fname").val();
$.post("signup.php", {email:email, fname:fname}, function(data) {
$("#result").html(data);
});
return false;
});
});
</script>
</code></pre>
<p>After clicking the submit button, we can get an error message
if the fields are not properly filled, in that case, the form can still
retain the values, but if "submission successful" message was returned,
how do I conditionally reset the form fields</p>
| 0debug |
How to set the CSS content property with a Google Material Icon? : <p>How can I insert the Google Material Icon "chevron icon right" (<a href="https://design.google.com/icons/#ic_chevron_right" rel="noreferrer">https://design.google.com/icons/#ic_chevron_right</a>) in the following CSS content property:</p>
<pre><code>.bullet li a:before {
content: "";
}
</code></pre>
| 0debug |
Bootstrap-vue doesn't load CSS : <p>I am writing a Vue.js app with Bootstrap 4 and I can't loaded though I followed the documentation.</p>
<p>Added to main.js</p>
<p><code>Vue.use(BootstrapVue);</code></p>
<p>Added to css file related to App.vue:</p>
<pre><code>@import '../../node_modules/bootstrap/dist/css/bootstrap.css';
@import '../../node_modules/bootstrap-vue/dist/bootstrap-vue.css';
</code></pre>
<p>Here is template:</p>
<pre><code><div class="main">
<div>
<b-modal id="modal1" title="Something went wrong" v-if="!serverStatusOk">
<p class="my-4">{{msg}}</p>
<p class="my-4">{{statusCode}}</p>
</b-modal>
</div>
<div>
<b-tab title="Players" active>
<br>Players data
</b-tab>
<b-tab title="Tournaments" active>
<br>Tournament data
</b-tab>
</div>
</code></pre>
<p></p>
<p>Result: no css rendered but in css file from dist dir I see Bootstrap
What am I missing? The project created by vue-cli 3.0-beta</p>
| 0debug |
static void ahci_migrate(AHCIQState *from, AHCIQState *to, const char *uri)
{
QOSState *tmp = to->parent;
QPCIDevice *dev = to->dev;
char *uri_local = NULL;
if (uri == NULL) {
uri_local = g_strdup_printf("%s%s", "unix:", mig_socket);
uri = uri_local;
}
migrate(from->parent, to->parent, uri);
memcpy(to, from, sizeof(AHCIQState));
to->parent = tmp;
to->dev = dev;
tmp = from->parent;
dev = from->dev;
memset(from, 0x00, sizeof(AHCIQState));
from->parent = tmp;
from->dev = dev;
verify_state(to);
g_free(uri_local);
}
| 1threat |
static int scsi_disk_emulate_mode_sense(SCSIDiskReq *r, uint8_t *outbuf)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint64_t nb_sectors;
bool dbd;
int page, buflen, ret, page_control;
uint8_t *p;
uint8_t dev_specific_param;
dbd = (r->req.cmd.buf[1] & 0x8) != 0;
page = r->req.cmd.buf[2] & 0x3f;
page_control = (r->req.cmd.buf[2] & 0xc0) >> 6;
DPRINTF("Mode Sense(%d) (page %d, xfer %zd, page_control %d)\n",
(r->req.cmd.buf[0] == MODE_SENSE) ? 6 : 10, page, r->req.cmd.xfer, page_control);
memset(outbuf, 0, r->req.cmd.xfer);
p = outbuf;
if (s->qdev.type == TYPE_DISK) {
dev_specific_param = s->features & (1 << SCSI_DISK_F_DPOFUA) ? 0x10 : 0;
if (bdrv_is_read_only(s->qdev.conf.bs)) {
dev_specific_param |= 0x80;
}
} else {
dev_specific_param = 0x00;
dbd = true;
}
if (r->req.cmd.buf[0] == MODE_SENSE) {
p[1] = 0;
p[2] = dev_specific_param;
p[3] = 0;
p += 4;
} else {
p[2] = 0;
p[3] = dev_specific_param;
p[6] = p[7] = 0;
p += 8;
}
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
if (!dbd && nb_sectors) {
if (r->req.cmd.buf[0] == MODE_SENSE) {
outbuf[3] = 8;
} else {
outbuf[7] = 8;
}
nb_sectors /= (s->qdev.blocksize / 512);
if (nb_sectors > 0xffffff) {
nb_sectors = 0;
}
p[0] = 0;
p[1] = (nb_sectors >> 16) & 0xff;
p[2] = (nb_sectors >> 8) & 0xff;
p[3] = nb_sectors & 0xff;
p[4] = 0;
p[5] = 0;
p[6] = s->qdev.blocksize >> 8;
p[7] = 0;
p += 8;
}
if (page_control == 3) {
scsi_check_condition(r, SENSE_CODE(SAVING_PARAMS_NOT_SUPPORTED));
return -1;
}
if (page == 0x3f) {
for (page = 0; page <= 0x3e; page++) {
mode_sense_page(s, page, &p, page_control);
}
} else {
ret = mode_sense_page(s, page, &p, page_control);
if (ret == -1) {
return -1;
}
}
buflen = p - outbuf;
if (r->req.cmd.buf[0] == MODE_SENSE) {
outbuf[0] = buflen - 1;
} else {
outbuf[0] = ((buflen - 2) >> 8) & 0xff;
outbuf[1] = (buflen - 2) & 0xff;
}
return buflen;
}
| 1threat |
Android Studio - Kotlin Tests Throwing - Class not found - Empty test suite : <p>When trying to run espresso tests written in Kotlin on Android Studio (as far as 3.2 Canary 9), I'm getting the error:
Process finished with exit code 1
Class not found: "com.myproject.directoryofwinning.VerifyAppIsAwesomeTest"Empty test suite.</p>
<p>Strangely, Java tests in the same project have no issues.</p>
<p>Have tried to reset the configurations and suggested by others, but this doesn't seem to make any difference.</p>
| 0debug |
def chkList(lst):
return len(set(lst)) == 1 | 0debug |
How to reset value of Bootstrap-select after button click : <p>I am using Bootstrap-select plugin (<a href="https://silviomoreto.github.io/bootstrap-select/" rel="noreferrer">https://silviomoreto.github.io/bootstrap-select/</a>) for my dropdown select box. After I click a button, I want the box to refresh and the "selected" option to reset. This is the dropdown</p>
<pre><code><select id="dataPicker" class="selectpicker form-control">
<option value="default" selected="selected">Default</option>
<option value="one">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
</select>
</code></pre>
<p>And this is my attempt at it, does not work. Any ideas on how it should be?</p>
<pre><code>$("#dataPicker option:selected").val('default');
$("#dataPicker").selectpicker("refresh");
</code></pre>
| 0debug |
Why did all div appear under each other? : <p>I am not asking this because it's a problem for me, actually, that's exactly how I wanted to display the divs, but I didn't know they would appear below each other. Why is that? I only gave them width and height, I didn't position them.
I thought they would appear on each other at the same position</p>
<pre><code><div class="D1">
</div>
<div class="D2">
</div>
<div class="D3">
</div>
<div class="D4">
</div>
.D1,.D2,.D3,.D4{
border:1px solid;
border-color:red;
width:500px;
height:200px;
}
/* OR
div{
border:1px solid;
border-color:red;
width:500px;
height:200px;
}
*/
</code></pre>
<p>Sorry for this probably dumb question, but I'm just curious :D</p>
| 0debug |
static uint64_t ich_elrsr_read(CPUARMState *env, const ARMCPRegInfo *ri)
{
GICv3CPUState *cs = icc_cs_from_env(env);
uint64_t value = 0;
int i;
for (i = 0; i < cs->num_list_regs; i++) {
uint64_t lr = cs->ich_lr_el2[i];
if ((lr & ICH_LR_EL2_STATE_MASK) == 0 &&
((lr & ICH_LR_EL2_HW) == 1 || (lr & ICH_LR_EL2_EOI) == 0)) {
value |= (1 << i);
}
}
trace_gicv3_ich_elrsr_read(gicv3_redist_affid(cs), value);
return value;
}
| 1threat |
How can I center the title of navigation drawer application (Android studio)? : How can I change the title position of nevigation drawer application (Android studio)? | 0debug |
Add name os file to Array of strings : I have this code witch detect file on usb, I want to add the name of the files to array list of strings, how can I continue?
final String CP = "cp ";
final String DEST = " /home/user/Desktop";
final String TERMINAL_COMMAND = "ls /media/user/";
String USB_UUID = null;
//System.out.println(TERMINAL_COMMAND);
try {
Process p = Runtime.getRuntime().exec( TERMINAL_COMMAND );
BufferedReader in = new BufferedReader(
new InputStreamReader(p.getInputStream()) );
while ((USB_UUID = in.readLine()) != null) {
//System.out.println(USB_UUID);
final String FILETOSTART = "/media/user/"+USB_UUID;
}
in.close();
} | 0debug |
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
{
int ret = 0;
AVDictionary *tmp = NULL;
if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
return AVERROR(EINVAL);
if (options)
av_dict_copy(&tmp, *options, 0);
if (ff_lockmgr_cb) {
if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
return -1;
entangled_thread_counter++;
if(entangled_thread_counter != 1){
av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
goto end;
if(avctx->codec || !codec) {
ret = AVERROR(EINVAL);
goto end;
avctx->internal = av_mallocz(sizeof(AVCodecInternal));
if (!avctx->internal) {
ret = AVERROR(ENOMEM);
goto end;
if (codec->priv_data_size > 0) {
if(!avctx->priv_data){
avctx->priv_data = av_mallocz(codec->priv_data_size);
if (!avctx->priv_data) {
ret = AVERROR(ENOMEM);
goto end;
if (codec->priv_class) {
*(AVClass**)avctx->priv_data= codec->priv_class;
av_opt_set_defaults(avctx->priv_data);
if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp)) < 0)
} else {
avctx->priv_data = NULL;
if ((ret = av_opt_set_dict(avctx, &tmp)) < 0)
if(!( avctx->coded_width && avctx->coded_height && avctx->width && avctx->height && avctx->codec_id == CODEC_ID_H264)){
if(avctx->coded_width && avctx->coded_height)
avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
else if(avctx->width && avctx->height)
avcodec_set_dimensions(avctx, avctx->width, avctx->height);
if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
&& ( av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx) < 0
|| av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)) {
av_log(avctx, AV_LOG_WARNING, "ignoring invalid width/height values\n");
avcodec_set_dimensions(avctx, 0, 0);
if (codec->decode)
av_freep(&avctx->subtitle_header);
#define SANE_NB_CHANNELS 128U
if (avctx->channels > SANE_NB_CHANNELS) {
ret = AVERROR(EINVAL);
avctx->codec = codec;
if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
avctx->codec_id == CODEC_ID_NONE) {
avctx->codec_type = codec->type;
avctx->codec_id = codec->id;
if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type
&& avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
av_log(avctx, AV_LOG_ERROR, "codec type or id mismatches\n");
ret = AVERROR(EINVAL);
avctx->frame_number = 0;
#if FF_API_ER
av_log(avctx, AV_LOG_DEBUG, "err{or,}_recognition separate: %d; %X\n",
avctx->error_recognition, avctx->err_recognition);
switch(avctx->error_recognition){
case FF_ER_EXPLODE : avctx->err_recognition |= AV_EF_EXPLODE | AV_EF_COMPLIANT | AV_EF_CAREFUL;
break;
case FF_ER_VERY_AGGRESSIVE:
case FF_ER_AGGRESSIVE : avctx->err_recognition |= AV_EF_AGGRESSIVE;
case FF_ER_COMPLIANT : avctx->err_recognition |= AV_EF_COMPLIANT;
case FF_ER_CAREFUL : avctx->err_recognition |= AV_EF_CAREFUL;
av_log(avctx, AV_LOG_DEBUG, "err{or,}_recognition combined: %d; %X\n",
avctx->error_recognition, avctx->err_recognition);
#endif
if (!HAVE_THREADS)
av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
if (HAVE_THREADS && !avctx->thread_opaque) {
ret = ff_thread_init(avctx);
if (ret < 0) {
if (!HAVE_THREADS && !(codec->capabilities & CODEC_CAP_AUTO_THREADS))
avctx->thread_count = 1;
if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) {
av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
avctx->codec->max_lowres);
ret = AVERROR(EINVAL);
if (avctx->codec->encode) {
int i;
if (avctx->codec->sample_fmts) {
for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
break;
if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
ret = AVERROR(EINVAL);
if (avctx->codec->supported_samplerates) {
for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++)
if (avctx->sample_rate == avctx->codec->supported_samplerates[i])
break;
if (avctx->codec->supported_samplerates[i] == 0) {
av_log(avctx, AV_LOG_ERROR, "Specified sample_rate is not supported\n");
ret = AVERROR(EINVAL);
if (avctx->codec->channel_layouts) {
if (!avctx->channel_layout) {
av_log(avctx, AV_LOG_WARNING, "channel_layout not specified\n");
} else {
for (i = 0; avctx->codec->channel_layouts[i] != 0; i++)
if (avctx->channel_layout == avctx->codec->channel_layouts[i])
break;
if (avctx->codec->channel_layouts[i] == 0) {
av_log(avctx, AV_LOG_ERROR, "Specified channel_layout is not supported\n");
ret = AVERROR(EINVAL);
if (avctx->channel_layout && avctx->channels) {
if (av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) {
av_log(avctx, AV_LOG_ERROR, "channel layout does not match number of channels\n");
ret = AVERROR(EINVAL);
} else if (avctx->channel_layout) {
avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
avctx->pts_correction_num_faulty_pts =
avctx->pts_correction_num_faulty_dts = 0;
avctx->pts_correction_last_pts =
avctx->pts_correction_last_dts = INT64_MIN;
if(avctx->codec->init && !(avctx->active_thread_type&FF_THREAD_FRAME)){
ret = avctx->codec->init(avctx);
if (ret < 0) {
ret=0;
end:
entangled_thread_counter--;
if (ff_lockmgr_cb) {
(*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);
if (options) {
av_dict_free(options);
*options = tmp;
return ret;
free_and_end:
av_dict_free(&tmp);
av_freep(&avctx->priv_data);
av_freep(&avctx->internal);
avctx->codec= NULL;
goto end; | 1threat |
Authentication for Azure Functions : <p>I've spent the past 24 hours reading all about how to create Azure Functions and have successfully converted a MVC WebApi over to a new Function App with multiple functions. My problem is that I've not found any clear documentation or tutorials on how to do the most basic of authentication with them. </p>
<p>My scenario is pretty straight forward. Provision users in my AAD, then grant those users access to specific functions. Users on a website will click on UI elements that in turn trigger Javascript that calls my Azure Functions. In the function I need to be able to verify their identity somehow as I'll be passing that along to other functions that interact with a SQL instance. </p>
<p>Can someone please point me at docs, articles, an example, something, that shows how I can achieve this? </p>
<p>For the record I've found in the portal the "Authentication" config for my Function App and have chosen AAD as my Authentication Provider. I've added my Function App to it and have provisioned a few users. I've then wrote the following test function:</p>
<pre><code>[FunctionName("GetThings")]
public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.User, "GET", Route = null)]HttpRequestMessage req, TraceWriter log)
{
log.Info("Getting all the things");
var identity = ClaimsPrincipal.Current.Identity;
return identity.IsAuthenticated ?
req.CreateResponse(HttpStatusCode.Unauthorized, "Not authenticated!") :
req.CreateResponse(HttpStatusCode.OK, $"Hi {identity.Name}!");
}
</code></pre>
<p>Currently when trying to hit the endpoint directly I get redirected to a login page... so I guess that part is working. How I generate / retrieve user tokens, send them along on the request to the functions, or process them on the server isn't clear to me though. </p>
<p>Help?</p>
| 0debug |
static void rtas_quiesce(sPAPREnvironment *spapr, uint32_t token,
uint32_t nargs, target_ulong args,
uint32_t nret, target_ulong rets)
{
VIOsPAPRBus *bus = spapr->vio_bus;
BusChild *kid;
VIOsPAPRDevice *dev = NULL;
if (nargs != 0) {
rtas_st(rets, 0, -3);
return;
}
QTAILQ_FOREACH(kid, &bus->bus.children, sibling) {
dev = (VIOsPAPRDevice *)kid->child;
spapr_vio_quiesce_one(dev);
}
rtas_st(rets, 0, 0);
}
| 1threat |
(Swift) Initializer for conditional binding must have Optional type, not 'AVAudioInputNode' : <p>I am trying to create a speech to text function and I am getting the error:</p>
<p><code>Initializer for conditional binding must have Optional type, not 'AVAudioInputNode'</code></p>
<pre><code>guard let inputNode = audioEngine.inputNode else {
fatalError("Audio engine has no input node")
}
</code></pre>
| 0debug |
value of optional type 'String?' not unwrapped;did you mean to use '!'or '?'? : my code is below:
@IBAction func registerButtonTapped(sender: AnyObject)
{
let userEmail = userEmailTextField.text;
let userPassword = userPasswordTextField.text;
let userConfirmPassword = confirmPasswordTextField.text;
//check for empty fields
if userEmail.isEmpty || userPassword.isEmpty || userConfirmPassword.isEmpty
{
//Display alert message
displayMyAlertMessage("All fields are required");
return ;
}
| 0debug |
What is the best way to debug jQuery selector? : <pre><code><div id="chart2Carousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active"><div class="chartjs-size-monitor"><div class="chartjs-size-monitor-expand"><div class=""></div></div><div class="chartjs-size-monitor-shrink"><div class=""></div></div></div>
<canvas width="683" height="341" id="chart2" class="chartjs-render-monitor" style="display: block; width: 683px; height: 341px;"></canvas>
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#chart2Carousel" data-slide="prev">
<span class="fa fa-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#chart2Carousel" data-slide="next" style="display: block;">
<span class="fa fa-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</code></pre>
<p>I've tried </p>
<p>//selectedChart = chart2 </p>
<pre><code>$('#' + selectedChart).closest(".carousel-inner").find(".left.carousel-control").hide();
</code></pre>
<p>Why does it not working ? </p>
<p><strong>What is the best way to debug jQuery selector ?</strong> </p>
| 0debug |
int page_unprotect(target_ulong address, uintptr_t pc)
{
unsigned int prot;
bool current_tb_invalidated;
PageDesc *p;
target_ulong host_start, host_end, addr;
mmap_lock();
p = page_find(address >> TARGET_PAGE_BITS);
if (!p) {
mmap_unlock();
return 0;
}
if ((p->flags & PAGE_WRITE_ORG) && !(p->flags & PAGE_WRITE)) {
host_start = address & qemu_host_page_mask;
host_end = host_start + qemu_host_page_size;
prot = 0;
current_tb_invalidated = false;
for (addr = host_start ; addr < host_end ; addr += TARGET_PAGE_SIZE) {
p = page_find(addr >> TARGET_PAGE_BITS);
p->flags |= PAGE_WRITE;
prot |= p->flags;
current_tb_invalidated |= tb_invalidate_phys_page(addr, pc);
#ifdef CONFIG_USER_ONLY
if (DEBUG_TB_CHECK_GATE) {
tb_invalidate_check(addr);
}
#endif
}
mprotect((void *)g2h(host_start), qemu_host_page_size,
prot & PAGE_BITS);
mmap_unlock();
return current_tb_invalidated ? 2 : 1;
}
mmap_unlock();
return 0;
}
| 1threat |
int av_packet_ref(AVPacket *dst, AVPacket *src)
{
int ret;
ret = av_packet_copy_props(dst, src);
if (ret < 0)
return ret;
if (!src->buf) {
ret = packet_alloc(&dst->buf, src->size);
if (ret < 0)
goto fail;
memcpy(dst->buf->data, src->data, src->size);
} else
dst->buf = av_buffer_ref(src->buf);
dst->size = src->size;
dst->data = dst->buf->data;
return 0;
fail:
av_packet_free_side_data(dst);
return ret;
}
| 1threat |
How to use Vuetify tabs with vue-router : <p>I have the following <a href="https://jsfiddle.net/jjloneman/e5a6L27u/12/" rel="noreferrer">jsfiddle</a> that has two Vuetify tabs. The documentation doesn't show examples on using <code>vue-router</code> with them.</p>
<p>I found this <a href="https://medium.com/front-end-hacking/vue-js-mobile-navbar-using-vuetify-803856f00dfd" rel="noreferrer">Medium.com post</a> on how to use Vuetify with <code>vue-router</code>, which has the following code:</p>
<pre><code><div id="app">
<v-tabs grow light>
<v-tabs-bar>
<v-tabs-item href="/" router>
<v-icon>motorcycle</v-icon>
</v-tabs-item>
<v-tabs-item href="/dog" router>
<v-icon>pets</v-icon>
</v-tabs-item>
</v-tabs-bar>
</v-tabs>
<router-view />
</div>
</code></pre>
<p>However, the code is now outdated as the <a href="https://vuetifyjs.com/en/components/tabs" rel="noreferrer">Vuetify 1.0.13 Tabs documentation</a> doesn't specify a <code>router</code> prop in their api, so the embedded example in the post doesn't work.</p>
<p>I also found this <a href="https://stackoverflow.com/questions/46710477/vue-vuetify-how-to-add-router-link-to-tab">StackOverflow answer</a> which had the following code:</p>
<pre><code><v-tabs-item :to="{path:'/path/to/somewhere'}">
</code></pre>
<p>However, using the <code>to</code> prop doesn't work and it's also not listed in the Vuetify api. In contrast, the <code>v-button</code> Vuetify component does list a <code>to</code> prop and utilizes <code>vue-router</code>, so I would expect a <code>vue-router</code> supported component to support the <code>to</code> prop.</p>
<p>Digging around in the old <a href="https://vuetifyjs.com/releases/0.17/#/components/tabs#api" rel="noreferrer">old Vuetify 0.17 docs</a>, the <code>to</code> prop is specified for <code>v-tabs-item</code>. It seems that support might have been removed in 1.0.13.</p>
<p>How can I use <code>vue-router</code> with Vuetify tabs?</p>
| 0debug |
display 7 string variables in a toast : I wanna display the information of 7 edit texts in a toast so I put the edit texts information in 7 string variables but I don't know how
Here is what I written:
public class MainActivity extends Activity {
EditText ed1;
EditText ed2;
EditText ed3;
EditText ed4;
EditText ed5;
EditText ed6;
EditText ed7;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
showinfo();
}
private void showinfo() {
ed1= (EditText) findViewById(R.id.editText1);
ed2= (EditText) findViewById(R.id.editText2);
ed3= (EditText) findViewById(R.id.editText3);
ed4= (EditText) findViewById(R.id.editText4);
ed5= (EditText) findViewById(R.id.editText5);
ed6= (EditText) findViewById(R.id.editText6);
ed7= (EditText) findViewById(R.id.editText7);
btn= (Button) findViewById(R.id.button1);
///////
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String str1 = ed1.getText().toString();
String str2 = ed2.getText().toString();
String str3 = ed3.getText().toString();
String str4 = ed4.getText().toString();
String str5 = ed5.getText().toString();
String str6 = ed6.getText().toString();
String str7 = ed7.getText().toString();
////////////
Toast.makeText(getApplicationContext(), ,Toast.LENGTH_LONG).show();
}
});
}
how can I display all the string variables in toast? | 0debug |
Why is my Array's Value Undefined? (Javascript) : <p>I'm trying to console.log one of the items in my "images" array. Here's the code I have written so far:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var projects = {
projects : [
{
"title" : "Jarvis Systems",
"dates" : "2015",
"description" : "A simple control panel for stuff.",
"images" : ["http://www.bitrebels.com/wp-content/uploads/2013/10/MAKO-Voice-Recognition-System-3.jpg", "https://i.ytimg.com/vi/ah6tHb7eWBY/maxresdefault.jpg"]
}
]
};
console.log(projects.projects.images[0])</code></pre>
</div>
</div>
</p>
<p>Sadly, when I run the code, the console says that my array is undefined. How can that be when I just defined it?</p>
| 0debug |
How to get websockets working in Elm 0.19 : <p>I am trying to upgrade from version 0.18 to 0.19 of Elm. My project depends on <code>elm-lang/websocket</code> in 0.18? I cannot seem to find the equivalent package in 0.19. What am I missing?</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.