text:
Q: Unsure how to insert rows into sheet based on the number of visible cells in a filtered column I am working of project for work where a macro will automatically generate credit notes and invoices. The problem that I am running into is how to write a code where excel will enter a number of rows that is equal to the total number of visible cells in a filtered column.
Right now the code (rather inelegantly) inserts 20 rows and then copies and pastes in the data from the filtered column. The problem is that sometimes the number of filtered cells in the column is greater than 20, which leads to different sections of the credit notes and invoices being overwritten.
Here's the section of the code that is causing all the issues.
Rows("30:30").Select
Selection.EntireRow.Resize(20).Insert Shift:=xlDown

 ' InvoiceDates Macro

Dim ws As Worksheet
Set ws = Application.Worksheets("Old Invoices")

ws.Range("b2:b1000").AutoFilter field:=2, Criteria1:="Advertising Invoices", VisibleDropDown:=True

ws.Range("a2:a1000" & data_end_row_number).SpecialCells(xlCellTypeVisible).Copy
Worksheets("creditnotes").Range("d30").PasteSpecial xlPasteValues

'invoice issue dates
ws.Range("c2:c1000" & data_end_row_number).SpecialCells(xlCellTypeVisible).Copy
Worksheets("creditnotes").Range("h30").PasteSpecial xlPasteValues

'Invoice Month
ws.Range("c2:c1000" & data_end_row_number).SpecialCells(xlCellTypeVisible).Copy
Worksheets("creditnotes").Range("d53").PasteSpecial xlPasteValues

'Total Amount
ws.Range("d2:d1000" & data_end_row_number).SpecialCells(xlCellTypeVisible).Copy
Worksheets("creditnotes").Range("j53").PasteSpecial xlPasteValues

'VAT Amount
ws.Range("e2:e1000" & data_end_row_number).SpecialCells(xlCellTypeVisible).Copy
Worksheets("creditnotes").Range("l53").PasteSpecial xlPasteValues

A: So I think I would restructure your code a bit first. Currently, you are copying a range of nearly 1000 cells and pasting over, though I assume the number of required values is actually much smaller. So the first step is to determine the number of cells you want to copy. Once you have that, you'll be able to be more selective with which cells you copy and the number of rows you insert. Reference this topic for help with that : I need a VBA code to count the number rows, which varies from ss to ss, return that number and copy and paste that row and all other columns


text:
Q: Changing colors in a protovis node-link tree I'm new to Protovis although it is no longer under development and D3 is the newer software. However, I'm using the Node-Link Tree from Protovis to display my data for various reasons, so I prefer to stick to Protovis however if anyone has an R package in mind that I haven't come across yet (other than dendextend, ggplot2, d3network, etc) to get me to use R instead of Protovis please let me know. Anyhow, a snippet of my data for Protovis looks like this:
var PB = {
    PBC03013: {
"103937011_PbUn_2838": 3013,
"103934808_PbUn_26206": 3013,
"103930675_PbUn_35145": 3013,
"103941984_PbUn_52102": 3013,
"103935933_PbUn_63128": 3013,
"103966210_PbUn_64271": 3013
},
PBC03018: {
"103935981_PbUn_53113": 3018,
"103934997_PbUn_59093": 3018,
"103936640_PbUn_65330": 3018,
"103955166_PbUn_112582": 3018
},
...
}
}
I'm trying to change the node colors such that the dots for the elements in PB03013 and PB03018 are different, say "green" and "red", respectively. So all of the PB03013 element dots are green and all of the PB03018 element dots are red. There are 10 nodes in total. I've done a lot of research on this but I'm having such a hard time setting different dot colors I decided to post for help.

This is the body of my html code:
var tree = vis.add(pv.Layout.Tree)
    .nodes(pv.dom(PB).root("PB").nodes())
    .depth(127)
    .breadth(7.25)
    .orient("radial");

tree.link.add(pv.Line);

tree.node.add(pv.Dot)
    .fillStyle(function(n) n.firstChild ? "#a1d99b" : "#de2d26");

tree.label.add(pv.Label);

So far, I've been using pv.Color pallets or n.key n.parentNode, etc code alterations to no success. I also set a new variable to force different colors like:
var re = "",
    color = pv.Colors.category19().by(function(d) d.parentNode.nodeName)
    nodes = pv.dom(PB).root("PB").nodes();

Then:

treemap.leaf.add(pv.Panel)
    .fillStyle(function(d) color(d).alpha(title(d).match(re) ? 1 : .2))

The node-link tree code can also be found here:
http://mbostock.github.io/protovis/ex/tree.html

Any help is greatly appreciated.

A: networkD3 is the successor to d3Network and is much more capable and may suit your needs. In particular, the current dev version (v0.4.9000 as of 2017.09.06) has a new treeNetwork function that is very capable, including the ability to explicitly set the color of each individual node and link. We'd be happy to get feedback as it's still in development.

redpajama_set_name: RedPajamaStackExchange


text:
Q: haskell basecase in balanced-fold There are different kinds of folds in Haskell like foldl and foldr.
I read about the following balanced-fold:
balanced_fold::(e->e->e)->e->[e]->e
balanced_fold _ b [] =b
balanced_fold f b l@(_:_:_)=
   let
      len= length l
      (half1,half2)=
        divide_list (div len 2) l
      value1=balanced_fold f b half1
      value2=balanced_fold f b half2
   in
      f value1 value2
divide_list :: Int-> [a]->([a],[a])
divide_list _ [] =([],[])
divide_list n (x:xs)
     | n==0 =([],x:xs)
     | otherwise =
         let (half1,half2)=
             divide_list (n-1) xs
         in
             (x:half1, half2)

From the definition, when the list just contains one element [x] the output will be x.
My question is: is it right that, when a list just contains one element, we don't need to use the base value to deal with this element?
As we know, foldr and foldl do use the base value to deal with the element in the list even there is just one.
foldl::(v->e->v)->v->[e]->v
foldl _ base [] =base
foldl f base (x:xs)=
     let newbase =f base x in
     foldl f newbase xs

A: I hope this answers your question:
First let's fix your function:
balanced_fold :: (e -> e -> e) -> e -> [e] -> e
balanced_fold _ b []  = b
balanced_fold f b [a] = f b a
balanced_fold f b l =
   let len= length l
       (half1,half2)= divide_list (div len 2) l
       value1=balanced_fold f b half1
       value2=balanced_fold f b half2
   in f value1 value2

