text:
Q: Unable to click link to get rid of tour popup I'm trying to click on the 'End Tour' link in order to close a perky popup, as in the attached screenshot. My goal is to get rid of the popup entirely, as it is stopping me from moving past that screen during my tests.
I have tried to using cssSelector, xpath and linkText, none of which seem to be working.  See the HTML bellow and the browser console of the inspected popup element shown below:

    « Prev

    Next »
    End Tour

A: Yes, I see your problem, you might be using the correct selectors, but the element your are trying to find apparently resides in an iframe(see closing  tag in your console). So basically your popup is opened in a different window, and displayed in your current TAB via an iframe.
You will need to .switchTo() your driver context, to the one of your iframe (which I will consider as having id="carlsonIframe", due to lack of  tag attributes). Should look something like this:
// We have to switch to the popup:
driver.switchTo().frame("carlsonIframe");

// And now click the 'End Tour' button:
driver.findElement(By.css("div.popover-navigation a:contains('End Tour')")).click();
// or: driver.findElement(By.css("div.popover-navigation a:nth-of-type(3)")).click();

// Finally, go back to your original context:
driver.switchTo().defaultContent();

Let me know if this works for you. Cheers!

A: It is not best way but you can use that code for skip the walk me popup.
try{
    Thread.sleep(2000);
    driver.findElement(By.xpath("//div[@class='popover-navigation']/a[@data-role='end']")).click();
}catch (NoSuchElementException ignore) {
    logger.info("walk me popup didn't seen")
}

A: Whenever there is an  in the Document Object Model (DOM) / HTML Source, you have to switch to it first, using driver.switchTo().frame("NAME_OR_ID_OF_THE_IFRAME");
In your case,
// Switch to the iframe
driver.switchTo().frame("kdsiframe");

// Locate the element by link Text
driver.findElement(By.linkText("End Tour")).click();

// Switch back to default content
driver.switchTo().defaultContent();

After switching to the iframe, these are the following ways you can locate the 'End Tour' link:

*

*Link Text:

By lnkEndTour = By.linkText("End Tour");

*XPATH:

By xpEndTour = By.xpath("//*[@id='index-page']//*[contains(@id,'step')]//a[@data-role='end' and contains(text(),'End Tour')]");

A: May be your trying to access the frame elements before it is loading. So wait for the frame to load and find the element and do the action.
You can use explicit wait as given below.
WebDriverWait wait=new WebDriverWait(driver, 90);        wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("frameID"));
driver.findElement(By.cssSelector(".popover-navigation>a[data-role='end']")).click();

Change the frameID here.


text:
Q: Python- Tkinter Radio Button changes not being registered I am trying to use tkinter to create a basic program. It is not capturing my radio button input.
It should display a screen with a title and a next button. If the next button is pressed it should bring up another window with two radio buttons and a next button. If that one is pressed it should bring up a third screen telling you what you choose. Currently, it tells you that you chose nothing no matter what
from tkinter import *
from tkinter import ttk
from functools import partial

def forward():
    root2=Tk()
    mainframe2=ttk.Frame(root2)
    mainframe2.grid(row=0,column=0)
    pick=StringVar()
    ttk.Radiobutton(mainframe2, text='A', variable=pick, value='A').grid(row=1,column=1)
    ttk.Radiobutton(mainframe2, text='B', variable=pick, value='B').grid(row=2,column=1)

    #What I have tried
    #ttk.Button(mainframe2, text='Next',command=lambda: advance(pick)).grid(row=3,column=1)
    ttk.Button(mainframe2, text='Next',command=partial(advance,pick)).grid(row=3,column=1)
    #ttk.Button(mainframe2, text='Next',command=advance).grid(row=3,column=1)#if you this and def
advance(args) it says pick is undefined

    root2.mainloop()
def advance(pick):
    choice=pick.get()
    screen3=Tk()
    mainframe3=ttk.Frame(screen3)
    mainframe3.grid(row=0,column=0)
    result=str('You Chose '+choice)
    ttk.Label(mainframe3, text=result).grid(row=1,column=1)
    screen3.mainloop()

root = Tk()
mainframe=ttk.Frame(root) #create a screen
mainframe.grid(row=0,column=0)
ttk.Label(mainframe, text='Welcome to my Broken Program').grid(row=1,column=1)
ttk.Button(mainframe, text='Next',command=forward).grid(row=2,column=1)
root.mainloop()

redpajama_set_name: RedPajamaStackExchange


text:
Q: Cycle in ER diagram: Bad design? BCNF? I want to model linguistic syntax trees in my database. In my design, a syntax tree consists of inner nodes and terminal nodes; both types of nodes are weak entity types that are identified by the syntax tree they belong to. Syntax trees themselves are also weak entities; they are identified by the sentence whose syntactic structure they are to represent. A given sentence may have more than one syntax tree.
A terminal node can be associated (1:m-relation) with a token from the sentence its syntax tree is identified by. Tokens, too, are weak entities that are identified by the sentence they belong to.
So overall, after translating my ER diagram into relation schemas some of my relation schemas look like this (simplified):

sentence(sentenceID)
syntaxTree(sentenceID, treeDiscr)
token(sentenceID, tokenDiscr)
terminalNode(sentenceIDFromTree, treeDiscr, nodeID, sentenceIDFromToken, tokenDiscr)

As you can see, the relation schema of terminalNode contains two foreign keys that each reference a sentenceID: One holds the ID of the sentence the syntax tree represents, and one holds the ID of the sentence the token belongs to. Of course, the values of these sentenceIDs always need to be the same. Thus, for terminalNode the following two functional dependencies hold:

sentenceIDFromTree -> sentenceIDFromToken
sentenceIDFromToken-> sentenceIDFromTree

For neither of these dependencies does the right side correspond to a subset of the left side, i.e. they are not trivial; nor does their left side correspond to a superkey -- i.e. the relation schema is not in BCNF. In order to make the relation schema be in BCNF, I thought that I could merge sentenceIDFromTree and sentenceIDFromToken into one attribute; after all, the two attributes always need to have the same values anyway. As far as I understand, in SQL I cannot make one foreign key reference several tables at the same time directly, so I would probably have to work with some additional trigger(s) to make sure that both the syntaxTree and the token table get referenced by the single sentenceID.
As I do not have much experience with database design and have admittedly no idea what is considered 'good DB design', I wonder now whether I should really merge the two foreign keys, or leave my design as it is (or maybe there are further ways to deal with this?). Additionally, I fear that the whole problem might indicate that there is something really wrong about my conceptual design, but I have no idea how I could model this scenario differently. Any help will be greatly appreciated.

A: You wrote:

in SQL I cannot make one foreign key reference several tables at the same time directly

There is some imprecision here which is the source of your problem.   A foreign key can only reference one table.  However a single table column can be part of one or more foreign keys.
Therefore, the correct design is:

*

*only have one sentenceID column in terminalNode

*have two foreign keys, both of which include the sentenceID
This overlapping ensures that the two parents are correct in relation to each other.


text:
Q:  element inside svg? I have an interactive SVG - displayed at full window size. I want to add some buttons to it. Is it possible to add normal <button> elements inside <svg> tag?
I think not, but I'm asking if there is something similar for SVG.
 From some drawing I get bad results like this:
https://jsfiddle.net/pvxr6g8k/1/
<svg version="1.1" id="svg9723" height="768" width="1268">
<g style="fill:#e6e6e6" id="g3332-7" transform="matrix(0.27404175,0,0,-0.447665,86.580009,508.16151)">
      <g style="fill:#e6e6e6" clip-path="url(#clipPath3336-0-0)" id="g3334-7">
        <g style="fill:#e6e6e6" transform="translate(992.5469,164.3086)" id="g3340-6">
          <path inkscape:connector-curvature="0" id="path3342-2" style="fill:#e6e6e6;stroke:#241a5d;stroke-width:4.48957968;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" d="m 0,0 c -6.937,0 -12.58,5.645 -12.58,12.58 l 0,63.277 c 0,6.937 5.643,12.581 12.58,12.581 l 279.488,0 c 6.936,0 12.58,-5.644 12.58,-12.581 l 0,-63.277 C 292.068,5.645 286.424,0 279.488,0 L 0,0 Z"></path>
        </g>
      </g>
    </g>
    <text transform="scale(0.9324557,1.072437)" id="text3390-1" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:11.87269115px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, Bold';writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none" x="413.18262" y="390.15326">
      <tspan style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:'Arial Bold'" y="390.15326" x="413.18262" id="tspan3392-0" sodipodi:role="line">BUTTON</tspan>
    </text>
    </svg>

The problem is not the visual appearance, but the structure, which not allow me to bind event or interact with it using JS. Not to mention the visual click effect of button "press" is harder to achieve like that.
So what is the solution for buttons in interactive SVG? Any good element like button in HTML?
I don't have to embed html button,  any good button replacement would be fine

A: You can insert at least a link (and style it afterwards like a button). I put the link with Illustrator in the SVG. Maybe a button is possible too. But you can see working links on our site http://www.kleinefische.com
In the svg it looks like:
<a xlink:href="http://www.kleinefische.com" >
   <polygon fill="none" points="162,263.3 251.6,256 252.7,273.3 163,280.5"/>
   <text transform="matrix(0.9967 -8.087198e-02 8.087198e-02 0.9967 162.7812 272.6545)"
    fill="#FFFFFF" font-family="'TradeGothicLT-Bold'" font-size="12.9937">
      /AGENTUR
   </text>
</a>

A: <button> is an HTML element, and therefore can't go (directly) in an SVG element.
However, you can consider using
<foreignObject position attributes>
    <html:button>Button1</html:button>
</foreignObject>

Just make sure you properly declare the namespace, for instance on your root <svg> element, with xmlns:html="http://www.w3.org/1999/xhtml"
This works in most browsers. Internet Explorer doesn't support it, but Microsoft Edge does.
Alternatively, you could just draw your own button-like <rect> and attach a click event handler to it, that'll work just fine too.

A: You could add an onclick property to your svg object, something like:
onclick='window.location =("http://...");'

A: You can use  <foreignObject> for that. SVG allows inclusion of elements from foreign namespaces anywhere with the SVG content. In general, the SVG user agent will include the unknown elements in the DOM but will otherwise ignore unknown elements.
 foreignObject

A: You could try out D3JS.
See documentation here on handling mouse events: https://github.com/d3/d3-selection/blob/master/README.md#handling-events
And an example: Unable to get click event in D3 JavaScript library


text:
Q: Creating user on the server with random username and no password I am very new to Meteor and trying to develop an online synchronous game experiment. Generally, once participants AGREE to the consent form, I want to create a user and add that user into my Players collection.
My consent_page.js looks like this:
import './consent_page.html';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { Meteor } from 'meteor/meteor'
import '../../../api/players/methods.js'

Template.consent_page.events({
    'submit .consent-form'(event) {
        event.preventDefault();
        Meteor.call('players.addPlayer');
        FlowRouter.go('/instructions')
    }
});

and my players.addPlayer method looks like this
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { Players } from './players.js';
import { Random } from 'meteor/random'

