problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
How can I make a generic TypeScript interface extend from another generic interface? : <p>I have an interface, with several elements:</p>
<pre><code>export interface Item {
id: string;
code: string;
createdAt: string;
updatedAt: string;
level: number;
seq: number;
hasChildren: boolean;
parentObject?: Item;
children?: Item[];
}
</code></pre>
<p>I wanted something like the <code>Partial<T></code> which I helpfully discovered here:
<a href="https://stackoverflow.com/questions/39713349/make-all-properties-within-a-typescript-interface-optional#40076355">Make all properties within a Typescript interface optional</a></p>
<p>However, I would like to make <strong>one</strong> of the fields mandatory. I implemented this:</p>
<pre><code>export interface ItemUpdate extends Partial<Item> {
id: string;
}
</code></pre>
<p>and that compiled well. However, I would like to avoid declaring it for each interface. For that, I made it more generic:</p>
<pre><code>export interface UpdateOf<T> extends Partial<T> {
id: string; // the ID is the only mandatory value for an update
}
</code></pre>
<p>However, that is no longer compiling, returning the following error:</p>
<pre><code>error TS2312: An interface may only extend a class or another interface.
</code></pre>
<p>I am running Angular 6.1.5, which comes with Typescript 2.9 (as far as I know).</p>
| 0debug
|
static void ffmpeg_cleanup(int ret)
{
int i, j;
if (do_benchmark) {
int maxrss = getmaxrss() / 1024;
printf("bench: maxrss=%ikB\n", maxrss);
}
for (i = 0; i < nb_filtergraphs; i++) {
FilterGraph *fg = filtergraphs[i];
avfilter_graph_free(&fg->graph);
for (j = 0; j < fg->nb_inputs; j++) {
av_freep(&fg->inputs[j]->name);
av_freep(&fg->inputs[j]);
}
av_freep(&fg->inputs);
for (j = 0; j < fg->nb_outputs; j++) {
av_freep(&fg->outputs[j]->name);
av_freep(&fg->outputs[j]);
}
av_freep(&fg->outputs);
av_freep(&fg->graph_desc);
av_freep(&filtergraphs[i]);
}
av_freep(&filtergraphs);
av_freep(&subtitle_out);
for (i = 0; i < nb_output_files; i++) {
OutputFile *of = output_files[i];
AVFormatContext *s = of->ctx;
if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb)
avio_closep(&s->pb);
avformat_free_context(s);
av_dict_free(&of->opts);
av_freep(&output_files[i]);
}
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
AVBitStreamFilterContext *bsfc = ost->bitstream_filters;
while (bsfc) {
AVBitStreamFilterContext *next = bsfc->next;
av_bitstream_filter_close(bsfc);
bsfc = next;
}
ost->bitstream_filters = NULL;
av_frame_free(&ost->filtered_frame);
av_frame_free(&ost->last_frame);
av_parser_close(ost->parser);
av_freep(&ost->forced_keyframes);
av_expr_free(ost->forced_keyframes_pexpr);
av_freep(&ost->avfilter);
av_freep(&ost->logfile_prefix);
av_freep(&ost->audio_channels_map);
ost->audio_channels_mapped = 0;
avcodec_free_context(&ost->enc_ctx);
av_freep(&output_streams[i]);
}
#if HAVE_PTHREADS
free_input_threads();
#endif
for (i = 0; i < nb_input_files; i++) {
avformat_close_input(&input_files[i]->ctx);
av_freep(&input_files[i]);
}
for (i = 0; i < nb_input_streams; i++) {
InputStream *ist = input_streams[i];
av_frame_free(&ist->decoded_frame);
av_frame_free(&ist->filter_frame);
av_dict_free(&ist->decoder_opts);
avsubtitle_free(&ist->prev_sub.subtitle);
av_frame_free(&ist->sub2video.frame);
av_freep(&ist->filters);
av_freep(&ist->hwaccel_device);
avcodec_free_context(&ist->dec_ctx);
av_freep(&input_streams[i]);
}
if (vstats_file)
fclose(vstats_file);
av_freep(&vstats_filename);
av_freep(&input_streams);
av_freep(&input_files);
av_freep(&output_streams);
av_freep(&output_files);
uninit_opts();
avformat_network_deinit();
if (received_sigterm) {
av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n",
(int) received_sigterm);
} else if (ret && transcode_init_done) {
av_log(NULL, AV_LOG_INFO, "Conversion failed!\n");
}
term_exit();
}
| 1threat
|
Front-End Website learning sources : <p>I've seen a lot of awesome websites from Awwwarrds ranking and trying to learn how they made their websites, all their effects are just wonderful and beautiful. But I have no clue how to do something similar, I understand this involves a lot of javascript. Is there somewhere on the internet I can learn how to achieve this? I only understand javascript to the part of using packages like JQuery.
For <a href="https://www.fisheyegallery.fr/" rel="nofollow noreferrer">example</a> what i saw.</p>
<p>I just want to know where I can learn the basic of this effects, and able to make something great as they can.Any recommend source?</p>
| 0debug
|
Android app crashes when trying to add data to sqlite database : <p>So I've created an sqlite database table which I checked was created. However the app crashes every time I try to add data. I have another similar table that is implemented the same way and works just fine so I'm guessing the problem is somewhere in the button?</p>
<p>My Database class:</p>
<pre><code>package com.example.drivopro.drivopro;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.ArrayList;
import java.util.List;
public class DatabaseHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "Company.db";
//My company table
public static final String TABLE_ME = "TABLE_ME";
public static final String MY_ID = "ID";
public static final String MY_NAME = "NAME";
public static final String MY_ADDRESS = "ADDRESS";
public static final String MY_ZIP = "ZIPCODE";
public static final String MY_CITY = "CITY";
public static final String MY_PHONE = "PHONE";
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_ME + "(ID INTEGER PRIMARY KEY AUTOINCREMENT,NAME TEXT,ADDRESS TEXT,ZIPCODE TEXT,CITY TEXT,PHONE TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_ME);
onCreate(db);
}
public boolean insertMyCompany(String name, String address, String zipcode, String city, String phone) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(MY_NAME, name);
contentValues.put(MY_ADDRESS, address);
contentValues.put(MY_ZIP, zipcode);
contentValues.put(MY_CITY, city);
contentValues.put(MY_PHONE, phone);
long result = db.insert(TABLE_ME, null, contentValues);
if (result == -1)
return false;
else
return true;
}
}
</code></pre>
<p>Activity I'm working with:</p>
<pre><code>package com.example.drivopro.drivopro;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class ModifyCompanyInfo extends AppCompatActivity {
DatabaseHelper myDb;
Button btnsave;
EditText changeName, changeAddress, changeZip, changeCity, changePhone;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_modify_company_info);
btnsave = (Button)findViewById(R.id.saveComp);
changeName = (EditText)findViewById(R.id.myName);
changeAddress = (EditText)findViewById(R.id.myAddress);
changeZip = (EditText)findViewById(R.id.myZip);
changeCity = (EditText)findViewById(R.id.myCity);
changePhone = (EditText)findViewById(R.id.myPhone);
addData();
}
public void addData(){
btnsave.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isInserted = myDb.insertMyCompany(changeName.getText().toString(),
changeAddress.getText().toString(),
changeZip.getText().toString(),
changeCity.getText().toString(),
changePhone.getText().toString());
if(isInserted)
Toast.makeText(ModifyCompanyInfo.this, "Tietoja muutettu", Toast.LENGTH_LONG).show();
else
Toast.makeText(ModifyCompanyInfo.this, "Mitään ei tapahtunut", Toast.LENGTH_LONG).show();
}
}
);
}
}
</code></pre>
<p>And the XML:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.drivopro.drivopro.ModifyCompanyInfo">
<EditText
android:id="@+id/myName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Nimi"
android:inputType="textPersonName"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintVertical_bias="0.084" />
<EditText
android:id="@+id/myAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Osoite"
android:inputType="textPersonName"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.503"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintTop_toBottomOf="@+id/myName" />
<EditText
android:id="@+id/myZip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Postinumero"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.503"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/myAddress"
android:layout_marginBottom="-1dp"
app:layout_constraintVertical_bias="0.0" />
<EditText
android:id="@+id/myCity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Kaupunki"
android:inputType="textPersonName"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="7dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/myZip"
app:layout_constraintVertical_bias="0.0" />
<EditText
android:id="@+id/myPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="142dp"
android:ems="10"
android:hint="Puhelinnumero"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/myCity"
app:layout_constraintVertical_bias="0.0" />
<Button
android:id="@+id/cancelChanges"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="poistu"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_bias="0.75"
app:layout_constraintVertical_bias="0.691" />
<Button
android:id="@+id/saveComp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:text="Save"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.253"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.691" />
</android.support.constraint.ConstraintLayout>
</code></pre>
<p>Any help appreciated. Thanks in advance!</p>
| 0debug
|
static int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov,
AVFormatContext *s)
{
int i;
offset_t pos = url_ftell(pb);
put_be32(pb, 0);
put_tag(pb, "moov");
mov->timescale = globalTimescale;
for (i=0; i<MAX_STREAMS; i++) {
if(mov->tracks[i].entry <= 0) continue;
if(mov->tracks[i].enc->codec_type == CODEC_TYPE_VIDEO) {
mov->tracks[i].timescale = mov->tracks[i].enc->time_base.den;
mov->tracks[i].sampleDuration = mov->tracks[i].enc->time_base.num;
} else if(mov->tracks[i].enc->codec_type == CODEC_TYPE_AUDIO) {
mov->tracks[i].timescale = mov->tracks[i].enc->sample_rate;
mov->tracks[i].sampleDuration = mov->tracks[i].enc->frame_size;
}
mov->tracks[i].trackDuration =
(int64_t)mov->tracks[i].sampleCount * mov->tracks[i].sampleDuration;
mov->tracks[i].time = mov->time;
mov->tracks[i].trackID = i+1;
}
mov_write_mvhd_tag(pb, mov);
for (i=0; i<MAX_STREAMS; i++) {
if(mov->tracks[i].entry > 0) {
mov_write_trak_tag(pb, &(mov->tracks[i]));
}
}
if (mov->mode == MODE_PSP)
mov_write_uuidusmt_tag(pb, s);
else
mov_write_udta_tag(pb, mov, s);
return updateSize(pb, pos);
}
| 1threat
|
what's wrong with this simple code : `public static void main (String[] args) {
Scanner input = new Scanner(System.in);
int[] array = new int[5];
System.out.print("Please enter five numbers. \na=");
array[0] = input.nextInt();
System.out.print("\nb=");
array[1] = input.nextInt();
System.out.print("\nc=");
array[2] = input.nextInt();
System.out.print("\nd=");
array[3] = input.nextInt();
System.out.print("\ne=");
array[4] = input.nextInt();
boolean totalIsZero = false;
for (int i=0;i<array.length ;i++) {
for (int j=1;i>j ;j++ ) {
if ((array[i] + array[j])==0) {
System.out.println("The numbers " + array[i] + " and " + array[j] + " have a total sum equal to 0.");
totalIsZero = true;
}
}
}
if (!totalIsZero) {
System.out.print("None of the numbers have a total sum of 0 with each other. ");
}
}`
Here is a simple code I just wrote. Its task is to check if the sum between every two numbers in an array(consisting of five numbers) is equal to zero. The problem I have is that when there are two couples of numbers, both equal to 0, at the end of the program there is a message for one of the couples only, not for both, as I expected. How can I fix that, so the user can read that there are two couples of numbers equal to 0. Thanks in advance!
| 0debug
|
how to validate form in jquery this code not working : $(document).ready(function(){
var name = $('#signup-name').val();
var email = $('#signup-email').val();
var password = $('#signup-password').val();
var email_regex = new RegExp(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
var pass_regex = new RegExp(/^(?=.[0-9])(?=.[!@#$%^&])[a-zA-Z0-9!@#$%^&]{7,15}$/);
$('#signup-form').on('submit',function(e){
e.preventDefault();
if (validate()) {
$.ajax({
type : 'post',
url : 'signup',
data :{email : email, password : password, name: name},
});
}else {
return false;
};
});
function validate() {
// name cheak here
if (name.length == "") {
$('.nameerror').html("Name field required !");
return false;
}else if (name.length =< 3) {
$('.nameerror').html("Name Should be greater than 3");
return false;
};
// email cheak here
if (email.length == "") {
$('.emailerror').html("Email field required !");
return false;
}else if (!email_regex.test(email)) {
$('.emailerror').html("Please enter correct email.");
return false;
};
// password cheak here
if (password.length == "") {
$('.passerror').html("password field required !");
return false;
}else if (!pass_regex.test(password)) {
#('.passerror').html("Minimum eight characters, at least one letter and one number:");
return false;
};
};
});
**i want to send my form data to server by validating in jquery or javascript but my form data not validated ,i don't know why? please help me fast**
//.........................................nothing here dude..............................................uiygfiuyfiiiiiiiiuuuuyiugyuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiuiui//
| 0debug
|
How to Pass List<> to Store Proc : I am trying to pass alist to database (sql server 2008 r2) using user defined table types but get some errors my code is:
public int DAL_SaveIncramentSalary(tbl_Employee_Master obj, List<dtIncrementSalary> tbl)
{ try { SqlParameter[] objSqlParameter = new SqlParameter[4]; objSqlParameter[0] = new SqlParameter("@Company_ID", obj.Company_ID); objSqlParameter[1] = new SqlParameter("@Employee_ID", obj.Employee_ID); objSqlParameter[2] = new SqlParameter("@Salary_Month", obj.Govt_DA);
objSqlParameter[3] = new SqlParameter("@dt", SqlDbType.Structured); objSqlParameter[3].Value = tbl; objSqlParameter[3].Direction = ParameterDirection.Input; DataSet fdd = SqlHelper.ExecuteDataset(_cnnString2, "usp_Insert_Increment_Salary_List", CommandType.StoredProcedure, bjSqlParameter); DataSet fddd = SqlHelper.ExecuteDataset(_cnnString2, "usp_Insert_Increment_Salary_List", objSqlParameter); DataSet ds = SqlHelper.ExecuteDataset(_cnnString2, CommandType.StoredProcedure, "usp_Insert_Increment_Salary_List", objSqlParameter); return SqlHelper.ExecuteNonQuery(_cnnString2, CommandType.StoredProcedure, "usp_Insert_Increment_Salary_List", objSqlParameter); } catch (Exception ex) { throw new Exception(ex.Message); } } I got error like this: Dataset dff error : Parameter count does not match Parameter Value count. DataSet fddd error : ailed to convert parameter value from a List`1 to a IEnumerable`1. DataSet ds error :Failed to convert parameter value from a List`1 to a IEnumerable`1.
sql user defined type CREATE TYPE dtIncrementSalary AS TABLE(Head_Id int null,
SalAmt numeric(18,2) null, Per float null, OldSalAmt numeric(18,2) null, OldPer float null ) sql proc alter PROCEDURE [dbo].[usp_Insert_Increment_Salary_List] ( @Company_ID int, @Employee_ID int, @Salary_Month int, @dt dtIncrementSalary readonly ) AS
BEGIN select * from @dt END
| 0debug
|
Automatic documentation/contract generation for Pub/Sub RabbitMQ : <p>In the REST world, we have something like a Swagger Specification, which fully describes the contract over a REST interface boundary (between client and server). Those Swagger specifications can be used to auto-generate REST clients, but also to automatically generate documentation for your REST API consumers. These Swagger Specification, moreover, are also a valuable asset w.r.t. CI and versioning of your API.</p>
<p>I was wondering if a similar solution exists in the asynchronous Publish Subscribe world: let's say a typical AMQP Consumer/Producer on RabbitMQ....</p>
<p>Best regards,</p>
<p>Bart</p>
| 0debug
|
Library to build animation like slack-demo : <p>I want to build an animation like the one in <a href="https://slackdemo.com/?vst=.1wl4q6p32ubd8c0zflxmi0kfn#Team" rel="nofollow noreferrer">slack-demo</a> page. Basically I am trying to demonstrate a feature of my Application with animation. I can do so using Vanilla JS and CSS. But it will be a lot of code and difficult to maintain. </p>
<p>What library/Framework can I use to build animation like slack-demo? </p>
| 0debug
|
static void usbredir_control_packet(void *priv, uint32_t id,
struct usb_redir_control_packet_header *control_packet,
uint8_t *data, int data_len)
{
USBRedirDevice *dev = priv;
int len = control_packet->length;
AsyncURB *aurb;
DPRINTF("ctrl-in status %d len %d id %u\n", control_packet->status,
len, id);
aurb = async_find(dev, id);
if (!aurb) {
free(data);
return;
}
aurb->control_packet.status = control_packet->status;
aurb->control_packet.length = control_packet->length;
if (memcmp(&aurb->control_packet, control_packet,
sizeof(*control_packet))) {
ERROR("return control packet mismatch, please report this!\n");
len = USB_RET_NAK;
}
if (aurb->packet) {
len = usbredir_handle_status(dev, control_packet->status, len);
if (len > 0) {
usbredir_log_data(dev, "ctrl data in:", data, data_len);
if (data_len <= sizeof(dev->dev.data_buf)) {
memcpy(dev->dev.data_buf, data, data_len);
} else {
ERROR("ctrl buffer too small (%d > %zu)\n",
data_len, sizeof(dev->dev.data_buf));
len = USB_RET_STALL;
}
}
aurb->packet->result = len;
usb_generic_async_ctrl_complete(&dev->dev, aurb->packet);
}
async_free(dev, aurb);
free(data);
}
| 1threat
|
static bool vring_notify(VirtIODevice *vdev, VirtQueue *vq)
{
uint16_t old, new;
bool v;
if (((vdev->guest_features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) &&
!vq->inuse && vring_avail_idx(vq) == vq->last_avail_idx)) {
return true;
}
if (!(vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX))) {
return !(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT);
}
v = vq->signalled_used_valid;
vq->signalled_used_valid = true;
old = vq->signalled_used;
new = vq->signalled_used = vring_used_idx(vq);
return !v || vring_need_event(vring_used_event(vq), new, old);
}
| 1threat
|
NullPointerException when using a fragment to get values from another class : <p>I am a beginner in android and having some problem in handling NullPointerException.I need to pass the magnetometer reading values in an array from one class to a fragment.
Here is the magnetometer class:</p>
<pre><code>public class Magnetometer implements SensorEventListener {
private Sensor mag;
private SensorManager magman;
private boolean magAvailable;
private float[] magValue;
public Magnetometer(MagFragment context){
magman=(SensorManager)context.getActivity().getSystemService(Context.SENSOR_SERVICE);
magAvailable=magman.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)!=null;
if(isMagAvailable()){
magValue=new float[3];
mag=magman.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
magman.registerListener(this,mag,SensorManager.SENSOR_DELAY_NORMAL);
}
}
@Override
public void onSensorChanged(SensorEvent event) {
for(int i=0;i<3;i++)
magValue[i]=event.values[i];
}
public float[] getLastReading(){
return this.magValue;
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
public boolean isMagAvailable(){
return this.magAvailable;
}
public void unregister(){
if(isMagAvailable())
magman.unregisterListener(this,mag);
}
}
</code></pre>
<p>Here is the fragment:</p>
<pre><code>ublic class MagFragment extends Fragment {
private Magnetometer mag;
private TextView x,y,z;
private float[] magValues;
public MagFragment() {
// Required empty public constructor
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//returning our layout file
//change R.layout.yourlayoutfilename for each of your fragments
View rootView = inflater.inflate(R.layout.fragment_mag, container, false);
x=(TextView) rootView.findViewById(R.id.mx);
y=(TextView) rootView.findViewById(R.id.my);
z=(TextView) rootView.findViewById(R.id.mz);
magValues=new float[3];
getData(this);
return rootView;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//you can set the title for your toolbar here for different fragments different titles
getActivity().setTitle("Magnetometer");
}
public void getData(MagFragment context)
{
magValues=mag.getLastReading();
displayData(magValues);
}
public void displayData(float [] magV)
{
x.setText(String.valueOf(magV[0]));
y.setText(String.valueOf(magV[1]));
z.setText(String.valueOf(magV[2]));
}
}
</code></pre>
<p>I understand,that the function returns some NULL values.
The error I get is "Attempt to invoke virtual method 'float[] com.example.ark.ark.Sensors.Magnetometer.getLastReading()' on a null object reference"</p>
| 0debug
|
The respons from the retrofit call is too slow and it returns a null list : public class RequestClass {
private static final String TAG = RequestClass.class.getSimpleName();
private final static String API_KEY = "apikey";
static ApiInterface apiService =
ApiClient.getClient().create(ApiInterface.class);
static public List<Movie> getTopMovies(String page) {
final List<Movie> lowDetailMovies = new ArrayList<Movie>();
Call<MoviesResponse> call = apiService.getTopRatedMovies(API_KEY, page);
call.enqueue(new Callback<MoviesResponse>() {
@Override
public void onResponse(Call<MoviesResponse> call, Response<MoviesResponse> response) {
List<DBMovie> movies = response.body().getResults();
for (DBMovie movie : movies) {
String[] genres = new String[6];
int i = 0;
for (int gen : movie.getGenreIds())
genres[i++] = gen + "";
lowDetailMovies.add(new Movie(movie.getId(), Double.toString(movie.getVote_average()), movie.getTitle(), movie.getTitle(), movie.getPoster_path(), movie.getOriginal_language(),
movie.getOriginal_title(), genres, movie.getOverview(), movie.getRelease_date(), false, false));
}
}
@Override
public void onFailure(Call<MoviesResponse> call, Throwable t) {
Log.e(TAG, t.toString());
}
});
return lowDetailMovies;
}
}
Anyone can help me with a solution to get the list after onRespons method.
The duration of the onRespons method has about 400 ms.
This is the part of the code where I need the list:
@OnClick(R.id.popular_button)
public void showPopularMovies(View view) {
List<Movie> movies;
movies = RequestClass.getTopMovies("1");
Intent intent = new Intent(MainActivity.this, VODActivity.class);
Collections.sort(movies, Util.compareByPopularityAscending);
Bundle bundle = new Bundle();
bundle.putSerializable(Constants.bundleMovieKey, (Serializable) movies);
bundle.putString(Constants.bundleVodActivityTitle, Constants.PopularMoviesTitle);
intent.putExtras(bundle);
startActivity(intent);
}
Thanks.
| 0debug
|
C# Fill array values in just one line of code : <p>I'm adding value to an array of bytes with the following code:</p>
<pre><code>byte[] ConnectionPath;
ConnectionPath[0] = 0;
ConnectionPath[1] = 2;
ConnectionPath[2] = 1;
ConnectionPath[3] = 0;
</code></pre>
<p>My question is, can't I do this in just 1 line of code? I tried this, but this doesn't work. (I know that you can do this by declaration, but of course this value changes through the program)</p>
<pre><code>ConnectionPath = { 0, 2, 1, 0};
</code></pre>
| 0debug
|
How to change whole page background-color in Angular : <p>I am trying to change the background color for the whole page in Angular(would use body, or html tag when working without framework). and I can't find the best practice for this, I want it to be within the framework if possible since I am building an application for years to come.</p>
| 0debug
|
Can we use a closure within a closure in javascript? : <p>If I write something like below </p>
<pre><code>function sum(x){
return function(y){
return function(z){
return x + y + z;
}
}
}
</code></pre>
<p>and call it like sum(2)(3)(4) // output is 8</p>
<p>can we call the above function, an example of closure within a closure ??? </p>
| 0debug
|
PHP is not recognizing file upload extension : <p>I have the following array sent by ajax when echoed in php</p>
<pre><code>[file] => Array
( [name] => XXXX.jpg [type] => image/jpeg [tmp_name] => D:\xampp\tmp\phpC5F2.tmp
[error] => 0 [size] => 25245 )
</code></pre>
<p>and the following code to process the upload:</p>
<pre><code>if(isset($_FILES['file'])) {
$natid = '9999';
$target_dir = "../uploads/";
$fname = $_FILES['file']['name'];
$target_file = $target_dir . $natid .'/'. $fname;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
if($imageFileType == "jpg" && $imageFileType == "png" && $imageFileType == "jpeg" && $imageFileType == "gif") {
$check = getimagesize($_FILES["file"]["tmp_name"]);
if($check !== false) { // !== not equal
echo "File is an image - " . $check["mime"] . ".<br>";
} else {
echo "the file is not an image.";
}
} elseif ($imageFileType == "pdf"){
echo "File is a PDF - " . $check["mime"] . ".<br>";
} else {
echo "Sorry, only PDF, JPG, JPEG, PNG & GIF files are allowed.";
}
}
</code></pre>
<p>When I run the code I get the reply from php saying that file is neither an image nor a PDF although </p>
<blockquote>
<p>$imageFileType gives me 'jpg'</p>
</blockquote>
| 0debug
|
void OPPROTO op_fdiv_STN_ST0(void)
{
ST(PARAM1) /= ST0;
}
| 1threat
|
if else statement in boolean operations : <pre><code>L = [1,2,3,4,5]
r = None
for item in L:
#if item is odd or 0 bind it to r. if r is None then 0
if (item % 2 or item == 0) and item >= 0 if r == None else r:
print(r)
r = item
</code></pre>
<p>This prints:</p>
<pre><code>None
1
2
3
4
</code></pre>
<p>It is not clear why boolean operator works like this, it clearly lets 2 and 4 through even if both of them are even numbers.</p>
| 0debug
|
static inline int RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
int srcSliceH, uint8_t* dst[], int dstStride[]){
int y, h_size;
if(c->srcFormat == PIX_FMT_YUV422P){
srcStride[1] *= 2;
srcStride[2] *= 2;
}
h_size= (c->dstW+7)&~7;
if(h_size*2 > FFABS(dstStride[0])) h_size-=8;
__asm__ __volatile__ ("pxor %mm4, %mm4;" );
for (y= 0; y<srcSliceH; y++ ) {
uint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0];
uint8_t *_py = src[0] + y*srcStride[0];
uint8_t *_pu = src[1] + (y>>1)*srcStride[1];
uint8_t *_pv = src[2] + (y>>1)*srcStride[2];
long index= -h_size/2;
b5Dither= dither8[y&1];
g6Dither= dither4[y&1];
g5Dither= dither8[y&1];
r5Dither= dither8[(y+1)&1];
__asm__ __volatile__ (
"movd (%2, %0), %%mm0;"
"movd (%3, %0), %%mm1;"
"movq (%5, %0, 2), %%mm6;"
"1: \n\t"
YUV2RGB
#ifdef DITHER1XBPP
"paddusb "MANGLE(b5Dither)", %%mm0 \n\t"
"paddusb "MANGLE(g5Dither)", %%mm2 \n\t"
"paddusb "MANGLE(r5Dither)", %%mm1 \n\t"
#endif
"pand "MANGLE(mmx_redmask)", %%mm0;"
"pand "MANGLE(mmx_redmask)", %%mm2;"
"pand "MANGLE(mmx_redmask)", %%mm1;"
"psrlw $3,%%mm0;"
"psrlw $1,%%mm1;"
"pxor %%mm4, %%mm4;"
"movq %%mm0, %%mm5;"
"movq %%mm2, %%mm7;"
"punpcklbw %%mm4, %%mm2;"
"punpcklbw %%mm1, %%mm0;"
"psllw $2, %%mm2;"
"por %%mm2, %%mm0;"
"movq 8 (%5, %0, 2), %%mm6;"
MOVNTQ " %%mm0, (%1);"
"punpckhbw %%mm4, %%mm7;"
"punpckhbw %%mm1, %%mm5;"
"psllw $2, %%mm7;"
"movd 4 (%2, %0), %%mm0;"
"por %%mm7, %%mm5;"
"movd 4 (%3, %0), %%mm1;"
MOVNTQ " %%mm5, 8 (%1);"
"add $16, %1 \n\t"
"add $4, %0 \n\t"
" js 1b \n\t"
: "+r" (index), "+r" (_image)
: "r" (_pu - index), "r" (_pv - index), "r"(&c->redDither), "r" (_py - 2*index)
);
}
__asm__ __volatile__ (EMMS);
return srcSliceH;
}
| 1threat
|
"UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure." when plotting figure with pyplot on Pycharm : <p>I am trying to plot a simple graph using pyplot, e.g.:</p>
<pre><code>import matplotlib.pyplot as plt
plt.plot([1,2,3],[5,7,4])
plt.show()
</code></pre>
<p>but the figure does not appear and I get the following message:</p>
<pre><code>UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
</code></pre>
<p>I saw in several places that one had to change the configuration of matplotlib using the following:</p>
<pre><code>import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
</code></pre>
<p>I did this, but then got an error message because it cannot find a module:</p>
<pre><code>ModuleNotFoundError: No module named 'tkinter'
</code></pre>
<p>Then, I tried to install "tkinter" using <code>pip install tkinter</code> (inside the virtual environment), but it does not find it:</p>
<pre><code>Collecting tkinter
Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter
</code></pre>
<p>I should also mention that I am running all this on Pycharm Community Edition IDE using a virtual environment, and that my operating system is Linux/Ubuntu 18.04.</p>
<p><strong>I would like to know how I can solve this problem in order to be able to display the graph.</strong></p>
| 0debug
|
static void init_proc_POWER9(CPUPPCState *env)
{
init_proc_book3s_common(env);
gen_spr_book3s_207_dbg(env);
gen_spr_book3s_ids(env);
gen_spr_amr(env);
gen_spr_iamr(env);
gen_spr_book3s_purr(env);
gen_spr_power5p_common(env);
gen_spr_power5p_lpar(env);
gen_spr_power5p_ear(env);
gen_spr_power6_common(env);
gen_spr_power6_dbg(env);
gen_spr_power8_tce_address_control(env);
gen_spr_power8_ids(env);
gen_spr_power8_ebb(env);
gen_spr_power8_fscr(env);
gen_spr_power8_pmu_sup(env);
gen_spr_power8_pmu_user(env);
gen_spr_power8_tm(env);
gen_spr_power8_pspb(env);
gen_spr_vtb(env);
gen_spr_power8_ic(env);
gen_spr_power8_book4(env);
gen_spr_power8_rpr(env);
spr_register_kvm(env, SPR_TIDR, "TIDR", NULL, NULL,
KVM_REG_PPC_TIDR, 0);
#if !defined(CONFIG_USER_ONLY)
env->slb_nr = 32;
#endif
env->ci_large_pages = true;
env->dcache_line_size = 128;
env->icache_line_size = 128;
init_excp_POWER8(env);
ppcPOWER7_irq_init(ppc_env_get_cpu(env));
}
| 1threat
|
static void omap_mcbsp_writew(void *opaque, hwaddr addr,
uint32_t value)
{
struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
int offset = addr & OMAP_MPUI_REG_MASK;
if (offset == 0x04) {
if (((s->xcr[0] >> 5) & 7) < 3)
return;
if (s->tx_req > 3) {
s->tx_req -= 4;
if (s->codec && s->codec->cts) {
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 24) & 0xff;
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 16) & 0xff;
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 8) & 0xff;
s->codec->out.fifo[s->codec->out.len ++] =
(value >> 0) & 0xff;
}
if (s->tx_req < 4)
omap_mcbsp_tx_done(s);
} else
printf("%s: Tx FIFO overrun\n", __FUNCTION__);
return;
}
omap_badwidth_write16(opaque, addr, value);
}
| 1threat
|
how to replace all the zeros in javascript : How can I replace all the zeros in a javascript variable, I have some variables like this one:
var a = 00000004567,
and I need to replace the zeros with *, I'm using :
a.replace(/0*\d/g,'*')
the problem is that it returns -> ****567
Thanks
| 0debug
|
ajax send data to php file : send `$username` php with ` data: new FormData(this),` to add.php like `data: new FormData(this),$username` how can i do it with ajax code
<script type="text/javascript">
$(document).ready(function (e) {
$("#uploadFormuserimg").on('submit',(function(e) {
e.preventDefault();
$.ajax({
url: "add.php",
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData:false,
success: function(data)
{
$("#user_img_a").html(data);
},
error: function()
{ alert("error");
}
});
}));
});
</script>
| 0debug
|
attempt to set an attribute on NULL in R : Error in data.table::rbindlist(.data, ...) :
attempt to set an attribute on NULL
I am getting this error at:
FBInsightsExpanded <<- list.stack(list.select(FBInsightsExpanded, website_purchase_roas = website_purchase_roas$action_link_click_destination));
print(FBInsightsExpanded)
This is what the DF looks like. I am guessing I need to replace NULLs with NA's. But not able to get a fix for it so far
website_purchase_roas date_stop
1 0.673001 offsite_conversion.fb_pixel_purchase, 6.506892 2018-10-11
2 1.369035 offsite_conversion.fb_pixel_purchase, 0.594109 2018-10-11
3 2.084238 NULL 2018-10-11
4 1.31209 NULL 2018-10-11
5 2.337662 NULL 2018-10-11
6 0.996678 NULL 2018-10-11
7 1.936385 offsite_conversion.fb_pixel_purchase, 1.482508 2018-10-11
8 2.777778 NULL 2018-10-11
9 0 NULL 2018-10-11
10 1.994885 NULL 2018-10-11
11 2.402023 NULL 2018-10-11
12 4.635056 offsite_conversion.fb_pixel_purchase, 5.222421 2018-10-11
13 0 NULL 2018-10-11
14 1.990291 NULL 2018-10-11
15 6.557377 NULL 2018-10-11
16 3.703704 NULL 2018-10-11
17 3.038936 NULL 2018-10-11
| 0debug
|
I want to generate tableview form with JSON data : <p>I have a JSON data in my local file, I want to replicate same in my form.</p>
<p>JSON data tell us info like, which field is required, which is dropdown, placeholder and more info. </p>
<p>Almost I achieved my goal, but only the thing is keyboard taking double taps to show when I am switching the text fields.</p>
<p>I was stuck on this issue. Can anyone help me?</p>
<p>I cant explain the issue with the small code, that's why adding complete source code, so please excuse.</p>
<p><strong>here I am adding my source code link,</strong></p>
<p><a href="https://drive.google.com/file/d/12vhrz6CgDSuma6ViYOsGkCIb9SE6fSbR/view" rel="nofollow noreferrer">https://drive.google.com/file/d/12vhrz6CgDSuma6ViYOsGkCIb9SE6fSbR/view</a></p>
| 0debug
|
void cpu_loop(CPUTLGState *env)
{
CPUState *cs = CPU(tilegx_env_get_cpu(env));
int trapnr;
while (1) {
cpu_exec_start(cs);
trapnr = cpu_tilegx_exec(cs);
cpu_exec_end(cs);
switch (trapnr) {
case TILEGX_EXCP_SYSCALL:
env->regs[TILEGX_R_RE] = do_syscall(env, env->regs[TILEGX_R_NR],
env->regs[0], env->regs[1],
env->regs[2], env->regs[3],
env->regs[4], env->regs[5],
env->regs[6], env->regs[7]);
env->regs[TILEGX_R_ERR] = TILEGX_IS_ERRNO(env->regs[TILEGX_R_RE])
? - env->regs[TILEGX_R_RE]
: 0;
break;
case TILEGX_EXCP_OPCODE_EXCH:
do_exch(env, true, false);
break;
case TILEGX_EXCP_OPCODE_EXCH4:
do_exch(env, false, false);
break;
case TILEGX_EXCP_OPCODE_CMPEXCH:
do_exch(env, true, true);
break;
case TILEGX_EXCP_OPCODE_CMPEXCH4:
do_exch(env, false, true);
break;
case TILEGX_EXCP_OPCODE_FETCHADD:
case TILEGX_EXCP_OPCODE_FETCHADDGEZ:
case TILEGX_EXCP_OPCODE_FETCHAND:
case TILEGX_EXCP_OPCODE_FETCHOR:
do_fetch(env, trapnr, true);
break;
case TILEGX_EXCP_OPCODE_FETCHADD4:
case TILEGX_EXCP_OPCODE_FETCHADDGEZ4:
case TILEGX_EXCP_OPCODE_FETCHAND4:
case TILEGX_EXCP_OPCODE_FETCHOR4:
do_fetch(env, trapnr, false);
break;
case TILEGX_EXCP_SIGNAL:
do_signal(env, env->signo, env->sigcode);
break;
case TILEGX_EXCP_REG_IDN_ACCESS:
case TILEGX_EXCP_REG_UDN_ACCESS:
gen_sigill_reg(env);
break;
default:
fprintf(stderr, "trapnr is %d[0x%x].\n", trapnr, trapnr);
g_assert_not_reached();
}
process_pending_signals(env);
}
}
| 1threat
|
Write PHP code in Python : <p>Would like to know whats the Python function to call if I would like to write PHP script in Python.
I am trying to utilise a PHP function that would take in values from a table created in python, operate on the text in PHP (using that PHP library) and throw the result back into a python table.</p>
| 0debug
|
Track user location through mobile number : <p>I want to create an application, when I enter any mobile number it should give me current location of that number.
Guys please help me if it is possible then tell me how it is possible ?</p>
| 0debug
|
Executing sbt run in current project with ensime emacs : <p>I have a Scala project called <code>scala-playground</code> and I generated the configuration for Ensime with <code>sbt ensimeConfig</code> and <code>sbt ensimeConfigProject</code>.</p>
<p>When running <code>M-x ensime</code> from a buffer of the project, I can see in the Emacs statusbar that Ensime is connected: it displays <code>Scala[scala-playground]</code>.</p>
<p>When running the project with <code>C-c C-b r</code>, a new sbt instance is started in the home directory, a directory in <code>$HOME/project</code> is created and instead of the project directory and fails:</p>
<pre><code>[info] Loading project definition from /home/user/project
[info] Set current project to user (in build file:/home/user/)
[info] sbt server started at 127.0.0.1:4766
sbt:user>
sbt:user> run
[error] java.lang.RuntimeException: No main class detected.
[error] at scala.sys.package$.error(package.scala:27)
[error] at sbt.Defaults$.$anonfun$runTask$4(Defaults.scala:1199)
[error] at scala.Option.getOrElse(Option.scala:121)
[error] at sbt.Defaults$.$anonfun$runTask$3(Defaults.scala:1199)
[error] at sbt.Defaults$.$anonfun$runTask$3$adapted(Defaults.scala:1198)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:42)
[error] at sbt.std.Transform$$anon$4.work(System.scala:64)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:257)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
[error] at sbt.Execute.work(Execute.scala:266)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:257)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:167)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:32)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] (compile:run) No main class detected.
[error] Total time: 0 s, completed Aug 28, 2017 9:10:03 PM
</code></pre>
<p>What is going on?</p>
| 0debug
|
void OPPROTO op_lmsw_T0(void)
{
T0 = (env->cr[0] & ~0xf) | (T0 & 0xf);
helper_movl_crN_T0(0);
}
| 1threat
|
import math
def degree_radian(radian):
degree = radian*(180/math.pi)
return degree
| 0debug
|
nil is the only return value permitted in initializer? : <p>I'm attempting to subclass UICollectionViewFlowLayout but I get the error that 'nil is the only return value permitted in an initializer.' I attempted to check the super class for an initializer and if there wasn't, I would return nil, but alas, I get another error saying that self is immutable.</p>
<pre><code>import UIKit
class CollectionViewSpringLayout: UICollectionViewFlowLayout {
var dynamicAnimator: UIDynamicAnimator?
override init() {
self.minimumInteritemSpacing = 10
self.minimumInteritemSpacing = 10
//self.itemSize = CGSizeMake(44, 44)
self.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10)
self.dynamicAnimator = UIDynamicAnimator(collectionViewLayout: self)
return self
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
</code></pre>
| 0debug
|
static inline bool extended_addresses_enabled(CPUARMState *env)
{
return arm_el_is_aa64(env, 1)
|| ((arm_feature(env, ARM_FEATURE_LPAE)
&& (env->cp15.c2_control & (1U << 31))));
}
| 1threat
|
How to send a packed structure in C++ and recieve it in C# : I need to write a client on C++, which would send packed structure to the server. Server must be written on C#. I dont understand, how to convert it in C#. May be you will suggest a better way to do this.
| 0debug
|
How to add data to a Linked Link : Am working on a Linked list in java when i add data in it and print out the linked the result i get shows that the linked list is empty. but i just added some data to it below is my code.
package linked;
import java.util.LinkedList;
public class workPls {
public LinkedList List= new LinkedList();
public void addNode(PlsWork st){
List.add(st);
}
public LinkedList getList(){
return List;
}
public void print(){
System.out.println(List.size());
System.out.println(List);
}
}
package linked;
import java.net.InetAddress;
public class Linked {
public static void main(String[] args) {
try {
InetAddress inetAddress = InetAddress.getLocalHost();
PlsWork ok = new PlsWork(inetAddress,"pc");
workPls oks = new workPls();
workPls okss = new workPls();
oks.addNode(ok);
oks.addNode(ok);
oks.addNode(ok);
okss.print();
}
catch (Exception error){
error.printStackTrace();
}
}
}
| 0debug
|
How to print text in center of receipt using cpcl language (not ZPL & EPL) in Zebra Printers through Android app? : This answers doesn't helped me
https://stackoverflow.com/questions/7158308/centering-a-receipt-title-with-cpcl-programmingzebra-mobile-printeres
| 0debug
|
QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
int permit_abbrev)
{
const char *firstname;
char value[1024], *id = NULL;
const char *p;
QemuOpts *opts;
assert(!permit_abbrev || list->implied_opt_name);
firstname = permit_abbrev ? list->implied_opt_name : NULL;
if (strncmp(params, "id=", 3) == 0) {
get_opt_value(value, sizeof(value), params+3);
id = qemu_strdup(value);
} else if ((p = strstr(params, ",id=")) != NULL) {
get_opt_value(value, sizeof(value), p+4);
id = qemu_strdup(value);
}
opts = qemu_opts_create(list, id, 1);
if (opts == NULL)
return NULL;
if (qemu_opts_do_parse(opts, params, firstname) != 0) {
qemu_opts_del(opts);
return NULL;
}
return opts;
}
| 1threat
|
static bool scsi_block_is_passthrough(SCSIDiskState *s, uint8_t *buf)
{
switch (buf[0]) {
case READ_6:
case READ_10:
case READ_12:
case READ_16:
case VERIFY_10:
case VERIFY_12:
case VERIFY_16:
case WRITE_6:
case WRITE_10:
case WRITE_12:
case WRITE_16:
case WRITE_VERIFY_10:
case WRITE_VERIFY_12:
case WRITE_VERIFY_16:
if (!(bdrv_get_flags(s->qdev.conf.bs) & BDRV_O_NOCACHE)) {
break;
}
if (s->qdev.type != TYPE_ROM) {
return false;
}
break;
default:
break;
}
return true;
}
| 1threat
|
How to give Image src dynamically in react js? : <p>I am trying to give image name in src dynamically. I want to set image name dynamically using variable with path. but I am not able to set src correctly. I tried solutions on stackoverflow but nothing is working. </p>
<p>I tried to give path like this </p>
<pre><code><img src={`../img/${img.code}.jpg`}></img>
<img src={'../img/' + img.code + '.jpg'}></img>
<img src={'../img/{img.code}.jpg'}></img>
</code></pre>
<p>my images are saved in src/img path
if i give path like this</p>
<pre><code><img src={require('../img/nokia.jpg')}/>
</code></pre>
<p>image is showing </p>
<p>I know this question is asked before but nothing is working for me.
Please help me how can I set image path?</p>
| 0debug
|
Unlimited ArrayList in Java : <p>I need to make trivial array of strings in Java but I can not find a simple way to do it. I try to use <code>List<String> myList = new ArrayList<>();</code> but implementation says this is limited to 10 items. The question is simple how to make array of strings without limit which is able to add new items and iterate in for cycle around it. </p>
| 0debug
|
static void scsi_unrealize(SCSIDevice *s, Error **errp)
{
scsi_device_purge_requests(s, SENSE_CODE(NO_SENSE));
blockdev_mark_auto_del(s->conf.blk);
}
| 1threat
|
Chrome DevTools won't let me set breakpoints on certain lines : <p><a href="https://i.stack.imgur.com/utVAf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/utVAf.png" alt="enter image description here"></a></p>
<p>In the image above, I tried setting breakpoints on every line from line 437 to line 443. However, I cannot set breakpoints on lines 439 and 440. When the function runs, the breakpoints on lines 437, 438, 441, and 442 are ignored. Chrome breaks on line 443. This means that I cannot do some debugging before the first conditional runs.</p>
<p>When I click on lines 439 or 440, the breakpoint appears for half a second and jumps to line 443.</p>
<p>Is this a bug or am I missing something? How do I set a breakpoint at or before line 439?</p>
| 0debug
|
Vector Array in C++ : <p>If vector consists from these numbers <code>55 55 55 55 1 23 45</code>, how I am possible to print the number who repeat itself for more then once, so basically <strong>it should print:</strong> <code>55, 1, 23, 45</code>.</p>
| 0debug
|
char variables doesn't work with switch properly c++ : <p>I'm new to c++ and coding and having a problem trying to write a simple program based on switch-case instruction. I want to let the user set value for char variables and then compare them using switch-case instruction, but the problem is that when I enter values I need, the instruction do not recognize them and runs the default switch case. I have tried to fix this a lot, but still don't know how to do it and what the problem is. I'm surely missing something very simple and will very appreciate if someone would explain the thing to me.</p>
<pre><code>#include <iostream>
#include <stdio.h>
using namespace std;
void main(){
char original_currency_type[4], nedeed_currency_type[4];
float money_amount;
cout << "Enter your currency type (choose between USD,EUR and RUB) \n";
cin >> original_currency_type;
cout << "Ok, so now enter the currency type you need to convert your money to (choose between USD,EUR and RUB, again) \n";
cin >> nedeed_currency_type;
cout << "Enter your money amount \n";
cin >> money_amount;
switch (original_currency_type[4]){
case ('RUB') :{
if (nedeed_currency_type[4] = 'USD')
cout << money_amount << " RUB is " << money_amount*60 << " USD";
else
cout << money_amount << " RUB is " << money_amount*100 << " EUR";
break;
}
case'USD':{
if (nedeed_currency_type[4] = 'RUB')
cout << money_amount << " USD is " << money_amount/60 << " RUB";
else
cout << money_amount << " USD is " << money_amount*1.2 << " EUR";
break;
}
case 'EUR':{
if (nedeed_currency_type[4] = 'RUB')
cout << money_amount << " EUR is " << money_amount/100 << " RUB";
else
cout << money_amount << " EUR is " << money_amount/1,2 << ' USD';
break;
}
default :{
cout << " You haven't been able to choose one of three options right \n";
break;
}
}
}
</code></pre>
| 0debug
|
int64_t qemu_strtosz(const char *nptr, char **end)
{
return do_strtosz(nptr, end, 'B', 1024);
}
| 1threat
|
static void filter_line_c(uint8_t *dst,
uint8_t *prev, uint8_t *cur, uint8_t *next,
int w, int refs, int parity, int mode)
{
int x;
uint8_t *prev2 = parity ? prev : cur ;
uint8_t *next2 = parity ? cur : next;
for (x = 0; x < w; x++) {
int c = cur[-refs];
int d = (prev2[0] + next2[0])>>1;
int e = cur[+refs];
int temporal_diff0 = FFABS(prev2[0] - next2[0]);
int temporal_diff1 =(FFABS(prev[-refs] - c) + FFABS(prev[+refs] - e) )>>1;
int temporal_diff2 =(FFABS(next[-refs] - c) + FFABS(next[+refs] - e) )>>1;
int diff = FFMAX3(temporal_diff0>>1, temporal_diff1, temporal_diff2);
int spatial_pred = (c+e)>>1;
int spatial_score = FFABS(cur[-refs-1] - cur[+refs-1]) + FFABS(c-e)
+ FFABS(cur[-refs+1] - cur[+refs+1]) - 1;
#define CHECK(j)\
{ int score = FFABS(cur[-refs-1+j] - cur[+refs-1-j])\
+ FFABS(cur[-refs +j] - cur[+refs -j])\
+ FFABS(cur[-refs+1+j] - cur[+refs+1-j]);\
if (score < spatial_score) {\
spatial_score= score;\
spatial_pred= (cur[-refs +j] + cur[+refs -j])>>1;\
CHECK(-1) CHECK(-2) }} }}
| 1threat
|
How to limit the results on a percentage rather than fix limit numer in mysql? : The below mysql question returns only the 10 first rows. How can I limit the them to 10% of all?
SELECT page,
poso,
diff
FROM (SELECT page,
Count(*) AS poso,
( Sum(Date(timestamp) = Curdate()) - Sum(
Date(timestamp) = Date_sub(Curdate(),
INTERVAL 1 day)) )
diff
FROM `behaviour`
WHERE Date(timestamp) >= Date_sub(Curdate(), INTERVAL 1 day)
GROUP BY page
ORDER BY ( Sum(Date(timestamp) = Curdate()) - Sum(
Date(timestamp) = Date_sub(Curdate(),
INTERVAL 1 day))
) DESC
LIMIT 10) AS u
ORDER BY diff DESC
| 0debug
|
How to lay out B-Tree data on disk? : <p>I know how a B-Tree works in-memory, it's easy enough to implement. However, what is currently completely beyond me, is how to find a data layout that works effectively on disk, such that:</p>
<ul>
<li>The number of entries in the B-Tree can grow indefinitly (or at least to > 1000GB)</li>
<li>Disk-level copying operations are minimized</li>
<li>The values can have arbitrary size (i.e. no fixed schema)</li>
</ul>
<p>If anyone could provide insight into layouting B-Tree structures on disk level, I'd be very grateful. Especially the last bullet point gives me a lot of headache. I would also appreciate pointers to books, but most database literature I've seen explains only the high-level structure (i.e. "this is how you do it in memory"), but skips the nitty gritty details on the disk layout.</p>
| 0debug
|
Cannot read property 'charAt' of undefined wordpress theme : <p>Can anyone please help me in understanding what am i doing wrong here. Downloaded a theme for a client and the whole theme is breaking due to: Cannot read property 'charAt' of undefined.</p>
<p><a href="https://i.stack.imgur.com/3NDvh.png" rel="nofollow noreferrer">screenshot of issue</a>:</p>
| 0debug
|
Why is my CSS keyframe fade in animation working? : <p><a href="https://i.stack.imgur.com/hrUR3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hrUR3.png" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/YnCdm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YnCdm.png" alt="enter image description here"></a></p>
<p>Heres the complete CSS for the animation. I have it on an a tag in my html as a class="fadeInUp animated animatedFadeInUp". Does anyone know why it wouldnt be working? I'm not sure what a -webkit-animation is so I did not add it. Could that be the reason?</p>
| 0debug
|
warning: Swift error in module. Debug info from this module will be unavailable in the debugger : <p>I have no debugging values in my console for my swift + obj-c app, and I get a really unhelpful message that explains why the debugger isn't working: "warning: Swift error in module XXX.". XXX is the name of my module, not a 3rd party that I include.</p>
<p>My app has been around before swift. I used the bridging header to start using swift, and I recently use the xcode tool to migrate all the swift 2 files to swift 3. (but I still have obj-c legacy in there). I use cocoa pods, which may be contributing to the problem.</p>
<p><a href="https://i.stack.imgur.com/DVNhz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DVNhz.png" alt="no debugger information..."></a></p>
<p><code>
(lldb) po self
warning: Swift error in module XXX.
Debug info from this module will be unavailable in the debugger.
</code></p>
<p>I tried following the second answer to this <a href="https://stackoverflow.com/questions/39467654/cannot-debug-swift-module-framework-embedded-in-objective-c-app">post</a> and a couple others
I have found that suggest the same thing: remove duplicate imports.</p>
<p>I tried removing duplicate imports from my swift project. In fact if I run <code>find . -name "*swift" | xargs grep "import"</code> and I get no results. So I went to the extreme of removing all imports from all of my swift files (and commenting out code to get it to compile) just to see if I can get my debugger to come back.</p>
<p>So...</p>
<ul>
<li>Is there another solution to this problem?</li>
<li>Is there a way to get a more detailed error message?</li>
<li>Is it a problem to have duplicate headers in the my bridging header? For example, a lot of my obj-c files import UIKit, and I include a few of those files in the bridging header. </li>
</ul>
| 0debug
|
Laravel Passport token lifetime : <p>I don't get what I'm doing wrong.
I can't set token expiration time.</p>
<pre><code><?php
namespace App\Providers;
class AuthServiceProvider extends ServiceProvider
{
public function boot()
{
$this->registerPolicies();
Passport::tokensExpireIn(Carbon::now()->addDays(1));
Passport::refreshTokensExpireIn(Carbon::now()->addDays(30));
}
}
</code></pre>
<p>BUT when I call <code>$user->createToken()</code>, for example like this:</p>
<pre><code><?php
// as a demo
namespace App\Http\Middleware;
class ParseSpecialToken
{
public function handle($request, Closure $next)
{
$user = User::find(1);
$accessToken = $user->createToken('Some token')->accessToken;
$request->headers->add(['Authorization' => 'Bearer '. $accessToken]);
return $next($request);
}
}
</code></pre>
<p>Token expiration is still 1 year, not 1 day. Why? How to change exp time?</p>
| 0debug
|
How I can rearrange the last element of an array to the first place? : <p>I have an array of objects in javascript:</p>
<pre><code>shapeToolsTarget: Array(4)
0: {id: 20, name: "Background", type: "shape"}
1: {id: 21, name: "BorderColor", type: "shape"}
2: {id: 22, name: "BorderWeight", type: "shape"}
3: {id: 3, name: "Paste", type: "text"}
</code></pre>
<p>How I can rearrange the last element of an array to the first place? Like that:</p>
<pre><code>shapeToolsTarget: Array(4)
0: {id: 3, name: "Paste", type: "text"}
1: {id: 20, name: "Background", type: "shape"}
2: {id: 21, name: "BorderColor", type: "shape"}
3: {id: 22, name: "BorderWeight", type: "shape"}
</code></pre>
| 0debug
|
int qemu_strtoull(const char *nptr, const char **endptr, int base,
uint64_t *result)
{
char *p;
int err = 0;
if (!nptr) {
if (endptr) {
*endptr = nptr;
}
err = -EINVAL;
} else {
errno = 0;
*result = strtoull(nptr, &p, base);
err = check_strtox_error(endptr, p, errno);
}
return err;
}
| 1threat
|
Excel Macro to auto fill formula : I want to create an Excel macro that can expand my formula on a column with different sizes.
I currently have 2 Pivot Tables and at the end of each one I have created a column of concatenated values.
Eg:
- Table 1: Cols D:I , concatenated col J
First Cell with formula is J12 (=CONCATENATE(D12;E12;F12;G12))
- Table 2: Cols O:T , concatenated col U
First Cell with formula is U12 (same as before)
I want to be able to press a button after refreshing the tables that will delete cols J and U and fill them with the formula again according to the tables' ranges.
I have created tried codes like
Range("J12:M" & LastRow).Formula = "=CONCATENATE ... "
but it is not working.
Thank you in advance
| 0debug
|
the result of uint32_t become octonary automatically : int main()
{
uint32_t n1 = 00000000000000000000000000001000;
uint32_t n2 = 00000000000000000000000000000100;
cout << n2;
}
when I use vs2013 (c++):
the result is 64. why this turns to octonary number system instead of binary?
| 0debug
|
static inline void RENAME(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
unsigned int width, unsigned int height,
int lumStride, int chromStride, int srcStride)
{
unsigned y;
const unsigned chromWidth= width>>1;
for(y=0; y<height; y+=2)
{
#ifdef HAVE_MMX
asm volatile(
"xorl %%eax, %%eax \n\t"
"pcmpeqw %%mm7, %%mm7 \n\t"
"psrlw $8, %%mm7 \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 64(%0, %%eax, 4) \n\t"
"movq (%0, %%eax, 4), %%mm0 \n\t"
"movq 8(%0, %%eax, 4), %%mm1 \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm7, %%mm1 \n\t"
"psrlw $8, %%mm2 \n\t"
"psrlw $8, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm2, (%1, %%eax, 2) \n\t"
"movq 16(%0, %%eax, 4), %%mm1 \n\t"
"movq 24(%0, %%eax, 4), %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
"movq %%mm2, %%mm4 \n\t"
"pand %%mm7, %%mm1 \n\t"
"pand %%mm7, %%mm2 \n\t"
"psrlw $8, %%mm3 \n\t"
"psrlw $8, %%mm4 \n\t"
"packuswb %%mm2, %%mm1 \n\t"
"packuswb %%mm4, %%mm3 \n\t"
MOVNTQ" %%mm3, 8(%1, %%eax, 2) \n\t"
"movq %%mm0, %%mm2 \n\t"
"movq %%mm1, %%mm3 \n\t"
"psrlw $8, %%mm0 \n\t"
"psrlw $8, %%mm1 \n\t"
"pand %%mm7, %%mm2 \n\t"
"pand %%mm7, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm0, (%3, %%eax) \n\t"
MOVNTQ" %%mm2, (%2, %%eax) \n\t"
"addl $8, %%eax \n\t"
"cmpl %4, %%eax \n\t"
" jb 1b \n\t"
::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth)
: "memory", "%eax"
);
ydst += lumStride;
src += srcStride;
asm volatile(
"xorl %%eax, %%eax \n\t"
".balign 16 \n\t"
"1: \n\t"
PREFETCH" 64(%0, %%eax, 4) \n\t"
"movq (%0, %%eax, 4), %%mm0 \n\t"
"movq 8(%0, %%eax, 4), %%mm1 \n\t"
"movq 16(%0, %%eax, 4), %%mm2 \n\t"
"movq 24(%0, %%eax, 4), %%mm3 \n\t"
"psrlw $8, %%mm0 \n\t"
"psrlw $8, %%mm1 \n\t"
"psrlw $8, %%mm2 \n\t"
"psrlw $8, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
MOVNTQ" %%mm0, (%1, %%eax, 2) \n\t"
MOVNTQ" %%mm2, 8(%1, %%eax, 2) \n\t"
"addl $8, %%eax \n\t"
"cmpl %4, %%eax \n\t"
" jb 1b \n\t"
::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth)
: "memory", "%eax"
);
#else
unsigned i;
for(i=0; i<chromWidth; i++)
{
udst[i] = src[4*i+0];
ydst[2*i+0] = src[4*i+1];
vdst[i] = src[4*i+2];
ydst[2*i+1] = src[4*i+3];
}
ydst += lumStride;
src += srcStride;
for(i=0; i<chromWidth; i++)
{
ydst[2*i+0] = src[4*i+1];
ydst[2*i+1] = src[4*i+3];
}
#endif
udst += chromStride;
vdst += chromStride;
ydst += lumStride;
src += srcStride;
}
#ifdef HAVE_MMX
asm volatile( EMMS" \n\t"
SFENCE" \n\t"
:::"memory");
#endif
}
| 1threat
|
int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq)
{
int rc;
uint8_t byte;
if (!dev->crq.qsize) {
fprintf(stderr, "spapr_vio_send_creq on uninitialized queue\n");
return -1;
}
rc = spapr_tce_dma_read(dev, dev->crq.qladdr + dev->crq.qnext, &byte, 1);
if (rc) {
return rc;
}
if (byte != 0) {
return 1;
}
rc = spapr_tce_dma_write(dev, dev->crq.qladdr + dev->crq.qnext + 8,
&crq[8], 8);
if (rc) {
return rc;
}
kvmppc_eieio();
rc = spapr_tce_dma_write(dev, dev->crq.qladdr + dev->crq.qnext, crq, 8);
if (rc) {
return rc;
}
dev->crq.qnext = (dev->crq.qnext + 16) % dev->crq.qsize;
if (dev->signal_state & 1) {
qemu_irq_pulse(dev->qirq);
}
return 0;
}
| 1threat
|
static void coroutine_enter_cb(void *opaque, int ret)
{
Coroutine *co = opaque;
qemu_coroutine_enter(co, NULL);
}
| 1threat
|
Converting a Google Apps Script to VB Script (Excel) : I guess this will seem a bit lazy, but I have been working on this for quite a few hours to get it to work in Google Sheets. Now I have the need to also get it to work in Excel, using VB script. It's a pretty simple script for experienced programmers, which I am not. :-)
I have a range of letters in a spreadsheet. Each letter represent a value. The Google Apps Script looks like this:
function Arsarbetstid(v,year) {
switch(year) {
case 2020: // Tider gällande 2020
var n=6.7, // N
np=9, // N+
k=8.8, // K
km=7, // K-
k4=4, // K4
d=8.8, // D
h=12, // H
hp=13; // H+
break;
case 2019: // Tider gällande 2019
var n=6.9, // N
np=9, // N+
k=8.7, // K
km=7, // K-
k4=4, // K4
d=9, // D
h=12, // H
hp=13; // H+
break;
case 2018: // Tider gällande 2018
var n=6.9, // N
np=9, // N+
k=8.7, // K
km=7, // K-
k4=4, // K4
d=9, // D
h=12, // H
hp=13; // H+
break;
case 2017: // Tider gällande 2017
var n=7, // N
np=9, // N+
k=8.8, // K
km=7, // K-
k4=4, // K4
d=9.1, // D
h=12, // H
hp=13; // H+
break;
case 2016: // Tider gällande 2016
var n=7, // N
np=9, // N+
k=8.8, // K
km=7, // K-
k4=4, // K4
d=9.1, // D
h=12, // H
hp=13; // H+
break;
case 2015: // Tider gällande 2015
var n=7, // N
np=9, // N+
k=8.8, // K
km=7, // K-
k4=4, // K4
d=9.1, // D
h=12, // H
hp=13; // H+
break;
case 2014: // Tider gällande 2014
var n=7, // N
np=9, // N+
k=8.8, // K
km=7, // K-
k4=4, // K4
d=9.1, // D
h=12, // H
hp=13; // H+
break;
case 2013: // Tider gällande 2013
var n=7, // N
np=9, // N+
k=8.8, // K
km=7, // K-
k4=4, // K4
d=9.1, // D
h=12, // H
hp=13; // H+
break;
default: // Tider gällande om inget årtal anges.
var n=6.7, // N
np=9, // N+
k=8.8, // K
km=7, // K-
k4=4, // K4
d=8.8, // D
h=12, // H
hp=13; // H+
break;
}
var total = 0;
for (var i=0;i < v.length;i++) {
var row = v[i];
for (var j=0;j < row.length;j++) {
switch(row[j]) {
case "N":
total += n;
break;
case "N+":
total += np;
break;
case "D":
total += d;
break;
case "H":
total += h;
break;
case "H+":
total += hp;
break;
case "K":
total += k;
break;
case "K-":
total += km;
break;
case "K4":
total += k4;
break;
}
}
}
return total;
};
v is the range of letters and year is just an integer representing a year so I can chose different values of the letters depending of the year.
I have tried, and so far failed, to convert this to VBscript. Is there anyone out there skilled enough to help me convert this? It shouldn't be too hard to anyone with at least a little above basic skills in both Javascript and VBscript.
I would be very grateful for the help.
Kind regards,
Michael
| 0debug
|
av_cold void ff_fft_fixed_init_arm(FFTContext *s)
{
int cpu_flags = av_get_cpu_flags();
if (have_neon(cpu_flags)) {
s->fft_permutation = FF_FFT_PERM_SWAP_LSBS;
s->fft_calc = ff_fft_fixed_calc_neon;
#if CONFIG_MDCT
if (!s->inverse && s->mdct_bits >= 5) {
s->mdct_permutation = FF_MDCT_PERM_INTERLEAVE;
s->mdct_calc = ff_mdct_fixed_calc_neon;
s->mdct_calcw = ff_mdct_fixed_calcw_neon;
}
#endif
}
}
| 1threat
|
static void tricore_cpu_class_init(ObjectClass *c, void *data)
{
TriCoreCPUClass *mcc = TRICORE_CPU_CLASS(c);
CPUClass *cc = CPU_CLASS(c);
DeviceClass *dc = DEVICE_CLASS(c);
mcc->parent_realize = dc->realize;
dc->realize = tricore_cpu_realizefn;
mcc->parent_reset = cc->reset;
cc->reset = tricore_cpu_reset;
cc->class_by_name = tricore_cpu_class_by_name;
cc->has_work = tricore_cpu_has_work;
cc->dump_state = tricore_cpu_dump_state;
cc->set_pc = tricore_cpu_set_pc;
cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb;
}
| 1threat
|
static TCGv_i64 gen_muls_i64_i32(TCGv a, TCGv b)
{
TCGv_i64 tmp1 = tcg_temp_new_i64();
TCGv_i64 tmp2 = tcg_temp_new_i64();
tcg_gen_ext_i32_i64(tmp1, a);
dead_tmp(a);
tcg_gen_ext_i32_i64(tmp2, b);
dead_tmp(b);
tcg_gen_mul_i64(tmp1, tmp1, tmp2);
tcg_temp_free_i64(tmp2);
return tmp1;
}
| 1threat
|
visual basic 2017 - how do i use keyboard keys to trigger controls? : i have been trying this for the past week and i need this information urgently for an upcoming competition. please help me out if you can...
it took me a long time to research and make my select case code error free, but i have done it, and it just won't work. i'm attaching a screenshot. please have a look.[enter image description here][1]
[this is the image][1]
[1]: https://i.stack.imgur.com/UgDzE.jpg
| 0debug
|
How to Draw a point in an image using given co-ordinate with python opencv? : <p>I have one image and one co-ordinate (X, Y). How to draw a point with this co-ordinate on the image. I want to use Python OpenCV.</p>
| 0debug
|
How to remove side space : <p>I'm working on this website <a href="http://shapeofyou.lotusong.info/" rel="nofollow noreferrer">http://shapeofyou.lotusong.info/</a> and I am trying to make the boxes on the main page fill up the entire screen. How do I do that? I tried looking for any padding or margin but there wasn't any. Any help will be appreciated. </p>
<p>Thanks!</p>
| 0debug
|
DISAS_INSN(branch)
{
int32_t offset;
uint32_t base;
int op;
int l1;
base = s->pc;
op = (insn >> 8) & 0xf;
offset = (int8_t)insn;
if (offset == 0) {
offset = cpu_ldsw_code(env, s->pc);
s->pc += 2;
} else if (offset == -1) {
offset = read_im32(env, s);
}
if (op == 1) {
gen_push(s, tcg_const_i32(s->pc));
}
gen_flush_cc_op(s);
if (op > 1) {
l1 = gen_new_label();
gen_jmpcc(s, ((insn >> 8) & 0xf) ^ 1, l1);
gen_jmp_tb(s, 1, base + offset);
gen_set_label(l1);
gen_jmp_tb(s, 0, s->pc);
} else {
gen_jmp_tb(s, 0, base + offset);
}
}
| 1threat
|
Addition of integers in C : <p>I want to create a program which asks to the user to type in two integers, from 0 - 10. The program then turns the integers into words and the result is also printed into words.
EXAMPLE:
Please enter two integers: 2 5
two + five = seven</p>
| 0debug
|
Font Awesome 5 Icons not working on Bootstrap 4 : <p>I was trying to add the github (<code>class="fas fa-github"</code>) icon on a bootstrap dark button, but the button icon and text doesn't appear (the console shows nothing)</p>
<p>Code:</p>
<pre><code><div class="jumbotron">
<h1 class="display-4">Henrique Borges</h1>
<p class="lead">Programador experiente e Web Designer.</p>
<hr class="my-4">
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<p class="lead">
<a class="fas fa-github btn btn-dark btn-lg" href="#" role="button">Github</a>
</p>
</div>
</code></pre>
<p>I´ve already included both the BS and FA libraries:</p>
<pre><code><link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/fontawesome-all.min.js"></script>
</code></pre>
| 0debug
|
static void x86_iommu_realize(DeviceState *dev, Error **errp)
{
X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(dev);
X86IOMMUClass *x86_class = X86_IOMMU_GET_CLASS(dev);
MachineState *ms = MACHINE(qdev_get_machine());
MachineClass *mc = MACHINE_GET_CLASS(ms);
PCMachineState *pcms =
PC_MACHINE(object_dynamic_cast(OBJECT(ms), TYPE_PC_MACHINE));
QLIST_INIT(&x86_iommu->iec_notifiers);
if (!pcms) {
error_setg(errp, "Machine-type '%s' not supported by IOMMU",
mc->name);
return;
}
if (x86_class->realize) {
x86_class->realize(dev, errp);
}
x86_iommu_set_default(X86_IOMMU_DEVICE(dev));
}
| 1threat
|
How to convert string to char in Kotlin? : <pre><code>fun main(args: Array<String>) {
val StringCharacter = "A"
val CharCharacter = StringCharacter.toChar()
println(CharCharacter)
}
</code></pre>
<p>I am unable to convert string A to char.
I know that StringCharacter = 'A' makes it char but I need the conversion.</p>
<p>Thanks.</p>
| 0debug
|
void stl_phys_notdirty(target_phys_addr_t addr, uint32_t val)
{
uint8_t *ptr;
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
addr = memory_region_section_addr(section, addr);
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
io_mem_write(section->mr, addr, val, 4);
} else {
unsigned long addr1 = (memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr);
ptr = qemu_get_ram_ptr(addr1);
stl_p(ptr, val);
if (unlikely(in_migration)) {
if (!cpu_physical_memory_is_dirty(addr1)) {
tb_invalidate_phys_page_range(addr1, addr1 + 4, 0);
cpu_physical_memory_set_dirty_flags(
addr1, (0xff & ~CODE_DIRTY_FLAG));
}
}
}
}
| 1threat
|
How can I call a function out of another functione inside a Class : I have the following problem: I want to call the Function "printHello" from the Function "testHello". The printHello function works on its own, however, when I try to call "printHello" from the "testHello" function, I get an reference error. Thank you for your help.
´´´´´´´´´´´´
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
class Test{
constructor(name){
this.name;
}
printHello(parameter){
console.log(parameter);
}
testHello(){
printHello(printHello(this.name));
}
}
var test = new Test("Sandro");
test.printHello("hello"); //works, prints "Hello" to the Console
test.testHello(); // does not work: Reference Error: printHello is not defined
<!-- end snippet -->
| 0debug
|
static void spapr_finalize_fdt(sPAPRMachineState *spapr,
hwaddr fdt_addr,
hwaddr rtas_addr,
hwaddr rtas_size)
{
MachineState *machine = MACHINE(qdev_get_machine());
sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
const char *boot_device = machine->boot_order;
int ret, i;
size_t cb = 0;
char *bootlist;
void *fdt;
sPAPRPHBState *phb;
fdt = g_malloc(FDT_MAX_SIZE);
_FDT((fdt_open_into(spapr->fdt_skel, fdt, FDT_MAX_SIZE)));
ret = spapr_populate_memory(spapr, fdt);
if (ret < 0) {
fprintf(stderr, "couldn't setup memory nodes in fdt\n");
exit(1);
}
ret = spapr_populate_vdevice(spapr->vio_bus, fdt);
if (ret < 0) {
fprintf(stderr, "couldn't setup vio devices in fdt\n");
exit(1);
}
if (object_resolve_path_type("", TYPE_SPAPR_RNG, NULL)) {
ret = spapr_rng_populate_dt(fdt);
if (ret < 0) {
fprintf(stderr, "could not set up rng device in the fdt\n");
exit(1);
}
}
QLIST_FOREACH(phb, &spapr->phbs, list) {
ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt);
if (ret < 0) {
error_report("couldn't setup PCI devices in fdt");
exit(1);
}
}
ret = spapr_rtas_device_tree_setup(fdt, rtas_addr, rtas_size);
if (ret < 0) {
fprintf(stderr, "Couldn't set up RTAS device tree properties\n");
}
spapr_populate_cpus_dt_node(fdt, spapr);
bootlist = get_boot_devices_list(&cb, true);
if (cb && bootlist) {
int offset = fdt_path_offset(fdt, "/chosen");
if (offset < 0) {
exit(1);
}
for (i = 0; i < cb; i++) {
if (bootlist[i] == '\n') {
bootlist[i] = ' ';
}
}
ret = fdt_setprop_string(fdt, offset, "qemu,boot-list", bootlist);
}
if (boot_device && strlen(boot_device)) {
int offset = fdt_path_offset(fdt, "/chosen");
if (offset < 0) {
exit(1);
}
fdt_setprop_string(fdt, offset, "qemu,boot-device", boot_device);
}
if (!spapr->has_graphics) {
spapr_populate_chosen_stdout(fdt, spapr->vio_bus);
}
if (smc->dr_lmb_enabled) {
_FDT(spapr_drc_populate_dt(fdt, 0, NULL, SPAPR_DR_CONNECTOR_TYPE_LMB));
}
if (smc->dr_cpu_enabled) {
int offset = fdt_path_offset(fdt, "/cpus");
ret = spapr_drc_populate_dt(fdt, offset, NULL,
SPAPR_DR_CONNECTOR_TYPE_CPU);
if (ret < 0) {
error_report("Couldn't set up CPU DR device tree properties");
exit(1);
}
}
_FDT((fdt_pack(fdt)));
if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {
error_report("FDT too big ! 0x%x bytes (max is 0x%x)",
fdt_totalsize(fdt), FDT_MAX_SIZE);
exit(1);
}
qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt));
cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));
g_free(bootlist);
g_free(fdt);
}
| 1threat
|
No shortcut for DDMS in Android Studio 2.2 : <p>After updating Android studio to version 2.2, I am not able to find option of DDMS in the toolbar.
Though I can find it in <em>Tools -> Android -> Android Device Monitor</em>.
<br><br>
Any help is highly appreciated.</p>
| 0debug
|
def is_Perfect_Square(n) :
i = 1
while (i * i<= n):
if ((n % i == 0) and (n / i == i)):
return True
i = i + 1
return False
| 0debug
|
Runtime error happens when deleting a node of the linklist : <p>Here's my C++ code of a simple structured linklist.</p>
<pre><code>#include <iostream>
using namespace std;
class Node{
public:
int data;
Node* next;
Node* prev;
Node(){
data=-1;
next=NULL;
prev=NULL;
}
Node(int d,Node *nnext){
data=d;
next=nnext;
}
void add(Node* nnext){
next=nnext;
nnext->prev=this;
}
};
void print(Node* head){
Node* cNode;
cNode=head;
while (cNode!=NULL){
cout <<"["<<cNode->data<<"]" << endl;
cNode=cNode->next;
}
}
void insertAfter(Node* pNode, Node* nNode){
nNode->next = pNode->next;
pNode->next = nNode;
pNode->next->prev = nNode;
}
void deleteNode(Node* b){
Node* c=b->next;
Node* a=b->prev;
a->next=c;
c->prev=a;
delete b;
}
void main(){
Node* head;
head=new Node();
head->data=1;
Node * currentNode=head;
for (int i=2;i<=5;i++){
Node* nNode=new Node(i,NULL);
currentNode->add(nNode);
currentNode=nNode;
}
cout << currentNode->data << endl;
print(head);
insertAfter(head, new Node(99,NULL));
//deleteNode(currentNode);
print(head);
}
</code></pre>
<p>The case checking is unnecessary because I just need the concept of the linklist. If you have another version of these kind of simple linklist code, please let me know! Thank you!</p>
| 0debug
|
static void monitor_read_command(Monitor *mon, int show_prompt)
{
if (!mon->rs)
return;
readline_start(mon->rs, "(qemu) ", 0, monitor_command_cb, NULL);
if (show_prompt)
readline_show_prompt(mon->rs);
}
| 1threat
|
will an hashcode ever give a negative value? : <p>In the code given, it was trying to give a valid index for a hashtable by checking for any collision using another method linearprobe. I am just confuse of why we need to check for index < 0, so will there be instance when hashCode will be negative? When/why will that happens?</p>
<pre><code>private int getHashIndex(K key)
{
//1.convert key to hashcode, then get the index;
//2. then use linear probing to check for the correct index;
int index = key.hashCode() % hashTable.length;
if(index < 0) { //So a hash code can be negative?
index += hashTable.length;
}
index = linearProbe(index,key);
return index;
}
</code></pre>
| 0debug
|
static av_cold int libopenjpeg_encode_close(AVCodecContext *avctx)
{
LibOpenJPEGContext *ctx = avctx->priv_data;
opj_cio_close(ctx->stream);
ctx->stream = NULL;
opj_destroy_compress(ctx->compress);
ctx->compress = NULL;
opj_image_destroy(ctx->image);
ctx->image = NULL;
av_freep(&avctx->coded_frame);
return 0;
}
| 1threat
|
What kind of font files do I need for modern browsers, Android and IOS? : <p>I have these as my font files:</p>
<pre><code>@font-face {
font-family: 'FontAwesome';
src: url('@{fa-font-path}/fontawesome-webfont.eot') format('embedded-opentype'),
url('@{fa-font-path}/fontawesome-webfont.woff2') format('woff2'),
url('@{fa-font-path}/fontawesome-webfont.woff') format('woff'),
url('@{fa-font-path}/fontawesome-webfont.ttf') format('truetype'),
url('@{fa-font-path}/fontawesome-webfont.svg fontawesomeregular') format('svg');
// src: url('@{fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts
font-weight: normal;
font-style: normal;
}
</code></pre>
<p>Would just these meet my needs:</p>
<pre><code>@font-face {
font-family: 'FontAwesome';
src: url('@{fa-font-path}/fontawesome-webfont.eot');
src: url('@{fa-font-path}/fontawesome-webfont.woff2') format('woff2'),
url('@{fa-font-path}/fontawesome-webfont.woff') format('woff'),
url('@{fa-font-path}/fontawesome-webfont.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
</code></pre>
<p>Would just the woff and woff2 meet my needs?</p>
| 0debug
|
Html/css Table border lines/separate editing : i am working on a html/css project for my school but have run into a problem
on one of my pages i have 3 table's witch i want to edit with css separately
if tried to put class in all of the table's but it still only takes the commands of the second table am i suppose to put class in all of the TR's and TD's too?
here is my css code:
body{
background-color: lightgrey;
.tabel1{
border-color: purple;
width: 400px;
text-align: center;
height: 100px;
}
.tabel2, tr, td{
width: 350px;
border-color: grey;
border-style: solid;
border-collapse: collapse;
}
.tabel3{
border-radius: 25px;
background: purple;
padding-left: 2%;
padding-right: 2%;
padding-bottom: 4%;
padding-top: 4%;
width: 400px;
border-color: purple;
box-shadow: 15px 6px 10px purple;
}
| 0debug
|
WPF display record weekly wise in Datagrid with Summary : <p><a href="https://i.stack.imgur.com/lkJTM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lkJTM.png" alt="enter image description here"></a></p>
<p>I have a timesheet data, whose data model is defined as</p>
<pre><code>public class Timesheet
{
public int Id { get; set; }
public string Name { get; set; }
public int Effort { get; set; }
public DateTime Day { get; set; }
}
</code></pre>
<p>My challenge is to display the records in the week's format. However, I'm not sure what is the best approach to design the Datagrid in a way that when the list gets bind with it, the total summary of each column also gets displayed. </p>
| 0debug
|
Testing if an event has been triggered in Jasmine : <p>How do you test if an event has been fired in Jasmine without <code>jquery-jasmine</code>? </p>
<p>I'm working on a project where we don't use jQuery (wohoo), and I'm trying to write a unit test for my menu triggering function. It works like this:</p>
<ul>
<li>You click a button</li>
<li>My testable component then runs <code>document.dispatchEvent(new CustomEvent('menu.toggle'))</code></li>
<li>I want to test that the component indeed dispatched the custom event. </li>
</ul>
<p>How do I test this?</p>
| 0debug
|
custom CMD command for running python script with input parameter : <p>I want to create a custom cmd command that will open a python script and also have a input parameter.</p>
<p>example:
C:\Users\myName> create newFolder</p>
<p>so create is for opening the python script (create.py)
and the parameter is for making a new folder with the same name.</p>
<p>kinda like this video <a href="https://www.youtube.com/watch?v=7Y8Ppin12r4" rel="nofollow noreferrer">https://www.youtube.com/watch?v=7Y8Ppin12r4</a></p>
| 0debug
|
want to remove 2 consecutive lines in r : [Data base Picture][1]
[1]: https://i.stack.imgur.com/52NrJ.png
Hi,
attached is the link of transaction.
this is a scenario of cancelled transaction in a restaurant check.
I want R to check if an item has flag "U", then remove the U and 1 similar item which is not u.
I have marked the items to be removed in Yellow.
Much appreciate the support.
NS
| 0debug
|
understading tcpdump.c file in contiki : I am trying to go through this file in contiki and finding it difficult to comprehend what is the purpose and why it is using such obfuscated code
/*---------------------------------------------------------------------------*/
static char *
s(char *str, char *ptr)
{
strcpy(ptr, str);
return ptr + strlen(str);
}
/*---------------------------------------------------------------------------*/
int
tcpdump_format(uint8_t *packet, uint16_t packetlen,
char *buf, uint16_t buflen)
{
char flags[8];
if(IPBUF->proto == UIP_PROTO_ICMP) {
if(ICMPBUF->type == ICMP_ECHO) {
return s(" ping",
n(IPBUF->destipaddr[3], d(
n(IPBUF->destipaddr[2], d(
n(IPBUF->destipaddr[1], d(
n(IPBUF->destipaddr[0],
s(" ",
n(IPBUF->srcipaddr[3], d(
n(IPBUF->srcipaddr[2], d(
n(IPBUF->srcipaddr[1], d(
n(IPBUF->srcipaddr[0],
buf)))))))))))))))) - buf;
/* return sprintf(buf, "%d.%d.%d.%d %d.%d.%d.%d ping",
IPBUF->srcipaddr[0], IPBUF->srcipaddr[1],
IPBUF->srcipaddr[2], IPBUF->srcipaddr[3],
IPBUF->destipaddr[0], IPBUF->destipaddr[1],
IPBUF->destipaddr[2], IPBUF->destipaddr[3]);*/
}
[https://github.com/contiki-os/contiki/blob/master/tools/wpcapslip/tcpdump.c][1]
the commented part tells what the code is trying to do but why in this way..?
[1]: http://complete%20file
| 0debug
|
How to make an image provider from an Icon in flutter for FadeInImage widget? : <p>I want to use <code>FadeInImage</code> with an icon as a placeholder.</p>
<p><code>FadeInImage</code> has few constructors.</p>
<p>In a default constructor it takes <code>ImageProvider</code> as a placeholder, and in <code>FadeInImage.MemoryNetwork(</code> it takes <code>Uint8List</code> as a memory placeholder.</p>
<p>The third constructor creates AssetImage, but I doubt that is useful here.</p>
<p>Is there any way to convert an Icon to one of those data types?</p>
<p>Example signature:</p>
<p><code>FadeInImage(placeholder: iconPlaceholder, image: NetworkImage("url"))</code></p>
| 0debug
|
static abi_long lock_iovec(int type, struct iovec *vec, abi_ulong target_addr,
int count, int copy)
{
struct target_iovec *target_vec;
abi_ulong base;
int i;
target_vec = lock_user(VERIFY_READ, target_addr, count * sizeof(struct target_iovec), 1);
if (!target_vec)
return -TARGET_EFAULT;
for(i = 0;i < count; i++) {
base = tswapal(target_vec[i].iov_base);
vec[i].iov_len = tswapal(target_vec[i].iov_len);
if (vec[i].iov_len != 0) {
vec[i].iov_base = lock_user(type, base, vec[i].iov_len, copy);
} else {
vec[i].iov_base = NULL;
}
}
unlock_user (target_vec, target_addr, 0);
return 0;
}
| 1threat
|
static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist,
int32_t offset)
{
AHCICmdHdr *cmd = ad->cur_cmd;
uint16_t opts = le16_to_cpu(cmd->opts);
uint16_t prdtl = le16_to_cpu(cmd->prdtl);
uint64_t cfis_addr = le64_to_cpu(cmd->tbl_addr);
uint64_t prdt_addr = cfis_addr + 0x80;
dma_addr_t prdt_len = (prdtl * sizeof(AHCI_SG));
dma_addr_t real_prdt_len = prdt_len;
uint8_t *prdt;
int i;
int r = 0;
uint64_t sum = 0;
int off_idx = -1;
int64_t off_pos = -1;
int tbl_entry_size;
IDEBus *bus = &ad->port;
BusState *qbus = BUS(bus);
if (!prdtl) {
DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
return -1;
}
if (!(prdt = dma_memory_map(ad->hba->as, prdt_addr, &prdt_len,
DMA_DIRECTION_TO_DEVICE))){
DPRINTF(ad->port_no, "map failed\n");
return -1;
}
if (prdt_len < real_prdt_len) {
DPRINTF(ad->port_no, "mapped less than expected\n");
r = -1;
goto out;
}
if (prdtl > 0) {
AHCI_SG *tbl = (AHCI_SG *)prdt;
sum = 0;
for (i = 0; i < prdtl; i++) {
tbl_entry_size = prdt_tbl_entry_size(&tbl[i]);
if (offset <= (sum + tbl_entry_size)) {
off_idx = i;
off_pos = offset - sum;
break;
}
sum += tbl_entry_size;
}
if ((off_idx == -1) || (off_pos < 0) || (off_pos > tbl_entry_size)) {
DPRINTF(ad->port_no, "%s: Incorrect offset! "
"off_idx: %d, off_pos: %"PRId64"\n",
__func__, off_idx, off_pos);
r = -1;
goto out;
}
qemu_sglist_init(sglist, qbus->parent, (prdtl - off_idx),
ad->hba->as);
qemu_sglist_add(sglist, le64_to_cpu(tbl[off_idx].addr) + off_pos,
prdt_tbl_entry_size(&tbl[off_idx]) - off_pos);
for (i = off_idx + 1; i < prdtl; i++) {
qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr),
prdt_tbl_entry_size(&tbl[i]));
if (sglist->size > INT32_MAX) {
error_report("AHCI Physical Region Descriptor Table describes "
"more than 2 GiB.\n");
qemu_sglist_destroy(sglist);
r = -1;
goto out;
}
}
}
out:
dma_memory_unmap(ad->hba->as, prdt, prdt_len,
DMA_DIRECTION_TO_DEVICE, prdt_len);
return r;
}
| 1threat
|
Iterate over nth amount of indexes in an array of objects : <p>i am trying to return the sum of the <strong>first 4</strong> grid values from the object below (expected output <strong>5</strong>)</p>
<pre><code>[
{
"id": 1,
"grid": 1
},
{
"id": 2,
"grid": 2
},
{
"id": 3,
"grid": 1
},
{
"id": 4,
"grid": 1
},
{
"id": 5,
"grid": 1
}
]
data.map(item => {
console.log(item.grid);
});
</code></pre>
<p>Relatively new with .map, I would usually use a forwhile iterator but wondered if someone could suggest a more es6 style pattern for solving the problem.</p>
| 0debug
|
project migrating to new version of java (Java 1.8) : <p>Currently my project uses java 1.7 and we have requirement to upgrade it to 1.8.
what are the key points i have to consider before estimating the hours?</p>
| 0debug
|
static int poll_rest(gboolean poll_msgs, HANDLE *handles, gint nhandles,
GPollFD *fds, guint nfds, gint timeout)
{
DWORD ready;
GPollFD *f;
int recursed_result;
if (poll_msgs) {
ready = MsgWaitForMultipleObjectsEx(nhandles, handles, timeout,
QS_ALLINPUT, MWMO_ALERTABLE);
if (ready == WAIT_FAILED) {
gchar *emsg = g_win32_error_message(GetLastError());
g_warning("MsgWaitForMultipleObjectsEx failed: %s", emsg);
g_free(emsg);
}
} else if (nhandles == 0) {
if (timeout == INFINITE) {
ready = WAIT_FAILED;
} else {
SleepEx(timeout, TRUE);
ready = WAIT_TIMEOUT;
}
} else {
ready =
WaitForMultipleObjectsEx(nhandles, handles, FALSE, timeout, TRUE);
if (ready == WAIT_FAILED) {
gchar *emsg = g_win32_error_message(GetLastError());
g_warning("WaitForMultipleObjectsEx failed: %s", emsg);
g_free(emsg);
}
}
if (ready == WAIT_FAILED) {
return -1;
} else if (ready == WAIT_TIMEOUT || ready == WAIT_IO_COMPLETION) {
return 0;
} else if (poll_msgs && ready == WAIT_OBJECT_0 + nhandles) {
for (f = fds; f < &fds[nfds]; ++f) {
if (f->fd == G_WIN32_MSG_HANDLE && f->events & G_IO_IN) {
f->revents |= G_IO_IN;
}
}
if (timeout != 0 || nhandles == 0) {
return 1;
}
recursed_result = poll_rest(FALSE, handles, nhandles, fds, nfds, 0);
return (recursed_result == -1) ? -1 : 1 + recursed_result;
} else if (
ready < WAIT_OBJECT_0 + nhandles) {
for (f = fds; f < &fds[nfds]; ++f) {
if ((HANDLE) f->fd == handles[ready - WAIT_OBJECT_0]) {
f->revents = f->events;
}
}
if (timeout == 0 && nhandles > 1) {
int i;
if (ready < nhandles - 1) {
for (i = ready - WAIT_OBJECT_0 + 1; i < nhandles; i++) {
handles[i-1] = handles[i];
}
}
nhandles--;
recursed_result = poll_rest(FALSE, handles, nhandles, fds, nfds, 0);
return (recursed_result == -1) ? -1 : 1 + recursed_result;
}
return 1;
}
return 0;
}
| 1threat
|
static void gen_rac(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
TCGv t0;
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
t0 = tcg_temp_new();
gen_addr_reg_index(ctx, t0);
gen_helper_rac(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
tcg_temp_free(t0);
#endif
}
| 1threat
|
Decrease List style bullet size using css? : <p>I searched at different sites but I can't get an actual solution for me. I want to decrease the size of bullet icon on li. But I don't wanna use the image at li:: before. Are there any ideas?</p>
| 0debug
|
static int svq1_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MpegEncContext *s=avctx->priv_data;
uint8_t *current, *previous;
int result, i, x, y, width, height;
AVFrame *pict = data;
svq1_pmv *pmv;
init_get_bits(&s->gb,buf,buf_size*8);
s->f_code = get_bits (&s->gb, 22);
if ((s->f_code & ~0x70) || !(s->f_code & 0x60))
return -1;
if (s->f_code != 0x20) {
uint32_t *src = (uint32_t *) (buf + 4);
for (i=0; i < 4; i++) {
src[i] = ((src[i] << 16) | (src[i] >> 16)) ^ src[7 - i];
}
}
result = svq1_decode_frame_header (&s->gb, s);
if (result != 0)
{
av_dlog(s->avctx, "Error in svq1_decode_frame_header %i\n",result);
return result;
}
if(s->pict_type==AV_PICTURE_TYPE_B && s->last_picture_ptr==NULL) return buf_size;
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B)
||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I)
|| avctx->skip_frame >= AVDISCARD_ALL)
return buf_size;
if(MPV_frame_start(s, avctx) < 0)
return -1;
pmv = av_malloc((FFALIGN(s->width, 16)/8 + 3) * sizeof(*pmv));
if (!pmv)
return -1;
for (i=0; i < 3; i++) {
int linesize;
if (i == 0) {
width = FFALIGN(s->width, 16);
height = FFALIGN(s->height, 16);
linesize= s->linesize;
} else {
if(s->flags&CODEC_FLAG_GRAY) break;
width = FFALIGN(s->width/4, 16);
height = FFALIGN(s->height/4, 16);
linesize= s->uvlinesize;
}
current = s->current_picture.f.data[i];
if(s->pict_type==AV_PICTURE_TYPE_B){
previous = s->next_picture.f.data[i];
}else{
previous = s->last_picture.f.data[i];
}
if (s->pict_type == AV_PICTURE_TYPE_I) {
for (y=0; y < height; y+=16) {
for (x=0; x < width; x+=16) {
result = svq1_decode_block_intra (&s->gb, ¤t[x], linesize);
if (result != 0)
{
av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_block %i (keyframe)\n",result);
goto err;
}
}
current += 16*linesize;
}
} else {
memset (pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv));
for (y=0; y < height; y+=16) {
for (x=0; x < width; x+=16) {
result = svq1_decode_delta_block (s, &s->gb, ¤t[x], previous,
linesize, pmv, x, y);
if (result != 0)
{
av_dlog(s->avctx, "Error in svq1_decode_delta_block %i\n",result);
goto err;
}
}
pmv[0].x =
pmv[0].y = 0;
current += 16*linesize;
}
}
}
*pict = *(AVFrame*)&s->current_picture;
MPV_frame_end(s);
*data_size=sizeof(AVFrame);
result = buf_size;
err:
av_free(pmv);
return result;
}
| 1threat
|
static VncServerInfo *vnc_server_info_get(VncDisplay *vd)
{
VncServerInfo *info;
Error *err = NULL;
info = g_malloc(sizeof(*info));
vnc_init_basic_info_from_server_addr(vd->lsock,
qapi_VncServerInfo_base(info), &err);
info->has_auth = true;
info->auth = g_strdup(vnc_auth_name(vd));
if (err) {
qapi_free_VncServerInfo(info);
info = NULL;
error_free(err);
}
return info;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.