as you can see I added a case that deals with lists of lenght 1 (the missing piece) - also I hope you now see where your base-case  is
The problem with what you had was, that it had no matching cases for lists with just one element - and even if you would remove the (_:_:_) (which you don't really need) you would end up in situations where divide_list always give you something like ([],[x]) and the [x] would recurse in the same case - that's why you need the extra case to deal with exactly this situation.
Here is a quick test-session to see if it works:
λ> balanced_fold (+) 0 []
0
λ> balanced_fold (+) 0 [1]
1
λ> balanced_fold (+) 0 [1..4]
10
λ> balanced_fold (+) 0 [1..5]
15

seems to be ok I think

maybe nice to know
notice how this all only works when your operation is associative and if you have some kind of base/neutral element (to this operation).
There is already a class Monoid for all this and so you could write this too:
import Data.Monoid

balanced_fold :: Monoid e => [e] -> e
balanced_fold []  = mempty
balanced_fold [a] = a
balanced_fold l =
   let len           = length l
       (half1,half2) = divide_list (div len 2) l
       value1        = balanced_fold half1
       value2        = balanced_fold half2
   in value1 `mappend ` value2

See it's just

*

*f is now mappend

*b is just mempty
Now it's a bit ugly to apply for the example:
λ> balanced_fold (map Sum [1..4])
Sum {getSum = 10}

but that's just because there is more than one monoid possible for numbers.


text:
Q: Guaranteed CPU cache update after a certain time Let's say I have a variable var located somewhere in memory and that an arbitrary number of processors/threads could read and modify it at any given time. But it's guaranteed that at least n seconds will have elapsed between a processor modifying var and any other one reading var. Is it possible to be certain that, if time in seconds is n, there's a value for n that guarantees that the processor reading var will read the updated value?

A: If your concern really is Cache coherence you should generally be safe 1.
Specifically, however, you may be not.
Cache coherence is usually handled by the hardware2 without the help of the software.
However this is very implementation specific: NUMA may be non cache-coherent, a Compute Shader may need specific built-in functions, IA32e and ARM generally hide cache coherence from the programmer.
To answer you question directly: No, you have no guarantees whatsoever.
The point is that cache coherence is something you deal with in clustered and parallel non uniform architectures.
While in this situations the programming model is inherently multi-threading, the two concepts3 are separated and what really should bug you is how to properly handle multi-threading, specifically synchronization and memory order.
Your question seems to suggest a simple case, where the readers are executed long after the writer is done.
If this property is really enforced you don't need any synchronization nor memory barrier. Beware however that sleep functions don't qualify as a valid enforcement.
If you instead need to synchronize (and so to order the memory accesses) then you need to use language specific constructs, for example volatile in C# and Java, atomics in C and C++ or specific instructions in assembly.
You may need to implement Critical sections too.
If you actually need to manually control the cache coherence for your architecture, than you have to check the specifications of interest (usually datasheets and formal papers) because there is no uniform way to deal with it and the compiler should provide some intrinsic or the runtime should provide a library.
So to add something to the direct answer above: No, you have no guarantees whatsoever, but when an usual CPU, in an usual architecture, need that data, it will be able to use the most updated one anyway. So you don't need to worry about that aspect.
Please note the use of the words common and that

1 For example if you use an Intel/AMD/ARM CPU, don't even think about cache coherence.
2 Either the CPU itself, a local monitor, a system monitor or a specific device.
3 Multi-threading and cache-coherence.

A: The cache will tend to get flushed on operating system tick interrupts when it goes into the scheduler to see if there's a different task to run.
However, as operating systems get smarter with things such as tickless NoHz and as CPU core counts go up, this gets less and less likely, and you shouldn't count on it.
Supercomputer clusters may not task switch for minutes at a time because they're using customized operating system code that doesn't interrupt the running jobs, ever. Compute jobs are assigned to a core from 1-7 with no interrupts and all of the other work runs on core-0.

A: There are two concepts mixed in you question: software synchronization and hardware coherency. Hardware coherency is talked by Margaret already so I won't cover it here.
Software Synchronization
x86 provides guarantee that quadword access would be carried out atomically if aligned on 64-bit boundary. But this guarantees that other processor won't read partial result (e.g. [32bit New]<32bit Old> weird mixture). It does not guarantee a hard time deadline before which another processor would see the newly assigned value. Let another thread wait for some time is not quite an elegant solution because first the two threads need to have the same starting time synchronized. So, if you need such guarantee, you need conditional variable to make sure another thread should wait.
https://en.wikipedia.org/wiki/Monitor_(synchronization)
In a word, use conditional variable if you need a sequencing effect and use locks/transactional memory, etc. to protect variable longer than quadword or not 64bit aligned.
Btw, here is an useful material for cache coherency if you are interested.
http://www.cs.cmu.edu/afs/cs/academic/class/15418-s12/www/lectures/10_coherence.pdf


text:
Q: Frame border disappears from ViewCell while listview scroll up and down in Xamarin form android I have set list border using trigger according to my requirement but when I scroll up the listview and selected view cell  is gone than I scroll down when ViewCell is appearing on screen than selected border is gone
To prevent this I also created frame renderer but still ViewCell border gone.
Attached image here
class FrameHighLightRenderer : VisualElementRenderer<Frame>
{
    ACanvas _canvas = null;
    private FrameDrawable _frameDrawable;
    protected override void OnElementChanged(ElementChangedEventArgs<Frame> e)
    {
        base.OnElementChanged(e);

        if (e.NewElement != null)
        {
            if (_frameDrawable != null && e.NewElement.ClassId != null)       //This block execute while any cell appearing in scroll time up/dowm
            {                                                                 // I added classId =10 to identify colored/selected cell

                if (e.NewElement.ClassId=="10")
                {

                     e.NewElement.OutlineColor = Xamarin.Forms.Color.Red;
                     this.Invalidate();
                                     }
                else
                {
                    e.NewElement.BackgroundColor = Xamarin.Forms.Color.TransParent;
                }

            }
            else
            {

                UpdateBackground();
            }
        }
    }

    void UpdateBackground()
    {
        _frameDrawable = new FrameDrawable(Element, Context.ToPixels);
        this.SetBackground(_frameDrawable);

    }

    class FrameDrawable : Drawable
    {
        readonly Frame _frame;
        readonly Func<double, float> _convertToPixels;
        public ACanvas _canvas;
        bool _isDisposed;
        Bitmap _normalBitmap;

        public FrameDrawable(Frame frame, Func<double, float> convertToPixels)
        {
            _frame = frame;
            _convertToPixels = convertToPixels;
            frame.PropertyChanged += FrameOnPropertyChanged;
        }

        public override bool IsStateful
        {
            get { return false; }
        }

        public override int Opacity
        {
            get { return 0; }
        }

        public override void Draw(ACanvas canvas)
        {
            SetBorderColorandWidth(canvas);
        }

        private void SetBorderColorandWidth(ACanvas canvas)
        {
            int width = Bounds.Width();
            int height = Bounds.Height();
            if (width <= 0 || height <= 0)
            {
                if (_normalBitmap != null)
                {
                    _normalBitmap.Dispose();
                    _normalBitmap = null;
                }
                return;
            }

            if (_normalBitmap == null || _normalBitmap.Height != height || _normalBitmap.Width != width)
            {

                _normalBitmap = CreateBitmap(false, width, height);
            }
            Bitmap bitmap = _normalBitmap;

            // if(canvas)
            if (InspectionQAPage._highlight_color)
            {
                using (var paint = new Paint { AntiAlias = true })
                using (var path = new Path())
                using (Path.Direction direction = Path.Direction.Cw)
                using (Paint.Style style = Paint.Style.Stroke)
                using (var rect = new RectF(0, 0, width, height))
                {
                    float rx = Forms.Context.ToPixels(4);
                    float ry = Forms.Context.ToPixels(4);
                    path.AddRoundRect(rect, rx, ry, direction);
                    if (this._frame.OutlineColor == Xamarin.Forms.Color.Red)
                    {
                        paint.Color = Android.Graphics.Color.Red;
                        this._frame.ClassId = "10";
                        // this._frame.BackgroundColor = Xamarin.Forms.Color.Red;
                        // paint.SetStyle = (Paint.Style)(Resource.Style.WithBorder);
                    }
                    else
                    {
                       // paint.Reset();
                       paint.Color = Android.Graphics.Color.Transparent;
                       // this._frame.BackgroundColor = Xamarin.Forms.Color.Transparent;
                    }

                    paint.StrokeWidth = 10f;  //set outline stroke
                    paint.SetStyle(style);
                    canvas.DrawPath(path, paint);

                }
                InspectionQAPage._highlight_color = false;
            }
            else
            {
                using (var paint = new Paint())
                    canvas.DrawBitmap(bitmap, 0, 0, paint);
            }
           // InvalidateSelf();

        }
        public override void SetAlpha(int alpha)
        {
        }

        public override void SetColorFilter(ColorFilter cf)
        {
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && !_isDisposed)
            {
                if (_normalBitmap != null)
                {
                    _normalBitmap.Dispose();
                    _normalBitmap = null;
                }

                _isDisposed = true;
            }

            base.Dispose(disposing);
        }

        protected override bool OnStateChange(int[] state)
        {
            return false;
        }

        Bitmap CreateBitmap(bool pressed, int width, int height)
        {
            Bitmap bitmap;
            using (Bitmap.Config config = Bitmap.Config.Argb8888)
                if (width <= 0 || height <= 0)
                {
                    return null;
                }
                else
                    bitmap = Bitmap.CreateBitmap(width, height, config);

            using (var canvas = new ACanvas(bitmap))
            {
               // DrawCanvas(canvas, width, height, pressed);
            }

            return bitmap;
        }

        void FrameOnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName ||
                e.PropertyName == Frame.OutlineColorProperty.PropertyName ||
                e.PropertyName == Frame.CornerRadiusProperty.PropertyName)
            {
                try
                {
                    if (_normalBitmap == null)
                        return;

                    int width = Bounds.Width();
                    int height = Bounds.Height();

                    if (width <= 0 || height <= 0)
                    {
                        return;
                    }

                    if (_canvas == null)
                    {
                        var canvas = new ACanvas(_normalBitmap);
                            _canvas = canvas;
                            _canvas.DrawColor(global::Android.Graphics.Color.Red, PorterDuff.Mode.Clear);
                            DrawCanvas(_canvas, width, height, false, sender);
                    }
                    else
                    {
                        _canvas.DrawColor(global::Android.Graphics.Color.Red, PorterDuff.Mode.Clear);
                        DrawCanvas(_canvas, width, height, false, sender);
                    }

                       InvalidateSelf();

                }
                catch (Exception ex)
                {

                    Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>" + ex);
                    throw;
                }
            }
        }

        public void DrawCanvas(ACanvas canvas, int width, int height, bool pressed, object sender)
        {
              using (var paint = new Paint { AntiAlias = true })
                using (var path = new Path())
                using (Path.Direction direction = Path.Direction.Cw)
                using (Paint.Style style = Paint.Style.Stroke)
                using (var rect = new RectF(0, 0, width, height))
                {
                    float rx = Forms.Context.ToPixels(4);
                    float ry = Forms.Context.ToPixels(4);
                    path.AddRoundRect(rect, rx, ry, direction);

                    if (((Frame)sender).OutlineColor == Xamarin.Forms.Color.Red)
                    {
                        paint.Color = Android.Graphics.Color.Red;

                        ((Frame)sender).ClassId = "10";

                    }
                    else
                    {

                    ((Frame)sender).BackgroundColor = Xamarin.Forms.Color.Transparent;

                }
                    paint.StrokeWidth = 10f;  //set outline stroke
                    paint.SetStyle(style);
                    canvas.DrawPath(path, paint);

                }
            }

    }

}

}


text:
Q: How to reset cumulative sum per group when a certain column is 0 in pandas I have following dataframe in which I want to make a cumulative sum on a certain column (Value), together with a group by on field Group, but reset that cumulative sum to 0 when a value in another column (Quantity) is 0.

Group
Quantity
Value
Cumulative_sum

A
10
200
200

B
5
300
300

A
1
50
250

A
0
100
0

C
5
400
400

A
10
300
300

B
10
200
500

A
15
350
650

I have tried working with blocks like in the code below, but the issue is that it doesn't do the cumulative sum correctly:
blocks = df['Quantity'].eq(0)[::-1].cumsum()[::-1]

df['temp_field'] = (df.groupby(['Group', blocks])
   ['Value'].cumsum()
   .where(df['Quantity']!=0,df['Value'])
)

df['Cumulative_sum'] = np.where(df['Quantity'] == 0, 0, df['temp_field'])

Could anyone help with this?

A: *

*For the given resetting condition, use groupby.cumsum to create a Reset grouper that tells us when Quantity hits 0 within each Group:
condition = df.Quantity.eq(0)
df['Reset'] = condition.groupby(df.Group).cumsum()

#   Group  Quantity  Value  Cumulative_sum  Reset
# 0     A        10    200             200      0
# 1     B         5    300             300      0
# 2     A         1     50             250      0
# 3     A         0    100               0      1
# 4     C         5    400             400      0
# 5     A        10    300             300      1
# 6     B        10    200             500      0
# 7     A        15    350             650      1

*mask the Value column whenever the resetting condition is met and use another groupby.cumsum on both Group and Reset:
df['Cumul'] = df.Value.mask(condition, 0).groupby([df.Group, df.Reset]).cumsum()

#   Group  Quantity  Value  Cumulative_sum  Reset  Cumul
# 0     A        10    200             200      0    200
# 1     B         5    300             300      0    300
# 2     A         1     50             250      0    250
# 3     A         0    100               0      1      0
# 4     C         5    400             400      0    400
# 5     A        10    300             300      1    300
# 6     B        10    200             500      0    500
# 7     A        15    350             650      1    650


text:
Q: Why do constraints 0 0 0 0 not fit the whole view? EXAMPLE 1
I am using Xcode 8.2 beta and when I try to make view fits the whole screen it does not include the section where battery icon at .

update the frames and then

EXAMPLE 2
When I try to cover whole view first  and then set constraints 0 0 0 0  it fits the whole screen.

In both example I set constraints 0 0 0 0  but different results. Why ?
Can somebody explain please ? Thank you !

A: You have set up constraints with the controller's top layout guide, instead of the view itself. The top layout guide is influenced by things, such as status bar, navigation bar, etc. That is why you are seeing two different results.


text:
Q: Naruto & Selfie Hats I have some doubts about how earn these hats.

Selfie

ask and answer your own question

I did a Selfie yesterday, but nothing happened (yet).
I earned this hat right now. I guess that this post woke up some process. As @ShadowWizard said You got Selfie due to the upvote on the question. :)

Naruto

post an accepted answer that receives no other votes for 12 hours

I answered a question with no upvotes (accepted 20 hours ago), but I have not earned the hat (yet)
Is it just lag? Or are there other rules not written in the description of these hats?