Meteor.methods({
    'players.addPlayer'() {
        console.log('I am in the method');
        username = Random.id();
        user = create_user(username);

        alert(username);
        alert(user);

        Players.insert({
            _id: this.userId,
            enterTime: new Date(),
            status: 'instructions',
            passedQuiz: false,
            quizAttempts: 0,
            needRematch: false,
            condition: 'control'
        });
    }
});

/*
* Helper functions for the methods
*/
//create user in the server
create_user = function (username) {
    return Accounts.createUser({
        username: username,
    });
};

The collection Players.js has the definition of the collection.
import { Mongo } from 'meteor/mongo'
export const Players = new Mongo.Collection('players');

However, this doesn't work. I do get redirected to the instructions page, but the user doesn't get created ..  I get the following error:
Error invoking Method 'players.addPlayer': Method 'players.addPlayer' not found [404]

Although, I get the I am in the method message printed in the console. The alert with the return of create_user is undefined. Also, I want to create the users without a password (how can I do that?).

A: Accounts.createUser() method is a part of accounts-base package. You need to import that at first. I'm sharing a snippet from my working project. Hope this helps:
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';

const bcrypt = require('bcrypt');

Meteor.methods({
  'user.create':function(data){
       return Accounts.createUser({
         name: data.name,
         username: data.userId,
         password: data.password,
       });
  }
});


text:
Q: EF Core - use projection and include a collection of an entity I have a base repository:
public async Task<TEntity> GetByCondition(Expression<Func<TEntity, bool>> predicate, Func<DbSet<TEntity>, IQueryable<TEntity>> baseQuery = null, Expression<Func<TEntity, TEntity>> projection = null)
{
    IQueryable<TEntity> q = _context.Set<TEntity>();

    if (baseQuery != null)
    {
        q = baseQuery(_context.Set<TEntity>());
    }

    q = q.Where(predicate);

    if (projection != null)
    {
        q = q.Select(projection);
    }

    return await q.FirstOrDefaultAsync();
}

I try to get the business entity and also include the image.inverseParents but with no success:
 Expression<Func<Businesses, bool>> predicate = x => x.Id == id;

            Expression<Func<Businesses, Businesses>> projection = x => new Businesses
            {
                BusinessImages = x.BusinessImages
                                  .Where(bi => bi.Status == (int)EnumGringo.LU_Status.active && bi.Image.Status == (int)EnumGringo.LU_Status.active)
                                  .Select(bi => new BusinessImages
                                  {
                                       //Won't complie
                                      Image = bi.Image.Include(i=>i.InverseParent)
                                  }).ToList()
            };

            Businesses business = await _repository.GetByCondition(predicate, projection: projection);

How can I do something like this to work?
Image = bi.Image.Include(i=>i.InverseParent)
Things I tried:
Image = bi.Image.Select(i=>i.InverseParent.Parent).FirstOrDefault()
Adding
IQueryable<Businesses> baseQuery(DbSet<Businesses> x) => x
    .Include(c => c.BusinessImages)
    .ThenInclude(c => c.Image)
    .ThenInclude(c => c.InverseParent);

Businesses business = await _repository.GetByCondition(predicate, projection: projection);

The base repository ignores the basequery.

A: Projection queries ignores Include, once you go with Select you need to continue with select all the way.
This works for me:
 BusinessImages = x.BusinessImages
                                  .Where(bi => bi.Status == (int)EnumGringo.LU_Status.active && bi.Image.Status == (int)EnumGringo.LU_Status.active)
                                  .Select(bi => new BusinessImages
                                  {
                                      Image = new UserImages
                                      {
                                          InverseParent = bi.Image.InverseParent
                                      }
                                  })


text:
Q: Multiple 'having' clauses blows up Rails 3 / Arel I think I've found a bug in Rails 3 / Arel, but I'm hoping someone can clarify my problem before I try and fix it and/or submit a bug report.

*

*On a very simple app, with a Question model: (submitter_id: integer, option_count: integer)

The code that I'm using:
q = Question.where(:submitter_id => 1)
q = q.having(['option_sum > ?', 5])
q = q.having(['option_sum < ?', 10])
q = q.select("#{Question.table_name}.*, MAX(#{Question.table_name}.option_count) AS option_sum")
q.to_sql
q

