problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
arrays additional and average is not showing output in c program but is is asking for the 2 inputs : <pre><code>#include<stdio.h>
main()
{
int scores[3], sum;
float avg;
printf("enter the value for scores\n");
scanf("%d\n %d\n %d\n",&scores[0],&scores[1],&scores[2]);
sum=scores[0]+scores[1]+scores[2];
avg=sum/3;
printf("The sum is :%d\n The avg is :%f\n",sum,avg);
system("pause");
}
</code></pre>
<p>When I am running the program then program is asking for the input but it is not showing the output.</p>
| 0debug
|
Understanding OOP and static in java : Alright,
Suppose you have **class A** and **class B**. **Class A** is the main class which builds a frame with a GUI. It contains all the GUI variables (such as buttons, labels, strings) along with whatever methods that you'll be using. **Class A** also creates a **class B** object:
ClassB name = new ClassB();
Inside **class B** you will find a **for loop**. Now, once the for loop is finished looping, I want to call a method located in **class A.** Whenever I try calling a method located in **class A**, Eclipse insists making that method **static**. I'm trying to avoid making static methods. Is there any way around this problem?
| 0debug
|
'react-native' is not recognized as an internal or external command, operable program or batch file : <p>I recently started with react-native. I install it using the tutorial on the facebook site and everything works well for a day or two, until this message comes up:</p>
<pre><code>'react-native' is not recognized as an internal or external command,
operable program or batch file.
</code></pre>
<p>Nothing works except uninstalling everything and starting all over again. The environments are ok and work (npm, choco, etc.). I have also tried removing and adding react-native to environment variables, restarting, running cmd in administrator mode, but nothing so far. I should add that I use windows 10 64-bit.</p>
| 0debug
|
How can I compute histogram using three variable in matlab : I have three variable, for e.g latitude, longitude and temperature. For each latitude and longitude, I have corresponding temperature value. I want to plot latitude v/s longitude plot in 5 degree x 5 degree grid , with mean temperature value inserted in that particular grid instead of occurring frequency.
| 0debug
|
Change Background color of MenuItem on MouseOver : <p>I want to change the default background color of a MenuItem at mouseOver. Here is my xaml code:</p>
<p><a href="https://i.stack.imgur.com/S5SwM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/S5SwM.png" alt="enter image description here"></a></p>
<p>Style :</p>
<pre><code><Style TargetType="{x:Type MenuItem}" x:Key="MenuItemStyle" >
<Setter Property="BorderBrush" Value="White"></Setter>
<Setter Property="BorderThickness" Value="0,0,0,5"></Setter>
<Setter Property="Background" Value="#0264AD"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="FontSize" Value="12"></Setter>
<Setter Property="FontFamily" Value="Arial"></Setter>
<Setter Property="FontWeight" Value="Bold"></Setter>
<Setter Property="Margin" Value="-5,0,0,0"></Setter>
<Setter Property="Padding" Value="0,12,0,12"></Setter>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="LightGray"></Setter>
<Setter Property="Background" Value="#0264AD"></Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="#0264AD"></Setter>
<Setter Property="Background" Value="Yellow"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</code></pre>
<p>Control : </p>
<pre><code><ContextMenu x:Name="settingContextMenu" Width="220" >
<MenuItem Style="{StaticResource MenuItemStyle}" Name="CustomizeLocationNames" Click="CustomizeLocationNames_Click" >
<MenuItem.Header>
<TextBlock Text="Customize Location Names" VerticalAlignment="Center"></TextBlock>
</MenuItem.Header>
</MenuItem>
<MenuItem Style="{StaticResource MenuItemStyle}" Name="ZoomRoute" Click="ZoomRoute_Click">
<MenuItem.Header>
<TextBlock Text="Zoom Route" VerticalAlignment="Center"></TextBlock>
</MenuItem.Header>
</MenuItem>
<MenuItem Style="{StaticResource MenuItemStyle}" Name="PrintRoute" Click="PrintRoute_Click">
<MenuItem.Header>
<TextBlock Text="Print Route" VerticalAlignment="Center" >/TextBlock>
</MenuItem.Header>
</MenuItem>
</ContextMenu>
</code></pre>
<p>So I have mouse over trigger which should turn background color to yellow if mouse is over, but it is showing default light grey color as shown in snap,</p>
<p>Can anyone tell me how to get background color YELLOW on mouse over?</p>
| 0debug
|
This site is not authotized : Please help me!
I am creating find near by places application in android, when i request for places using UnRestricted key. It will response me fully.
- But after restricting Key with my project name, Released SHA1 and Debug SHA1
it will not responding and give me error.
"This IP, site or mobile application is not authorized to use this API key.
Ask Question".
- I am requesting using HttpURLConnection,
- My request code is
StringBuilder googlePlaceUrl = new StringBuilder ("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=" + latitude + "," + longitude + "&rankby=distance&type="+ nearbyPlace +"&key=xxxxxxxxxxx");
- I my manifest <meta-data
android:name="com.google.android.geo.API_KEY"
android:value="xxxxxxxxx" />
I am not expecting this answer.
{ "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 103.24.99.82, with empty referer",
"routes" : [], "status" : "REQUEST_DENIED"
}
| 0debug
|
How To Remove Navigation Controller Back Button Text : <p>When you create a navigation controller in the storyboard and create a segue to another view controller you automatically get this back button with an arrow and the title of previous page. (see image)</p>
<p><a href="https://i.stack.imgur.com/iSYTy.jpg" rel="nofollow noreferrer">Image of problem</a></p>
<p>How can I delete the text and still have the arrow there?
or
How can I replace with my own image?</p>
<p>Thanks!</p>
| 0debug
|
How to make an .exe generated by Visual Studio 2013 run in other computers? : <p>Greetings to everyone in this forum.</p>
<p>I just finished my mid-term project in Visual Studio 2013 for collegue and my professor want us to give him the .exe of the project. The problem is that it only works in my computer. When I try to open the .exe in other computers, this error shows up:</p>
<ul>
<li>The program can't start because MSVCP120.dll is missing from your computer. Try reinstalling the program to fix this problem. </li>
</ul>
<p>I was wondering if there is any way to fix this problem, so that the .exe can work in any computer that run Windows.</p>
<p>I really appreciate any help you can provide.</p>
| 0debug
|
static void sr_1d97_float(float *p, int i0, int i1)
{
int i;
if (i1 <= i0 + 1) {
if (i0 == 1)
p[1] *= F_LFTG_K/2;
else
p[0] *= F_LFTG_X/2;
return;
}
extend97_float(p, i0, i1);
for (i = i0 / 2 - 1; i < i1 / 2 + 2; i++)
p[2 * i] -= F_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]);
for (i = i0 / 2 - 1; i < i1 / 2 + 1; i++)
p[2 * i + 1] -= F_LFTG_GAMMA * (p[2 * i] + p[2 * i + 2]);
for (i = i0 / 2; i < i1 / 2 + 1; i++)
p[2 * i] += F_LFTG_BETA * (p[2 * i - 1] + p[2 * i + 1]);
for (i = i0 / 2; i < i1 / 2; i++)
p[2 * i + 1] += F_LFTG_ALPHA * (p[2 * i] + p[2 * i + 2]);
}
| 1threat
|
Why can't I change colobox title font size? : I am currently using the colorbox plugin for my gallery from:
http://www.jacklmoore.com/colorbox/.
I want to change the font-size of the title in the anchor tag, so I tried adding a font-size into the properties of #cboxtitle. However, it the size of the font is still the same. I also tried doing an inline styling on the anchor tag but to no avail. Is there a way to change the size of the font of the title for the anchor tag?
Below is the html code I am using:
<div class="col-sm-12 col-md-4" id="section">
<p><a class="group4 cboxTitle" href="Images/event1.jpg" title="Gallery 1 image"><img src="Images/event1.JPG" alt="" style="height: 200px; width: 300px;"/></a></p>
</div>
<div class="col-sm-12 col-md-4" id="section">
<p><a class="group4" href="Images/event2.jpg" title="Gallery 2 image"><img src="Images/event2.JPG" alt="" style="height: 200px; width: 300px;"/></a></p>
</div>
<div class="col-sm-12 col-md-4" id="section">
<p><a class="group4" href="Images/event3.jpg" title="Gallery 3 image."><img src="Images/event3.JPG" alt="" style="height: 200px; width: 300px;"/></a></p>
</div>
CSS for the colorbox:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden; -webkit-transform: translate3d(0,0,0);}
#cboxWrapper {max-width:none;}
#cboxOverlay{position:fixed; width:100%; height:100%;}
#cboxMiddleLeft, #cboxBottomLeft{clear:left;}
#cboxContent{position:relative;}
#cboxLoadedContent{overflow:auto; -webkit-overflow-scrolling: touch;}
#cboxTitle{margin:0; font-size: 40px !important;}
#cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;}
#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}
.cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;}
.cboxIframe{width:100%; height:100%; display:block; border:0; padding:0; margin:0;}
#colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;}
#cboxOverlay{background:#fff; opacity: 0.9; filter: alpha(opacity = 90);}
#colorbox{outline:0;}
#cboxTopLeft{width:25px; height:25px; background:url(images/border1.png) no-repeat 0 0;}
#cboxTopCenter{height:25px; background:url(images/border1.png) repeat-x 0 -50px;}
#cboxTopRight{width:25px; height:25px; background:url(images/border1.png) no-repeat -25px 0;}
#cboxBottomLeft{width:25px; height:25px; background:url(images/border1.png) no-repeat 0 -25px;}
#cboxBottomCenter{height:25px; background:url(images/border1.png) repeat-x 0 -75px;}
#cboxBottomRight{width:25px; height:25px; background:url(images/border1.png) no-repeat -25px -25px;}
#cboxMiddleLeft{width:25px; background:url(images/border2.png) repeat-y 0 0;}
#cboxMiddleRight{width:25px; background:url(images/border2.png) repeat-y -25px 0;}
#cboxContent{background:#fff; overflow:hidden;}
.cboxIframe{background:#fff;}
#cboxError{padding:50px; border:1px solid #ccc;}
#cboxLoadedContent{margin-bottom:20px;}
#cboxTitle{position:absolute; bottom:0px; left:0; text-align:center; width:100%; color:#999;}
#cboxCurrent{position:absolute; bottom:0px; left:100px; color:#999;}
#cboxLoadingOverlay{background:#fff url(images/loading.gif) no-repeat 5px 5px;}
<!-- end snippet -->
| 0debug
|
static void writer_print_time(WriterContext *wctx, const char *key,
int64_t ts, const AVRational *time_base, int is_duration)
{
char buf[128];
if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
writer_print_string(wctx, key, "N/A", 1);
} else {
double d = ts * av_q2d(*time_base);
struct unit_value uv;
uv.val.d = d;
uv.unit = unit_second_str;
value_string(buf, sizeof(buf), uv);
writer_print_string(wctx, key, buf, 0);
}
}
| 1threat
|
VB.Net "Convertion of the string into the type double is not valid" : Guys, I need some help with a VB.Net code, I can´t go through
Every time I run it I get the message "THe convertion of the string is not valid for double, can you help me with that. thanks
Dim num1 As Double = 0
Dim num2 As Double = 0
Dim operacion As Decimal
' Asignar n valores a las variables declaradas
num1 = TextBox1.Text
num2 = TextBox2.Text
' Operacion de incremento porcentual
operacion = num1 + num1 * num2 / 100
' Mostrar el resultado de la operacion mediante un MsgBox - Se redondea el resultado
MsgBox(Math.Round(operacion, 2), MsgBoxStyle.OkOnly, "Incremento Porcentual")
End Sub
| 0debug
|
How do I get time diiference between two dates in milliseconds in C#? : <p>In Javascript I can use <code>var d = new Date();
var n = d.getTime();</code> to get the time in milliseconds. Is there any similar method in C#?</p>
| 0debug
|
can't use Piccaso in Fragments : Here's my code where I've got error in
Picasso.with(ThreeFragement.this).load(model.getMoviePoster()).into(viewHolder.ivMoviePoster);
even if im setting ThreeFragment to getContext, it is not working.
the whole code is written below where in i want to implement piccaso to a firebase recycler view in a fragment and retrieve images over it.
this was just a tutorial implemented on an activity which i tried putting in Fragment.
Thanks in advance!
package com.tabs.ayushmaniac.letsmanageit;
import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import com.tabs.ayushmaniac.letsmanageit.fragment.AddMovieFragment;
import com.tabs.ayushmaniac.letsmanageit.models.Movie;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.squareup.picasso.Picasso;
public class ThreeFragment extends Fragment {
private FloatingActionButton fab;
ScaleAnimation shrinkAnim;
private RecyclerView mRecyclerView;
private StaggeredGridLayoutManager mLayoutManager;
private TextView tvNoMovies;
//Getting reference to Firebase Database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference mDatabaseReference = database.getReference();
private static final String USER_ID = "53";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_three, container, false);
return rootView;
//Initializing our Recyclerview
mRecyclerView = (RecyclerView)getView().findViewById(R.id.my_recycler_view);
tvNoMovies = (TextView)getView().findViewById(R.id.tv_no_movies);
//scale animation to shrink floating actionbar
shrinkAnim = new ScaleAnimation(1.15f, 0f, 1.15f, 0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
if (mRecyclerView != null) {
//to enable optimization of recyclerview
mRecyclerView.setHasFixedSize(true);
}
//using staggered grid pattern in recyclerview
mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(mLayoutManager);
//Say Hello to our new Firebase UI Element, i.e., FirebaseRecyclerAdapter
final FirebaseRecyclerAdapter<Movie,MovieViewHolder> adapter = new FirebaseRecyclerAdapter<Movie, MovieViewHolder>(
Movie.class,
R.layout.movie_board_item,
MovieViewHolder.class,
//referencing the node where we want the database to store the data from our Object
mDatabaseReference.child("users").child(USER_ID).child("movies").getRef()
) {
@Override
protected void populateViewHolder(MovieViewHolder viewHolder, Movie model, int position) {
if(tvNoMovies.getVisibility()== View.VISIBLE){
tvNoMovies.setVisibility(View.GONE);
}
viewHolder.tvMovieName.setText(model.getMovieName());
viewHolder.ratingBar.setRating(model.getMovieRating());
Picasso.with(this).load(model.getMoviePoster()).into(viewHolder.ivMoviePoster);
}
};
mRecyclerView.setAdapter(adapter);
fab = (FloatingActionButton)getView().findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
getFragmentManager().beginTransaction()
.replace(R.id.frame_container, new AddMovieFragment())
.addToBackStack(null)
.commit();
//animation being used to make floating actionbar disappear
shrinkAnim.setDuration(400);
fab.setAnimation(shrinkAnim);
shrinkAnim.start();
shrinkAnim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
//changing floating actionbar visibility to gone on animation end
fab.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
});
}
public static class MovieViewHolder extends RecyclerView.ViewHolder{
TextView tvMovieName;
RatingBar ratingBar;
ImageView ivMoviePoster;
public MovieViewHolder(View v) {
super(v);
tvMovieName = (TextView) v.findViewById(R.id.tv_name);
ratingBar = (RatingBar) v.findViewById(R.id.rating_bar);
ivMoviePoster = (ImageView) v.findViewById(R.id.iv_movie_poster);
}
}
}
| 0debug
|
show alertdialog but cover the actionbar : I'm new in android and I try using alertdialog but always cover the actionbar.
how can doing something like dropdown menu like the picture shown?
I[![enter image description here][1]][1]
[1]: http://i.stack.imgur.com/dX4lF.png
| 0debug
|
static int spapr_post_load(void *opaque, int version_id)
{
sPAPRMachineState *spapr = (sPAPRMachineState *)opaque;
int err = 0;
if (!object_dynamic_cast(OBJECT(spapr->ics), TYPE_ICS_KVM)) {
CPUState *cs;
CPU_FOREACH(cs) {
PowerPCCPU *cpu = POWERPC_CPU(cs);
icp_resend(ICP(cpu->intc));
if (version_id < 3) {
err = spapr_rtc_import_offset(&spapr->rtc, spapr->rtc_offset);
if (kvm_enabled() && spapr->patb_entry) {
PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
bool radix = !!(spapr->patb_entry & PATBE1_GR);
bool gtse = !!(cpu->env.spr[SPR_LPCR] & LPCR_GTSE);
err = kvmppc_configure_v3_mmu(cpu, radix, gtse, spapr->patb_entry);
error_report("Process table config unsupported by the host");
return -EINVAL;
| 1threat
|
Please be understanding, I am new to this. Can some please explain the verify function? : <pre><code>#include <stdio.h>
#define TRUE 1
#define FALSE 0
void limit(int stop)
{
int x;
for(x=0;x<=100;x=x+1)
{
printf("%d\t",x);
if(x==stop)
{
printf("You Won!\n");
return;
}
}
}
int verify(int check) /*this part*/
{
if(check<0 || check>100)
{
return FALSE;
}
return TRUE;
}
int main()
{
int x;
printf("Enter a stopping value(1-100): ");
scanf("%d",&x);
if(verify(x))/*this part too*/
{
limit(x);
}
else
{
printf("%d is out of range.\n",x);
}
return 0;
}
</code></pre>
<p>I want to know how the verify function works. The parts I do not know are commented. How do the verify function verify if the input value is within the range? The verify function returns FALSE which is 0 when it is out of range but how is it use? </p>
| 0debug
|
Updated ms access table by joining other table not working : UPDATE tbl_a a
INNER JOIN tbl_a b IN '' [MS Access;PWD=Cb4XTNLq34c$;DATABASE=C:\data\memberdetails.mdb] ON a.mobile=b.mobile
SET a.Mobilenew = b.Mobilenew, a.isUpdated = 1, a.Operator = b.Operator where b.isupdated=1
| 0debug
|
How to lock threads in real-time applications : <p>Absolute multi-threading newbie here. </p>
<p>I have a multimedia application that plays music. Specifically, it has an audio thread that reads some data - e.g. a waveform - and sends it to the sound card. This is a real-time operation, so it must be executed as quick as possible in a "non-blocking" way. </p>
<p>On the other side there is another thread that takes care of the user interface. Here the user can perform some operations on that data - e.g. modify the waveform by adding or removing chunks. This of course should be possible, but the audio thread must keep running undisturbed with that data always available.</p>
<p>My first idea was something like this (c++-ish pthread pseudo code):</p>
<p>Audio thread:</p>
<pre class="lang-cpp prettyprint-override"><code>vector<sample> samples; // this is shared between this thread and the UI thread
mutexLock();
for (Sample sample : samples)
play(sample);
mutexUnlock();
</code></pre>
<p>And the UI thread:</p>
<pre class="lang-cpp prettyprint-override"><code>void onEditSample()
{
while (mutexTryLock() == 0)
{
editSamples(samples);
mutexUnlock();
break;
}
}
</code></pre>
<p>But I'm not really sure about the try-lock part. What is in your opinion the best way to deal with this?</p>
| 0debug
|
Try/catch to get ipv4 adress : I was reading a lesson about protocol , but I don't understand why use a try/catch to get an ipv4 adress.
Thank you
[Code][1]
[1]: https://i.stack.imgur.com/IKbLj.jpg
| 0debug
|
Can't get errorlevel in batch : When I run commands "Start C:\temp\sub2.bat" per line, errlrlevel return "4" and this is correct because a file which is indicated in batch does not exist. But when I run through this below, errorlevel returns "0". I have no idea why return code are different. Can anyone give me an advice for this?
@echo off
Call :Sub1
GOTO :EOF
:Sub1
start C:\temp\sub2.bat
echo %errorLevel%
| 0debug
|
ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
MemoryRegion *mr)
{
RAMBlock *new_block;
size = TARGET_PAGE_ALIGN(size);
new_block = g_malloc0(sizeof(*new_block));
new_block->mr = mr;
new_block->offset = find_ram_offset(size);
if (host) {
new_block->host = host;
new_block->flags |= RAM_PREALLOC_MASK;
} else {
if (mem_path) {
#if defined (__linux__) && !defined(TARGET_S390X)
new_block->host = file_ram_alloc(new_block, size, mem_path);
if (!new_block->host) {
new_block->host = qemu_vmalloc(size);
qemu_madvise(new_block->host, size, QEMU_MADV_MERGEABLE);
}
#else
fprintf(stderr, "-mem-path option unsupported\n");
exit(1);
#endif
} else {
if (xen_enabled()) {
xen_ram_alloc(new_block->offset, size, mr);
} else if (kvm_enabled()) {
new_block->host = kvm_vmalloc(size);
} else {
new_block->host = qemu_vmalloc(size);
}
qemu_madvise(new_block->host, size, QEMU_MADV_MERGEABLE);
}
}
new_block->length = size;
QLIST_INSERT_HEAD(&ram_list.blocks, new_block, next);
ram_list.phys_dirty = g_realloc(ram_list.phys_dirty,
last_ram_offset() >> TARGET_PAGE_BITS);
cpu_physical_memory_set_dirty_range(new_block->offset, size, 0xff);
if (kvm_enabled())
kvm_setup_guest_memory(new_block->host, size);
return new_block->offset;
}
| 1threat
|
static BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{
RawPosixAIOData *acb = g_slice_new(RawPosixAIOData);
acb->bs = bs;
acb->aio_type = type;
acb->aio_fildes = fd;
if (qiov) {
acb->aio_iov = qiov->iov;
acb->aio_niov = qiov->niov;
}
acb->aio_nbytes = nb_sectors * 512;
acb->aio_offset = sector_num * 512;
trace_paio_submit(acb, opaque, sector_num, nb_sectors, type);
return thread_pool_submit_aio(aio_worker, acb, cb, opaque);
}
| 1threat
|
static void s390_ipl_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
k->init = s390_ipl_init;
dc->props = s390_ipl_properties;
dc->reset = s390_ipl_reset;
dc->no_user = 1;
}
| 1threat
|
Getting todays date in a specific date format in a react application : I will like to get todays date in the format below in a react.js application.
"2019020420"
I am able to get the current date with this function. How can I modify this such that
it will give me the above date format.
getCurrentDate() {
var tempDate = new Date();
var date = tempDate.getFullYear() + '-' + (tempDate.getMonth()+1) + '-' + tempDate.getDate() +' '+ tempDate.getHours()+':'+ tempDate.getMinutes()+':'+ tempDate.getSeconds();
const currDate = date;
return currDate;
}
| 0debug
|
How do I properly setup pipenv in PyCharm? : <p>I need krakenex in a project, so I import it with</p>
<pre><code>import krakenex
</code></pre>
<p>I have one version of krakenex in </p>
<blockquote>
<p>/Users/x/Library/Python/3.6/lib/python/site-packages</p>
</blockquote>
<p>. When I execute the script and</p>
<pre><code>print(krakenex)
</code></pre>
<p>it shows me the path mentioned above.</p>
<p>In the future, I want to use the modules from the packages I installed with e.g.</p>
<pre><code>pipenv install krakenex
</code></pre>
<p>with priority.</p>
<p>How do I manage to do that? Is it sufficient to add the path of the virtual environment to the sys path, or is there a more elegant way?</p>
| 0debug
|
void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action,
bool is_read, int error)
{
assert(error >= 0);
bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read);
if (action == BDRV_ACTION_STOP) {
vm_stop(RUN_STATE_IO_ERROR);
bdrv_iostatus_set_err(bs, error);
}
}
| 1threat
|
Node can run .ts files, so why use tsc to transpile to .js? : <p>The following works on node version 12</p>
<pre><code>node hello.ts
</code></pre>
<p>What is the point of installing </p>
<pre><code> npm install -g typescript
</code></pre>
<p>And then doing</p>
<pre><code>tsc hello.ts
</code></pre>
<p>To obtain hello.js and then do</p>
<pre><code>node hello.js
</code></pre>
<p>Is there a difference between the two? I have only tested this with minimal code. Is there a fundamentally different implementation inside node that transpiles to javascript compared to what tsc does?</p>
<p>Thank you</p>
| 0debug
|
Angular 2: Functions to be used across all components : <p>I have an angular 2 webpack project where I currently have some functions that are repeated throughout several components. I would like to inherit all of these components from a "master" class OR component (whichever works), in order to be able to call my functions from all my components that need them.</p>
<p>As an example, if I have a function foo in 3 different components:</p>
<pre><code>foo(s: string){
console.log(s);
}
</code></pre>
<p>I would like you move this function to another file/class/components:</p>
<pre><code>class parent{
foo(s: string){
console.log(s);
}
}
</code></pre>
<p>And having someway to call my foo function from my a given component. For instance:</p>
<pre><code>class child{
constructor(){
foo("Hello");
}
}
</code></pre>
<p>How would I do this using Angular 2 / Typescript?</p>
| 0debug
|
static ssize_t nbd_co_send_reply(NBDRequestData *req, NBDReply *reply,
int len)
{
NBDClient *client = req->client;
ssize_t rc, ret;
g_assert(qemu_in_coroutine());
qemu_co_mutex_lock(&client->send_lock);
client->send_coroutine = qemu_coroutine_self();
if (!len) {
rc = nbd_send_reply(client->ioc, reply);
} else {
qio_channel_set_cork(client->ioc, true);
rc = nbd_send_reply(client->ioc, reply);
if (rc >= 0) {
ret = write_sync(client->ioc, req->data, len, NULL);
if (ret < 0) {
rc = -EIO;
}
}
qio_channel_set_cork(client->ioc, false);
}
client->send_coroutine = NULL;
qemu_co_mutex_unlock(&client->send_lock);
return rc;
}
| 1threat
|
Communicating with fragment NullPointerException : <p>I'm very new to Android UI, I've been looking for a place I can learn the basic structure of UI and how communication and layouts should work. But regardless. My problem comes from me trying to change the value of a TextView within a fragment. I keep getting a nullPointerException when i try to change the value. I am using a fragment manager to refer to the fragment.</p>
<p>Here's the fragment code:</p>
<pre><code>package com.archronix.infotainment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class Fragment1 extends android.support.v4.app.Fragment {
public TextView status;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_fragment1, container,
false);
return v;
}
public static Fragment1 newInstance() {
Fragment1 f = new Fragment1();
return f;
}
public void postText(String str){
status.setText(status.getText()+"\n"+str);
}
}
</code></pre>
<p>And this is how i declare my fragment manager:</p>
<pre><code>fragment1 = (Fragment1)
getSupportFragmentManager().findFragmentById(R.id.fragment1);
</code></pre>
<p>And, how I use it:</p>
<pre><code>fragment1.postText("testtext");
</code></pre>
<p>My logcat:</p>
<p>05-15 10:56:42.406 4109-4109/com.archronix.infotainment E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.archronix.infotainment, PID: 4109
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.archronix.infotainment/com.archronix.infotainment.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.archronix.infotainment.Fragment1.postText(java.lang.String)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.archronix.infotainment.Fragment1.postText(java.lang.String)' on a null object reference
at com.archronix.infotainment.MainActivity.onCreate(MainActivity.java:102)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) </p>
<p>Apologies for my newbieness. I've read 20 stack overflow posts regarding similar topics but all seem to be either outdated or not consistent. What is the best way to accomplish my task? Thank you.</p>
| 0debug
|
static void gen_rfi(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_update_cfar(ctx, ctx->nip);
gen_helper_rfi(cpu_env);
gen_sync_exception(ctx);
#endif
}
| 1threat
|
Jquery click doesn't work with custom cursor (div following mouse) : <p>I have a div following the mouse, to make a custom cursor, but the issue is, then no jquery click listeners on anything works, because technically I'm clicking the "cursor", not what I'm trying to click on, I've tried changing the z-index but that doesn't seem to help, </p>
<p>Any help appreciated.</p>
| 0debug
|
void drive_hot_add(Monitor *mon, const QDict *qdict)
{
int dom, pci_bus;
unsigned slot;
int type, bus;
int success = 0;
PCIDevice *dev;
DriveInfo *dinfo;
const char *pci_addr = qdict_get_str(qdict, "pci_addr");
const char *opts = qdict_get_str(qdict, "opts");
BusState *scsibus;
if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
return;
}
dev = pci_find_device(pci_bus, slot, 0);
if (!dev) {
monitor_printf(mon, "no pci device with address %s\n", pci_addr);
return;
}
dinfo = add_init_drive(opts);
if (!dinfo)
return;
if (dinfo->devaddr) {
monitor_printf(mon, "Parameter addr not supported\n");
return;
}
type = dinfo->type;
bus = drive_get_max_bus (type);
switch (type) {
case IF_SCSI:
success = 1;
scsibus = LIST_FIRST(&dev->qdev.child_bus);
scsi_bus_legacy_add_drive(DO_UPCAST(SCSIBus, qbus, scsibus),
dinfo, dinfo->unit);
break;
default:
monitor_printf(mon, "Can't hot-add drive to type %d\n", type);
}
if (success)
monitor_printf(mon, "OK bus %d, unit %d\n",
dinfo->bus,
dinfo->unit);
return;
}
| 1threat
|
BATCH FILE FOR DATA COPY BY USER INPUT : Everyone i need your help in below batch file code for MS Windows.
@echo off
cd\
dir/s *.docx *.xlsx *.ppt *.docx
SET /p input= %data% "
copy "%data%" C:\abc\
pause
This command shows all 4 types of extension list all over drives but here i want to take input from user and copy to the desired location , Code does not works properly and show **FILE PATH NOT SPECIFIED **ERROR .
PLEASE HELP ME !!.
| 0debug
|
templates causing Segmentation Fault in c++ : there is a problem in the simple code snippet below that i can't uncover even with a debugger. Thanks for your help in advance.
Command.h
class word{
private : static int next_word;
private : int word_id;
public : word();
public : void grabIt();
public : void raiseIt();
public : void putItDown();
};
class Command{
public : typedef void(word::*Method)();
private : word* w;
private : Method m;
public : Command(word *w, Method m);
public : void execute();
};
template<typename T>
class Queue{
private : enum{
SIZE=9
};
private : T* commandArray[SIZE];
private : int m_added = 0, m_removed = 0;
public : void enqueue(T* t){
commandArray[m_added] = t;
m_added = (m_added + 1) % SIZE;
}
public : T* dequeue(){
int temp = m_removed;
m_removed = (m_removed + 1) % SIZE;
return commandArray[temp];
}
};
Command.cpp
int word::next_word = 0;
word::word(){
this->word_id = next_word++;
}
void word::grabIt(){
std::cout << "Grabbed it" << std::endl;
}
void word::raiseIt(){
std::cout << "Raised it" << std::endl;
}
void word::putItDown(){
std::cout << "Put it down" << std::endl;
}
Command::Command(word *w, Method m){
w = w;
m = m;
}
void Command::execute(){
(w->*m)(); // -------------->>>>> Causing Seg-Fault
}
Main.cpp
Queue<Command> queue;
Command *commandArray[9];
Command command1(new word, &word::grabIt); commandArray[0] = &command1;
Command command2(new word, &word::raiseIt); commandArray[1] = &command2;
Command command3(new word, &word::putItDown); commandArray[2] = &command3;
Command command4(new word, &word::grabIt); commandArray[3] = &command4;
Command command5(new word, &word::raiseIt); commandArray[4] = &command5;
Command command6(new word, &word::putItDown); commandArray[5] = &command6;
Command command7(new word, &word::grabIt); commandArray[6] = &command7;
Command command8(new word, &word::raiseIt); commandArray[7] = &command8;
Command command9(new word, &word::putItDown); commandArray[8] = &command9;
for( int i=0 ; i < 9; i++){
queue.enqueue(commandArray[i]);
}
for( int i=2 ; i < 6 ; i++){
queue.dequeue()->execute();
}
some word objects inside the queue appear NULL in the debugger, so cause Seg-Fault.
| 0debug
|
When I define a function of reverse. It not only reverses the digits but it prints it thrice. How can I get only one reversed answered? : '''
def reverse_int():
num=(input("Enter a 3-digit number: "))
for number in num:
print (num[::-1])
reverse_int()
'''
| 0debug
|
static void mips_tlb_flush_extra (CPUState *env, int first)
{
while (env->tlb_in_use > first) {
invalidate_tlb(--env->tlb_in_use, 0);
}
}
| 1threat
|
static int dump_init(DumpState *s, int fd, bool has_format,
DumpGuestMemoryFormat format, bool paging, bool has_filter,
int64_t begin, int64_t length, Error **errp)
{
CPUState *cpu;
int nr_cpus;
Error *err = NULL;
int ret;
if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
assert(!paging && !has_filter);
}
if (runstate_is_running()) {
vm_stop(RUN_STATE_SAVE_VM);
s->resume = true;
} else {
s->resume = false;
}
cpu_synchronize_all_states();
nr_cpus = 0;
CPU_FOREACH(cpu) {
nr_cpus++;
}
s->fd = fd;
s->has_filter = has_filter;
s->begin = begin;
s->length = length;
guest_phys_blocks_init(&s->guest_phys_blocks);
guest_phys_blocks_append(&s->guest_phys_blocks);
s->start = get_start_block(s);
if (s->start == -1) {
error_set(errp, QERR_INVALID_PARAMETER, "begin");
goto cleanup;
}
ret = cpu_get_dump_info(&s->dump_info, &s->guest_phys_blocks);
if (ret < 0) {
error_set(errp, QERR_UNSUPPORTED);
goto cleanup;
}
s->note_size = cpu_get_note_size(s->dump_info.d_class,
s->dump_info.d_machine, nr_cpus);
if (s->note_size < 0) {
error_set(errp, QERR_UNSUPPORTED);
goto cleanup;
}
memory_mapping_list_init(&s->list);
if (paging) {
qemu_get_guest_memory_mapping(&s->list, &s->guest_phys_blocks, &err);
if (err != NULL) {
error_propagate(errp, err);
goto cleanup;
}
} else {
qemu_get_guest_simple_memory_mapping(&s->list, &s->guest_phys_blocks);
}
s->nr_cpus = nr_cpus;
get_max_mapnr(s);
uint64_t tmp;
tmp = DIV_ROUND_UP(DIV_ROUND_UP(s->max_mapnr, CHAR_BIT), TARGET_PAGE_SIZE);
s->len_dump_bitmap = tmp * TARGET_PAGE_SIZE;
if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
switch (format) {
case DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB:
s->flag_compress = DUMP_DH_COMPRESSED_ZLIB;
break;
case DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO:
#ifdef CONFIG_LZO
if (lzo_init() != LZO_E_OK) {
error_setg(errp, "failed to initialize the LZO library");
goto cleanup;
}
#endif
s->flag_compress = DUMP_DH_COMPRESSED_LZO;
break;
case DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY:
s->flag_compress = DUMP_DH_COMPRESSED_SNAPPY;
break;
default:
s->flag_compress = 0;
}
return 0;
}
if (s->has_filter) {
memory_mapping_filter(&s->list, s->begin, s->length);
}
s->phdr_num = 1;
if (s->list.num < UINT16_MAX - 2) {
s->phdr_num += s->list.num;
s->have_section = false;
} else {
s->have_section = true;
s->phdr_num = PN_XNUM;
s->sh_info = 1;
if (s->list.num <= UINT32_MAX - 1) {
s->sh_info += s->list.num;
} else {
s->sh_info = UINT32_MAX;
}
}
if (s->dump_info.d_class == ELFCLASS64) {
if (s->have_section) {
s->memory_offset = sizeof(Elf64_Ehdr) +
sizeof(Elf64_Phdr) * s->sh_info +
sizeof(Elf64_Shdr) + s->note_size;
} else {
s->memory_offset = sizeof(Elf64_Ehdr) +
sizeof(Elf64_Phdr) * s->phdr_num + s->note_size;
}
} else {
if (s->have_section) {
s->memory_offset = sizeof(Elf32_Ehdr) +
sizeof(Elf32_Phdr) * s->sh_info +
sizeof(Elf32_Shdr) + s->note_size;
} else {
s->memory_offset = sizeof(Elf32_Ehdr) +
sizeof(Elf32_Phdr) * s->phdr_num + s->note_size;
}
}
return 0;
cleanup:
guest_phys_blocks_free(&s->guest_phys_blocks);
if (s->resume) {
vm_start();
}
return -1;
}
| 1threat
|
static uint32_t get_level1_table_address(CPUARMState *env, uint32_t address)
{
uint32_t table;
if (address & env->cp15.c2_mask)
table = env->cp15.ttbr1_el1 & 0xffffc000;
else
table = env->cp15.ttbr0_el1 & env->cp15.c2_base_mask;
table |= (address >> 18) & 0x3ffc;
return table;
}
| 1threat
|
MongoDb shuts down with Code 100 : <p>I followed the MongoDb <a href="https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-windows/#run-mongodb" rel="noreferrer">Docs</a> to setup my first MongoDb, </p>
<p>When I start MongoDB using the command </p>
<pre><code>C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe
</code></pre>
<p>I get the following error
<a href="https://i.stack.imgur.com/RCFPU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RCFPU.png" alt="enter image description here"></a></p>
| 0debug
|
unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi)
{
size_t pos = hbi->pos;
const HBitmap *hb = hbi->hb;
unsigned i = HBITMAP_LEVELS - 1;
unsigned long cur;
do {
cur = hbi->cur[--i];
pos >>= BITS_PER_LEVEL;
} while (cur == 0);
if (i == 0 && cur == (1UL << (BITS_PER_LONG - 1))) {
return 0;
}
for (; i < HBITMAP_LEVELS - 1; i++) {
pos = (pos << BITS_PER_LEVEL) + ffsl(cur) - 1;
hbi->cur[i] = cur & (cur - 1);
cur = hb->levels[i + 1][pos];
}
hbi->pos = pos;
trace_hbitmap_iter_skip_words(hbi->hb, hbi, pos, cur);
assert(cur);
return cur;
}
| 1threat
|
static int get_channel_idx(char **map, int *ch, char delim, int max_ch)
{
char *next = split(*map, delim);
int len;
int n = 0;
if (!next && delim == '-')
len = strlen(*map);
sscanf(*map, "%d%n", ch, &n);
if (n != len)
if (*ch < 0 || *ch > max_ch)
*map = next;
return 0;
}
| 1threat
|
how can I convert string to list in python : <p>i am trying to parse a xml file, it works very well. I have string output, which i would like to make as list, but i doesnot work.
I get for tuple or list, that every line is a list...Somebody any idea?</p>
<pre><code>def handleToc(self,elements):
for element in elements:
self.name = element.getElementsByTagName("name")[0]
self.familyname = element.getElementsByTagName("family")[0]
#self.position = element.getElementsByTagName("position")[0].firstChild.nodeValue
position = element.getElementsByTagName("position")[0].firstChild.nodeValue
liste=position.encode('utf-8')
nameslist = [y for y in (x.strip() for x in liste.splitlines()) if y]
#print names_list[1:-1]
#print ''.join(repr(x).lstrip('u')[1:-1] for x in position)
#converted_degrees = {int(value) for value in position}
liste1=tuple(liste)
print liste
print list1
</code></pre>
<p>and the output is:
66.5499972
70.5500028
73.7
76.3
79.4499972
83.4500028
86.6
89.2</p>
| 0debug
|
React DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node : <p>If state is true to play youtube video, and it is false I would like to delete youtube playing.
MY code is as follows.</p>
<pre><code>{this.state.isPreViewVideo && <PlayYouTube video_id="ScSn235gQx0" />}
</code></pre>
<p>sandbox URL:</p>
<p><a href="https://codesandbox.io/s/xryoz10k6o" rel="noreferrer">https://codesandbox.io/s/xryoz10k6o</a></p>
<p>Reproduction method:</p>
<p>If 4-digit characters are included in input form, "isPreViewVideo: true" by setState and if it is less than false</p>
<p>It works fine when state is true,
but when state is false, I encounter this error as follows.</p>
<pre><code>DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
</code></pre>
<p>is there a way to avoid or resolve this error?</p>
| 0debug
|
static ssize_t test_block_init_func(QCryptoBlock *block,
void *opaque,
size_t headerlen,
Error **errp)
{
Buffer *header = opaque;
g_assert_cmpint(header->capacity, ==, 0);
buffer_reserve(header, headerlen);
return headerlen;
}
| 1threat
|
static int twin_decode_frame(AVCodecContext * avctx, void *data,
int *data_size, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
TwinContext *tctx = avctx->priv_data;
GetBitContext gb;
const ModeTab *mtab = tctx->mtab;
float *out = data;
enum FrameType ftype;
int window_type;
static const enum FrameType wtype_to_ftype_table[] = {
FT_LONG, FT_LONG, FT_SHORT, FT_LONG,
FT_MEDIUM, FT_LONG, FT_LONG, FT_MEDIUM, FT_MEDIUM
};
if (buf_size*8 < avctx->bit_rate*mtab->size/avctx->sample_rate + 8) {
av_log(avctx, AV_LOG_ERROR,
"Frame too small (%d bytes). Truncated file?\n", buf_size);
return AVERROR(EINVAL);
}
init_get_bits(&gb, buf, buf_size * 8);
skip_bits(&gb, get_bits(&gb, 8));
window_type = get_bits(&gb, WINDOW_TYPE_BITS);
if (window_type > 8) {
av_log(avctx, AV_LOG_ERROR, "Invalid window type, broken sample?\n");
return -1;
}
ftype = wtype_to_ftype_table[window_type];
read_and_decode_spectrum(tctx, &gb, tctx->spectrum, ftype);
imdct_output(tctx, ftype, window_type, out);
FFSWAP(float*, tctx->curr_frame, tctx->prev_frame);
if (tctx->avctx->frame_number < 2) {
*data_size=0;
return buf_size;
}
*data_size = mtab->size*avctx->channels*4;
return buf_size;
}
| 1threat
|
Stadard "veiw contact" icon : I'm developing a texting app and would like to create a view contact button. Anyone know what the standard menu icon for such an action is?
| 0debug
|
int kvm_arch_process_async_events(CPUState *env)
{
return 0;
}
| 1threat
|
What is the default user and password for elasticsearch? : <p>I have <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html" rel="noreferrer">installed Elastic with Docker</a>:</p>
<pre><code>docker run -p 9200:9200 \
-p 9300:9300 \
-e "discovery.type=single-node" \
docker.elastic.co/elasticsearch/elasticsearch:5.6.2
</code></pre>
<p>But <code>curl localhost:9200</code> fails with authentication error:</p>
<pre><code>{
"error": {
"root_cause": [
{
"type": "security_exception",
"reason": "missing authentication token for REST request [/]",
"header": {
"WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
}
}
],
"type": "security_exception",
"reason": "missing authentication token for REST request [/]",
"header": {
"WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
}
},
"status": 401
}
</code></pre>
<p><strong>What is the default username/password combo for Elasticsearch?</strong></p>
| 0debug
|
How to find the sum of numbers that have digits higher than 5 : <p>so I want to write a function that returns the sum of all numbers in an array who's digits are higher then 5 so for example if the array is [12, 66, 23, 67] the answer would be 66+67
This code summs all the numbers in the array and I can'\t figure out why</p>
<pre><code>
using namespace std;
int func(int n[], int size){
int digit, S=0, a;
for(int i=0; i<size; i++){
a= n[i];
while( n[i]!=0){
digit= n[i]%10;
if(digit>=5){
n[i]= n[i]/10;
}
else break;
}
S=S+a;
}
return S;
}
int main()
{
int n[3], i;
for(int i=0; i<3; i++){
cin>>n[i];
}
cout<<func(n, 3)<<endl;
return 0;
}```
</code></pre>
| 0debug
|
Connecting to Telnet through Xcode : I am currently trying to code an application for a Mac OS to control an arduino. To do this I need to be able to access telnet and send string commands to it. Any ideas on how to do so? Thanks.
| 0debug
|
CPUState *ppc4xx_init (const char *cpu_model,
clk_setup_t *cpu_clk, clk_setup_t *tb_clk,
uint32_t sysclk)
{
CPUState *env;
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find PowerPC %s CPU definition\n",
cpu_model);
exit(1);
}
cpu_clk->cb = NULL;
cpu_clk->opaque = env;
tb_clk->cb = ppc_emb_timers_init(env, sysclk);
tb_clk->opaque = env;
ppc_dcr_init(env, NULL, NULL);
qemu_register_reset((QEMUResetHandler*)&cpu_reset, env);
return env;
}
| 1threat
|
What library can I use to implement this chart in my website? : <p>apologies if the question is not phrased the best way but I'm not a native English speaker and I'm not sure how this chart is called exactly. Basically this is what I'm looking for :</p>
<p><a href="https://i.stack.imgur.com/IYUVh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IYUVh.png" alt="enter image description here"></a></p>
<p>Do you know a library that I can use to implement this chart and if you could point me to an example I'd be very grateful!</p>
| 0debug
|
connection error in php from databse : i am getting this warning
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp\www\S_WEB\connection\dbcon.php on line 14`
my code is
<?php
//Connect to database
$servername = "127.0.0.1";
$username = "root";
$password = "root";
$dbname = "s_web";
// Create connection
$db = mysqli_connect('127.0.0.1','root','root','s_web')
or die('Error connecting to MySQL server.');
$query = "SELECT * FROM user" ;
mysqli_query($db, $query) or die('Error querying database');
$result = mysqli_query($db, $query);
$row = mysqli_fetch_array($result);
while ($row = mysqli_fetch_array($result)) {
echo $row['username'] . ' ' . $row['password'] . '<br />';
}
?>`
i am new to php and mysqli. and my question is that i am getting an error when i am trying to establishing a connection database using mysqli.
there i am getting many errors. last two days i am trying to fix my problem but i didn't.
sorry my English is not good.
| 0debug
|
How to use "Session" in Jquery? : Has a similar something `"Session["Param"]"` in `C#` for jquery? How can i use?
I research `"sessionStorage"` in `Jquery`, but I'm not understand.
| 0debug
|
static int handle_metadata(RTMPContext *rt, RTMPPacket *pkt)
{
int ret, old_flv_size, type;
const uint8_t *next;
uint8_t *p;
uint32_t size;
uint32_t ts, cts, pts = 0;
old_flv_size = update_offset(rt, pkt->size);
if ((ret = av_reallocp(&rt->flv_data, rt->flv_size)) < 0) {
rt->flv_size = rt->flv_off = 0;
return ret;
}
next = pkt->data;
p = rt->flv_data + old_flv_size;
ts = pkt->timestamp;
while (next - pkt->data < pkt->size - RTMP_HEADER) {
type = bytestream_get_byte(&next);
size = bytestream_get_be24(&next);
cts = bytestream_get_be24(&next);
cts |= bytestream_get_byte(&next) << 24;
if (!pts)
pts = cts;
ts += cts - pts;
pts = cts;
bytestream_put_byte(&p, type);
bytestream_put_be24(&p, size);
bytestream_put_be24(&p, ts);
bytestream_put_byte(&p, ts >> 24);
memcpy(p, next, size + 3 + 4);
next += size + 3 + 4;
p += size + 3 + 4;
}
memcpy(p, next, RTMP_HEADER);
return 0;
}
| 1threat
|
Typescript - What is the difference between null and undefined? : <p>I want to know what is the difference between null and undefined in typescript. I know in javascript it is possible to use both of them in order to check a variable has no value. But in typescript I want to know the difference exactly and when it is better to use each one of them.
Thanks.</p>
| 0debug
|
static int tgv_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
TgvContext *s = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int chunk_type;
if (buf_end - buf < EA_PREAMBLE_SIZE)
return AVERROR_INVALIDDATA;
chunk_type = AV_RL32(&buf[0]);
buf += EA_PREAMBLE_SIZE;
if (chunk_type==kVGT_TAG) {
int pal_count, i;
if(buf_end - buf < 12) {
av_log(avctx, AV_LOG_WARNING, "truncated header\n");
return -1;
}
s->width = AV_RL16(&buf[0]);
s->height = AV_RL16(&buf[2]);
if (s->avctx->width!=s->width || s->avctx->height!=s->height) {
avcodec_set_dimensions(s->avctx, s->width, s->height);
cond_release_buffer(&s->frame);
cond_release_buffer(&s->last_frame);
}
pal_count = AV_RL16(&buf[6]);
buf += 12;
for(i=0; i<pal_count && i<AVPALETTE_COUNT && buf_end - buf >= 3; i++) {
s->palette[i] = 0xFF << 24 | AV_RB24(buf);
buf += 3;
}
}
if (av_image_check_size(s->width, s->height, 0, avctx))
return -1;
FFSWAP(AVFrame, s->frame, s->last_frame);
if (!s->frame.data[0]) {
s->frame.reference = 3;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;
s->frame.linesize[0] = s->width;
s->frame.data[0] = av_malloc(s->width*s->height + 12);
if (!s->frame.data[0])
return AVERROR(ENOMEM);
s->frame.data[1] = av_malloc(AVPALETTE_SIZE);
if (!s->frame.data[1]) {
av_freep(&s->frame.data[0]);
return AVERROR(ENOMEM);
}
}
memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE);
if(chunk_type==kVGT_TAG) {
s->frame.key_frame = 1;
s->frame.pict_type = AV_PICTURE_TYPE_I;
if (unpack(buf, buf_end, s->frame.data[0], s->avctx->width, s->avctx->height)<0) {
av_log(avctx, AV_LOG_WARNING, "truncated intra frame\n");
return -1;
}
}else{
if (!s->last_frame.data[0]) {
av_log(avctx, AV_LOG_WARNING, "inter frame without corresponding intra frame\n");
return buf_size;
}
s->frame.key_frame = 0;
s->frame.pict_type = AV_PICTURE_TYPE_P;
if (tgv_decode_inter(s, buf, buf_end)<0) {
av_log(avctx, AV_LOG_WARNING, "truncated inter frame\n");
return -1;
}
}
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
return buf_size;
}
| 1threat
|
Detect if page is load from back button : <p>Is there any way to detect if current page came from back button?</p>
<p>I want to load data from cookie only if current page came from back button. </p>
| 0debug
|
Project 'Pods' - Turn on Whole Module Optimization : <p>In Xcode 9 I'm getting the following suggestion for a cocoa pods project:
<a href="https://i.stack.imgur.com/JqeB7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JqeB7.png" alt="suggestion"></a></p>
<p>What does it do? And, shall I turn it on, or it will break things up?</p>
| 0debug
|
Facing deficulties of reading specified data from one after another in java : I think problem lies with my text file but i can't understand ??please help to solve out this.
Thanks in advance..
/* This is mocTest.txt file
*/
/*
##Question##
Which is not a JDK component?
##Ans1##
Java SE libraries
##Ans2##
Java SE libraries2
##Ans3##
Java SE libraries3
##Ans4##
Java SE libraries4
*/
/* Here is my java class file
*
*
*
*
*/
public class QuesSheet {
String strQues;
String[] ansQues = new String[4];
public void testRead() {
try {
Scanner scReader = new Scanner(new File("mocTest.txt"));
while (scReader.hasNext()) {
if (scReader.nextLine().equals("##Question##")) {
strQues = scReader.nextLine();
// System.out.println(str);
} else if (scReader.nextLine().equals("##Ans1##")) {
ansQues[0] = scReader.nextLine();
} else if (scReader.nextLine().equals("##Ans2##")) {
ansQues[1] = scReader.nextLine();
} else if (scReader.nextLine().equals("##Ans3##")) {
ansQues[2] = scReader.nextLine();
} else if (scReader.nextLine().equals("##Ans4##")) {
ansQues[3] = scReader.nextLine();
}
}
} catch (FileNotFoundException ex) {
Logger.getLogger(QuesSheet.class.getName()).log(Level.SEVERE, null, ex);
}}
public static void main(String[] args) {
QuesSheet qs = new QuesSheet();
qs.testRead();
System.out.println(qs.ansQues[0]);
System.out.println(qs.ansQues[1]);//Why this is not working?? result show s null in both.
System.out.println(qs.ansQues[2]);//and also same to this??
System.out.println(qs.ansQues[3]);
}}
| 0debug
|
Calculate length of a string input : <p>I made a program that calculates the length of a string that the user inputs. My program works fine for the most part but when I print "Hello World", it gives the length 5 (whereas it should be 11). How can I fix this?</p>
<pre><code>import java.util.Scanner;
public class StringLength {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Enter the string: \n");
String word = in.next();
System.out.println("The length is: " +word.length());
}
}
</code></pre>
| 0debug
|
How to change the text color of a Vuetify button? : <p>Maybe I'm missing something obvious, but I can't figure out the proper way to change the text color in a <code>v-btn</code>. This works, but having to use <code>!important</code> doesn't seem ideal:</p>
<pre><code>.v-btn
color: red !important
</code></pre>
<p>The <code>color</code> prop is only for the background color, as far as I'm aware. And I guess I could change the theme primary/secondary when calling <code>Vue.use(Vuetify, { theme: {...}} )</code>, but what if I want to override a single component?</p>
| 0debug
|
Replace string in array : <p>I want to replace a string within an array with another string.<br>
In my example <code>cat</code> should be replaced with <code>mouse</code>:</p>
<pre><code>var arr1 = [ "dog", "cat"];
for(i=0; i<arr1.length; i++){
arr1[i].replace("cat", "mouse");
}
</code></pre>
<p>Unfortunately, the array remains unchanged.</p>
<p>Where is the error?</p>
| 0debug
|
static void sdhci_generic_reset(DeviceState *ds)
{
SDHCIState *s = SDHCI(ds);
SDHCI_GET_CLASS(s)->reset(s);
}
| 1threat
|
I have a TextArea in javafx but I need to get the coordinates or positions (x, y) to move a floating menu inside the textArea :
I have a problem and I can not find how to solve it and searched the internet and no information can tell me how I can get the coordinates or the position (x, y) of the cursor inside a TextArea javafx.
| 0debug
|
def pos_count(list):
pos_count= 0
for num in list:
if num >= 0:
pos_count += 1
return pos_count
| 0debug
|
what does fd:// mean exactly in dockerd -H fd:// : <p><a href="https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option" rel="noreferrer">Docker daemon documentation</a> suggests the following <code>hosts</code> option for most setups:</p>
<pre><code>dockerd -H fd://
</code></pre>
<p>I guess <code>fd</code> stands for file descriptor. I don't understand how <code>fd</code> is used for socket communication. </p>
<p>I understand the following options:</p>
<pre><code>-H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2
</code></pre>
<p>These are unix domain sockets and tcp sockets. I know how to call docker daemon using these sockets:</p>
<pre><code>docker -H tcp://0.0.0.0:2375 ps
</code></pre>
<p>But if I started docker daemon using <code>-H fd://</code>, the following call gives error:</p>
<pre><code>$ docker -H fd:// ps
error during connect: Get http:///v1.26/containers/json: http: no Host in request URL
</code></pre>
<p>So what is the meaning of <code>fd://</code>? Is there any use for it?</p>
| 0debug
|
has HttpObserve disappeared in angular 8 release for a HttpClient get request : I am developping an angular 8 application. I am trying to implement a HttpClient get request according to the documentation : https://angular.io/api/common/http/HttpClient.
So globally I am trying to use a get(url: string, httpHeader: HttpHeaders, observe: HttpObserve, params : HttpParams) request, but it seems that HttpObserve disappeared. Can you help me ?
| 0debug
|
How to split first 4 digits of a numeric ID in Python : Let the ID (column) instance be 1120170002 , How do I separate 112017 from the ID 1120170002 to form two separate columns in python.
type of data --> pandas.core.frame.DataFrame
| 0debug
|
static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size,
MemTxAttrs attrs)
{
NVICState *s = (NVICState *)opaque;
uint32_t offset = addr;
unsigned i, startvec, end;
unsigned setval = 0;
trace_nvic_sysreg_write(addr, value, size);
if (attrs.user && !nvic_user_access_ok(s, addr)) {
return MEMTX_ERROR;
}
switch (offset) {
case 0x100 ... 0x13f:
offset += 0x80;
setval = 1;
case 0x180 ... 0x1bf:
startvec = 8 * (offset - 0x180) + NVIC_FIRST_IRQ;
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
if (value & (1 << i)) {
s->vectors[startvec + i].enabled = setval;
}
}
nvic_irq_update(s);
return MEMTX_OK;
case 0x200 ... 0x23f:
offset += 0x80;
setval = 1;
case 0x280 ... 0x2bf:
startvec = 8 * (offset - 0x280) + NVIC_FIRST_IRQ;
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
if (value & (1 << i)) {
s->vectors[startvec + i].pending = setval;
}
}
nvic_irq_update(s);
return MEMTX_OK;
case 0x300 ... 0x33f:
return MEMTX_OK;
case 0x400 ... 0x5ef:
startvec = 8 * (offset - 0x400) + NVIC_FIRST_IRQ;
for (i = 0; i < size && startvec + i < s->num_irq; i++) {
set_prio(s, startvec + i, (value >> (i * 8)) & 0xff);
}
nvic_irq_update(s);
return MEMTX_OK;
case 0xd18 ... 0xd23:
for (i = 0; i < size; i++) {
unsigned hdlidx = (offset - 0xd14) + i;
set_prio(s, hdlidx, (value >> (i * 8)) & 0xff);
}
nvic_irq_update(s);
return MEMTX_OK;
}
if (size == 4) {
nvic_writel(s, offset, value);
return MEMTX_OK;
}
qemu_log_mask(LOG_GUEST_ERROR,
"NVIC: Bad write of size %d at offset 0x%x\n", size, offset);
return MEMTX_OK;
}
| 1threat
|
int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar)
{
CPUS390XState *env = &cpu->env;
uint8_t oc, dmaas;
uint32_t fh;
ZpciFib fib;
S390PCIBusDevice *pbdev;
uint64_t cc = ZPCI_PCI_LS_OK;
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 6);
return 0;
}
oc = env->regs[r1] & 0xff;
dmaas = (env->regs[r1] >> 16) & 0xff;
fh = env->regs[r1] >> 32;
if (fiba & 0x7) {
program_interrupt(env, PGM_SPECIFICATION, 6);
return 0;
}
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev || !(pbdev->fh & FH_MASK_ENABLE)) {
DPRINTF("mpcifc no pci dev fh 0x%x\n", fh);
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
if (s390_cpu_virt_mem_read(cpu, fiba, ar, (uint8_t *)&fib, sizeof(fib))) {
return 0;
}
if (fib.fmt != 0) {
program_interrupt(env, PGM_OPERAND, 6);
return 0;
}
switch (oc) {
case ZPCI_MOD_FC_REG_INT:
if (pbdev->summary_ind) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else if (reg_irqs(env, pbdev, fib)) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_RES_NOT_AVAIL);
}
break;
case ZPCI_MOD_FC_DEREG_INT:
if (!pbdev->summary_ind) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else {
pci_dereg_irqs(pbdev);
}
break;
case ZPCI_MOD_FC_REG_IOAT:
if (dmaas != 0) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL);
} else if (pbdev->iommu_enabled) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else if (reg_ioat(env, pbdev, fib)) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_INSUF_RES);
}
break;
case ZPCI_MOD_FC_DEREG_IOAT:
if (dmaas != 0) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL);
} else if (!pbdev->iommu_enabled) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else {
pci_dereg_ioat(pbdev);
}
break;
case ZPCI_MOD_FC_REREG_IOAT:
if (dmaas != 0) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL);
} else if (!pbdev->iommu_enabled) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
} else {
pci_dereg_ioat(pbdev);
if (reg_ioat(env, pbdev, fib)) {
cc = ZPCI_PCI_LS_ERR;
s390_set_status_code(env, r1, ZPCI_MOD_ST_INSUF_RES);
}
}
break;
case ZPCI_MOD_FC_RESET_ERROR:
pbdev->error_state = false;
pbdev->lgstg_blocked = false;
break;
case ZPCI_MOD_FC_RESET_BLOCK:
pbdev->lgstg_blocked = false;
break;
case ZPCI_MOD_FC_SET_MEASURE:
pbdev->fmb_addr = ldq_p(&fib.fmb_addr);
break;
default:
program_interrupt(&cpu->env, PGM_OPERAND, 6);
cc = ZPCI_PCI_LS_ERR;
}
setcc(cpu, cc);
return 0;
}
| 1threat
|
ssize_t nbd_wr_sync(int fd, void *buffer, size_t size, bool do_read)
{
size_t offset = 0;
int err;
if (qemu_in_coroutine()) {
if (do_read) {
return qemu_co_recv(fd, buffer, size);
} else {
return qemu_co_send(fd, buffer, size);
}
}
while (offset < size) {
ssize_t len;
if (do_read) {
len = qemu_recv(fd, buffer + offset, size - offset, 0);
} else {
len = send(fd, buffer + offset, size - offset, 0);
}
if (len < 0) {
err = socket_error();
if (err == EINTR || err == EAGAIN) {
continue;
}
return -err;
}
if (len == 0) {
break;
}
offset += len;
}
return offset;
}
| 1threat
|
int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type,
int timestamp, int size)
{
pkt->data = av_malloc(size);
if (!pkt->data)
return AVERROR(ENOMEM);
pkt->data_size = size;
pkt->channel_id = channel_id;
pkt->type = type;
pkt->timestamp = timestamp;
pkt->extra = 0;
pkt->ts_delta = 0;
return 0;
| 1threat
|
int ff_scale_eval_dimensions(void *log_ctx,
const char *w_expr, const char *h_expr,
AVFilterLink *inlink, AVFilterLink *outlink,
int *ret_w, int *ret_h)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(outlink->format);
const char *expr;
int w, h;
int factor_w, factor_h;
int eval_w, eval_h;
int ret;
const char scale2ref = outlink->src->nb_inputs == 2 && outlink->src->inputs[1] == inlink;
double var_values[VARS_NB + VARS_S2R_NB], res;
const AVPixFmtDescriptor *main_desc;
const AVFilterLink *main_link;
const char *const *names = scale2ref ? var_names_scale2ref : var_names;
if (scale2ref) {
main_link = outlink->src->inputs[0];
main_desc = av_pix_fmt_desc_get(main_link->format);
}
var_values[VAR_PI] = M_PI;
var_values[VAR_PHI] = M_PHI;
var_values[VAR_E] = M_E;
var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w;
var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h;
var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN;
var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN;
var_values[VAR_A] = (double) inlink->w / inlink->h;
var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ?
(double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
var_values[VAR_HSUB] = 1 << desc->log2_chroma_w;
var_values[VAR_VSUB] = 1 << desc->log2_chroma_h;
var_values[VAR_OHSUB] = 1 << out_desc->log2_chroma_w;
var_values[VAR_OVSUB] = 1 << out_desc->log2_chroma_h;
if (scale2ref) {
var_values[VARS_NB + VAR_S2R_MAIN_W] = main_link->w;
var_values[VARS_NB + VAR_S2R_MAIN_H] = main_link->h;
var_values[VARS_NB + VAR_S2R_MAIN_A] = (double) main_link->w / main_link->h;
var_values[VARS_NB + VAR_S2R_MAIN_SAR] = main_link->sample_aspect_ratio.num ?
(double) main_link->sample_aspect_ratio.num / main_link->sample_aspect_ratio.den : 1;
var_values[VARS_NB + VAR_S2R_MAIN_DAR] = var_values[VARS_NB + VAR_S2R_MDAR] =
var_values[VARS_NB + VAR_S2R_MAIN_A] * var_values[VARS_NB + VAR_S2R_MAIN_SAR];
var_values[VARS_NB + VAR_S2R_MAIN_HSUB] = 1 << main_desc->log2_chroma_w;
var_values[VARS_NB + VAR_S2R_MAIN_VSUB] = 1 << main_desc->log2_chroma_h;
}
av_expr_parse_and_eval(&res, (expr = w_expr),
names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, log_ctx);
eval_w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res;
if ((ret = av_expr_parse_and_eval(&res, (expr = h_expr),
names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, log_ctx)) < 0)
goto fail;
eval_h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res;
if ((ret = av_expr_parse_and_eval(&res, (expr = w_expr),
names, var_values,
NULL, NULL, NULL, NULL, NULL, 0, log_ctx)) < 0)
goto fail;
eval_w = res;
w = eval_w;
h = eval_h;
factor_w = 1;
factor_h = 1;
if (w < -1) {
factor_w = -w;
}
if (h < -1) {
factor_h = -h;
}
if (w < 0 && h < 0)
eval_w = eval_h = 0;
if (!(w = eval_w))
w = inlink->w;
if (!(h = eval_h))
h = inlink->h;
if (w < 0)
w = av_rescale(h, inlink->w, inlink->h * factor_w) * factor_w;
if (h < 0)
h = av_rescale(w, inlink->h, inlink->w * factor_h) * factor_h;
*ret_w = w;
*ret_h = h;
return 0;
fail:
av_log(log_ctx, AV_LOG_ERROR,
"Error when evaluating the expression '%s'.\n"
"Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
expr, w_expr, h_expr);
return ret;
}
| 1threat
|
Npm global not being used? : <p>So I've previously had some npm issues and followed some stackoverflow/github issues commands to attempt to fix them. Which worked... Kinda. Everything was fine until recently when I realised that my global npm packages are not actually being read/used.</p>
<p>So whenever I did a npm -g install xxx, or an update. It updates the global folder alright, but it's just not being used. So I went to dig a little and found this.</p>
<p>Where npm is reading/using from</p>
<pre><code>usr/local/lib/node_modules
</code></pre>
<p>Where the global is installing to</p>
<pre><code>Users/Me/.npm-global/lib/node_modules
</code></pre>
<p>So whenever I did a -g check for my modules and stuff, everything is good and updated, but when I actually try to run anything, the npm command uses the one in the older folders. So basically I can't update or install anything using -g. And nothing goes into the old folder which is the one being actually used.</p>
<p>How do I resolve this? Was some linking or profile got screwed?</p>
| 0debug
|
static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
sPAPREventLogEntry *entry = NULL;
QTAILQ_FOREACH(entry, &spapr->pending_events, next) {
const sPAPREventSource *source =
rtas_event_log_to_source(spapr, entry->log_type);
if (source->mask & event_mask) {
break;
}
}
if (entry) {
QTAILQ_REMOVE(&spapr->pending_events, entry, next);
}
return entry;
}
| 1threat
|
Minecraft bukkit player shot another player with a bow : <p>How can I detect if a player shot another player with a bow?
I want to get the Names of the players.
So how can I do that?</p>
| 0debug
|
static inline void RENAME(rgb16to24)(const uint8_t *src, uint8_t *dst, long src_size)
{
const uint16_t *end;
#ifdef HAVE_MMX
const uint16_t *mm_end;
#endif
uint8_t *d = (uint8_t *)dst;
const uint16_t *s = (const uint16_t *)src;
end = s + src_size/2;
#ifdef HAVE_MMX
__asm __volatile(PREFETCH" %0"::"m"(*s):"memory");
mm_end = end - 7;
while(s < mm_end)
{
__asm __volatile(
PREFETCH" 32%1\n\t"
"movq %1, %%mm0\n\t"
"movq %1, %%mm1\n\t"
"movq %1, %%mm2\n\t"
"pand %2, %%mm0\n\t"
"pand %3, %%mm1\n\t"
"pand %4, %%mm2\n\t"
"psllq $3, %%mm0\n\t"
"psrlq $3, %%mm1\n\t"
"psrlq $8, %%mm2\n\t"
"movq %%mm0, %%mm3\n\t"
"movq %%mm1, %%mm4\n\t"
"movq %%mm2, %%mm5\n\t"
"punpcklwd %5, %%mm0\n\t"
"punpcklwd %5, %%mm1\n\t"
"punpcklwd %5, %%mm2\n\t"
"punpckhwd %5, %%mm3\n\t"
"punpckhwd %5, %%mm4\n\t"
"punpckhwd %5, %%mm5\n\t"
"psllq $8, %%mm1\n\t"
"psllq $16, %%mm2\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm2, %%mm0\n\t"
"psllq $8, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm5, %%mm3\n\t"
"movq %%mm0, %%mm6\n\t"
"movq %%mm3, %%mm7\n\t"
"movq 8%1, %%mm0\n\t"
"movq 8%1, %%mm1\n\t"
"movq 8%1, %%mm2\n\t"
"pand %2, %%mm0\n\t"
"pand %3, %%mm1\n\t"
"pand %4, %%mm2\n\t"
"psllq $3, %%mm0\n\t"
"psrlq $3, %%mm1\n\t"
"psrlq $8, %%mm2\n\t"
"movq %%mm0, %%mm3\n\t"
"movq %%mm1, %%mm4\n\t"
"movq %%mm2, %%mm5\n\t"
"punpcklwd %5, %%mm0\n\t"
"punpcklwd %5, %%mm1\n\t"
"punpcklwd %5, %%mm2\n\t"
"punpckhwd %5, %%mm3\n\t"
"punpckhwd %5, %%mm4\n\t"
"punpckhwd %5, %%mm5\n\t"
"psllq $8, %%mm1\n\t"
"psllq $16, %%mm2\n\t"
"por %%mm1, %%mm0\n\t"
"por %%mm2, %%mm0\n\t"
"psllq $8, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm4, %%mm3\n\t"
"por %%mm5, %%mm3\n\t"
:"=m"(*d)
:"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null)
:"memory");
__asm __volatile(
"movq %%mm0, %%mm4\n\t"
"movq %%mm3, %%mm5\n\t"
"movq %%mm6, %%mm0\n\t"
"movq %%mm7, %%mm1\n\t"
"movq %%mm4, %%mm6\n\t"
"movq %%mm5, %%mm7\n\t"
"movq %%mm0, %%mm2\n\t"
"movq %%mm1, %%mm3\n\t"
"psrlq $8, %%mm2\n\t"
"psrlq $8, %%mm3\n\t"
"psrlq $8, %%mm6\n\t"
"psrlq $8, %%mm7\n\t"
"pand %2, %%mm0\n\t"
"pand %2, %%mm1\n\t"
"pand %2, %%mm4\n\t"
"pand %2, %%mm5\n\t"
"pand %3, %%mm2\n\t"
"pand %3, %%mm3\n\t"
"pand %3, %%mm6\n\t"
"pand %3, %%mm7\n\t"
"por %%mm2, %%mm0\n\t"
"por %%mm3, %%mm1\n\t"
"por %%mm6, %%mm4\n\t"
"por %%mm7, %%mm5\n\t"
"movq %%mm1, %%mm2\n\t"
"movq %%mm4, %%mm3\n\t"
"psllq $48, %%mm2\n\t"
"psllq $32, %%mm3\n\t"
"pand %4, %%mm2\n\t"
"pand %5, %%mm3\n\t"
"por %%mm2, %%mm0\n\t"
"psrlq $16, %%mm1\n\t"
"psrlq $32, %%mm4\n\t"
"psllq $16, %%mm5\n\t"
"por %%mm3, %%mm1\n\t"
"pand %6, %%mm5\n\t"
"por %%mm5, %%mm4\n\t"
MOVNTQ" %%mm0, %0\n\t"
MOVNTQ" %%mm1, 8%0\n\t"
MOVNTQ" %%mm4, 16%0"
:"=m"(*d)
:"m"(*s),"m"(mask24l),"m"(mask24h),"m"(mask24hh),"m"(mask24hhh),"m"(mask24hhhh)
:"memory");
d += 24;
s += 8;
}
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
while(s < end)
{
register uint16_t bgr;
bgr = *s++;
*d++ = (bgr&0x1F)<<3;
*d++ = (bgr&0x7E0)>>3;
*d++ = (bgr&0xF800)>>8;
}
}
| 1threat
|
Facebook Graph Request using Swift3 - : <p>I am rewriting my graph requests with the latest Swift3. I am following the guide found here - <a href="https://developers.facebook.com/docs/swift/graph">https://developers.facebook.com/docs/swift/graph</a>. </p>
<pre><code>fileprivate struct UserProfileRequest: GraphRequestProtocol {
struct Response: GraphResponseProtocol {
init(rawResponse: Any?) {
// Decode JSON into other properties
}
}
let graphPath: String = "me"
let parameters: [String: Any]? = ["fields": "email"]
let accessToken: AccessToken? = AccessToken.current
let httpMethod: GraphRequestHTTPMethod = .GET
let apiVersion: GraphAPIVersion = .defaultVersion
}
fileprivate func returnUserData() {
let connection = GraphRequestConnection()
connection.add(UserProfileRequest()) {
(response: HTTPURLResponse?, result: GraphRequestResult<UserProfileRequest.Response>) in
// Process
}
connection.start()
</code></pre>
<p>However, I am getting this error in the connection.add method:</p>
<pre><code>Type ViewController.UserProfileRequest.Response does not conform to protocol GraphRequestProtocol.
</code></pre>
<p>I can't seem to figure this out what to change here. It seems like the developer guide is not up to date on Swift3, but I am not sure that is the issue. </p>
<p>Is anyone able to see what is wrong here?</p>
<p>Thanks.</p>
| 0debug
|
How run async / await in parallel in Javascript : <p>Finally <code>async</code>/<code>await</code> will be <a href="http://kangax.github.io/compat-table/es2016plus/#test-async_functions" rel="noreferrer">supported</a> in all major browser soon except IE.
So now we can start writing more readable code with <code>async</code>/<code>await</code> but there is a catch. A lot of people use async await like this:</p>
<pre><code>const userResponse = await fetchUserAsync();
const postsResponse = await fetchPostsAsync();
</code></pre>
<p>While this code is readable it has a problem, it runs the functions in series, it won't start fetching posts until the fetching of the user is finished. The solutions is simple, we need to fetch the resources in parallel.</p>
<p>So what I want to do is (in pseudo language): </p>
<pre><code>fn task() {
result-1 = doAsync();
result-2 = doAsync();
result-n = doLongAsync();
// handle results together
combinedResult = handleResults(result-1, result-2);
lastResult = handleLastResult(result-n);
}
</code></pre>
| 0debug
|
Create a custom Model Binder for a custom type : <p>In an ASP.NET CORE 1.1 project I have the following model:</p>
<pre><code>public class GetProductsModel {
public OrderExpression OrderBy { get; set; }
}
</code></pre>
<p>OrderExpression is a class which has the following method:</p>
<pre><code>Boolean TryParse(String value, out OrderExpression expression)
</code></pre>
<p>The method creates a <code>OrderExpression</code> instance from a <code>String</code> and can be used:</p>
<pre><code>OrderExpression expression;
Boolean parsed = OrderExpression.TryParse(value, out expression);
</code></pre>
<p>How can I create a custom Model Binder to properties of type <code>OrderExpression</code>?</p>
| 0debug
|
static int qcow2_do_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVQcow2State *s = bs->opaque;
unsigned int len, i;
int ret = 0;
QCowHeader header;
Error *local_err = NULL;
uint64_t ext_end;
uint64_t l1_vm_state_index;
bool update_header = false;
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read qcow2 header");
be32_to_cpus(&header.magic);
be32_to_cpus(&header.version);
be64_to_cpus(&header.backing_file_offset);
be32_to_cpus(&header.backing_file_size);
be64_to_cpus(&header.size);
be32_to_cpus(&header.cluster_bits);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
be32_to_cpus(&header.l1_size);
be64_to_cpus(&header.refcount_table_offset);
be32_to_cpus(&header.refcount_table_clusters);
be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots);
if (header.magic != QCOW_MAGIC) {
error_setg(errp, "Image is not in qcow2 format");
if (header.version < 2 || header.version > 3) {
error_setg(errp, "Unsupported qcow2 version %" PRIu32, header.version);
ret = -ENOTSUP;
s->qcow_version = header.version;
if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) {
error_setg(errp, "Unsupported cluster size: 2^%" PRIu32,
header.cluster_bits);
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - BDRV_SECTOR_BITS);
if (header.version == 2) {
header.incompatible_features = 0;
header.compatible_features = 0;
header.autoclear_features = 0;
header.refcount_order = 4;
header.header_length = 72;
} else {
be64_to_cpus(&header.incompatible_features);
be64_to_cpus(&header.compatible_features);
be64_to_cpus(&header.autoclear_features);
be32_to_cpus(&header.refcount_order);
be32_to_cpus(&header.header_length);
if (header.header_length < 104) {
error_setg(errp, "qcow2 header too short");
if (header.header_length > s->cluster_size) {
error_setg(errp, "qcow2 header exceeds cluster size");
if (header.header_length > sizeof(header)) {
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields,
s->unknown_header_fields_size);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read unknown qcow2 header "
"fields");
if (header.backing_file_offset > s->cluster_size) {
error_setg(errp, "Invalid backing file offset");
if (header.backing_file_offset) {
ext_end = header.backing_file_offset;
} else {
ext_end = 1 << header.cluster_bits;
s->incompatible_features = header.incompatible_features;
s->compatible_features = header.compatible_features;
s->autoclear_features = header.autoclear_features;
if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {
void *feature_table = NULL;
qcow2_read_extensions(bs, header.header_length, ext_end,
&feature_table, flags, NULL, NULL);
report_unsupported_feature(errp, feature_table,
s->incompatible_features &
~QCOW2_INCOMPAT_MASK);
ret = -ENOTSUP;
g_free(feature_table);
if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {
if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) {
error_setg(errp, "qcow2: Image is corrupt; cannot be opened "
"read/write");
ret = -EACCES;
if (header.refcount_order > 6) {
error_setg(errp, "Reference count entry width too large; may not "
"exceed 64 bits");
s->refcount_order = header.refcount_order;
s->refcount_bits = 1 << s->refcount_order;
s->refcount_max = UINT64_C(1) << (s->refcount_bits - 1);
s->refcount_max += s->refcount_max - 1;
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
if (bdrv_uses_whitelist() &&
s->crypt_method_header == QCOW_CRYPT_AES) {
error_setg(errp,
"Use of AES-CBC encrypted qcow2 images is no longer "
"supported in system emulators");
error_append_hint(errp,
"You can use 'qemu-img convert' to convert your "
"image to an alternative supported format, such "
"as unencrypted qcow2, or raw with the LUKS "
"format instead.\n");
ret = -ENOSYS;
if (s->crypt_method_header == QCOW_CRYPT_AES) {
s->crypt_physical_offset = false;
} else {
s->crypt_physical_offset = true;
bs->encrypted = true;
s->l2_bits = s->cluster_bits - 3;
s->l2_size = 1 << s->l2_bits;
s->refcount_block_bits = s->cluster_bits - (s->refcount_order - 3);
s->refcount_block_size = 1 << s->refcount_block_bits;
bs->total_sectors = header.size / 512;
s->csize_shift = (62 - (s->cluster_bits - 8));
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
s->refcount_table_offset = header.refcount_table_offset;
s->refcount_table_size =
header.refcount_table_clusters << (s->cluster_bits - 3);
if (header.refcount_table_clusters > qcow2_max_refcount_clusters(s)) {
error_setg(errp, "Reference count table too large");
ret = validate_table_offset(bs, s->refcount_table_offset,
s->refcount_table_size, sizeof(uint64_t));
if (ret < 0) {
error_setg(errp, "Invalid reference count table offset");
if (header.nb_snapshots > QCOW_MAX_SNAPSHOTS) {
error_setg(errp, "Too many snapshots");
ret = validate_table_offset(bs, header.snapshots_offset,
header.nb_snapshots,
sizeof(QCowSnapshotHeader));
if (ret < 0) {
error_setg(errp, "Invalid snapshot table offset");
if (header.l1_size > QCOW_MAX_L1_SIZE / sizeof(uint64_t)) {
error_setg(errp, "Active L1 table too large");
ret = -EFBIG;
s->l1_size = header.l1_size;
l1_vm_state_index = size_to_l1(s, header.size);
if (l1_vm_state_index > INT_MAX) {
error_setg(errp, "Image is too big");
ret = -EFBIG;
s->l1_vm_state_index = l1_vm_state_index;
if (s->l1_size < s->l1_vm_state_index) {
error_setg(errp, "L1 table is too small");
ret = validate_table_offset(bs, header.l1_table_offset,
header.l1_size, sizeof(uint64_t));
if (ret < 0) {
error_setg(errp, "Invalid L1 table offset");
s->l1_table_offset = header.l1_table_offset;
if (s->l1_size > 0) {
s->l1_table = qemu_try_blockalign(bs->file->bs,
align_offset(s->l1_size * sizeof(uint64_t), 512));
if (s->l1_table == NULL) {
error_setg(errp, "Could not allocate L1 table");
ret = -ENOMEM;
ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read L1 table");
for(i = 0;i < s->l1_size; i++) {
be64_to_cpus(&s->l1_table[i]);
ret = qcow2_update_options(bs, options, flags, errp);
if (ret < 0) {
s->cluster_cache_offset = -1;
s->flags = flags;
ret = qcow2_refcount_init(bs);
if (ret != 0) {
error_setg_errno(errp, -ret, "Could not initialize refcount handling");
QLIST_INIT(&s->cluster_allocs);
QTAILQ_INIT(&s->discards);
if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL,
flags, &update_header, &local_err)) {
error_propagate(errp, local_err);
if (s->crypt_method_header && !s->crypto) {
if (s->crypt_method_header == QCOW_CRYPT_AES) {
unsigned int cflags = 0;
if (flags & BDRV_O_NO_IO) {
cflags |= QCRYPTO_BLOCK_OPEN_NO_IO;
s->crypto = qcrypto_block_open(s->crypto_opts, "encrypt.",
NULL, NULL, cflags, errp);
if (!s->crypto) {
} else if (!(flags & BDRV_O_NO_IO)) {
error_setg(errp, "Missing CRYPTO header for crypt method %d",
s->crypt_method_header);
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
if (len > MIN(1023, s->cluster_size - header.backing_file_offset) ||
len >= sizeof(bs->backing_file)) {
error_setg(errp, "Backing file name too long");
ret = bdrv_pread(bs->file, header.backing_file_offset,
bs->backing_file, len);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read backing file name");
bs->backing_file[len] = '\0';
s->image_backing_file = g_strdup(bs->backing_file);
s->snapshots_offset = header.snapshots_offset;
s->nb_snapshots = header.nb_snapshots;
ret = qcow2_read_snapshots(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read snapshots");
update_header |= s->autoclear_features & ~QCOW2_AUTOCLEAR_MASK;
update_header =
update_header && !bs->read_only && !(flags & BDRV_O_INACTIVE);
if (update_header) {
s->autoclear_features &= QCOW2_AUTOCLEAR_MASK;
if (qcow2_load_autoloading_dirty_bitmaps(bs, &local_err)) {
update_header = false;
if (local_err != NULL) {
error_propagate(errp, local_err);
if (update_header) {
ret = qcow2_update_header(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not update qcow2 header");
qemu_co_mutex_init(&s->lock);
bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP;
if (!(flags & (BDRV_O_CHECK | BDRV_O_INACTIVE)) && !bs->read_only &&
(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {
BdrvCheckResult result = {0};
ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS | BDRV_FIX_LEAKS);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not repair dirty image");
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(bs, &result, 0);
#endif
return ret;
fail:
g_free(s->unknown_header_fields);
cleanup_unknown_header_ext(bs);
qcow2_free_snapshots(bs);
qcow2_refcount_close(bs);
qemu_vfree(s->l1_table);
s->l1_table = NULL;
cache_clean_timer_del(bs);
if (s->l2_table_cache) {
qcow2_cache_destroy(bs, s->l2_table_cache);
if (s->refcount_block_cache) {
qcow2_cache_destroy(bs, s->refcount_block_cache);
qcrypto_block_free(s->crypto);
qapi_free_QCryptoBlockOpenOptions(s->crypto_opts);
return ret;
| 1threat
|
How to perform Undo(remove last entered string) and Redo(add it back) Operations on Strings ? ( using Core Java data structures ) : How to perform Undo(remove last entered string) and Redo(add it back) Operations on Strings ? ( using Core Java data structures ) .
This was an interview question,which expected , creating our own pool of strings (asking for number of strings and strings from user)
UNDO : removing last string from
Redo : Adding it back
| 0debug
|
static inline void vmsvga_update_rect(struct vmsvga_state_s *s,
int x, int y, int w, int h)
{
DisplaySurface *surface = qemu_console_surface(s->vga.con);
int line;
int bypl;
int width;
int start;
uint8_t *src;
uint8_t *dst;
if (x < 0) {
fprintf(stderr, "%s: update x was < 0 (%d)\n", __func__, x);
w += x;
x = 0;
}
if (w < 0) {
fprintf(stderr, "%s: update w was < 0 (%d)\n", __func__, w);
w = 0;
}
if (x + w > surface_width(surface)) {
fprintf(stderr, "%s: update width too large x: %d, w: %d\n",
__func__, x, w);
x = MIN(x, surface_width(surface));
w = surface_width(surface) - x;
}
if (y < 0) {
fprintf(stderr, "%s: update y was < 0 (%d)\n", __func__, y);
h += y;
y = 0;
}
if (h < 0) {
fprintf(stderr, "%s: update h was < 0 (%d)\n", __func__, h);
h = 0;
}
if (y + h > surface_height(surface)) {
fprintf(stderr, "%s: update height too large y: %d, h: %d\n",
__func__, y, h);
y = MIN(y, surface_height(surface));
h = surface_height(surface) - y;
}
bypl = surface_stride(surface);
width = surface_bytes_per_pixel(surface) * w;
start = surface_bytes_per_pixel(surface) * x + bypl * y;
src = s->vga.vram_ptr + start;
dst = surface_data(surface) + start;
for (line = h; line > 0; line--, src += bypl, dst += bypl) {
memcpy(dst, src, width);
}
dpy_gfx_update(s->vga.con, x, y, w, h);
}
| 1threat
|
Need help in a school programming test : I have two lists called standards and credits. The standards list is added to a combo box. When I click an item in the combo box i want to be able to show an item in the credits list. For example i click first index in the combo box, I want to show item in the first index of the credits list. I have this code but it gives me an error i can't fix it
private void cboStandard1_SelectedIndexChanged(object sender, EventArgs e)
{
if (cboStandard1.SelectedIndex + 1 > 0)
{
lblCredits.Text = credits.ElementAt(standard.IndexOf(cboStandard1.Text));
}
}
| 0debug
|
static av_cold int libx265_encode_close(AVCodecContext *avctx)
{
libx265Context *ctx = avctx->priv_data;
av_frame_free(&avctx->coded_frame);
ctx->api->param_free(ctx->params);
if (ctx->encoder)
ctx->api->encoder_close(ctx->encoder);
return 0;
}
| 1threat
|
Restructuring an OOP datatype into Haskell types : <p>Coming from an OOP background, Haskell's type system and the way data constructors and typeclasses interact is difficult to conceptualize. I can understand how each are used for simple examples, but some more complication examples of data structures that are very well-suited for an OOP style are proving non-trivial to translate into similarly elegant and understandable types.</p>
<p>In particular, I have a problem with organizing a hierarchy of data such as the following.</p>
<p><img src="https://chitu.okoli.org/media/pro/teach/oop/uml.gif" alt="data"></p>
<p>This is a deeply nested hierarchical inheritance structure, and the lack of support for subtyping makes it unclear how to turn this structure into a natural-feeling alternative in Haskell. It may be fine to replace something like <code>Polygon</code> with a sum data type, declaring it like</p>
<pre><code>data Polygon
= Quad Point Point
| Triangle Point Point Point
| RegularNGon Int Radius
| ...
</code></pre>
<p>But this loses some of the structure, and can only really satisfactorily be done for one level of the hierarchy. Typeclasses can be used to implement a form of inheritance and substructure in that a <code>Polygon</code> typeclass could be a subclass of a <code>Shape</code>, and so maybe all <code>Polygon</code> instances have implementations for <code>centroid :: Point</code> and also <code>vertices :: [Point]</code>, but this seems unsatisfactory. What would be a good way of capturing the structure of the picture in Haskell?</p>
| 0debug
|
PHP Throws error when calling class method inside function : <pre><code>include "sys.php";
$logger = new logger();
$logger->write("Hello!");
</code></pre>
<p>This works. However,</p>
<pre><code>include "sys.php";
$logger = new logger();
function test() {
$logger->write("Hello!");
}
test();
</code></pre>
<p>This does not. The server crashes, error 500.</p>
<p>Why?</p>
| 0debug
|
static int gen_check_bw(URLContext *s, RTMPContext *rt)
{
RTMPPacket pkt;
uint8_t *p;
int ret;
if ((ret = ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE,
0, 21)) < 0)
return ret;
p = pkt.data;
ff_amf_write_string(&p, "_checkbw");
ff_amf_write_number(&p, ++rt->nb_invokes);
ff_amf_write_null(&p);
ret = ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size,
rt->prev_pkt[1]);
ff_rtmp_packet_destroy(&pkt);
return ret;
}
| 1threat
|
How can I await a minimum amount of time? : <p>I have an async C# method where I am getting an HTTP resource, and I am doing it in an infinite loop. However I don't want to hit the resource too quickly. My current code is:</p>
<pre><code>HttpClient http = new HttpClient();
while (true) {
// Long-poll the API
var response = await http.GetAsync(buildUri());
Console.WriteLine("Resp: " + response.ToString());
Console.WriteLine("CONTENT:");
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
</code></pre>
<p>However, I want to be able to make sure I don't make an HTTP request more often than once per 10 seconds. So I want to start a 10 second timer at the beginning of the loop, and at the end say "await the completion of the 10 second timer". Is there a way to do this in C#.NET?</p>
| 0debug
|
Python: flattening a zip? : <p>I have two list that I want to zip:</p>
<pre><code>a = ((1,2,3), (4,5,6), ... )
h = ('a','b', ... )
</code></pre>
<p>A simple <code>zip(a,h)</code> returns this:</p>
<pre><code>[ ((1,2,3),'a'), ((4,5,6),'b'), ... ]
</code></pre>
<p>Is there any clever way to return this?</p>
<pre><code>[ (1,2,3,'a'), (4,5,6,'b'), ... ]
</code></pre>
| 0debug
|
Notarizing Electron apps throws - "You must first sign the relevant contracts online. (1048)" error : <p>I am trying to Notarize an electron app to make it run on macOS Catalina. The packaging was successful but the <code>xcrun altool</code> command is throwing "You must first sign the relevant contracts online. (1048)" error.</p>
<p>Electron app package.json contents:</p>
<pre><code>"mac": {
"entitlements": "./build/entitlements.mac.inherit.plist",
"hardenedRuntime": true,
"type": "distribution",
"category": "public.app-category.productivity",
"icon": "build/icon.icns",
"target": [
"dmg",
"zip"
]
},
"dmg": {
"sign": false,
</code></pre>
<p>entitlements.mac.inherit.plist file:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.application-identifier</key>
<string><app.bundle.name></string>
<key>com.apple.developer.team-identifier</key>
<string><TEAMID></string>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string><app.bundle.name></string>
</array>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.inherit</key>
<true/>
</dict>
</plist>
</code></pre>
<p>I ran the command as mentioned in <a href="https://stackoverflow.com/a/53121755">https://stackoverflow.com/a/53121755</a></p>
<pre><code>xcrun altool --notarize-app -f App.dmg --primary-bundle-id app.bundle.name -u <username> -p <app-specific-password>
</code></pre>
<p>It is throwing <em>You must first sign the relevant contracts online. (1048)</em> error. I am unable to proceed with the app signing. Help!</p>
<p>ps: electron-notarize package is throwing the same error.</p>
| 0debug
|
Python - Remove extra empty strings : Let's say I have a Python list of strings like so:
x = ["", "", "test", "", "", "not empty", "", "yes", ""]
> ['', '', 'test', '', '', 'not empty', '', 'yes', '']
How can I remove excess (but not all) empty strings as well as trailing, and leading empty strings, like so:
> ['test', '', 'not empty', '', 'yes']
| 0debug
|
How can I test lambda in local using python? : <p>Is there any way that I can test aws lambda in local? I know there is a package which name is 'localstack' but seems like there is not many people who tried it.</p>
| 0debug
|
Error 111 connecting to localhost:6379. Connection refused. Django Heroku : <p>I am able to run redis locally and everything works. </p>
<p>However when I deploy to heroku I get this error: </p>
<pre><code>Error 111 connecting to localhost:6379. Connection refused.
</code></pre>
<p>I have set up a Procfile with...</p>
<pre><code>web: gunicorn odb.wsgi --log-file -
worker: python worker.py
</code></pre>
<p>I have a worker.py file...</p>
<pre><code>import os
import urlparse
from redis import Redis
from rq import Worker, Queue, Connection
listen = ['high', 'default', 'low']
redis_url = os.getenv('REDISTOGO_URL')
if not redis_url:
raise RuntimeError('Set up Redis To Go first.')
urlparse.uses_netloc.append('redis')
url = urlparse.urlparse(redis_url)
conn = Redis(host=url.hostname, port=url.port, db=0, password=url.password)
if __name__ == '__main__':
with Connection(conn):
worker = Worker(map(Queue, listen))
worker.work()
</code></pre>
<p>A REDISTOGO_URL variable appears in the heroku config.</p>
<p>Redis to go is an installed add-on for my app. </p>
<p>Does REDISTOGO_URL have to be defined in settings.py? Why is heroku trying to connect to the local host when it is not even defined in worker.py? </p>
| 0debug
|
How to get the data I want according to the rules : <p>I have a configuration table like the below, and some users with different attributes. I need to get a configuration data based on user attributes.</p>
<p>I don't know how to implement it, no idea.</p>
<p><a href="https://i.stack.imgur.com/vFKP3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vFKP3.png" alt="configuration data from db table"></a></p>
<p>Initial code: </p>
<pre><code>void Main()
{
var configList = new List<ConfigEntity>() {
new ConfigEntity { ConfigCode="37", GoodCode="A", UserType="personal", Country="US", State="NewYork", City="Buffalo", Price=37 },
new ConfigEntity { ConfigCode="36", GoodCode="A", UserType="personal", Country="US", State="NewYork", City="Albany", Price=36 },
new ConfigEntity { ConfigCode="35", GoodCode="A", UserType="personal", Country="US", State="NewYork", City="", Price=35 },
new ConfigEntity { ConfigCode="34", GoodCode="A", UserType="personal", Country="US", State="", City="", Price=34 },
new ConfigEntity { ConfigCode="40", GoodCode="A", UserType="personal", Country="China", State="Guangdong", City="Guangzhou", Price=40 },
new ConfigEntity { ConfigCode="39", GoodCode="A", UserType="personal", Country="China", State="Guangdong", City="", Price=39 },
new ConfigEntity { ConfigCode="38", GoodCode="A", UserType="personal", Country="China", State="", City="", Price=38 },
new ConfigEntity { ConfigCode="33", GoodCode="A", UserType="personal", Country="", State="", City="", Price=33 },
new ConfigEntity { ConfigCode="45", GoodCode="A", UserType="organization", Country="US", State="NewYork", City="Buffalo", Price=45 },
new ConfigEntity { ConfigCode="44", GoodCode="A", UserType="organization", Country="US", State="NewYork", City="Albany", Price=44 },
new ConfigEntity { ConfigCode="43", GoodCode="A", UserType="organization", Country="US", State="NewYork", City="", Price=43 },
new ConfigEntity { ConfigCode="42", GoodCode="A", UserType="organization", Country="US", State="", City="", Price=42 },
new ConfigEntity { ConfigCode="48", GoodCode="A", UserType="organization", Country="China", State="Guangdong", City="Guangzhou", Price=48 },
new ConfigEntity { ConfigCode="47", GoodCode="A", UserType="organization", Country="China", State="Guangdong", City="", Price=47 },
new ConfigEntity { ConfigCode="46", GoodCode="A", UserType="organization", Country="China", State="", City="", Price=46 },
new ConfigEntity { ConfigCode="41", GoodCode="A", UserType="organization", Country="", State="", City="", Price=41 },
new ConfigEntity { ConfigCode="29", GoodCode="A", UserType="", Country="US", State="NewYork", City="Buffalo", Price=29 },
new ConfigEntity { ConfigCode="28", GoodCode="A", UserType="", Country="US", State="NewYork", City="Albany", Price=28 },
new ConfigEntity { ConfigCode="27", GoodCode="A", UserType="", Country="US", State="NewYork", City="", Price=27 },
new ConfigEntity { ConfigCode="26", GoodCode="A", UserType="", Country="US", State="", City="", Price=26 },
new ConfigEntity { ConfigCode="32", GoodCode="A", UserType="", Country="China", State="Guangdong", City="Guangzhou", Price=32 },
new ConfigEntity { ConfigCode="31", GoodCode="A", UserType="", Country="China", State="Guangdong", City="", Price=31 },
new ConfigEntity { ConfigCode="30", GoodCode="A", UserType="", Country="China", State="", City="", Price=30 },
new ConfigEntity { ConfigCode="25", GoodCode="A", UserType="", Country="", State="", City="", Price=25 },
new ConfigEntity { ConfigCode="13", GoodCode="", UserType="personal", Country="US", State="NewYork", City="Buffalo", Price=13 },
new ConfigEntity { ConfigCode="12", GoodCode="", UserType="personal", Country="US", State="NewYork", City="Albany", Price=12 },
new ConfigEntity { ConfigCode="11", GoodCode="", UserType="personal", Country="US", State="NewYork", City="", Price=11 },
new ConfigEntity { ConfigCode="10", GoodCode="", UserType="personal", Country="US", State="", City="", Price=10 },
new ConfigEntity { ConfigCode="16", GoodCode="", UserType="personal", Country="China", State="Guangdong", City="Guangzhou", Price=16 },
new ConfigEntity { ConfigCode="15", GoodCode="", UserType="personal", Country="China", State="Guangdong", City="", Price=15 },
new ConfigEntity { ConfigCode="14", GoodCode="", UserType="personal", Country="China", State="", City="", Price=14 },
new ConfigEntity { ConfigCode="9", GoodCode="", UserType="personal", Country="", State="", City="", Price=9 },
new ConfigEntity { ConfigCode="21", GoodCode="", UserType="organization", Country="US", State="NewYork", City="Buffalo", Price=21 },
new ConfigEntity { ConfigCode="20", GoodCode="", UserType="organization", Country="US", State="NewYork", City="Albany", Price=20 },
new ConfigEntity { ConfigCode="19", GoodCode="", UserType="organization", Country="US", State="NewYork", City="", Price=19 },
new ConfigEntity { ConfigCode="18", GoodCode="", UserType="organization", Country="US", State="", City="", Price=18 },
new ConfigEntity { ConfigCode="24", GoodCode="", UserType="organization", Country="China", State="Guangdong", City="Guangzhou", Price=24 },
new ConfigEntity { ConfigCode="23", GoodCode="", UserType="organization", Country="China", State="Guangdong", City="", Price=23 },
new ConfigEntity { ConfigCode="22", GoodCode="", UserType="organization", Country="China", State="", City="", Price=22 },
new ConfigEntity { ConfigCode="17", GoodCode="", UserType="organization", Country="", State="", City="", Price=17 },
new ConfigEntity { ConfigCode="5", GoodCode="", UserType="", Country="US", State="NewYork", City="Buffalo", Price=5 },
new ConfigEntity { ConfigCode="4", GoodCode="", UserType="", Country="US", State="NewYork", City="Albany", Price=4 },
new ConfigEntity { ConfigCode="3", GoodCode="", UserType="", Country="US", State="NewYork", City="", Price=3 },
new ConfigEntity { ConfigCode="2", GoodCode="", UserType="", Country="US", State="", City="", Price=2 },
new ConfigEntity { ConfigCode="8", GoodCode="", UserType="", Country="China", State="Guangdong", City="Guangzhou", Price=8 },
new ConfigEntity { ConfigCode="7", GoodCode="", UserType="", Country="China", State="Guangdong", City="", Price=7 },
new ConfigEntity { ConfigCode="6", GoodCode="", UserType="", Country="China", State="", City="", Price=6 },
new ConfigEntity { ConfigCode="1", GoodCode="", UserType="", Country="", State="", City="", Price=1 }
};
configList.Dump();
}
public class ConfigEntity
{
public string ConfigCode { get; set; }
public string GoodCode { get; set; }
public string UserType { get; set; }
public string Country { get; set; }
public string State { get; set; }
public string City { get; set; }
public decimal Price { get; set; }
}
</code></pre>
<p>if GoodCode="A" and user (UserType="personal", Country="US", State="NewYork", City="Albany"), I expect get a data of ConfigCode="36";</p>
<p>if GoodCode="A" and user (UserType="personal", Country="China", State="Guangdong", City=""), I expect get a data of ConfigCode="39";</p>
<p>if GoodCode="A" and user (UserType="personal", Country="", State="", City=""), I expect get a data of ConfigCode="33";</p>
<p>if GoodCode="" and user (UserType="personal", Country="", State="", City=""), I expect get a data of ConfigCode="9";</p>
<p>if GoodCode="B" and user (UserType="", Country="", State="", City=""), I expect get a data of ConfigCode="1";</p>
| 0debug
|
static int ffm_is_avail_data(AVFormatContext *s, int size)
{
FFMContext *ffm = s->priv_data;
int64_t pos, avail_size;
int len;
len = ffm->packet_end - ffm->packet_ptr;
if (size <= len)
return 1;
pos = url_ftell(s->pb);
if (!ffm->write_index) {
if (pos == ffm->file_size);
return AVERROR_EOF;
avail_size = ffm->file_size - pos;
} else {
if (pos == ffm->write_index) {
return AVERROR(EAGAIN);
} else if (pos < ffm->write_index) {
avail_size = ffm->write_index - pos;
} else {
avail_size = (ffm->file_size - pos) + (ffm->write_index - FFM_PACKET_SIZE);
}
}
avail_size = (avail_size / ffm->packet_size) * (ffm->packet_size - FFM_HEADER_SIZE) + len;
if (size <= avail_size)
return 1;
else
return AVERROR(EAGAIN);
}
| 1threat
|
How does EF6 TPT inheritance operate under the hood, specifically when adding entities and why does can't I implement it in EF Core? : I am aware that when using TPT inheritance in EF6 you can execute code like:
`WarehouseEmployee wEmp = new WarehouseEmployee();
_context.Employees.Add(wEmp);
`
Where WarehouseEmployee derives from Employee and Employee is an abstract class. Here Employees would be a `DbSet<Employee> Employees` in the derived `DbContext` class.
**Since this example is TPT that means we have a table per type**
So let's say our DB has the tables Employee, WarehouseEmployee, OfficeEmployee
How does EF6 handle, under the hood, adding information to the database in a situation like this? Why can't I use the same line of code in EF Core(2.0)?
Similary, why not with reads?
Why could I not set up my EF Core model classes with inheritance so I could query a derived type?" E.g. `_context.Employees.OfType<WarehouseEmployee>.Where(e=>e.Id == employeeId)`
**Why do I ask this?**
We inherited an application we are converting from desktop to web. Legacy uses TPT and EF6 and management is asking us to use asp.net core 2.0. The database is complex and we'd like to use it as is.
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.