A: Selfie (and "On the Road") requires the posted question to have a score of 1 or higher.
I just got "Selfie" from a question I posted hours ago, just a moment after someone upvoted it.

A: The Selfie has already been explained; also see Why didn't (or did) I or some other user get a hat although the requirements were (or weren't) fulfilled?.
The Naruto issue was indeed a bug; an overzealous optimization that caused the awarding to fail when the time between the answer being written and being accepted was too long. I've fixed that bug, and you have just been awarded the Naruto. Thanks for pointing it out.


text:
Q: Here is my source code of a page. I need to click on a "Click Here" element Any suggestions how to do this using selenium webdriver? Below is a sample of the source code of a page. I need to click on the "Click Here" element, any suggestions how to do this using Selenium Webdriver?

    Click Here

A: I'm assuming that is NOT the rendered object, but in the event that it is, you can click it by using this CSS selector:
driver.findElement(By.cssSelector("div.railcontent > a[href*='NoticeDisplayManager']")).click();


text:
Q: Multiple Documents/Views in MFC Splitter Window I currently have an MFC SDI program that displays data in Open GL.  I am trying to modify the program to display multiple data files at once using splitter windows.  In other words, if there are four splitter windows, each with display a different file.
So far all the examples I have found only display one document in multiple views, but I need to display multiple documents at once.
I am starting to conclude that the problem may be because this is an SDI interface.  I guess I originally thought that since I was using splitter windows that it would support multiple documents at once.
So my first question is, is the SDI interface the problem?  Am I limited to just one file at a time?
If the answer is that I need to use MDI, then can I display the multiple documents in one MDI view using splitters, or do I have to still open multiple MDI windows?
Thank you

A: I think creating multiple MDI-child windows should be very acceptable, as they are fully functional (they can be maximized, closed or tiled). You can also post a Window->Tile command, as soon as your app enters the idle state (yields); they will fully occupy the client area. You can even get deeper and provide some customizations to your CMDIChildWnd-derived class, like disabling closing, moving or resizing, or having a shorter or custom or no title bar (you may need to customize the non-client-area message processing). Also experiment with the WS_EX_TOOLWINDOW extended window style (not sure if this works well with MDI child windows though, and you will have to test it under at least Windows 8/10 and 7).
Another solution could be initially create an MDI app with tabbed views, and customize the window accommodating the tabs so that they are not... actually tabs, just simple non-overlapping child windows (you will have to arrange them on the client area yourself). This may be preferable if the view wnidows are of "fixed" size (either a set size or determined by the document data, eg image size) and should not be resizable (by the user). The MainFrame window should then be customized too, to display scroll-bars if the area required to display all views exceeds its client area. This is a lot of work though, as you will need to modify the window classes so as to provide a functionality MFC was not originally meant to support, and dig deeply into the MFC sources.

A: This is an old question but for those who might want to do the same thing, MFC does support the scenario mentioned. From the Microsoft documentation:
MFC supports three common user interfaces requiring multiple views on the same document. These models are:

*

*View objects of the same class, each in a separate MDI document frame window.

You might want to support creating a second frame window on a document. The user could choose a New Window command to open a second frame with a view of the same document and then use the two frames to view different portions of the document simultaneously. The framework supports the New Window command on the Window menu for MDI applications by duplicating the initial frame window and view attached to the document.

*View objects of the same class in the same document frame window.

Splitter windows split the view space of a single document window into multiple separate views of the document. The framework creates multiple view objects from the same view class. For more information, see Splitter Windows.

*View objects of different classes in a single frame window.

In this model, a variation of the splitter window, multiple views share a single frame window. The views are constructed from different classes, each view providing a different way to view the same document. For example, one view might show a word-processing document in normal mode while the other view shows it in outline mode. A splitter control allows the user to adjust the relative sizes of the views.
Microsoft MFC references
https://learn.microsoft.com/en-us/cpp/mfc/multiple-document-types-views-and-frame-windows?view=msvc-170
https://learn.microsoft.com/en-us/cpp/mfc/multiple-document-types-views-and-frame-windows?view=msvc-170#_core_splitter_windows
MFC samples
https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-samples?view=msvc-170#mfc-samples
MFC splitter sample
https://github.com/microsoft/VCSamples/tree/master/VC2010Samples/MFC/general/viewex


text:
Q: Custom Settings to Fire off Shell Script So, I am working on a "custom settings" app for my android phone, and I am in need of a little help here....
Here's what I'd like to do...
I'd like to be able to set a Preference in the /res/xml/file.xml that on tap fires off a shell script based on some value in the xml
So, say my Preference is:
<ListPreference android:key="dp_cleaner" android:title="My Cleaner" android:entries="@array/dp_cleaner_entries" android:entryValues="@array/dp_cleaner_entries_values" />

And the .smali method to fire off the shell scripts is
.method public static execRootCmdSilent(Ljava/lang/String;)I
# Contains all my code to fire it off...
.end method

Usage
:try_start_0
const-string v2, "THE_COMMAND"
invoke-static {v2}, Lcom/android/settings/ExecSH;->execRootCmdSilent(Ljava/lang/String;)I
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

How could I populate my const-string from the tapped value in the list?  I'm assuming that I would need to findPreference somehow via the key, but I don't know how I can pass the tapped value to the method....
Could it be something as simple as:
.class public Lcom/android/settings/ExecSH;
.super Lcom/android/settings/SettingsPreferenceFragment;
.source "ExecSH.java"

.implements Landroid/preference/Preference$OnPreferenceChangeListener;
.implements Landroid/preference/Preference$OnPreferenceClickListener;

# direct methods
.method public onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z

    :try_start_0
    const-string v2, Landroid/preference/Preference;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    invoke-static {v2}, Lcom/android/settings/ExecSH;->execRootCmdSilent(Ljava/lang/String;)I
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

.end method

.method public static execRootCmdSilent(Ljava/lang/String;)I
#MY CODE
.end method

A: Your class needs to implement the Preference.OnPreferenceChangedListener interface and be set as your ListPreference's change listener. Your listener method will be passed the new value as a parameter, at which point you can pass that in to your execRootCmdSilent method.
The critical smali section is toward the bottom of the below files:
.method public onPreferenceChange(Landroid/preference/Preference;Ljava/lang/Object;)Z

    move-object v2, p2

    // there are some more moves here and a test, which is why we're shuffling registers

    move-object v3, v2

    invoke-virtual {v3}, Ljava/lang/Object;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v3}, Lsarbs/com/tinker/SettingsActivity;->execRootCmdSilent(Ljava/lang/String;)I

Basically, the p2 value is the second parameter being passed to the onPreferenceChange method (newValue). We move that into a local register, and then invoke-virtual the toString method on it. Move the result of that call into the v3 register, and then you can invoke-static your execRootCmdSilent method using that v3 register as the parameter.
The Java code I used to implement this:
package sarbs.com.tinker;

import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;

public class SettingsActivity extends PreferenceActivity implements Preference.OnPreferenceChangeListener {
    ListPreference mListPreference;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        addPreferencesFromResource(R.xml.pref_general);

        mListPreference = (ListPreference) findPreference("dp_cleaner");
        mListPreference.setOnPreferenceChangeListener(this);
    }

    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        if (preference == mListPreference) {
            execRootCmdSilent(newValue.toString());
        }
        return true;
    }

    public static int execRootCmdSilent(String str) {
        return 0;
    }
}

And the smali code it produced:
.class public Lsarbs/com/tinker/SettingsActivity;
.super Landroid/preference/PreferenceActivity;
.source "SettingsActivity.java"

# interfaces
.implements Landroid/preference/Preference$OnPreferenceChangeListener;

# instance fields
.field mListPreference:Landroid/preference/ListPreference;

# direct methods
.method public constructor <init>()V
    .registers 3

    .prologue
    .line 8
    move-object v0, p0

    .local v0, "this":Lsarbs/com/tinker/SettingsActivity;
    move-object v1, v0

    invoke-direct {v1}, Landroid/preference/PreferenceActivity;-><init>()V

    return-void
.end method

.method public static execRootCmdSilent(Ljava/lang/String;)I
    .registers 3

    .prologue
    .line 30
    move-object v0, p0

    .local v0, "str":Ljava/lang/String;
    const/4 v1, 0x0

    move v0, v1

    .end local v0    # "str":Ljava/lang/String;
    return v0
.end method

# virtual methods
.method protected onCreate(Landroid/os/Bundle;)V
    .registers 7

    .prologue
    .line 13
    move-object v0, p0

    .local v0, "this":Lsarbs/com/tinker/SettingsActivity;
    move-object v1, p1

    .local v1, "savedInstanceState":Landroid/os/Bundle;
    move-object v2, v0

    move-object v3, v1

    invoke-super {v2, v3}, Landroid/preference/PreferenceActivity;->onCreate(Landroid/os/Bundle;)V

    .line 15
    move-object v2, v0

    const v3, 0x7f030001

    invoke-virtual {v2, v3}, Lsarbs/com/tinker/SettingsActivity;->addPreferencesFromResource(I)V

    .line 17
    move-object v2, v0

    move-object v3, v0

    const-string v4, "dp_cleaner"

    invoke-virtual {v3, v4}, Lsarbs/com/tinker/SettingsActivity;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v3

    check-cast v3, Landroid/preference/ListPreference;

    iput-object v3, v2, Lsarbs/com/tinker/SettingsActivity;->mListPreference:Landroid/preference/ListPreference;

    .line 18
    move-object v2, v0

    iget-object v2, v2, Lsarbs/com/tinker/SettingsActivity;->mListPreference:Landroid/preference/ListPreference;

    move-object v3, v0

    invoke-virtual {v2, v3}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V

    .line 19
    return-void
.end method

.method public onPreferenceChange(Landroid/preference/Preference;Ljava/lang/Object;)Z
    .registers 8

    .prologue
    .line 23
    move-object v0, p0

    .local v0, "this":Lsarbs/com/tinker/SettingsActivity;
    move-object v1, p1

    .local v1, "preference":Landroid/preference/Preference;
    move-object v2, p2

    .local v2, "newValue":Ljava/lang/Object;
    move-object v3, v1

    move-object v4, v0

    iget-object v4, v4, Lsarbs/com/tinker/SettingsActivity;->mListPreference:Landroid/preference/ListPreference;

    if-ne v3, v4, :cond_12

    .line 24
    move-object v3, v2

    invoke-virtual {v3}, Ljava/lang/Object;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v3}, Lsarbs/com/tinker/SettingsActivity;->execRootCmdSilent(Ljava/lang/String;)I

    move-result v3

    .line 26
    :cond_12
    const/4 v3, 0x1

    move v0, v3

    .end local v0    # "this":Lsarbs/com/tinker/SettingsActivity;
    return v0