This blows up with:
ArgumentError: wrong number of arguments (2 for 1)
from ~/.rvm/gems/ruby-1.9.2-p0/bundler/gems/arel-f092ae544f58/lib/arel/select_manager.rb:94:in `having'
from ~/.rvm/gems/ruby-1.9.2-p0/bundler/gems/rails-76053fe4d12b/activerecord/lib/active_record/relation/query_methods.rb:193:in `build_arel'
from ~/.rvm/gems/ruby-1.9.2-p0/bundler/gems/rails-76053fe4d12b/activerecord/lib/active_record/relation/query_methods.rb:162:in `arel'

Taking out one of the 'having' clauses fixes the issue, and generates the proper SQL.
Any comments would be appreciated. Arel and Rails 3 are edge versions, with revisions as listed in the error above.

A: Sometimes Arel gives similar error, when scope operators are not in SQL-like order, for example try to invoke select("..") before havings. Also, I'm not sure, that multiple havings are allowed in such requests, so try
q = q.having(['(option_sum > ? AND option_sum < ?)', 5, 10])

A: After extensive testing, this looks like a Rails bug after all, although I haven't been able to confirm it. This problem occurs on a minimal test Rails app as well.


text:
Q: Let $M$ be a noetherian $R$-module and $I=\mathrm{Ann}_R(M)$. Then $R/I$ is a noetherian ring for all ring $R$? Matsumura $p22$,thm$3.5$ says

Let $M$ be a noetherian $R$-module and $I=\mathrm{Ann}_R(M)$. Then $R/I$ is a noetherian ring.

My question is,; is this true for arbitrary ring $R$,or,is this true for non-commutative rings?
I would be appreciated if you could give me some examples.
Thank you for your kind help.

A: It is not true that $R/\text{ann}_R(M)$ must be right Noetherian if $M$ is a Noetherian right $R$-module.  Any right primitive ring that is not right Noetherian is a counterexample: take $M$ to be a faithful simple module (which is certainly Noetherian).  Examples of such rings include endomorphism rings of infinite dimensional vector spaces, free algebras on more than one generator, and group algebras of free groups on more than one generator.  (See, e.g., ``The Algebraic Stucture of Group Rings'' by Passman, Corollary 9.2.11 for the group algebra case.)
If you want a noncommutative result, you have to assume $M$ is a bimodule.  For example, if $M$ is an $R$-$R$-bimodule that is Noetherian as both a left and a right $R$-module, then $R/\text{ann}_R(M)$ is right (or left) Noetherian, where the annihilator is the right (or left) annihilator.
To see this, suppose $m_1,\dots,m_n$ generate $M$ as a left $R$-module and define a right $R$-module map $\phi:R\to M^n$ by $\phi(r)=(m_1r,\dots,m_nr)$.  Because $m_1,\dots,m_n$ generate $M$ as a left $R$-module, the kernel of $\phi$ is $\text{ann}_R(M)$, where the annihilator is the right annihilator of $M$.  Thus $R/\text{ann}_R(M)$ emebeds in $M^n$ as a right module and so is right Noetherian.
We can weaken the hypotheses.  If we assume $M$ is an $S$-$R$-bimodule for some ring $S$ and assume that ${}_SM$ is finitely generated and $M_R$ is Noetherian, then the same proof shows $R/\text{ann}_R(M)$ is right Noetherian.


text:
Q: Summing elements of a list in r I have a list with 10 elements, and each element contains two variables.
$`1.10%.100`
   sqm      tempo
127.4444   0.1500

$`10.10%.100`
   sqm      tempo
 367.00    0.16

$`2.10%.100`
   sqm      tempo
248.7778   0.1900

$`3.10%.100`
   sqm      tempo
 139.00    0.13

$`4.10%.100`
   sqm      tempo
 139.00    0.14

$`5.10%.100`
   sqm      tempo
 223.00    0.17

$`6.10%.100`
   sqm      tempo
155.4444   0.1500

$`7.10%.100`
   sqm      tempo
248.7778   0.1400

$`8.10%.100`
   sqm      tempo
90.11111  0.14000

$`9.10%.100`
   sqm      tempo
90.11111  0.17000

I want to calculate the average, two by two, and fill this in a new list.
For example i want: mean(127.4444, 367.00) and mean(0.15, 0.16)...the same for elements 3 and 4, 5 and 6, and so on.

A: You could try:
#generate some sample data hopefully similar to yours
set.seed(1)
#set the size of the aggregation (you can change it to 10 for instance)
n<-2
mylist<-replicate(10,c(sqm=runif(1,100,1000),tempo=runif(1)),simplify=FALSE)
matrix(colMeans(`dim<-`(do.call(rbind,mylist),c(n,length(mylist)/n*2))),ncol=2)
#         [,1]      [,2]
#[1,] 477.2629 0.6401658
#[2,] 615.8607 0.7795937
#[3,] 475.7899 0.1191715
#[4,] 755.5889 0.4409015
#[5,] 593.9442 0.8846757

First column you got the averages of the sqm elements, on the other column the tempo averages.


text:
Q: API for search products from zuora There is an API(v1/catalog/products) for get all the products from zuora. Likewise is there any API available for search product by product-name from zuora?

A: It seems, there is not.
I use Zoql for that (I search by SKU, but it's the same):
select Id from Product where Sku = '%s'

A: You can use the /v1/action/query API call which lets you write the query string in the body of the request. This query string can also have filters.


text:
Q: Getting error "Resources exceeded during query execution" in bigquery I have a table in Bigquery and I am applying following transformation
    SELECT *,
      CASE WHEN type = 'Monthly' THEN DATE_TRUNC(dt, MONTH) ELSE FIRST_VALUE(DATE_TRUNC(program_end_date, MONTH)) OVER (PARTITION BY id ORDER BY dt DESC) END AS activity_month
      from table

If my type is monthly then I pick it from dt column or i will get latest value. Here I am getting following error
Resources exceeded during query execution: The query could not be executed in the allotted memory. Peak usage: 121% of limit. Top memory consumer(s): sort operations used for analytic OVER() clauses: 99% other/unattributed: 1%

I know why it is failing, since there is ORDER BY in my partition its trying to put in single node and node's memory was not enough to get result. But if my transformation needs order by, how do i avoid it? Here i can not divide table as it might cause inconsistencies. My table has 2.4 billion rows and it is trying to process 576GB. Any help is appreciated


text:
Q: porqué tkinter no me deja colocar el button en el labelframe? hola soy nuevo en el mundo de la programación estoy creando un programa de ventas, con python 3 y tkinter. Estoy tratando de hacer un sistema de navegación de paginas para dicho programa con funciones, destruyendo los frames con destroy() y volviendo a llamar las funciones para cambiar el contenido de la pagina. El problema es cuando colocó el frame en root, el labelframe en frame ya no puedo colocar nada en labelframe, el botón aparece en frame y no en labelframe.
Espero que me puedan ayudar gracias.
from tkinter import *

root = Tk()
root.geometry("1280x720")
root.title('Punto de venta')

def des():

    frameI.destroy()

def ventanaI():

    global frameI
    frameI= Frame(root, width=1280, height=720, bg='blue')
    frameI.place(x=0, y=0)

    caja= LabelFrame(frameI, text='Iniciar sesion', width=400, height=300).place(x=440, y=210)

    bt1=Button(caja, text='Entrar' command=des).place(x=0, y=0)

ventanaI()

root.mainloop()

A: Prueba con esto, te falta indentar la llamada de la función ventanaI, tambien si quieres llamar el LabelFrame, tienes que primero lamarlo en la venta root.
from tkinter import *

root = Tk()
root.geometry("1280x720")
root.title('Punto de venta')
FrameI = Notebook(root)

def des():

    frameI.destroy()

def ventanaI():

    global frameI
    frameI= Frame(root, width=1280, height=720, bg='blue')
    frameI.place(x=0, y=0)

    caja= LabelFrame(frameI, text='Iniciar sesion', width=400, height=300).place(x=440, y=210)

    bt1=Button(caja, text='Entrar' command=des).place(x=0, y=0)

    ventanaI()

root.mainloop()

A: intenta empaquetar el LabelFrame en una linea diferente y veras que sale
caja= LabelFrame(frameI, text='Iniciar sesion', width=400, height=300)
caja.place(x=440, y=210)


text:
Q: Splitting an array into columns Expected result is below.  Trying to split old array into 3 arrays. I don't want to "chunk" it but instead want the items put into almost 'columns'
var old_array = ["1","2","3","4","5"];
var new_array = new Array();

for(i=0; i<old_array.length; i++)
{
    new_array[i%3].push(old_array[i]);
}

The result should be:
new_array[0] = [3]
new_array[1] = [1, 4]
new_array[2] = [2, 5]

A: start i at 1 and reference the values as old_array[i - 1]
var old_array = ["1","2","3","4","5"];
var new_array = new Array();

for(i = 1; i < old_array.length + 1; i++)
{
    new_array[i%3] = new_array[i%3] || [];
    new_array[i%3].push(old_array[i - 1]);
}

A: You can not call new_array[i%3].push, because new_array[i%3] doesn't exist. You need to initialize those sub-arrays before you can push a value into them for the first time.
And to get the result you want, you need to "shift" the index by one as well:
var old_array = ["1","2","3","4","5"];
var new_array = [];

for(i=0, mod_i=0; i<old_array.length; i++)
{
    mod_i = (i+1)%3;
    if(!new_array[mod_i]) {
        new_array[mod_i] = [];
    }
    new_array[mod_i].push(old_array[i]);
}

console.log(new_array);

http://jsfiddle.net/yjxdjmsa/

A: var old_array      = ["1","2","3","4","5"],
    new_array      = [],
    num_of_columns = 3;   // adjustable

for(var i=0, n=old_array.length; i<n; i++)
{

    // 1: turn string into an Int
    var val     = parseInt(old_array[i]);

    // 2: determine column placement
    // change 'val' to 'i' if wanting it by index of old_array (not by value)
    var col_num = val % num_of_columns;

    // 3: create the new column array if it doesn't exist, otherwise use the old one
    var col_arr = new_array[col_num] = new_array[col_num] || [];

    // 4: store the value in the correct column
    col_arr[ col_arr.length ] = val;
}

Explanation:

*

*Your output is showing that you've converted your input as string to a numeric value (no other answer does this conversion)

*It's unclear if you're grouping the columns by value, or the position they are in your old_array, so you'll have to decide, regardless, I've made it a simple change

*In order to add to an array, an array must exist; simply grab the column array if you've already created it, or create a new blank array to use next time

*Assign the value; notice the syntax, which should be a little faster than a .push() call

Result:
new_array[0] = [3]
new_array[1] = [1, 4]
new_array[2] = [2, 5]

A: As a note: in your function, i becomes a global variable, not a local one, because you didn't use var.
var mod = 3;
var old_array = ["1","2","3","4","5"];
var new_array = [];

for (var i = 0; i < mod; i++)
{
    new_array[i] = [];
}

for (var i = 0; i < old_array.length; i++)
{
    new_array[old_array[i] % mod].push(old_array[i]);
}

A: Almost there. You just needed to add the subarrays into your new_array
var old_array = ["1","2","3","4","5"];
var new_array = [[], [], []]

for(i=0; i<old_array.length; i++)
{
    new_array[i%3].push(old_array[i]);
}


text:
Q: Have 2 rows of a database display same point on Google Map I'm trying to have multiple values for profFName and profLName display on a map where a single point should display this value.
So, if I have (2) pID connected to the same marker... it should display the profFName and profLName on one point.
** Right now it is creating two markers at the exact same lat/longitude so it is plotting 3 points (as seen from the database) but it doesnt show (1) point if multiple professors exist at that location **
Javascript

PHP
<?php
require("phpsqlajax_dbinfo.php");

function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}

// Opens a connection to a MySQL server
$connection=mysql_connect ($host, $username, $password);
if (!$connection) {
  die('Not connected : ' . mysql_error());
}

// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die ('Can\'t use db : ' . mysql_error());
}

// Select all the rows in the markers table
$query = "SELECT * FROM markers M, professor P
WHERE P.id = M.id;";
if($row = mysql_fetch_array($result)) {
    do {
        echo $row;
    }
    while($row = mysql_fetch_array($result));
} else {
    die('No results.');
}

header("Content-type: text/xml");

// Start XML file, echo parent node
echo '<markers>';

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
  // ADD TO XML DOCUMENT NODE
  echo '<marker ';
  echo 'name="' . parseToXML($row['name']) . '" ';
  echo 'address="' . parseToXML($row['address']) . '" ';
  echo 'profFName="' . parseToXML($row['profFName']) . '" ';
  echo 'profLName="' . parseToXML($row['profLName']) . '" ';
  echo 'lat="' . $row['lat'] . '" ';
  echo 'lng="' . $row['lng'] . '" ';
  echo 'type="' . $row['type'] . '" ';
  echo '/>';
}

// End XML file
echo '</markers>';

?>

A: Quick solutions:

*

*Use GROUP_CONCAT function
Can I concatenate multiple MySQL rows into one field?

*display only markers and add attribute id to each marker. When you click on marker
select from database and concat received rows

*Create associative array of added markers {id: marker reference}. In function createMarker
check this array and if marker id is already present, concate html of marker in array with
marker passed in function. If not add marker to array.


text:
Q: How to assign a shell command output as value to envrionment variable? Below is my pipeline snippet and I am trying to assign RSTATE variable a value at run time. This value is basically stored in a text file but we need to grep and cut it. So a shell command output should be its value.
pipeline
{
    agent any
    environment
    {
        RSTATE = 'R4C'
        ISO_REV = 'TA'
        BuildSource = '18'
    }
    stages
    {
        stage('get Rstate')
        {
            echo env.RSTATE
        }
    }
}

I am trying to assign RSTATE value like:
 RSTATE = sh ( script: 'grep RSTATE /proj/MM/scm/com/iv_build/mm18_1/rstate/next_rstate.txt
                        |cut -d "=" -f2', returnStdout: true).trim()

But this is not working.
I also tried to run a shell script but that also not works. Only hard coded value is working. Please suggest.

A: I tested and worksm you need to validate if your script return the value you want.
    pipeline
    {
        agent any
        environment
        {
            RSTATE = 'R4C'
            ISO_REV = 'TA'
            BuildSource = '18'
        }
        stages
        {
            stage('get Rstate')
            {
                steps {
                    script {
                        def RSTATE2 = sh ( script: 'echo \${RSTATE}', returnStdout: true).trim()
                        echo env.RSTATE
                        echo RSTATE2
                    }
                }
            }
        }
    }


text:
Q: Tensorflow Serving with image input I'm trying to send image input over http to classify using tensorflow. I have looked in detail in the c++ code for https://www.tensorflow.org/versions/r0.9/tutorials/image_recognition/index.html
I have implemented the inception-v3 example model using C++ API. It takes image input in the following form:
bazel-bin/tensorflow/examples/label_image/label_image --image=my_image.png

However, I want to add the case of:
bazel-bin/tensorflow/examples/label_image/label_image --image=http://www.somewebsite.com/my_image.png

This is due to the fact that it only accepts local image files. I want to add the functionality to take file pointers from online images and classify it in memory. I'm currently working on this, but so far no luck. Can anyone offer some insight how I would go about implementing this?


text:
Q: need to write java program to fetch specific text so i dont have any idea how do i write such program ..please help...
so i want to write a program in java which reads the text between two strings
like i the full text is
             <name> XYZ </name>

so here i want to read the XYZ which can be anything i need the code so that it matches
        <name> ---- </name> and fetch the string in between them

and save it to a string..
please help me on this ..i dont know where to start..
i think i need to use regular expresion that matches the pattern
            <name>  </name>

but dont know how to do that....please suggest.........

A: import java.util.regex.*;

final Pattern p = Pattern.compile("<name>(.+?)</name>");
final Matcher m = p.matcher("<name>any string you want to retrieve</name>");
m.find();
System.out.println(m.group(1));

then you can assign your matcher result to a String for further processing.


text:
Q: Rebase a branch that has child branches My company's policy is that any pull request must be done with a rebased branch.  I have a local Dev branch and this has 'task' branches:
remote master --------
     \
     Dev ------------------
            \-----task1  \
                          \---task2

When master gets updated, I rebase Dev on master.  What is a optimal way to manage branches task1 and task2.  They are still being worked on.  Rebasing each task branch seems like the only way I can see.

A: Try first do rebase dev while preserving merges:
git checkout Dev
git rebase --preserve-merges master

That should keep task1 and 2 correctly rebased as well.
See "What exactly does git's "rebase --preserve-merges" do (and why?)"

A: If you have a lot of task branches, then the best I can think of is to temporarily octopus merge them with Dev into a temp branch and then rebase temp onto master with --preserve-merges. Then reset the branch labels to the proper places.
$ git checkout -b temp Dev && git merge task1 task2
$ git rebase master --preserve-merges
$ git checkout Dev   && git reset --hard temp^
$ git checkout task1 && git reset --hard temp^2
$ git checkout task2 && git reset --hard temp^3
$ git branch -D temp

It's still a lot of commands, but:

*

*Since the tree is inherently preserved, it saves you from having to manually reconstruct the graph, i.e. less human error from having to graft each task branch onto the proper corresponding commit of the rebased Dev branch. It's just a matter of resetting the Dev and task branch markers onto the correct parent commit, which corresponds to the order they were used/named in the octopus merge.

*If you have to do this kind of thing a lot, this should be straightforward to script and use as an alias.


text:
Q: EXC_BAD_ACCESS on IPhone Cocos2d I Have the following code:
-(void) changeAnimation:(NSString*)name forTime:(int) times {
 if(currentAnimation != @"attack")
 {
  id action = [CCAnimate actionWithAnimation:[self animationByName:name]];
  id repeatAction = [CCRepeat actionWithAction:action times:times];
  currentAction = [self runAction:repeatAction];
  lastANimation = currentAnimation;
  currentAnimation = name;
 }
 else if(currentAction.isDone)
 {
   //Here is where I would change the animation
   //but I commented the code for now
 }
}

So when I run this and click on the button that changes the animation to "attack" (by calling [mysprite changeAnimation:@"attack" forTime:1];), I get a EXC_BAD_ACCESS error from the "currentAction.isDone" line, the next time the function is called (the joystick will call changeAnimation to try and change the animation to "run" or "idle", but I want the attack animation to finish first). Any thoughts on whyI get this? currentAction is declared in my class.
Edit: there is nothing in the rest of the class that interacts with currentAction, beside a getter. Its declaration is in the .h (CCAction* surrentAction). Do I need to initialize it? I thought the returned value from runAction would be sufficient? ANyways, when I run the debugger, it is not nil, and assigned to the correct action.
Thanks,
Dave
Edit:
I ended up creating a sequence when "attacking" that calls a function that changes the currentAnimation, so i avoided the issue. Still no idea what was happening.
Here's the answer if your interested:
Other Post

A: More of the class is probably needed to really answer this properly, but the EXC_BAD_ACCESS typically happens because you're accessing something that has been released and is no longer available in memory.
I'm guessing that somewhere in your class you're releasing, either explicitly, or implicitly, the "currentAction" object asynchronously - and when you're checking later, it's done & gone and you're hitting this crasher.
In general, keeping a state variable or two that you always have known values on is a good way to go, and for the "actions" that you're going through, if they're asynchronous and doing their own memory management, leave them as such and work through some state variables that you maintain and control all the memory management around. It's a pretty reasonable pattern for asynchronous callbacks, either with the classic stuff or as you move into using blocks with iOS 4.0


text:
Q: Algorithm, such as MD5 that is symmetric Algorithm, such as MD5 do you know that any amount of symbols that give it a certain number of coding or hash, and yet reversible (ie symmetrical) is?

A: You're probably looking for encryption. Hashing loses information by design.

A: A reversible hash becomes regular compression (eg. ZIP - .Net has classes for that) and/or encryption (eg. AES, included in .Net as well). You can't compress a long piece of text into a short hash and hope to be able to reverse it, since information would become lost - see Shannon's theorem, which specifies the limits on how much you can compress information.


text:
Q: Hint for Markov chain problem Prove that if a Markov Chain has $M$ states and if state $j$ can be accessed from state $i$, then it can be reached in $M$ steps or less. I am trying to show if $P_{ij}^n = 0$ for all $n \leq M$ then $P_{ij}^n = 0$ for all natural numbers. I am trying to figure out how to "decompose" $n > M$ into factors less than M, but the fact that this is matrix multiplication makes it harder.

A: Hint. It seems that you can proceed by using a pigeonhole argument of sorts:
Proposition: Any minimal path from $i$ to $j$ must not contain any state more than once.  Argument: Suppose the minimal path from $i$ to $j$ contains some state $k$ (at least) twice.  Then, because the process is memoryless, the path of the process after the last entry to $k$ could have taken after the first entry to $k$, avoiding re-entry into $k$.
Since there are only $M$ states in all, and no state need be entered more than once, the minimal path from $i$ to $j$ (assuming it exists) requires no more than $M$ steps (including initial and final state).


text:
Q: Bootstrap Carousel not moving as part of a Rails App I want to use the Bootstrap carousel in my Rails app. JQuery, Bootstrap and JS is all loaded and a working database set up. So I am wondering if there is a mistake in my code for the carousel. The first image is displayed but it is not changing and clicking the arrows does not make it move to the next.

    <% @products.each do |product| %>
     <div class="item<%= " active" if product == @products.first %>">
       <%= image_tag(product.image_url) %>

         <%= product.name %>

   <% end %>
   ...

    Previous

    Next

A: Nothing is standing out as being an error necessarily but the approach that I've used previously that works takes a slightly different approach like this:
<% @products.each_with_index do |product, index| %>
    <div class="item <%= 'active' if index == 0 %>">
      <%= image_tag(product.image_url) %>

        <%= product.name %>

<% end %>

Also, have you double checked that you have the Bootstrap JS file loaded?
Edit: Based on the fact that the JS is still non-functioning I would expect that it's potentially an issue with the asset pipeline properly loading the JS assets. While you can include bootstrap through the CDN I would recommend that you add: gem 'bootstrap-sass' to your gem file and bundle install. This will add bootstrap via the Gem (and it's more of a Rails approach) and then you'll head into your application.js file and update the load order to look like this (assuming you have jquery_ujs):
//= require jquery
//= require bootstrap
//= require jquery_ujs
//= require turbolinks
//= require_tree .

A: Okay, just to be sure this is where I load bootstrap, so far it didnt cause any issues but I only used it for a navbar so far.

    <title>Rails1</title>
    <%= csrf_meta_tags %>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>

    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

    <meta name="viewport" content="width=device-width, initial-scale=1">

A: Your JS is not loaded that why it is not working
make sure that you include bootstrap js in your application.js or just include it in the layout


text:
Q: Magento Error: Controller file was loaded but class does not exist I tried with official website and Alan Storm's tutorial. I created simple test project to display "Hello world".But when i tried to ran it it gives me this "There has been an error processing your request".
I tried to search it gave suggestions to do this
- check class name of the controller. but it didn't work for me.
Getting this error
Controller file was loaded but class does not exist

Trace:
#0:/Users/bhaveshthakrar/Documents/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(326): Mage::exception('Mage_Core', 'Controller file...')
#1:/Users/bhaveshthakrar/Documents/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(293): Mage_Core_Controller_Varien_Router_Standard->_includeControllerClass('/Users/bhavesht...', 'Magentotutorial...')
#2:/Users/bhaveshthakrar/Documents/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(196): Mage_Core_Controller_Varien_Router_Standard->_validateControllerClassName('Magentotutorial...', 'foo')
#3:/Users/bhaveshthakrar/Documents/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#4:/Users/bhaveshthakrar/Documents/magento/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#5:/Users/bhaveshthakrar/Documents/magento/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#6:/Users/bhaveshthakrar/Documents/magento/index.php(87): Mage::run('', 'store')
#7:{main}

Let me know if you need code. I am not adding because i followed first tutorial and my code is same is their 's. Any help would be appreciated.

A: I solved this problem by appending <?php at the beginning of the controller file.

A: Try to look in /path_to_your_magento/var/report
It contains reports with errors you admit


text:
Q: Checking if vendor is present in shopify cart.js I'm trying to find out if a vendor is present within my customers cart using Javascript like so:
$.getJSON('/cart.js', function(cart) {

  var inArray = false;
  for (var i = 0; i < cart.length; i++) {
    if (cart[i].vendor === 'example') {
      inArray = true;
      break;
    }
  }
  alert(inArray);

});

If I have a product in my cart from the vendor "example", my alert returns false. Can anyone shine a light on why?
If I do:
$.getJSON('/cart.js', function(cart) {

  $.each(cart.items, function(index, cartItem) {
    alert('This product is ' + cartItem.vendor);
  });

});

I will get an alert with the vendor name for each item in the cart - I just cant seem to check if it exists.
I know I could use liquid to get this information fairly easily, but i'm wanting to restrict delivery days to the jQuery datepicker based on vendors in the cart and current time (on the users machine) so I'm having to use Javascript.

A: I'm surprised your first script even runs. You should be iterating on cart.items not cart.
for(var i = 0; i< cart.items.length; i++){
    if(cart.items[i].vendor == 'example'){
        inArray = true;
        break;
    }
}


text:
Q: How can I speed up this image matching code in EmguCV C# code? Here's the code. See the commented line for where possible optimization could be (at the foreach). Anyone have suggestions on improving the speed here?
public void FindMatches(Matrix<float> dbDescriptors, Matrix<float> queryDescriptors, ref IList<IndecesMapping> imap)
    {
        var indices = new Matrix<int>(queryDescriptors.Rows, 2); // matrix that will contain indices of the 2-nearest neighbors found
        var dists = new Matrix<float>(queryDescriptors.Rows, 2); // matrix that will contain distances to the 2-nearest neighbors found

        // create FLANN index with 4 kd-trees and perform KNN search over it look for 2 nearest neighbours
        var flannIndex = new Index(dbDescriptors, 4);
        flannIndex.KnnSearch(queryDescriptors, indices, dists, 2, 24);

        for (int i = 0; i < indices.Rows; i++)
        {
            // filter out all inadequate pairs based on distance between pairs
            if (dists.Data[i, 0] < (0.5 * dists.Data[i, 1]))
            {
                // find image from the db to which current descriptor range belongs and increment similarity value.
                // in the actual implementation this should be done differently as it's not very efficient for large image collections.
                foreach (var img in imap)
                {
                    if (img.IndexStart <= indices[i, 0] && img.IndexEnd >= indices[i, 0])
                    {
                        img.Similarity++;
                        break;
                    }
                }
            }
        }
    }

A: You can improve your work by changing foreach loop as following:
 foreach (var img in imap)
            {
                if (img.IndexStart <= indices[i, 1] && img.IndexEnd >= indices[i, 1])
                {
                    img.Similarity++;
                    break;
                }
            }

Then it is working fine


text:
Q: .NET language for Concurrent programming This may be a question that others have seen, but I am trying to find a language designed for (or with language support for) concurrent programming that can run on the .net platform.
I have been doing side development in erlang to get a feel for the language and have loved how easy it is to get a stable concurrent or even distributed system up.  It led me to scala which also had a nice system using actors, however scala.net does not seem to have this functionality currently (Granted this is a concurrent system vs a distributed system).  The two .net languages I was looking at are Axum and F#.
Are these the only choices I have?  Are there others?  And, if they are the only choices, what are the advantages/disadvantages of each?

A: Axum is a research project. A real research project, where only ideas from it will end up in products. (Unlike F#, which was productized as a whole.) I'm not even sure the license allows using it to develop production applications.
F# is a fine choice.
Clojure also runs on the CLI, and is a good choice, too.
The CLI port of Scala is currently in the process of being resurrected (with officiall funding from Microsoft, actually), and Scala's Actor libraries (both the built-in one, as well as Akka) are pretty good.
Regarding @wmeyer's comment above: Scala itself doesn't have any provisions for distributed programming. (Neither does Clojure.) Both generally rely on the myriad of Java frameworks that exist for that purpose, such as Terracotta. However, Akka does have Remote Actors for distributed programming, and Akka is largely API-compatible with the built-in Scala Actor library, which allows for a smooth transition.
Erlang would be kind of cool. Kresten Krab Thorup is currently working on Erjang, an Erlang implementation on the JVM, and he has some pretty impressive results: running on HotSpot, Erjang scales comparably to BEAM, sometimes even better. For example, in the (in)famous process-ring benchmark with 10000 processes, Erjang starts up only minimally slower than BEAM, but when you repeat the run several times and the JIT kicks in, it overtakes BEAM after about 3 runs (and curiously, BEAM starts slowing down after 4 runs).
I'm pretty sure you could build an "#rlang" on the DLR and the TPL that performs equally well.

A: I am actually using F# to do both concurrent and distributed programming right now. I think it is working very well. Union types make it easy to define statically-typed messages. .NET serialization is too slow for us but replacing it using custom parser and unparser combinators was easy and performance is now good enough. Asynchronous workflows and mailbox processors make it easy to pass messages around easily. Type inference means my entire code base is tiny and easily maintainable.

A: I think that Jörg already answered your question about Axum (and I don't know much about it), so I'll just add a couple of things about F# - one thing to note is that F# isn't really a concurrent language. It just has good libraries for doing parallel development. The most notable options are:

*

*Task Parallel Library and PLINQ which are available in C# too, but may look a bit nicer in F#, especially if you use immutable data types. There are some nice F# examples of using these two in Parallel Programming with .NET and I wrote a blog post about the F# version.

*Asynchronous workflows are not essentially designed for concurrent programming - they allow you to write non-blocking code in general (which is quite useful in concurrent programming) and they allow you to write computations that can be started and managed. You can use them for:

*

*Task-based parallelism (a bit like Task Parallel Library) using StartChild method

*Data-parallel computations using Async.Parallel
_

*Agent-based programming using the MailboxProcessor type from F# allows you to use message-passing concurrency that is quite similar to Erlang. It is based on asynchronous workflows, which gives you some benefits (e.g. waiting for a message is non-blocking).

In summary, I think it is more important to choose the right parallel programming model for your task than the language used to encode it - as long as the language gives you enough power to encode the programming model. In this case, the programming model shapes your mind more than the language. Axum is based on the actor (message-passing) model, so I think that with some effort, you could wrap F# agents to look quite similar to the Axum API.

A: Since .NET 4.5 you can use C# async/await. I tried to explain a threadsafe, actor based design using async/await. AsyncWcfLib is intended to help when creating concurrent or distributed systems.


text:
Q: Parameterized queries with psycopg2: SELECT from a Python list Given a large (~10,000) list of integers in Python, How do I efficiently SELECT all items from a table whose id is in the list?
I've tried:
>>> lst2
[{'id': 97600167}, {'id': 97600168}, {'id': 97611194}]
>>> cur.executemany("SELECT id, parent_id FROM my_table WHERE id=%(id)s", lst2)
>>> cur.fetchall()
[(97611194, 10020688), (None, None), (None, None)]

The second and third id (97600168, 97611194) do exist in the table.

A: Using your example, use where id in and then pass a parameter which is a tuple of the id values you want to select:
>>> lst2
[{'id': 97600167}, {'id': 97600168}, {'id': 97611194}]
>>> ids = tuple(x['id'] for x in lst2)
>>> cur.execute("SELECT id, parent_id FROM my_table where id in %s",[ids])


text:
Q: How to verify the derived type of a parameter passed to a mocked function I have a base class and two derived classes, like this:
class Base { ... };
class DerivedA : public Base { ... };
class DerivedB : public Base { ... };

I also have an interface class which I'm mocking (with Google Mock), like this:
class MockSomeInterface : public SomeInterface
{
  public:
    MOCK_METHOD1(someMethod, void(Base* basePtr));
};

I can expect calls to the mocked method like this, not verifying the parameter in the call at all:
EXPECT_CALL(mockSomeInterfaceObj, someMethod(_))
  Times(2);

What i would like to do is verify the type of the parameter given to someMethod, to check that it is in fact called with a DerivedA* once and a DerivedB* once, instead of just twice with any parameter.

A: You can write matcher functions for this. Your expectations will then look like this
{
  InSequence s;
  EXPECT_CALL(mockSomeInterfaceObj, someMethod(IsDerivedA()))
    Times(1);
  EXPECT_CALL(mockSomeInterfaceObj, someMethod(IsDerivedB()))
    Times(1);
}

if you have defined the following matcher functions:
MATCHER(IsDerivedA, "")
{
  if (arg == NULL)
  {
    return false;
  }
  DerivedA* derived = dynamic_cast<DerivedA*>(arg);
  if (derived == NULL)
  {
    *result_listener << "is NOT a DerivedA*";
    return false;
  }
  return true;
}

MATCHER(IsDerivedB, "")
{
  if (arg == NULL)
  {
    return false;
  }
  DerivedB* derived = dynamic_cast<DerivedB*>(arg);
  if (derived == NULL)
  {
    *result_listener << "is NOT a DerivedB*";
    return false;
  }
  return true;
}

Notice though that if it's not a pointer parameter but a reference, dynamic_cast will throw an std::bad_cast instead of returning NULL, in the case of types not matching (http://en.cppreference.com/w/cpp/language/dynamic_cast).

A: gMock provides a pointer matcher which can be used to match base class pointer to derived class object arguments. (https://github.com/google/googletest/blob/master/googlemock/docs/cheat_sheet.md#pointer-matchers)
using ::testing::NotNull;
using ::testing::WhenDynamicCastTo;

EXPECT_CALL(mockSomeInterfaceObj, someMethod(WhenDynamicCastTo<DerivedA*>(NotNull()))).Times(1);
EXPECT_CALL(mockSomeInterfaceObj, someMethod(WhenDynamicCastTo<DerivedB*>(NotNull()))).Times(1);


text:
Q: Core Text on Retina Macs I use Core Text to draw text to an offscreen bitmap context using CTLineDraw(). The bitmap is then processed internally before it is drawn to my window.
The problem here is that bitmap contexts aren't scaled on Retina Macs. Thus, on a Retina Mac, the text is still drawn at 72dpi to the bitmap but it should be drawn in 144dpi of course, because the pixel density is twice as high. Thus, the text currently looks blurry because it is drawn at 72dpi to the offscreen bitmap and this bitmap is then scaled when it is drawn to the window.
What is the best way to make Core Text Retina-aware in this context? Should I simply pass a transformation matrix to CTFontCreateWithName() that contains the screen's backingScaleFactor in its scale coefficients? That does look a little hackish, though. That's why I'm asking for some feedback or a better idea...


text:
Q: Is it possible to use an auto property with an explicit interface implementation? I have an interface that looks like this
public interface IFreezableEntity
{
    bool IsFrozen { get; }
    void Freeze();
}

And a class that looks something like this:
public class Foo : IFreezableEntity
{
    private bool isFrozen;

    bool IFreezableEntity.IsFrozen => this.isFrozen;

    void IFreezableEntity.Freeze()
    {
        // Do useful work
        this.isFrozen = true;
    }

    public void CanNotDoWhileFrozen()
    {
        if (this.isFrozen)
        {
            throw new MethodAccessException($"{nameof(this.CanNotDoWhileFrozen)} should not be called on a Frozen instance");
        }
        // Do some work
    }

    public void CanOnlyDoWhileFrozen()
    {
        if (!this.isFrozen)
        {
            throw new MethodAccessException($"{nameof(this.CanOnlyDoWhileFrozen)} should not be called unless instance is Frozen");
        }
        // Do some work
    }
}

I want to use explicit implementation of the interface because these are not methods that the consumers of my class should typically call. This works, but ideally, I would like to remove the backing isFrozen field.
I can change the read references of if (this.isFrozen) to if (((IFreezableEntity)this).IsFrozen) easy enough.
My problem is that if I define it as an auto property
    bool IFreezableEntity.IsFrozen
    {
        get;
    }

then I don't see how I can set it's value, unless I either:

*

*Add a setter to IFreezableEntity (which I don't want)

*Convert it to a regular public property with a private set (I might as well just leave the private bool isFrozen;)

My goal is to encapsulate the properties that are there for its IFreezableEntity logic from the other logic that will be in Foo.


text:
Q: Get youtube thumbnail simplepie So I'm trying to get a thumbnail of a youtube video in simple pie, my problem is that the get_thumbnail() function doesn't seem to be pulling it because the get_enclosure function seems to be returning no values.
Is there something that must be done to initialize the simplepie object to get the enclosure properly?

A: Not all feeds support/use RSS enclosures it isn't part of the RSS standard at least not the original RSS standard. It is part of something called MediaRSS. None the less this can be done. Another problem is Google has been changing GData API which is what actually makes the RSS feeds for YouTube or it did, you might want to use this API instead which produces Atom feeds. You probably want to look at some documentation.
You have to use additional code beyond SimplePie to create a thumbnail for some feeds, I used something called simple_html_dom and another script called thumbnail.php to make thumbnails as necessary. Your life is better if your have a feed like Flickr which supports MediaRSS but if you gotta force the creation of a thumbnail, I used this code:
if ($enclosure = $item->get_enclosure())
{
// Check to see if we have a thumbnail.  We need it because this is going to display an image.
    if ($thumb = $enclosure->get_thumbnail())
{
    // Add each item: item title, linked back to the original posting, with a tooltip containing the description.
    $html .= '
';
    $html .= 'get_permalink() . '" title="' . $title_attr . '">';
    $html .= 'get_title() . '" border="0" />';
    $html .= '';
    $html .= '
' . "\n";
}
}
else
{
// There are feeds that don't use enclosures that none the less are desireable to dsipaly wide as they contain primarily images
// Dakka Dakka and some YouTube feeds fall into this category, not sure what is up with Chest of Colors...
$htmlDOM = new simple_html_dom();
$htmlDOM->load($item->get_content());

$image = $htmlDOM->find('img', 0);
$link = $htmlDOM->find('a', 0);

// Add each item: item title, linked back to the original posting, with a tooltip containing the description.
$html .= '
';
$html .= 'href . '" title="' . $title_attr . '">';
// Sometimes I'm not getting thumbnails, so I'm going to try to make them on the fly using this tutorial:
// http://www.webgeekly.com/tutorials/php/how-to-create-an-image-thumbnail-on-the-fly-using-php/
$html .= 'src . '&maxw=100&maxh=150" alt="' . $item->get_title() . '" border="0" />';
$html .= '';
$html .= '
' . "\n";
}

The formatting seems a bit odd, but that is ripped right from my code which is running here. You're still best off not making a lot of thumbnails from a feed that doesn't support them.


text:
Q: Tuning MySQL on GROUP REPLICATION I'm close to switch from old version of MySQL 5.6 ( master / slave configuration ) to MySQL 8 ( 3 nodes on multi-master configuration ) in GROUP REPLICATION.
The tables are 99% InnoDB.
The webfarm just copied the previous InnoDB configuration variables to these new machines.
I was wondering how to improve performances, each machine has the below configuration:
1) Cpu:
            12 core (Intel Xeon Processor (Skylake, IBRS))

2) RAM:
            total        used       free           shared   buff/cache   available

Mem:        49456252     5164100    11487392       18972    32804760     43676276
Swap:        1998844        6924     1991920

3) Disk:
            Filesystem             Size  Used Avail Use% Mounted on
            /dev/sda2               54G  1.2G   50G   3% /
            /dev/mapper/vg0-mysql 1004G  414G  590G  42% /var/lib/mysql

All my databases are 250GB of datas.
InnnoDB variables:
*************************** 1. row ***************************
Variable_name: innodb_adaptive_flushing
        Value: ON
*************************** 2. row ***************************
Variable_name: innodb_adaptive_flushing_lwm
        Value: 10
*************************** 3. row ***************************
Variable_name: innodb_adaptive_hash_index
        Value: ON
*************************** 4. row ***************************
Variable_name: innodb_adaptive_hash_index_parts
        Value: 8
*************************** 5. row ***************************
Variable_name: innodb_adaptive_max_sleep_delay
        Value: 150000
*************************** 6. row ***************************
Variable_name: innodb_api_bk_commit_interval
        Value: 5
*************************** 7. row ***************************
Variable_name: innodb_api_disable_rowlock
        Value: OFF
*************************** 8. row ***************************
Variable_name: innodb_api_enable_binlog
        Value: OFF
*************************** 9. row ***************************
Variable_name: innodb_api_enable_mdl
        Value: OFF
*************************** 10. row ***************************
Variable_name: innodb_api_trx_level
        Value: 0
*************************** 11. row ***************************
Variable_name: innodb_autoextend_increment
        Value: 64
*************************** 12. row ***************************
Variable_name: innodb_autoinc_lock_mode
        Value: 2
*************************** 13. row ***************************
Variable_name: innodb_buffer_pool_chunk_size
        Value: 134217728
*************************** 14. row ***************************
Variable_name: innodb_buffer_pool_dump_at_shutdown
        Value: ON
*************************** 15. row ***************************
Variable_name: innodb_buffer_pool_dump_now
        Value: OFF
*************************** 16. row ***************************
Variable_name: innodb_buffer_pool_dump_pct
        Value: 25
*************************** 17. row ***************************
Variable_name: innodb_buffer_pool_filename
        Value: ib_buffer_pool
*************************** 18. row ***************************
Variable_name: innodb_buffer_pool_in_core_file
        Value: ON
*************************** 19. row ***************************
Variable_name: innodb_buffer_pool_instances
        Value: 8
*************************** 20. row ***************************
Variable_name: innodb_buffer_pool_load_abort
        Value: OFF
*************************** 21. row ***************************
Variable_name: innodb_buffer_pool_load_at_startup
        Value: ON
*************************** 22. row ***************************
Variable_name: innodb_buffer_pool_load_now
        Value: OFF
*************************** 23. row ***************************
Variable_name: innodb_buffer_pool_size
        Value: 34359738368
*************************** 24. row ***************************
Variable_name: innodb_change_buffer_max_size
        Value: 25
*************************** 25. row ***************************
Variable_name: innodb_change_buffering
        Value: all
*************************** 26. row ***************************
Variable_name: innodb_checksum_algorithm
        Value: crc32
*************************** 27. row ***************************
Variable_name: innodb_cmp_per_index_enabled
        Value: OFF
*************************** 28. row ***************************
Variable_name: innodb_commit_concurrency
        Value: 0
*************************** 29. row ***************************
Variable_name: innodb_compression_failure_threshold_pct
        Value: 5
*************************** 30. row ***************************
Variable_name: innodb_compression_level
        Value: 6
*************************** 31. row ***************************
Variable_name: innodb_compression_pad_pct_max
        Value: 50
*************************** 32. row ***************************
Variable_name: innodb_concurrency_tickets
        Value: 5000
*************************** 33. row ***************************
Variable_name: innodb_data_file_path
        Value: ibdata1:12M:autoextend
*************************** 34. row ***************************
Variable_name: innodb_data_home_dir
        Value:
*************************** 35. row ***************************
Variable_name: innodb_deadlock_detect
        Value: ON
*************************** 36. row ***************************
Variable_name: innodb_dedicated_server
        Value: OFF
*************************** 37. row ***************************
Variable_name: innodb_default_row_format
        Value: dynamic
*************************** 38. row ***************************
Variable_name: innodb_directories
        Value:
*************************** 39. row ***************************
Variable_name: innodb_disable_sort_file_cache
        Value: OFF
*************************** 40. row ***************************
Variable_name: innodb_doublewrite
        Value: ON
*************************** 41. row ***************************
Variable_name: innodb_fast_shutdown
        Value: 1
*************************** 42. row ***************************
Variable_name: innodb_file_per_table
        Value: ON
*************************** 43. row ***************************
Variable_name: innodb_fill_factor
        Value: 100
*************************** 44. row ***************************
Variable_name: innodb_flush_log_at_timeout
        Value: 1
*************************** 45. row ***************************
Variable_name: innodb_flush_log_at_trx_commit
        Value: 1
*************************** 46. row ***************************
Variable_name: innodb_flush_method
        Value: O_DIRECT
*************************** 47. row ***************************
Variable_name: innodb_flush_neighbors
        Value: 0
*************************** 48. row ***************************
Variable_name: innodb_flush_sync
        Value: ON
*************************** 49. row ***************************
Variable_name: innodb_flushing_avg_loops
        Value: 30
*************************** 50. row ***************************
Variable_name: innodb_force_load_corrupted
        Value: OFF
*************************** 51. row ***************************
Variable_name: innodb_force_recovery
        Value: 0
*************************** 52. row ***************************
Variable_name: innodb_fsync_threshold
        Value: 0
*************************** 53. row ***************************
Variable_name: innodb_ft_aux_table
        Value:
*************************** 54. row ***************************
Variable_name: innodb_ft_cache_size
        Value: 8000000
*************************** 55. row ***************************
Variable_name: innodb_ft_enable_diag_print
        Value: OFF
*************************** 56. row ***************************
Variable_name: innodb_ft_enable_stopword
        Value: ON
*************************** 57. row ***************************
Variable_name: innodb_ft_max_token_size
        Value: 84
*************************** 58. row ***************************
Variable_name: innodb_ft_min_token_size
        Value: 3
*************************** 59. row ***************************
Variable_name: innodb_ft_num_word_optimize
        Value: 2000
*************************** 60. row ***************************
Variable_name: innodb_ft_result_cache_limit
        Value: 2000000000
*************************** 61. row ***************************
Variable_name: innodb_ft_server_stopword_table
        Value:
*************************** 62. row ***************************
Variable_name: innodb_ft_sort_pll_degree
        Value: 2
*************************** 63. row ***************************
Variable_name: innodb_ft_total_cache_size
        Value: 640000000
*************************** 64. row ***************************
Variable_name: innodb_ft_user_stopword_table
        Value:
*************************** 65. row ***************************
Variable_name: innodb_io_capacity
        Value: 200
*************************** 66. row ***************************
Variable_name: innodb_io_capacity_max
        Value: 2000
*************************** 67. row ***************************
Variable_name: innodb_lock_wait_timeout
        Value: 120
*************************** 68. row ***************************
Variable_name: innodb_log_buffer_size
        Value: 134217728
*************************** 69. row ***************************
Variable_name: innodb_log_checksums
        Value: ON
*************************** 70. row ***************************
Variable_name: innodb_log_compressed_pages
        Value: ON
*************************** 71. row ***************************
Variable_name: innodb_log_file_size
        Value: 268435456
*************************** 72. row ***************************
Variable_name: innodb_log_files_in_group
        Value: 2
*************************** 73. row ***************************
Variable_name: innodb_log_group_home_dir
        Value: ./
*************************** 74. row ***************************
Variable_name: innodb_log_spin_cpu_abs_lwm
        Value: 80
*************************** 75. row ***************************
Variable_name: innodb_log_spin_cpu_pct_hwm
        Value: 50
*************************** 76. row ***************************
Variable_name: innodb_log_wait_for_flush_spin_hwm
        Value: 400
*************************** 77. row ***************************
Variable_name: innodb_log_write_ahead_size
        Value: 8192
*************************** 78. row ***************************
Variable_name: innodb_lru_scan_depth
        Value: 1024
*************************** 79. row ***************************
Variable_name: innodb_max_dirty_pages_pct
        Value: 90.000000
*************************** 80. row ***************************
Variable_name: innodb_max_dirty_pages_pct_lwm
        Value: 10.000000
*************************** 81. row ***************************
Variable_name: innodb_max_purge_lag
        Value: 0
*************************** 82. row ***************************
Variable_name: innodb_max_purge_lag_delay
        Value: 0
*************************** 83. row ***************************
Variable_name: innodb_max_undo_log_size
        Value: 1073741824
*************************** 84. row ***************************
Variable_name: innodb_monitor_disable
        Value:
*************************** 85. row ***************************
Variable_name: innodb_monitor_enable
        Value:
*************************** 86. row ***************************
Variable_name: innodb_monitor_reset
        Value:
*************************** 87. row ***************************
Variable_name: innodb_monitor_reset_all
        Value:
*************************** 88. row ***************************
Variable_name: innodb_numa_interleave
        Value: OFF
*************************** 89. row ***************************
Variable_name: innodb_old_blocks_pct
        Value: 37
*************************** 90. row ***************************
Variable_name: innodb_old_blocks_time
        Value: 1000
*************************** 91. row ***************************
Variable_name: innodb_online_alter_log_max_size
        Value: 134217728
*************************** 92. row ***************************
Variable_name: innodb_open_files
        Value: 3459
*************************** 93. row ***************************
Variable_name: innodb_optimize_fulltext_only
        Value: OFF
*************************** 94. row ***************************
Variable_name: innodb_page_cleaners
        Value: 4
*************************** 95. row ***************************
Variable_name: innodb_page_size
        Value: 16384
*************************** 96. row ***************************
Variable_name: innodb_parallel_read_threads
        Value: 4
*************************** 97. row ***************************
Variable_name: innodb_print_all_deadlocks
        Value: OFF
*************************** 98. row ***************************
Variable_name: innodb_print_ddl_logs
        Value: OFF
*************************** 99. row ***************************
Variable_name: innodb_purge_batch_size
        Value: 300
*************************** 100. row ***************************
Variable_name: innodb_purge_rseg_truncate_frequency
        Value: 128
*************************** 101. row ***************************
Variable_name: innodb_purge_threads
        Value: 4
*************************** 102. row ***************************
Variable_name: innodb_random_read_ahead
        Value: OFF
*************************** 103. row ***************************
Variable_name: innodb_read_ahead_threshold
        Value: 56
*************************** 104. row ***************************
Variable_name: innodb_read_io_threads
        Value: 4
*************************** 105. row ***************************
Variable_name: innodb_read_only
        Value: OFF
*************************** 106. row ***************************
Variable_name: innodb_redo_log_archive_dirs
        Value:
*************************** 107. row ***************************
Variable_name: innodb_redo_log_encrypt
        Value: OFF
*************************** 108. row ***************************
Variable_name: innodb_replication_delay
        Value: 0
*************************** 109. row ***************************
Variable_name: innodb_rollback_on_timeout
        Value: OFF
*************************** 110. row ***************************
Variable_name: innodb_rollback_segments
        Value: 128
*************************** 111. row ***************************
Variable_name: innodb_sort_buffer_size
        Value: 1048576
*************************** 112. row ***************************
Variable_name: innodb_spin_wait_delay
        Value: 6
*************************** 113. row ***************************
Variable_name: innodb_spin_wait_pause_multiplier
        Value: 50
*************************** 114. row ***************************
Variable_name: innodb_stats_auto_recalc
        Value: ON
*************************** 115. row ***************************
Variable_name: innodb_stats_include_delete_marked
        Value: OFF
*************************** 116. row ***************************
Variable_name: innodb_stats_method
        Value: nulls_equal
*************************** 117. row ***************************
Variable_name: innodb_stats_on_metadata
        Value: OFF
*************************** 118. row ***************************
Variable_name: innodb_stats_persistent
        Value: ON
*************************** 119. row ***************************
Variable_name: innodb_stats_persistent_sample_pages
        Value: 20
*************************** 120. row ***************************
Variable_name: innodb_stats_transient_sample_pages
        Value: 8
*************************** 121. row ***************************
Variable_name: innodb_status_output
        Value: OFF
*************************** 122. row ***************************
Variable_name: innodb_status_output_locks
        Value: OFF
*************************** 123. row ***************************
Variable_name: innodb_strict_mode
        Value: ON
*************************** 124. row ***************************
Variable_name: innodb_sync_array_size
        Value: 1
*************************** 125. row ***************************
Variable_name: innodb_sync_spin_loops
        Value: 30
*************************** 126. row ***************************
Variable_name: innodb_table_locks
        Value: ON
*************************** 127. row ***************************
Variable_name: innodb_temp_data_file_path
        Value: ibtmp1:12M:autoextend
*************************** 128. row ***************************
Variable_name: innodb_temp_tablespaces_dir
        Value: ./#innodb_temp/
*************************** 129. row ***************************
Variable_name: innodb_thread_concurrency
        Value: 12
*************************** 130. row ***************************
Variable_name: innodb_thread_sleep_delay
        Value: 0
*************************** 131. row ***************************
Variable_name: innodb_tmpdir
        Value:
*************************** 132. row ***************************
Variable_name: innodb_undo_directory
        Value: ./
*************************** 133. row ***************************
Variable_name: innodb_undo_log_encrypt
        Value: OFF
*************************** 134. row ***************************
Variable_name: innodb_undo_log_truncate
        Value: ON
*************************** 135. row ***************************
Variable_name: innodb_undo_tablespaces
        Value: 2
*************************** 136. row ***************************
Variable_name: innodb_use_native_aio
        Value: ON
*************************** 137. row ***************************
Variable_name: innodb_version
        Value: 8.0.17
*************************** 138. row ***************************
Variable_name: innodb_write_io_threads
        Value: 4
*************************** 139. row **************************
Variable_name: max_connections
        Value: 3072
*************************** 140. row ***************************
Variable_name: max_user_connections
        Value: 3072

I read a lot of articles about the size of buffer pool ( rule of 80% ), but i'm still thinking if there are other variables to increase or not.
In the actual master server i've the following statistics data:

In addition i tried to run the mysqltuner perl script, these are the suggestions:
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Control warning line(s) into /var/log/mysql/error.log file
    Control error line(s) into /var/log/mysql/error.log file
    MySQL was started within the last 24 hours - recommendations may be inaccurate
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    table_definition_cache(2000) > 464470 or -1 (autosizing if supported)
    innodb_buffer_pool_size (>= 241.7G) if possible.
    innodb_log_file_size should be (=3G) if possible, so InnoDB total log files size equals to 25% of buffer pool size.
    innodb_buffer_pool_instances(=24)

The line "innodb_buffer_pool_size (>= 241.7G) if possible." shocked me a bit, how is possibile to have an amount of RAM AND buffer pool so huge?
I understood it's related to my datas size ( 250GB ) i mention before but is not suggestable such a big amount of RAM?
Feel free to ask other details and thanks for your help!
@danblack
Below the mysql config file of one of the GROUP REPLICATION machines, these machines are not used by my customers right now, i'll switch to them when all is ready and properly configured.
https://pastebin.com/dS1AeM2R
This is the full mysqltuner report on GR machine:
https://pastebin.com/XEFbpGUV
@Wilson Hauck
I don't see an SSD or NVMEE as devices:
 pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdc
  VG Name               vg0
  PV Size               <651.93 GiB / not usable 4.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              166893
  Free PE               493
  Allocated PE          166400
  PV UUID               4Xco4e-Es5d-LcZ2-FHxt-8PYw-B1E6-h9nwP8

cat /sys/block/sdc/queue/rotational
1

These are the output of one machine where i'in going to switch, i repeat that these machines are still not used by the application:
UPTIME 25 hours:
B)
https://pastebin.com/Uqtre6BS
C)
https://pastebin.com/3HfWdCTR
D)
https://pastebin.com/EazB2XWZ
 ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 193064
max locked memory       (kbytes, -l) 65536
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 193064
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

In addition to these information i give you the output of the slave machine used by now from my customers:
UPTIME: 26 days
MySQL config file:
https://pastebin.com/EztvxgYX
mysqltuning script + SHOW GLOBAL STATUS + SHOW GLOBAL VARIABLES + SHOW FULL PROCESSLIST ( i put all here, i fineshed the link available for my reputation)
https://pastebin.com/5rq8sLF1
Disk type:
pvdisplay
--- Physical volume ---
PV Name               /dev/vdb1
VG Name               vg0
PV Size               912.54 GiB / not usable 2.00 MiB
Allocatable           yes
PE Size               4.00 MiB
Total PE              233611
Free PE               5259
Allocated PE          228352
PV UUID               G8aSfO-Ktbg-UcfP-4yoL-jjH9-qjxe-OUN9ni

cat /sys/block/vdb/queue/rotational
1

 ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 459880
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 459880
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

iostat -xm 5 3
Linux 3.2.0-4-amd64  02/24/20        _x86_64_        (12 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
    6.95    0.00    0.65    1.20    0.01   91.19

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
vda               0.00     0.16    0.09    0.15     0.00     0.00    22.30     0.00    1.02    1.94    0.46   0.46   0.01
vdb               5.84    89.65  156.08  208.73     7.59     3.05    59.71     0.92    2.53    1.93    2.97   0.68  24.89
dm-0              0.00     0.00  161.92  269.31     7.59     3.05    50.51     1.21    2.81    2.52    2.98   0.58  24.96

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
    3.35    0.00    0.54    4.43    0.00   91.69

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
vda               0.00     0.60    4.40    1.40     0.02     0.01     9.10     0.01    1.93    2.55    0.00   0.14   0.08
vdb               3.40    35.60  830.40   51.20    17.90     0.30    42.26     1.16    1.31    1.18    3.53   0.85  75.04
dm-0              0.00     0.00  833.80   74.60    17.90     0.30    41.01     1.54    1.69    1.53    3.47   0.83  75.20

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
    3.40    0.00    0.43    4.64    0.00   91.52

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
vda               0.00     0.40    0.00    0.40     0.00     0.00    16.00     0.00    0.00    0.00    0.00   0.00   0.00
vdb               5.80    30.80  810.60   46.80    14.65     0.27    35.63     1.39    1.59    1.61    1.32   1.04  89.36
dm-0              0.00     0.00  816.20   67.20    14.67     0.27    34.63     2.02    2.24    2.34    1.04   1.01  89.36

UPDATE 2ND EDIT

*

*SLAVE SERVER

( SHOW GLOBAL STATUS; + SHOW GLOBAL VARIABLES; + SHOW FULL PROCESSLIST; )
https://pastebin.com/nTeSuCjZ

*

*STAGE SERVER

SHOW GLOBAL VARIABLES;
https://pastebin.com/n369zpdB
( SHOW GLOBAL STATUS; + SHOW FULL PROCESSLIST; )
https://pastebin.com/8rDtkubv

A: B)C)D) -- a very lightly loaded 8.0 server.
Update 2 -- a very busy Slave.  Here is a critique:
Observations:

*

*Version: 5.6.26-log

*48 GB of RAM

*Uptime = 27d 07:48:48

*You are not running on Windows.

*Running 64-bit version

*You appear to be running entirely (or mostly) InnoDB.

The More Important Issues:
Increase table_open_cache from 2000 to 5000.  And/or see if you have too many tables.  Keep an eye on Table_open_cache_misses/Uptime
Increase table_definition_cache.
A lot or rows are being inserted and deleted -- at about the same rate.  If you are "replacing" big chunks of data, explain.  There may be better ways of doing the task.  Perhaps: http://mysql.rjweb.org/doc.php/deletebig#optimal_reload_of_a_table
Max_used_connections is quite high (507).  This may imply a burst of activity together with a bunch of slow queries.  Did you have a near-meltdown?
You do have a lot of slow queries.  See this for how to get specific help:  http://mysql.rjweb.org/doc.php/mysql_analysis#slow_queries_and_slowlog
If you are using SSD drive(s), then innodb_io_capacity = 1000 may help.
Why are you using SHOW SLAVE STATUS 3.8 times per second?  That may be a burden on the system.  Various other SHOWs are executed abnormally frequently.
There seem to be some MyISAM tables. Can they be converted to InnoDB?
Performance_schema...lost -- These indicate that the tables were not configured big enough.  And it probably indicates that you are not using the P_S.  So, perhaps it should be turned off.
Turn the Query cache completely off -- change query_cache_size to 0.  If you do want it on, don't set the size bigger than 50M.
Details and other observations:
( (key_buffer_size - 1.2 * Key_blocks_used * 1024) ) = ((1024M - 1.2 * 6797 * 1024)) / 49152M = 2.1% -- Percent of RAM wasted in key_buffer.
-- Decrease key_buffer_size (now 1073741824).
( Key_blocks_used * 1024 / key_buffer_size ) = 6,797 * 1024 / 1024M = 0.65% -- Percent of key_buffer used. High-water-mark.
-- Lower key_buffer_size (now 1073741824) to avoid unnecessary memory usage.
( Key_reads + Key_writes + Innodb_pages_read + Innodb_pages_written + Innodb_dblwr_writes + Innodb_buffer_pool_pages_flushed ) = (7204545 + 51732 + 265181067 + 156828295 + 12360935 + 156828295) / 2360928 = 253 /sec -- IOPs?
-- If the hardware can handle it, set innodb_io_capacity (now 200) to about this value.
( ( Key_reads + Key_writes + Innodb_pages_read + Innodb_pages_written + Innodb_dblwr_writes + Innodb_buffer_pool_pages_flushed ) / innodb_io_capacity / Uptime ) = ( 7204545 + 51732 + 265181067 + 156828295 + 12360935 + 156828295 ) / 200 / 2360928 = 126.7% -- This may be a metric indicating what innodb_io_capacity is set reasonably.
-- Increase innodb_io_capacity (now 200) if the hardware can handle it.
( Opened_tables ) = 295,211,003 / 2360928 = 125 /sec -- Frequency of opening Tables
-- increase table_open_cache (now 2000)
( Opened_table_definitions ) = 245,012,524 / 2360928 = 103 /sec -- Frequency of opening .frm files
-- Increase table_definition_cache (now 1400) and/or table_open_cache (now 2000).
( Table_open_cache_overflows ) = 295,192,212 / 2360928 = 125 /sec
-- May need to increase table_open_cache (now 2000)
( Table_open_cache_misses ) = 295,208,827 / 2360928 = 125 /sec
-- May need to increase table_open_cache (now 2000)
( Table_open_cache_misses / (Table_open_cache_hits + Table_open_cache_misses) ) = 295,208,827 / (1552264289 + 295208827) = 16.0% -- Effectiveness of table_open_cache.
-- Increase table_open_cache (now 2000) and check table_open_cache_instances (now 1).
( innodb_lru_scan_depth ) = 1,024
-- "InnoDB: page_cleaner: 1000ms intended loop took ..." may be fixed by lowering lru_scan_depth
( innodb_io_capacity_max / innodb_io_capacity ) = 2,000 / 200 = 10 -- Capacity: max/plain
-- Recommend 2. Max should be about equal to the IOPs your I/O subsystem can handle. (If the drive type is unknown 2000/200 may be a reasonable pair.)
( (Innodb_buffer_pool_reads + Innodb_buffer_pool_pages_flushed) ) = ((236228471 + 156828295) ) / 2360928 = 166 /sec -- InnoDB I/O
-- Increase innodb_buffer_pool_size (now 25769803776)?
( Innodb_os_log_written ) = 581,123,630,592 / 2360928 = 246142 /sec -- This is an indicator of how busy InnoDB is.
-- Very idle or very busy InnoDB.
( innodb_log_buffer_size ) = 128M -- Suggest 2MB-64MB, and at least as big as biggest blob set in transactions.
-- Adjust innodb_log_buffer_size (now 134217728).
( innodb_log_buffer_size / innodb_log_file_size ) = 128M / 256M = 50.0% -- Buffer is in RAM; file is on disk.
-- The buffer_size should be smaller and/or the file_size should be larger.
( Innodb_log_writes ) = 72,150,946 / 2360928 = 31 /sec
( Uptime / 60 * innodb_log_file_size / Innodb_os_log_written ) = 2,360,928 / 60 * 256M / 581123630592 = 18.2 -- Minutes between InnoDB log rotations Beginning with 5.6.8, this can be changed dynamically; be sure to also change my.cnf.
-- (The recommendation of 60 minutes between rotations is somewhat arbitrary.) Adjust innodb_log_file_size (now 268435456). (Cannot change in AWS.)
( Innodb_dblwr_writes ) = 12,360,935 / 2360928 = 5.2 /sec -- "Doublewrite buffer" writes to disk. "Doublewrites" are a reliability feature. Some newer versions / configurations don't need them.
-- (Symptom of other issues)
( innodb_flush_neighbors ) = 1 -- A minor optimization when writing blocks to disk.
-- Use 0 for SSD drives; 1 for HDD.
( innodb_io_capacity ) = 200 -- I/O ops per second capable on disk . 100 for slow drives; 200 for spinning drives; 1000-2000 for SSDs; multiply by RAID factor.
( innodb_print_all_deadlocks ) = innodb_print_all_deadlocks = OFF -- Whether to log all Deadlocks.
-- If you are plagued with Deadlocks, turn this on. Caution: If you have lots of deadlocks, this may write a lot to disk.
( max_connections ) = 3,072 -- Maximum number of connections (threads). Impacts various allocations.
-- If max_connections (now 3072) is too high and various memory settings are high, you could run out of RAM.
( join_buffer_size * Max_used_connections ) = (32M * 507) / 49152M = 33.0% -- (A metric for pondering the size of join_buffer_size.)
-- join_buffer_size (now 33554432) should probably be shrunk to avoid running out of RAM.
( character_set_server ) = character_set_server = latin1
-- Charset problems may be helped by setting character_set_server (now latin1) to utf8mb4. That is the future default.
( local_infile ) = local_infile = ON
-- local_infile (now ON) = ON is a potential security issue
( bulk_insert_buffer_size ) = 8 / 49152M = 0.02% -- Buffer for multi-row INSERTs and LOAD DATA
-- Too big could threaten RAM size. Too small could hinder such operations.
( Created_tmp_tables ) = 173,730,482 / 2360928 = 74 /sec -- Frequency of creating "temp" tables as part of complex SELECTs.
( Created_tmp_disk_tables ) = 60,901,114 / 2360928 = 26 /sec -- Frequency of creating disk "temp" tables as part of complex SELECTs
-- increase tmp_table_size (now 201326592) and max_heap_table_size (now 201326592).
Check the rules for temp tables on when MEMORY is used instead of MyISAM. Perhaps minor schema or query changes can avoid MyISAM.
Better indexes and reformulation of queries are more likely to help.
( Created_tmp_disk_tables / Questions ) = 60,901,114 / 1167645085 = 5.2% -- Pct of queries that needed on-disk tmp table.
-- Better indexes / No blobs / etc.
( tmp_table_size ) = 192M -- Limit on size of MEMORY temp tables used to support a SELECT
-- Decrease tmp_table_size (now 201326592) to avoid running out of RAM. Perhaps no more than 64M.
( (Com_insert + Com_update + Com_delete + Com_replace) / Com_commit ) = (33982982 + 45639342 + 27851942 + 6777983) / 97943382 = 1.17 -- Statements per Commit (assuming all InnoDB)
-- Low: Might help to group queries together in transactions; High: long transactions strain various things.
( Select_full_join ) = 9,805,365 / 2360928 = 4.2 /sec -- joins without index
-- Add suitable index(es) to tables used in JOINs.
( Select_scan ) = 251,823,622 / 2360928 = 106 /sec -- full table scans
-- Add indexes / optimize queries (unless they are tiny tables)
( Select_scan / Com_select ) = 251,823,622 / 1037614281 = 24.3% -- % of selects doing full table scan. (May be fooled by Stored Routines.)
-- Add indexes / optimize queries
( binlog_error_action ) = binlog_error_action = IGNORE_ERROR -- What to do if the binlog cannot be written.
-- IGNORE_ERROR is the default for backwards compatibility, but ABORT_SERVER is recommended.
( binlog_format ) = binlog_format = MIXED -- STATEMENT/ROW/MIXED.
-- ROW is preferred by 5.7 (10.3)
( slow_query_log ) = slow_query_log = OFF -- Whether to log slow queries. (5.1.12)
( long_query_time ) = 10 -- Cutoff (Seconds) for defining a "slow" query.
-- Suggest 2
( Slow_queries ) = 224,832,658 / 2360928 = 95 /sec -- Frequency (Slow queries per sec)
-- Rework slow guys; improve indexes; watch disk space for slow log file
( Slow_queries / Questions ) = 224,832,658 / 1167645085 = 19.3% -- Frequency (% of all queries)
-- Find slow queries; check indexes.
( log_slow_slave_statements ) = log_slow_slave_statements = OFF -- (5.6.11, 5.7.1) By default, replicated statements won't show up in the slowlog; this causes them to show.
-- It can be helpful in the slowlog to see writes that could be interfering with Slave reads.
( log_queries_not_using_indexes ) = log_queries_not_using_indexes = ON -- Whether to include such in slowlog.
-- This clutters the slowlog; turn it off so you can see the real slow queries. And decrease long_query_time (now 10) to catch most interesting queries.
( Max_used_connections ) = 507 -- High-water mark for connections
-- Lots of inactive connections is OK; over 100 active connections is likely to be a problem. Max_used_connections (now 507) does not distinguish them; Threads_running (now 1) is instantaneous.
( Com_change_db ) = 43,570,240 / 2360928 = 18 /sec -- Probably comes from USE statements.
-- Consider connecting with DB, using db.tbl syntax, eliminating spurious USE statements, etc.
( Connections ) = 52,611,835 / 2360928 = 22 /sec -- Connections
-- Increase wait_timeout (now 720); use pooling?
You have the Query Cache half-off. You should set both query_cache_type = OFF and query_cache_size = 0 . There is (according to a rumor) a 'bug' in the QC code that leaves some code on unless you turn off both of those settings.
Abnormally small:
(query_cache_size - Qcache_free_memory) / query_cache_size = 0.01%
1 - Qcache_free_memory / query_cache_size = 0.01%
delayed_insert_timeout = 8

Abnormally large:
Com_begin = 41 /sec
Com_create_view = 0.014 /HR
Com_rename_table = 0.1 /HR
Com_rollback_to_savepoint = 2 /HR
Com_show_binlogs = 11 /HR
Com_show_create_db = 2.2 /HR
Com_show_create_table = 0.2 /sec
Com_show_slave_status = 3.8 /sec
Com_show_table_status = 0.2 /sec
Com_show_triggers = 0.2 /sec
Handler_delete = 220 /sec
Handler_read_first = 99 /sec
Handler_read_key = 60959 /sec
Handler_read_last = 1 /sec
Handler_read_next = 467752 /sec
Handler_read_rnd = 11341 /sec
Handler_savepoint_rollback = 2 /HR
Handler_update = 3004 /sec
Innodb_buffer_pool_pages_misc = 134,346
Innodb_buffer_pool_pages_misc * 16384 / innodb_buffer_pool_size = 8.5%
Innodb_buffer_pool_write_requests = 8241 /sec
Innodb_rows_deleted = 220 /sec
Key_read_requests = 9261 /sec
Key_write_requests = 1843 /sec
Performance_schema_digest_lost = 5.68e+8
Performance_schema_file_instances_lost = 5.05e+8
Performance_schema_table_instances_lost = 8.75e+7
Qcache_free_memory = 192.0MB
Select_full_range_join = 0.62 /sec
Select_full_range_join / Com_select = 0.14%
Sort_range = 61 /sec
Sort_rows = 9214 /sec
Sort_scan = 68 /sec
Threads_cached = 95
max_user_connections = 3,072
net_buffer_length = 262,144
optimizer_trace_offset = --1
performance_schema_max_cond_instances = 15,188
performance_schema_max_file_instances = 31,508
performance_schema_max_socket_instances = 6,164
performance_schema_max_thread_instances = 6,244
thread_concurrency = 12

Abnormal strings:
Slave_heartbeat_period = 1800
Slave_running = ON
ignore_db_dirs = lost+found
innodb_fast_shutdown = 1
optimizer_trace = enabled=off,one_line=off
optimizer_trace_features = greedy_search=on, range_optimizer=on, dynamic_range=on, repeated_subselect=on
read_only = ON
slave_rows_search_algorithms = TABLE_SCAN,INDEX_SCAN

A: Rate Per Second = RPS
Suggestions to consider for your SLAVE my.cnf [mysqld] section
max_connections=750  # from 3072 to conserve RAM - max_used_connections was 507 in 27 days
read_rnd_buffer_size=192K  # from 2M to reduce handler_read_rnd_next RPS 133,629
innodb_io_capacity=900  # from 200 to enable higher IOPS to your HDD
join_buffer_size=16M  # from ~ 32M will still support 2.6M rows to be joined
connect_timeout=20  # from 8 seconds for tolerance and to reduce aborted_connects RPHr 593
table_definition_cache=20000  # from 1400 to reduce opened_table_definitions RPS 104
key_cache_age_threshold=7200  # from 300 (seconds) to reduce key_reads RPS 3
log_queries_not_using_indexes=OFF  # from ON to conserve CPU cycles - since log is OFF.

This is just the beginning. View my profile, Network profile for contact info and free Utility Scripts to assist with performance tuning.
Observations: 48G RAM is not enough for the load, 19% of your queries take more than 10 seconds to complete, investment needs to be made in getting indexes where you need them to avoid table scans, com_analyze and com_optimize each indicate no activity in 27 days and more opportunities to improve performance.