.end method


text:
Q: Angular PrimeNG datetimepicker I use component calendar from PrimeNG 5.0.1, Angular 5.1, which allows to choose both date and time:

But timepicker is frozen on time page was reloaded. Is it possible to update time value everytime when picker is shown?
I have not found any parameter is in charge for this.

A: I think you are just missing font awesome included in your app. In order to change hours or minutes their arrows up or down need to be clicked. These arrows are rendered using awesome icons, something like:

  <span [ngStyle]="{'display': currentHour < 10 ? 'inline': 'none'}">0
  {{currentHour}}

(Reference)
Arrows classes: fa fa-angle-up or fa fa-angle-down
This is how it looks without font loaded:

Please note that minutes number is displayed within  HTML element (not <input>), thus it is not editable.
If I load awesome fonts , then it looks like:
Font awesome may be added in your .angular-cli.json file under styles section.
I created a stackblitz: https://stackblitz.com/edit/angular-7bv266?file=app%2Fapp.component.ts.
If missing awesome font is not your case, please update my stackblitz and I will try to help.
UPDATE
In order to permanently set hours and minutes in the time picker we can use defaultDate calendar's input. In my example, I set it to current date and time 10:15, so it always show 10:15 unless changed explicitly.
HTML:

TS:
...
defaultDate = new Date();
...

constructor() {
  this.defaultDate.setHours(10);
  this.defaultDate.setMinutes(15);
}

defaultDate may be set to any desired date.
I updated stackblitz as well.

A: To resolve this problem, I use this code:
import { Calendar } from 'primeng/primeng';
...
@ViewChildren(Calendar) public cals: Calendar[];
...

    ngAfterViewInit() {
        this.cals.forEach(calendar => {
          let elem = calendar.inputfieldViewChild.nativeElement;
          elem.addEventListener('click', () => {
            if (!elem.value) {
              calendar.initTime(new Date());
            }
          });
        });
      }


text:
Q: Meaning of different Orders of Derivative I have been trying to analyse the meaning of higher order derivatives and their geometrical significance.
Given a function $f(x)$ what are the unique geometric interpretation of its higher orders?

*

*$f'(x)$ - slope (rate of change of x w.r.t y)

*$f''(x)$ - convexity / concavity of $f(x)$ based on $sign(f''(x))$

*$f'''(x)$ - increasing / decreasing slope of $f'(x)$

*$f''''(x)$ - ??

*...

*$f^n(x)$ - ??

I apologize if this question is rudimentary.

A: There are many ways to answer this. I think my favorite is this:
The Taylor expansion of a a function $f$ at $a$ is:
$$ f(x) = f(a)  + f^\prime (a)(x-a) + \frac{f^{\prime\prime}(a)}{2}(x-a)^2 + ... +\frac{f^{(n)}(a)}{n!}(x-a)^n+...$$
What you can do with this is take a function $f$ around some point $a$, then eliminate the information you get from the first $n$ derivatives by subtracting the first $n$ terms of the Taylor expansion, and then the lowest nonzero polynomial approximation you can get is, in a sense, the information that the $(n+1)$th  derivative holds.
Let's try to match what you already know to this approach:

*

*$f(a)$ is the most important information when trying to figure our how $f$ behaves around $a$ - it tells you where it's all located, and it's in fact the approximation of $f$ with a polynomial of degree $0$.

*$f^\prime(a)$ is the result of eliminating all information given by $f(a)$ (by subtracting it), and then trying to polynomially approximate the function. So in fact $f^\prime(x)$ is answering the question "What straight line does $f$ most look like around $a$?". If this line is ascending you can say that $f$ is ascending, you can say that the slope of the line can be very naturally thought of as the slope of $f$ at $a$, and so on.

*$f^{\prime\prime}(a)$. Once you get bored comparing $f$ to a straight line, you can eliminate this part too by subtracting $f^\prime(a) (x-a)$ and then the next lowest degree nontrivial polynomial approximation you can get is of degree $2$ - a parabola, and it's coefficient is (proportional to) $f^{\prime\prime}(a)$. And again, if $f^{\prime\prime}(x)>0$, the parabola is "smiling" and the function can be said to be concave, and if $f^{\prime\prime}(x)<0$, the parabola is "frowning" and $f$ can be said to be convex, the higher the coefficient the stronger the concavity / convexity, etc.

*$f^{\prime\prime\prime}(a)$. This is where it gets less intuitive, because you can subtract the previous approximation, but now you have two problems:
First, you already have a lot of information on the function, so how this changes what you know can be harder to visualize.
Second, It's not immediately intuitive what it means to be similar to a certain monomial of degree $3$.
It can, however, be a little clearer when $f^{\prime\prime}(a)=0$. In this case, $f$ is neither concave nor convex at $a$, but if the third derivative is positive, then it should be similar to $x^3$, meaning it's more convex on the left and more concave on the right, and if $f^{\prime\prime\prime}(a)<0$, then it should be similar to $-x^3$, that is, concave on the left and convex on the right. This is generally true, as the third derivative can be looked at as a measure of "how much more concave / convex the function gets passing around $a$", but this can be a little hard to visualize.

*$f^{(n)}(a)$. In the same manner as before, this can be thought of as a measure of what $n$-degree monomial is $f$ most similar to, discarding all information from lower degree polynomial approximations. I think this is hard for us to visualize as a quality for the same reason that it's hard to tell what is the true "qualitative" difference between $x^2$ and $x^4$, maybe because our intuition is naturally built to make do with good approximations, and the value, slope and concavity / convexity of a function at a point already describe a very good approximation for most "everyday" cases.

It can also sometimes be helpful to look at the physical interpretation of the derivatives of motion: $f(x)$ is where you are, $f^\prime(x)$ is your velocity, $f^{\prime\prime}(x)$ is your acceleration, $f^{\prime\prime\prime}(x)$ is the rate in which your acceleration changes (for example, if you're in a car and you're gradually stepping on the gas), etc.
I think this is a really good question, because understanding concepts like this can give very powerful intuition, and I can't say I have any geometric intuition of any higher derivatives, but the coefficients of the Taylor series prevent this from keeping me up at night.


text:
Q: Tkinter resizing frames inside frame In python, I am using the tkinter module in order to create a login screen. It is fully functioning with all the widgets in the correct places, but the only problem being is that when I drag the screen out larger, the widget's sizes don't increase in scale with the size of the main window.
from tkinter import *

root = Tk()

f1 = Frame(root)
f1.grid(row=0, column=0, sticky='news')

enter = Frame(f1)

e1 = Entry(enter,font=('Consolas',15),width=25)
e1.insert(0,'E-mail')
e1.pack(pady=10)

e2 = Entry(enter,font=('',15),show='*',width=25)
e2.insert(0,'E-mail')
e2.pack(pady=20)
enter.grid(row=1,column=0,columnspan=3,padx=20,sticky='nsew')

loginframe = Frame(f1)
loginbutton = Button(loginframe,text='Login!',bg='lightblue',height=2,width=39)
loginbutton.pack()
loginframe.grid(row=2,column=0,columnspan=3,sticky='ew')

account = Frame(f1)
Label(account,text="Don't have an account yet?").pack(side=LEFT)
link = Label(account,text="Sign Up!",cursor='hand2',fg='blue',
               font=('Helvetica',8,'underline'))
link.pack(side=BOTTOM)

account.pack()
account.grid(row=3,column=0,columnspan=3)

root.mainloop()

A: As default columns and rows don't change size but you can use this to change it.
columnconfigure(col_number, weight=1)
rowconfigure(row_number, weight=1)

If you have two rows with different weight then row with bigger weight will resize faster.
I added background color to frames to see which one still doesn't change size.
from tkinter import *

root = Tk()

root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)

f1 = Frame(root, bg='red')
f1.grid(row=0, column=0, sticky='news')

f1.columnconfigure(0 , weight=1)
f1.rowconfigure(1, weight=1)
#f1.rowconfigure(2, weight=1)

enter = Frame(f1, bg='green')
enter.grid(row=1, column=0,columnspan=3,padx=20, sticky='nsew')

loginframe = Frame(f1)
loginframe.grid(row=2,column=0,columnspan=3, sticky='ew')

e1 = Entry(enter,font=('Consolas',15),width=25)
e1.insert(0,'E-mail')
e1.pack(pady=10)

e2 = Entry(enter,font=('',15),show='*',width=25)
e2.insert(0,'E-mail')
e2.pack(pady=20)

loginbutton = Button(loginframe,text='Login!',bg='lightblue',height=2,width=39)
loginbutton.pack()

account = Frame(f1)
account.grid(row=3,column=0,columnspan=3)

Label(account,text="Don't have an account yet?").pack(side=LEFT)
link = Label(account,text="Sign Up!",cursor='hand2',fg='blue',
               font=('Helvetica',8,'underline'))
link.pack(side=BOTTOM)

root.mainloop()

Before resize:

After resize with columnconfigure and rowconfigure
:

Without columnconfigure and rowconfigure


text:
Q: is 'do we actually know where we are going any more' a question? I'm confused as to if

do we actually know where we are going any more

is a question or not, because of the 'do' I think yes but when read it seems like a sentence.

A: Apart from the gut reaction "yes, it is a question because, um, it just is", we can actually approach this systematically. The sentence exhibits three characteristics that are of interest to us:

*

*It says "do... know" rather than just "know",

*it says "do we" rather than "we do",

*and last but not least, it begins with a verb.

Each of these by itself can occur in a number of different scenarios:

*

*"Do... know" could be an emphatic do ("I do like this"), or it could be an auxilliary do (do-support), and the latter could indicate a question ("Do we know?") or a negation ("We do not know").

*"Do we" (subject–auxiliary inversion) could indicate a question ("Do we know?"), or negative polarity when there's a fronted adverbial that is a negative trigger ("Never/seldom/under no circumstances do we know").

*A verb at the beginning could indicate a question ("Do we know?") or an imperative ("Do this now!") or a simple ellipsis ("I like whistling. Do it all the time.")

As you can see for yourself, the only scenario in which all three meet is a question.

A: Yes, it's a question. It begins with a word that can either be a question or an imperative/command, but the context of the statement, there is no action to take: "Do this task." versus "Do we do this task?"


text:
Q: Joining data points with straight lines (MatLab) I have a pretty simple MatLab code her that perfectly well plots 6 datapoints. The x coordinates from the dt list; the y coordinates from the TempTable table in row 7. It all works fine, I just need to join the points with a straight line.
% Plotting T_new(7) vs. dt
dt=[0.001,0.005,0.01,0.05,0.1,0.25]    % The time steps
y=[300,320,330,340,345,350]

for i=1:1:6     % Looping through all temperature profiles
    hold all;
    plot( dt(i), y(i), 'b*-', 'LineWidth', 1);
    title(['Temperatures at nodal point 7']);
    xlabel( 'dt [s]' );
    ylabel( 'T [\circC]' );
    set( gca, 'LineWidth', 1 );
    axis( [ dt(2)-0.1, dt(6)+0.1, 300, 350 ] );
    pause( 0.1 );     % Animation step time
end

Shouldn't the dash - in b*- add these joining lines, or what? What is missing here, since they don't?

A: Your loop is your problem. With only one point plotted per iteration, it is impossible for Matlab to know what points to connect. So if you want to use a loop, you'll have to connect the points manually with another plot-statement.
A solution without a loop could be:
hold all;
plot( dt, TempTable(7,:), 'b*-', 'LineWidth', 1);
title(['Temperatures at nodal point 7']);
xlabel( 'dt [s]' );
ylabel( 'T [\circC]' );
set( gca, 'LineWidth', 1 );
axis( [ dt(2)-0.1, dt(6)+0.1, 300, 350 ] );
pause( 0.1 );     % Animation step time


text:
Q: Plot months of multiple years I have the following data frame:
        Cold      Date
1       Yes       "21/10/2018 22:00"
2       No        "05/10/2019 15:32"
3       Yes       "07/12/2020 21:20"
4       No        "31/08/2019 03:45"
5       No        "08/12/2020 11:12"

I would like to plot to see how many occurrences (counts) there are for each month. This means the months should be on the X-as. However, as you can see, the column "Date" is formatted as a string. Also, the timestamp is included.
Furthermore, there are multiple years included in the column. I think it's best to arrange multiple plots at the same time to get a nice overview of what is happening for each month in each year. Do you guys have an idea how I could tackle this problem? I have no idea where to begin.

A: Are you looking for this:
library(dplyr)
library(ggplot2)
library(lubridate)
df %>% mutate(Date = dmy_hm(Date)) %>% count(Month = month(Date)) %>%
       ggplot(aes(Month, n)) + geom_col()

Data used:
df
  Cold             Date
1  Yes 21/10/2018 22:00
2   No 05/10/2019 15:32
3  Yes 07/12/2020 21:20
4   No 31/08/2019 03:45
5   No 08/12/2020 11:12

A: Here is a base R option -
val <- format(sort(as.POSIXct(df$Date, format = '%d/%m/%Y %H:%M',tz = 'UTC')), '%b-%Y')
barplot(table(factor(val, unique(val))))


text:
Q: Getting rid of order status within the WooCommerce My Account - Orders Page I'd like to hide the Status columns within My Accounts - Orders (where it shows processing, refunded, etc...).
Does anyone know how I can do that?
Here is a screenshot showing the account status column:

Thanks.
Here is the code that's currently in my file (my-orders.php)
<?php
/**
 * My Orders
 *
 * Shows recent orders on the account page.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/myaccount/my-orders.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
 * will need to copy the new files to your theme to maintain compatibility. We try to do this.
 * as little as possible, but it does happen. When this occurs the version of the template file will.
 * be bumped and the readme will list any important changes.
 *
 * @see     http://docs.woothemes.com/document/template-structure/
 * @author  WooThemes
 * @package WooCommerce/Templates
 * @version 2.5.0
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

$my_orders_columns = apply_filters( 'woocommerce_my_account_my_orders_columns', array(
    'order-number'  => __( 'Order', 'woocommerce' ),
    'order-date'    => __( 'Date', 'woocommerce' ),
    'order-status'  => __( 'Status', 'woocommerce' ),
    'order-total'   => __( 'Total', 'woocommerce' ),
    'order-actions' => ' ',
) );

$customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array(
    'numberposts' => $order_count,
    'meta_key'    => '_customer_user',
    'meta_value'  => get_current_user_id(),
    'post_type'   => wc_get_order_types( 'view-orders' ),
    'post_status' => array_keys( wc_get_order_statuses() )
) ) );

/**
 * This is the entire "Recent Orders" section below my subscriptions. It has been commented out
 *
if ( $customer_orders ) : ?>

<?php echo apply_filters( 'woocommerce_my_account_my_orders_title', __( 'Recent Orders', 'woocommerce' ) ); ?>

                <?php foreach ( $my_orders_columns as $column_id => $column_name ) : ?>
                    <th class="<?php echo esc_attr( $column_id ); ?>"><?php echo esc_html( $column_name ); ?>
                <?php endforeach; ?>

            <?php foreach ( $customer_orders as $customer_order ) :
                $order      = wc_get_order( $customer_order );
                $item_count = $order->get_item_count();
                ?>

                    <?php foreach ( $my_orders_columns as $column_id => $column_name ) : ?>
                        <td class="<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
                            <?php if ( has_action( 'woocommerce_my_account_my_orders_column_' . $column_id ) ) : ?>
                                <?php do_action( 'woocommerce_my_account_my_orders_column_' . $column_id, $order ); ?>

                            <?php elseif ( 'order-number' === $column_id ) : ?>
                                <a href="<?php echo esc_url( $order->get_view_order_url() ); ?>">
                                    <?php echo _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number(); ?>

                            <?php elseif ( 'order-date' === $column_id ) : ?>
                                <time datetime="<?php echo date( 'Y-m-d', strtotime( $order->order_date ) ); ?>" title="<?php echo esc_attr( strtotime( $order->order_date ) ); ?>"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></time>

                            <?php elseif ( 'order-status' === $column_id ) : ?>
                                <?php echo wc_get_order_status_name( $order->get_status() ); ?>

                            <?php elseif ( 'order-total' === $column_id ) : ?>
                                <?php echo sprintf( _n( '%s for %s item', '%s for %s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ); ?>

                            <?php elseif ( 'order-actions' === $column_id ) : ?>
                                <?php
                                    $actions = array(
                                        'pay'    => array(
                                            'url'  => $order->get_checkout_payment_url(),
                                            'name' => __( 'Pay', 'woocommerce' )
                                        ),
                                        'view'   => array(
                                            'url'  => $order->get_view_order_url(),
                                            'name' => __( 'View', 'woocommerce' )
                                        ),
                                        'cancel' => array(
                                            'url'  => $order->get_cancel_order_url( wc_get_page_permalink( 'myaccount' ) ),
                                            'name' => __( 'Cancel', 'woocommerce' )
                                        )
                                    );

                                    if ( ! $order->needs_payment() ) {
                                        unset( $actions['pay'] );
                                    }

                                    if ( ! in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) {
                                        unset( $actions['cancel'] );
                                    }

                                    if ( $actions = apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order ) ) {
                                        foreach ( $actions as $key => $action ) {
                                            echo '' . esc_html( $action['name'] ) . '';
                                        }
                                    }
                                ?>
                            <?php endif; ?>

                    <?php endforeach; ?>

            <?php endforeach; ?>

<?php endif; ?>

**/

A: You need to override myaccount/orders.php WooCommerce via your active theme.
For that, if not done, you will need to copy from woocommerce plugin folder, a subfolder named templates to your active child theme (or theme) and to rename it woocommerce (see this related docs).
After that you find inside that new woocommerce folder in myaccount subfolder a template named orders.php.
Open/edit orders.php template and replace the code by this:
<?php
/**
 * Orders
 *
 * Shows orders on the account page.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/myaccount/orders.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see     https://docs.woocommerce.com/document/template-structure/
 * @author  WooThemes
 * @package WooCommerce/Templates
 * @version 2.6.0
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

do_action( 'woocommerce_before_account_orders', $has_orders ); ?>

<?php if ( $has_orders ) : ?>

                <?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) :
                    if( $column_name != 'Status' ){ // added this line
                ?>
                    <th class="<?php echo esc_attr( $column_id ); ?>"><?php echo esc_html( $column_name ); ?>
                <?php
                    } // and this too
                endforeach; ?>

            <?php foreach ( $customer_orders->orders as $customer_order ) :
                $order      = wc_get_order( $customer_order );
                $item_count = $order->get_item_count();
                ?>

                    <?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) :
                        if( $column_name != 'Status' ){ // added this line
                    ?>
                        <td class="<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
                            <?php if ( has_action( 'woocommerce_my_account_my_orders_column_' . $column_id ) ) : ?>
                                <?php do_action( 'woocommerce_my_account_my_orders_column_' . $column_id, $order ); ?>

                            <?php elseif ( 'order-number' === $column_id ) : ?>
                                <a href="<?php echo esc_url( $order->get_view_order_url() ); ?>">
                                    <?php echo _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number(); ?>

                            <?php elseif ( 'order-date' === $column_id ) : ?>
                                <time datetime="<?php echo date( 'Y-m-d', strtotime( $order->order_date ) ); ?>" title="<?php echo esc_attr( strtotime( $order->order_date ) ); ?>"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></time>

                            <?php elseif ( 'order-status' === $column_id ) : ?>
                                <?php echo wc_get_order_status_name( $order->get_status() ); ?>

                            <?php elseif ( 'order-total' === $column_id ) : ?>
                                <?php echo sprintf( _n( '%s for %s item', '%s for %s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ); ?>

                            <?php elseif ( 'order-actions' === $column_id ) : ?>
                                <?php
                                    $actions = array(
                                        'pay'    => array(
                                            'url'  => $order->get_checkout_payment_url(),
                                            'name' => __( 'Pay', 'woocommerce' )
                                        ),
                                        'view'   => array(
                                            'url'  => $order->get_view_order_url(),
                                            'name' => __( 'View', 'woocommerce' )
                                        ),
                                        'cancel' => array(
                                            'url'  => $order->get_cancel_order_url( wc_get_page_permalink( 'myaccount' ) ),
                                            'name' => __( 'Cancel', 'woocommerce' )
                                        )
                                    );

                                    if ( ! $order->needs_payment() ) {
                                        unset( $actions['pay'] );
                                    }

                                    if ( ! in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) {
                                        unset( $actions['cancel'] );
                                    }

                                    if ( $actions = apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order ) ) {
                                        foreach ( $actions as $key => $action ) {
                                            echo '' . esc_html( $action['name'] ) . '';
                                        }
                                    }
                                ?>
                            <?php endif; ?>

                    <?php
                        } // added this too
                    endforeach; ?>

            <?php endforeach; ?>

    <?php do_action( 'woocommerce_before_account_orders_pagination' ); ?>

    <?php if ( 1 < $customer_orders->max_num_pages ) : ?>

            <?php if ( 1 !== $current_page ) : ?>
                <a class="woocommerce-Button woocommerce-Button--previous button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page - 1 ) ); ?>"><?php _e( 'Previous', 'woocommerce' ); ?>
            <?php endif; ?>

            <?php if ( $current_page !== intval( $customer_orders->max_num_pages ) ) : ?>
                <a class="woocommerce-Button woocommerce-Button--next button" href="<?php echo esc_url( wc_get_endpoint_url( 'orders', $current_page + 1 ) ); ?>"><?php _e( 'Next', 'woocommerce' ); ?>
            <?php endif; ?>

    <?php endif; ?>

<?php else : ?>

        <a class="woocommerce-Button button" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
            <?php _e( 'Go Shop', 'woocommerce' ) ?>

        <?php _e( 'No order has been made yet.', 'woocommerce' ); ?>

<?php endif; ?>

<?php do_action( 'woocommerce_after_account_orders', $has_orders ); ?>

Save, you are done. This code is tested and working.

Update: for prior versions of woocommerce 2.5.x, the template file is named my-orders.php and you have just to comment one line in template code:
    // 'order-status'  => __( 'Status', 'woocommerce' ),

Here is an extract of this template with the commented line in the code:
<?php
/**
 * My Orders
 *
 * Shows recent orders on the account page.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/myaccount/my-orders.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
 * will need to copy the new files to your theme to maintain compatibility. We try to do this.
 * as little as possible, but it does happen. When this occurs the version of the template file will.
 * be bumped and the readme will list any important changes.
 *
 * @see     http://docs.woothemes.com/document/template-structure/
 * @author  WooThemes
 * @package WooCommerce/Templates
 * @version 2.5.0
 */
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}
$my_orders_columns = apply_filters( 'woocommerce_my_account_my_orders_columns', array(
    'order-number'  => __( 'Order', 'woocommerce' ),
    'order-date'    => __( 'Date', 'woocommerce' ),
    // 'order-status'  => __( 'Status', 'woocommerce' ),
    'order-total'   => __( 'Total', 'woocommerce' ),
    'order-actions' => ' ',
) );

Reference: Template Structure + Overriding Templates via a Theme

A: The easiest approach would probably be just to hide that column via CSS -- If that column has a unique ID or the TD's have a class you could target with display:none, that'd probably take care of what you'd need.
Alternatively, you could probably also hide it by hooking into the woocommerce_my_account_my_orders_columns filter.
Something like this (untested)
add_filter('woocommerce_my_account_my_orders_columns', 'my_custom_function_name', 10);

function my_custom_function_name($order){
  unset($order['order-status']);
  return $order;
}

I'm sure that exact code won't work, but I'll bet it gets you pretty close.


text:
Q: Confusion about z-test and chi square test on a very basic example I am confused with the difference between z-test and chi square test.
In book Agresti 2007 An introduction to categorical data analysis, page 9, the author had an example of testing

Do a majority or minority of adults in US believe that a pregnant woman should be able to obtain an abortion.

The data is 400 "yes" and 493 "no" in a "yes or no" survey question. And want to test if $\pi=0.5$, where observed/empirical ratio $p=0.448$
The author uses a z-test, where
$z=(0.448-0.5)/\sqrt{0.5*0.5/893}=-3.1$
But should we use chi-square goodness of fit test where we comparing observed with theoretical distribution ($\pi=0.5$)? It seems they are the same in this case. Why?


text:
Q: Disable STS (Eclipse) 'Method stub' suggestion The question is about Eclipse configuration (in fact I use STS but it's pretty much the same). Every time when I'm declaring some field in class Eclipse suggests me Method stub as the first position and only then the needed class, e.g. if I want to create EntityManager field it first suggests Enti():void - method stub and only then EntityManager which I need:

I never use this method stub (leaving alone that it doesn't make much sense to suggest method names started from the capital letter) so I'd really like to disable it but I've played a lot with different types of settings and still can't find it. Does anybody know whether it is possible at all?
Thanks in advance.


text:
Q: A question of topology. If S is a subset of $\hspace{0.1cm}$$[0,1]\times[0,1]$$\hspace{0.1cm}$ such taht one point of the ordered pair is rational and the other is irrational or both are irrationals,then which of the following is true?
$1$.S is closed.
$2$.S is open.
$3$.S is compact.
$4$.S is connected.
$5$.S is totally disconnected.
My Try:I think 5 is true.
{$(\frac{1}{3}+\frac{1}{\sqrt{2}n},\frac{1}{2}+\frac{1}{\sqrt{3}n})$} is a sequence in S which converges to $(\frac{1}{3},\frac{1}{2})$ which is not in S.Therefore S is not closed.Also because of this S is not compact.
Since the ordered pairs (x,y) with both x,y rational are not in S so should be totally disconnected.Also it is not open  because S contains boundary points.If i am wrong please correct me.Thanks in advance.

A: Your are right on 1., 2., 3. But 4. is true. Let $x,y \in S$. Consider a line $L \subseteq [0,1]^2$ which contains neither $x$ nor $y$. For each poinz $z \in L$ there is a path $\gamma_z$ connecting $x$ and $y$ consisting of the straight segments $[x,z]$ and $[z,y]$. Now $\gamma_z \cap \gamma_{z'} = \{x,y\}$ for $x\ne y$ and $\{\gamma_z \mid z \in L\}$ is uncountable, and $([0,1]\cap \mathbb Q)^2$ is countable. Hence there is a $\gamma_z$ not intersecting $([0,1]\cap \mathbb Q)^2$. So $S$ is pathwise connected and hence connected.


text:
Q: Android Cannot resolve symbol '?attr/selectableItemBackground' <android.support.v7.widget.CardView
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/card_outer_padding"
    android:layout_marginTop="@dimen/card_outer_padding"
    android:layout_marginRight="@dimen/card_outer_padding"
    android:layout_marginBottom='@{model.cardBottomMargin}'
    android:foreground="?attr/selectableItemBackground"
    android:onClick="@{model::onCardClick}"
    app:cardElevation="2dp"
    app:cardCornerRadius="2dp"
    app:cardUseCompatPadding="true">
</android.support.v7.widget.CardView>

I got this error message
Cannot resolve symbol ?attr/selectableItemBackground
Validates resource references inside Android XML files.
<TextView
    android:id="@+id/country_name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginRight="40dp"
    android:text="@{model.name}"
    style="@style/TextAppearance.AppCompat.Headline"
    tools:text="Country"/>

And, I got a similar error for the above as well
Cannot resolve symbol '@style/TextAppearance.AppCompat.Headline'
Validates resource references inside Android XML files.
Any pointer would be great! Thank you!
It seems to be related to this thread but no solution was provided:

A: 2 options:
Option 1

Another possible reason is: Google's maven repository is not set for
  the build script.
Open your project's main build.gradle add this line:
buildscript {
    repositories {
        google()  <-- this
        // Be also sure that google() is before jcenter()
    }
}

Without this, it may not be able to download the Android Studio Gradle
  plugin 3.0+. It's not distributed in jCenter but in the Google's maven
  repository.

Option 2
Run this command in root of project and resync project
Linux:
rm .idea/libraries/Gradle__com_android_support_*.xml
Windows:
del .idea\libraries\Gradle__com_android_support_*.xml

A: For version Lollipop and higher use this:
android:foreground="?android:attr/selectableItemBackground"

for Pre-Lollipop use this:
android:foreground="?attr/selectableItemBackground"

A: I faced with same error after updating Kotlin. Solved with "Invalidate caches/Restart"

UPDATE
Today this solution did not helped me. But the solution of this question did: Android Studio 3.1 Cannot Resolve Symbol (Themes, Widget, attr, etc.)

A: Both resources are defined with the Android Support Library and since these symbols cannot be resolved, it seems like you're missing to define the support dependency.
dependencies {
    compile "com.android.support:appcompat-v7:$androidSupportVersion"
}

A: I believe this is a communication problem with the IDE and Android Gradle Plugin. In any case, the only way I've reliably found to resolve this is to delete the problematic libs in the .idea/libraries/ folder.
So, for you, since the lint checks aren't recognizing ?attr/selectableItemBackground

*

*LOCATE the Gradle__com_android_support_xxx.xml files

*DELETE those files

*SYNC IDE with file system

*SYNC project with Gradle files

*REBUILD your project

You can sync by clicking on 'File' at the top by the toolbar and selecting "Sync with File System" and then afterwards selecting "Sync project with gradle files".
I've tried other suggested solutions - had the appcompat-v7 dependency in my module build.gradle file & the google() repository as the first line in the project build.gradle dependencies. Nada.
These solutions also haven't helped...

*

*Invalidating the caches/restarting didn't work.

*Cleaning/Rebuilding the project.

A: I have solved by,

*

*Deleting the .idea folder in project explorer.

*Invalidate Caches/Restart

*Refresh Project Gradle

A: In my case help adding maven to build.gradle Project in buildscripts.repositories AND allprojects.repositories. It looks like this:
google()
maven { url 'https://maven.google.com' }
jcenter()

A: This is what solved to me:

*

*Close Android Studio

*Delete .idea directory in the root project directory

*Reimport the project

A: I updated my gradle version to 4.10.1 and fix and reimport repaired it. There were no libraries folder under .idea before.

A: If you use applicationContext for LayoutInflater, then replace it to normal context. It works for me.


text:
Q: Novice WordPress Installation issues I am trying to install WordPress on www.000webhost.com
I have uploaded the most recent version of WordPress to the server and created a MySQL database. However, When I visit my site, I select the WordPress folder and it gives two error messages:

Warning: require_once(/home/username/public_html/wordpress//wp-includes/class-wp-error.php) [function.require-once]: failed to open stream: No such file or directory in /home/a5558093/public_html/wordpress/wp-load.php on line 48
Fatal error: require_once() [function.require]: Failed opening required '/home/username/public_html/wordpress//wp-includes/class-wp-error.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username/public_html/wordpress/wp-load.php on line 48

What do these mean? How can I solve these issues?

A: After reading this, I realized that the problem was that I needed to take the contents out of the "wordpress" folder, paste them in parallel to the "wordpress" folder, and delete the "wordpress" folder. Everything works fine now. Thankyou all.

A: I'll guess it has something to do with that extra / in the path wordpress//wp-includes, though I'm not sure why that's happening. Possibly an issue with how it's defining the ABSPATH setting in wp-load.php

A: This happens in a branch of code that is triggered when config files is missing on load, but if you had no chance to go through installation dialog yet that would be accurate...
Can yo verify that file it references is present and its content is sane? Maybe your upload got broken or cut short.


text:
Q: Embed SSRS Subreport into Main Report Is it possible to Embded a subreport into the main SSRS report, such that when i execute the main report subreport also gets loaded and executed (Local Reports).
In my application RDLs are stored in the database and when executed, RDL is fetched from Database and loaded in SSRS Report Viewer Locally. This concept will not work if i have sub reports.
I can load the Subreports in the database and link those to the main report, but was looking if i can just simply embed the report in the Main Report.

A: I think this is possible BUT you need to give the reportviewer the subreports definition and the necessary datasources.
ReportViewer.LocalReport.LoadSubreportDefinition(def);

And then somehow assign datasources, I haven't done this before but I hope that might point you in the right direction.

A: We can publish report parts, then assemble the various parts into a report. Report parts can be called by multiple reports. This is different than drilling down in to sub-reports.  Drill down is much easier, but does not serve your purpose.  See the article below, it is very helpful.
http://www.bidn.com/blogs/PatrickLeBlanc/ssis/671/sql-server-reporting-services-r2-publishing-report-parts


text:
Q: CSS centered tiles (adjustable width) I would like to create a page containing an arbitrary number of tiles of a fixed size where the number of tiles in each row will adjust according to the width of the window. I have created this functionality here.
However, I want these tiles to be centered within the gray box. I tried creating the intermediary #tile-box, which I was thinking I could center and make variable width to match the tiles inside of it, but I couldn't get that to work at all.
Any suggestions on how to get the tiles centered in the gray div?

A: well i only do this in your code
#tile-box {
    border: 1px solid blue;
    display: table;
    text-align:center; //i only added this line to your css
}

you can do this for centering your text, there are many ways that you can present your body in your html, i hope i helped you...

A: you were most of the the way there but you don't really need display:table..
JSfiddle Demo
CSS
#body {
    width: 50em;
    max-width: calc(100% - 5em);
    margin: auto;
    padding: 2em;
    margin-bottom: 2em;
    background-color: #ccc;
    overflow: auto;
}

#tile-box {
    border: 1px solid blue;
    text-align: center;
}

.tile {
    width: 5em;
    height: 5em;
    background-color: #fff;
    margin: 1em;
    padding: 0;
    display: inline-block;
    clear: left;
    vertical-align: top;
    position: relative;
    overflow: hidden;
}

A: Centering horizontal : text-align: center;
Centerign vertical : line-height: 12em;/* Height of the container less the font-size */
Result online here : http://jsfiddle.net/LHDJj/17/


text:
Q: How do I make a batch file run strings as commands? I want to make a batch file to circumvent some cmd problems on my computer, but for that I need to be able to take String user input and run it as a command.
Basically what I want to be able to do is type in a command when the batch file asks for input, and have the computer run that command, similar to python's os module (class?)

A: Use the set /p command to prompt for input. This command also displays a message. Example:
@echo off
set "command=dir"
set /p "command=type in a command: "
echo.command is: %command%
echo.press any key or ^<CTRL+C^> to abort . . .
>nul pause
%command%

A: Simply assign the string to a variable, then "execute" the variable as though it was a program
eg
set  myvar=ECHO Hello, World!
%myvar%

A: At its simplest, you want to use set /p to prompt for the command, setting an environment variable to the result, then simply expand the environment variable by itself and the OS will attempt to execute it as a command.
SET /P COMMAND=Command:
%COMMAND%

A: You can use the batch for loop, this works for me in the command prompt, but not the power shell:
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Administrator>FOR /F "delims=" %i IN ('python -c "print('set wow=yep')"') DO set toexec=%i

C:\Users\Administrator>set toexec=set wow=yep

C:\Users\Administrator>%toexec%

C:\Users\Administrator>echo %wow%
yep


text:
Q: Unity procedural generation spawning overlapping objects issues I have 2 scripts
one that check if an area is free
one that spawn an object if the area is free
this is to prevent overlapping
checker script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpaceCheck : MonoBehaviour
{
    public bool isFree = true;
    public GameObject RoomParent;

    void OnCollisionEnter(Collision col)
    {
        isFree = false;
    }

    void Start()
    {
        if(isFree == true)
        {
            RoomParent.SetActive(true);
        }
    }

    void Update()
    {

    }
}

spawner script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RoomSpawner : MonoBehaviour
{

    public List<Transform> Spawners;
    public List<GameObject> Rooms;
    int choosenSpawner = 0;
    public GameObject SpaceCheck;

    void Start()
    {
        choosenSpawner = Random.Range(0, Spawners.Count);
        GameObject manager = GameObject.Find("RoomsManager");
        RoomsManager managerProperty = manager.GetComponent<RoomsManager>();

        GameObject Space = SpaceCheck;
        SpaceCheck spaceProperty = Space.GetComponent<SpaceCheck>();

        if (managerProperty.maxRoom > managerProperty.RoomCount && spaceProperty.isFree == true)
        {
            Instantiate(Rooms[Random.Range(0, Rooms.Count)], Spawners[choosenSpawner].position, Spawners[choosenSpawner].rotation);
            RoomsManager.instance.AddRoomCount();
        }

    }
    void Update()
    {

    }
}

Problem is that they still overlaps
here is the video of the problem: https://www.youtube.com/watch?v=mUjMUSNhDcQ

A: This question is really vague, but here is an answer that assumes derHugo is correct, and you are asking how to pick random positions without duplicates:
You are storing your rooms inside a list, so all you have to do is check to see if the newly generated position is the same as any of the existing game objects in the list.
So first generate random floats in a new vector x, y, and z, and then check if that position is in the list of previously generated positions. If the list does not contain a gameobject with that position, then its unique, use it and add it to the list. If it isn't unique, throw it out and generate a new one until it is unique.
You'll want to check that the newly generated position is far enough away from the previously existing ones that they don't overlap, taking the size of the object into consideration.


text:
Q: How to use "--bind-address=ip_address" with ansible mysql_user module I have multiple interfaces in my application nodes, how to tell ansible mysql_user module to bind the connection on user specified (eth0/eth1... OR ip address ?)interface ?

A: Should be:
- name: Create user
  community.mysql.mysql_user:
    name: "your-user"
    host: "ip-goes-here"
    state: present


text:
Q: Unhandled exception - c++ program stops on cast I have several structs:
struct Token
{
 //some content
}

Then follows a bunch of structs that inherit from Token:
struct A : public Token{
 //Stuff
}

.
.
.
struct Z : public Token{
 //Other stuff
}

I have a vector std::vector filled with subclasses A through Z and my program crashes when I try to cast any element in the the vector to the subclass. I'm casting by doing the following:
A subclass = *((A * ) &vector[0]);

What am i doing wrong?

A: A meaningful usage would be
A &subclassref = vector[0]);

In above line, no new object is created.
BTW what is the type of your vector and what exactly do you want to achieve? If you store objects of type A to Z in a single vector, it may at some point of time suffer object slicing.

A: You should use dynamic_cast when casting pointers from one type to another in your use case.
The one you are using is a C style cast and I strongly suggest you to go with a dynamic_cast.
So your code should look something like:
if(dynamic_cast<A *>(vector[0]))
    A subclass = *(dynamic_cast<A *>(vector[0]));

When a dynamic_cast fails it will return a NULL pointer and you should take care of it appropriately.
Refer dynamic_cast and static_cast in C++ for more information.
Additionally When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used? will help you understand a lot more types of casts.

A: This answer may be wrong because I'm making a guess as to how you have filled the std::vector<>.
You simply cannot put objects of subclasses into an std::vector<Base>. All objects in an std::vector<Base> are precisely of type Base. If you try something like this:
std::vector<Base> myVec;
myVec.push_back(Derived1(...));

you first construct an object of class Derived1 which is subsequently spliced into an object of class Base, i. e. a new object of class Base is copy-constructed from the derived object. Only this copy constructed base class object ends up in the std::vector<>.
If you want to have an std::vector<> of polymorphic objects, you must use a pointer type as the template argument (and consequently allocate the contained objects with new).


text:
Q: Install specific version of apt package for specific ubuntu version I want to install package foo version 1234 in a docker container. I prefer this to the latest version, as it will always work the same way.
So my Dockerfile has this:
RUN apt-get update && apt-get install -y foo=1234

But the base image is mongodb:4.0.2, which is layered on Ubuntu xenial.
When I build the image, the apt install fails because it cannot find that version. I think xenial doesn't support that version.
So how do I find the latest supported version of a package foo on xenial? If I run apt policy foo it shows me the latest for the ubuntu I'm using (bionic), not for xenial.

A: If the package at stake is, say, rlwrap, you could just take a look at the webpage https://packages.ubuntu.com/xenial/rlwrap
But if you want a proper way to get this version info programatically, you can rely on the Launchpad API, which comes with an official API client implemented as a Python library.
Otherwise, you can directly query the API with tools such as curl and jq (to parse the retrieved JSON data):
$ curl -fsSL "https://api.launchpad.net/1.0/ubuntu/+archive/primary?ws.op=getPublishedSources&source_name=rlwrap&exact_match=true&distro_series=https://api.launchpad.net/1.0/ubuntu/xenial" \
  | jq --raw-output ".entries | .[0] | .source_package_version"

→ 0.41-1build1

As mentioned in this Askubuntu question, a similar API exists for Debian as well.


text:
Q: Are nested catches within promises required if then is used? I think I got the idea of Promise, then and catch as well as nesting promises as shown in Are nested catches within promises required?. However, if I'm nesting promises and want to avoid inner catchs by returning the inner promise, then I'm having trouble to get the following not to crash because of the Error thrown in promise2:
function promise1(): Promise<string> {
  return new Promise(function(resolve, reject) {
    return promise2().then(promise2Result => {
      if(promise2Result !== "") {
        resolve("The value is "+promise2Result);
      }else {
        reject(new Error("promise2.then error"));
      }
    })
  });
}

function promise2(): Promise<string> {
  return new Promise(function(resolve, reject) {
    throw new Error("promise2 error");
  });
}

Chrome shows me an Unhandled Rejection (Error): promise2 error of the yarn development server started with yarn run start. It points to the Error thrown in promise2. Firefox debugger jumps to a random line outside of my code and displays nothing.
If I add a catch after promise2().then(...) the Error is caught.
How can I avoid the inner catch? And catch the Error from promise2 e.g. in a catch in
promise1()
  .then(value => alert(value))
  .catch(err => alert("err: "+err));

Wrapping every function body in a try-catch block is not an option as an inner .catch(...) is already more elegant.
The throwing of Error is a minimal example, of course, assume it occurs by accident and that the promise returned by promise2 is expected to do something useful and has a bug.
I'm looking for a principle which allows deeper nesting, e.g. with a promise2 which returns a promise3 which then accidentally might throw an error like promise2 does now.

A: Your promise2 already returns a Promise, so there's no need for explicit construction of a Promise again. Instead, just chain off of the promise2, and if the value it resolves to is not OK, throw an error instead of calling reject. (Similarly, instead of calling resolve, return the expression you want the outer Promise to resolve to)

function promise1() {
  return promise2().then(promise2Result => {
      if (promise2Result !== "") {
        return "The value is " + promise2Result;
      } else {
        throw new Error("promise2.then error");
      }
    })
}

function promise2() {
  return new Promise(function(resolve, reject) {
    throw new Error("promise2 error");
  });
}

promise1()
  .catch(e => console.log(e.message));


text:
Q: Rabin fingerprinting tables I've been researching rabin fingerprinting for the past couple of days. While the general idea is simple enough I'm having significant troubles understanding the implementations that are circulating around the net. In particular all of them seem to be derived from the original LBFS paper, namely from librabinpoly the sliding window is defined as:
33 static u_int64_t slide8(RabinPoly *rp, unsigned char m) {
   34         rp->circbuf_pos++;
   35         if (rp->circbuf_pos >= rp->window_size) {
   36                 rp->circbuf_pos = 0;
   37         }
   38         unsigned char om = rp->circbuf[rp->circbuf_pos];
   39         rp->circbuf[rp->circbuf_pos] = m;
   40         return rp->fingerprint = append8 (rp, rp->fingerprint ^ rp->U[om], m);
   41 }
   42
   43 static u_int64_t append8(RabinPoly *rp, u_int64_t p, unsigned char m) {
   44         return ((p << 8) | m) ^ rp->T[p >> rp->shift];
   45 }

Where the U/T tables are generated from the initial polynomial. I haven't seen in any of the papers pertaining to rabin fingerprinting to discuss the usage of those 2 tables and the XOR operations. My gut feeling is this has something to do with the modulo arithmetics but I'm not entirely sure. Git's source code also uses rabin fingerprinting but instead of deriving the tables dynamically they have a set of pre-computed ones. So my question is - what exactly do those Xor operations achieve and the code generally looks fairly different than the 'canonical' explanation of the algorithm

A: The "canonical explanation" uses the rolling hash that is not a Rabin fingerprint. It's pretty similar, though. Without getting too deep into the weeds of abstract algebra, the idea behind both is to evaluate a polynomial derived from the message in a particular ring, which has 0, 1, addition, subtraction, multiplication but not division (integers mod m for the canonical explanation; GF(2k) for Rabin fingerprints, which is to say, polynomials with coefficients mod 2, modulo an irreducible polynomial of degree k).
The simplest ring is the integers mod 2, which has 0, 1 and defines
+  0 1        -  0 1        *  0 1
------        ------        ------
0  0 1        0  0 1        0  0 0
1  1 0        1  1 0        0  0 1  .

A very interesting thing happens: plus and minus have the same definition, and both are equivalent to XOR. Using a computer word to represent a polynomial with coefficients mod 2, we can add and subtract polynomials by using bitwise XOR. That's why XOR appears in rp->fingerprint ^ rp->U[om]: we're subtracting out the term from the byte that just left the window, using the U table since there are only 256 possibilities for that term.
The other use of XOR, ((p << 8) | m) ^ rp->T[p >> rp->shift], is in an expression that's modding by the irreducible polynomial, i.e., the equivalent of modding by m in the canonical explanation. If we were to do this by polynomial long division (how the T table gets computed in the first place, presumably), we'd notice that terms subtracted (in the ring) from the dividend are determined by the high-order bits alone (p >> rp->shift). A little algebraic manipulation later, we can cache the sum (in the ring) and subtract it (in the ring, so bitwise XOR) from the dividend (((p << 8) | m)).
For completeness, note that p << 8 is the equivalent of polynomial multiplication by x8.


text:
Q: Pandas groupby then drop groups below specified size I'm trying to separate a DataFrame into groups and drop groups below a minimum size (small outliers).
Here's what I've tried:
df.groupby(['A']).filter(lambda x: x.count() > min_size)
df.groupby(['A']).filter(lambda x: x.size() > min_size)
df.groupby(['A']).filter(lambda x: x['A'].count() > min_size)
df.groupby(['A']).filter(lambda x: x['A'].size() > min_size)

But these either throw an exception or return a different table than I'm expecting. I'd just like to filter, not compute a new table.

A: The number of rows is in the attribute .shape[0]:
df.groupby('A').filter(lambda x: x.shape[0] >= min_size)

NB: If you want to remove the groups below the minimum size, keep those that are above or at the minimum size (>=, not >).

A: You can use len:
In [11]: df = pd.DataFrame([[1, 2], [1, 4], [5, 6]], columns=['A', 'B'])

In [12]: df.groupby('A').filter(lambda x: len(x) > 1)
Out[12]:
   A  B
0  1  2
1  1  4

A: groupby.filter can be very slow for larger dataset / a large number of groups. A faster approach is to use groupby.transform:
Here's an example, first create the dataset:
import pandas as pd
import numpy as np

df = pd.concat([
    pd.DataFrame({'y': np.random.randn(np.random.randint(1,5))}).assign(A=str(i))
    for i in range(1,1000)
]).reset_index(drop=True)
print(df)

             y    A
0     1.375980    1
1    -0.023861    1
2    -0.474707    1
3    -0.151859    2
4    -1.696823    2
...        ...  ...
2424  0.276737  998
2425 -0.142171  999
2426 -0.718891  999
2427 -0.621315  999
2428  1.335450  999

[2429 rows x 2 columns]

Time it:


text:
Q: How to insert into Sqlite DB even app killed from recent history? May be my question title won't describe my actual problem. I will try to explain my problem in detail.

*

*I am writing 'XXX' App inside I am using 'YYY' android library project.

*'YYY' android library project will provides different call backs in one of the call back i will receive 'abc' object.

*Now I am processing the object and storing SQlite DB as per my requirement.

This entire process works perfectly if my app is running(fore ground / recent app history). But my requirement it should work even app is not running.
Can any one give suggestions how can i achieve this.
Thanks in advance.
Sample code snippet :
public class XXX AppCompatActivity implements YYYClass.SomeListener{

    onCreate(){...}
    .
    .
    .

    @Override
    public Object customCallback1(Object abc){

        //Database insertion happen here

       //this part is working only app is in foreground / background(app recent history)

       //I know that, this DB insertion won't work once the app got killed because this I am not doing any service.

      // If I want send this object to service class how can pass(I want
this should happen even app killed)

         return null;
    }

}


text:
Q: How to validate 2 form request in the same controller in laravel I am validating a credit card, for which I created two form requests:
php artisan make:request StoreAmexRequest
php artisan make:request StoreVisaRequest

How can I use them in the same controller?
public function store(Request $request)
{

    if ($request->credit_card['number'][0] == 3) {

       new StoreAmexRequest(),

    }
    if ($request->credit_card['number'][0] == 4) {

       new StoreVisaRequest(),

        ]);

    }}

My code doesn't work, the $request variable doesn't receive it StoreAmexRequest()
I am making a credit card validator, the AMEX card validator is different from VISA cards, since AMEX is 15 digits and the CVV is 4 digits, and in VISA it is 16 digits.
It is necessary to use php artisan make:request since it is for an API that returns the response in JSON
\app\Http\Requests\StoreAmexRequest
public function authorize()
{
    return true;
}

public function rules()
{
    $year = date('Y');

    return [
        'credit_card.name' => ['required', 'min:3'],
        'credit_card.number' => ['bail', 'required', 'min:15', 'max:16', new CredirCardRule],
        'credit_card.expiration_month' => ['required', 'digits:2'],
        'credit_card.expiration_year' => ['required', 'integer', 'digits:4', "min:$year"],
        'credit_card.cvv' => ['required', 'integer', 'digits_between:3,4']
    ];
}
public function failedValidation(Validator $validator)
{
    throw new HttpResponseException(response()->json([
        $validator->errors(),
    ]));
}

A: You could just use a single form request that validates both.
public function store(StoreCreditCardRequest $request)
{
    YourCreditCardModel::create($request->validated());
}

And split the rules inside the form request
public function rules(): array
{
    if ( $this->credit_card['number'][0] == 3 ) {
        return $this->amexRules();
    }

    if ( $this->credit_card['number'][0] == 4 ) {
        return $this->visaRules();
    }
}

protected function amexRules(): array
{
    return [
        // your validation rules for amex cards
    ];
}

protected function visaRules(): array
{
    return [
        // your validation rules for visa cards
    ];
}


text:
Q: How to delete same named directory in same location using linux? Am unable to delete the same named directory in the same location .
[root@server paid]# ls -ld AFO*
drwxr-x--- 4 j133 jsftp 26 Aug 10 08:24 AFOS
drwx------ 2 j133 jsftp 72 Aug  9 12:47 AFOS

I need to delete the aug 9 created directory but am unable to delete it . Renaming and moving the folder also not worked as i expected .

A: this will just print some info. use -delete flag when the desired directory is actually the info
find -maxdepth 1 ! -perm -710 -type d -name 'AFO*' -print -exec stat {} +

edit: -delete won't work with -maxdepth but you can replace stat with rm -r
find -maxdepth 1 ! -perm -710 -type d -name 'AFO*' -print -exec rm -r {} +


text:
Q: Trigger background mail for iOS swift I am working on an iOS swift App, where I have to trigger an email in the background with some 6-digit code to the recipient, for reset password.
I searched and it seems not feasible in iOS. Even the 'SKPSMTPMESSAGE' cannot be used for swift.
Is there any way I can use background email trigger for sending email from iOS swift?

A: You cannot do it with Apples MFMailComposeViewController which is used to show Mail interface for users to send mail.
What you would have to do is send email via your backend where you would call an API endpoint and server would send the mail. But you cannot do it with Apples frameworks...


text:
Q: A formula of Dirichlet and its proof Let $e(x):=e^{2\pi i x}$. I'd like to prove the following Dirichlet's formula with hints given below (From Iwaniec's Topics in Automorphic forms, page 5):

$$G(N)=\sum_{n\pmod{N}} e(\frac{n^2}{N})=\epsilon_N \sqrt{N}.$$

In the hint, we are asked to first prove the asymptotic formula for the above equation as $N\to \infty$
Take $f$ to be a smooth function on the real line supported on $[1-\delta, N+\delta]$ such that
$$G(N):=\sum_{n\in \mathbb Z} e(\frac{n^2}{N})f(n),$$
and we apply the Poisson summation formula to $$\sum_{n\in \mathbb Z} e(\frac{n^2}{N})f(n)=\sum_{n\in \mathbb Z} \widehat{e(\frac{x^2}{N})f(x)}[n] \\
=\sum_{n\in \mathbb Z}\int_{\mathbb R}e(\frac{x^2}{N})f(x)e(-nx)dx$$
But how to I continue from here? Should I try to approximate this Fourier transform somehow?
In below is the screenshot of the book.