text:
Q: Delphi7, Create many controls with same properties I am new to Delphi.
I would like to make an application in which will create a number of Buttons. Declaring an array of Tbuttons and create the buttons 1 by 1 is not very satisfying, because it is confusing and takes a lot of time. Using the Command For is also unsatisfying, because i won't be able to change some of button's properties, if needed, for example their position.
So i decided to declare a procedure in TForm1 Class, which creates the buttons based on what properties I send to the procedure. But for some reason it is not working (There aren't any syntax Errors):
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)                       //Declaring the procedure
  procedure CreateButton(Button: TButton; L: Integer; T: Integer);
  procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  B1, B2: TForm1;         //Declaring controls
implementation

{$R *.dfm}

procedure TForm1.CreateButton(Button: TButton; L: Integer; T: Integer);
begin
  Button:= TButton.Create(Self);
  Button.Parent:= Self;
  Button.Width:= 100; Button.Height:= 50;
  Button.Left:= L; Button.Top:= T;
end;

procedure TForm1.FormCreate(Sender: TObject);
Var
  Button1, Button2: TButton;
begin
  B1.CreateButton(Button1, 100, 50);           //Sending properties
  B2.CreateButton(Button2, 200, 40);           //Sending properties
end;

end.

A: AS: during the communication with topic starters answer grown too. The total outcome is like http://pastebin.ca/2426760
 procedure TForm1.CreateButton(VAR Button: TButton; CONST L: Integer; CONST T: Integer);

That is of basics of Pascal language how to pass parameters to procedures/functions.
http://docwiki.embarcadero.com/RADStudio/XE4/en/Parameters_(Delphi)

Actually, I don't think there is any problem with the parameters
  Button = nil, which means the values of "Button1" and "Button2" are not sent, however

http://pastebin.ca/2427238

Kudoes to Bill for spotting this. Using separate properties to position your controls is both inefficient and prone to copy-paste errors.

*

*http://docwiki.embarcadero.com/Libraries/XE3/en/Vcl.Controls.TControl.SetBounds

*http://docwiki.embarcadero.com/CodeExamples/XE3/en/BoundsRect_(Delphi)
Using the 2nd link:
procedure TForm1.CreateButton(out Button: TButton; const L: Integer; const T: Integer);
begin
  Button:= TButton.Create(Self);
  Button.Parent:= Self;
  Button.SetBounds( L, T, 100, 50);
end;

Actually what do you do with pointers to newly created buttons ?
In your code you just loose them!
procedure TForm1.FormCreate(Sender: TObject);
Var
  Button1, Button2: TButton;
begin
...
end;

In this your code those pointers would be just lost! If you do need those values - pass them outside of the procedure. If you do not - do not ask for them - http://en.wikipedia.org/wiki/YAGNI http://en.wikipedia.org/wiki/KISS_principle
Procedure TForm1.CreateButton(const L, T: Integer);
begin
  With TButton.Create(Self) do begin
       Parent := Self;
       SetBounds( L, T, 100, 50);
       Caption := 'Caption at ' + IntToStr(T);
       Name := 'Name at ' + IntToStr(L);
  End;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  B1.CreateButton( 100, 50);           //Sending properties
  B2.CreateButton( 200, 40);           //Sending properties
end;

Now to those B1, B2...
You claim that you want 2 buttons on the form, but you code shows you try to make THREE FORMS and one button on the 2nd form and one button on the 3rd form. So what do you really want ??? And do you check that B1 and B2 forms were created befoe tryign to add buttons to them ?
Perhaps you really wanted
procedure TForm1.FormCreate(Sender: TObject);
begin
  SELF.CreateButton( 100, 50);           //Sending properties
  SELF.CreateButton( 200, 40);           //Sending properties
end;

Then to go with DRY principle and to keep all the variables in one place.
http://docwiki.embarcadero.com/Libraries/XE2/en/System.Types.TPoint
Procedure TForm1.CreateButtons(const a: array of TPoint);
Var p: TPoint;
Begin
    for p in a do
        CreateButton( p.x, p.y );
End;

type TPointDynArray = array of TPoint;

procedure TForm1.FormCreate(Sender: TObject);
begin
   CreateButtons( TPointDynArray.Create(
       Point( 100,50 ), Point(200, 40) ) );
end;

Kudos to Delphi array initialization
Later you can always add more coordinates to an array and keep it consistent.
Well, to bring down this to Delphi 7 abilities that would - somewhat redundantly - be coded like
const BtnCnt = 2;
      BtnLocations : array [1..BtnCnt] of TSize = (
         ( cx: 100, cy: 50 ), ( cx: 200, cy: 40 )
      );

Procedure TForm1.CreateButtons(const a: array of TSize);
Var i: integer;
Begin
    for i := Low(a) to High(a) do
        with a[i] do
             CreateButton( cx, cy );
End;

procedure TForm1.FormCreate(Sender: TObject);
begin
   CreateButtons( BtnLocations );
end;

But while Delphi 5 and Dephi 7 were great releases, they are very outdated. I definitely suggest you either upgradeing to Delphi XE or more recent, or side-stepping to CodeTyphon

TForm1 = class(TForm)                       //Declaring the procedure
    procedure CreateButton(Button: TButton; L: Integer; T: Integer);

Declaring that one-purpose procedure in PUBLISHED section of the form class is also not a very good style. You'd better declare them in PRIVATE section.  Adhering to "least visibility" would help you to make interdependencies controllable. Otherwise in a year your program would become a spaghetti mess, where you just cannot change anything without ruining everything else. I am workign on a project with 10+ years of history now and i see the consequences of "everything is public" very clear. It is a great pain!


text:
Q: algorithm: is there a map-reduce way to merge a group of sets by deleting all the subsets The problem is: Suppose we have a group of Sets: Set(1,2,3) Set(1,2,3,4) Set(4,5,6) Set(1,2,3,4,6), we need to delete all the subsets and finally get the Result: Set(4,5,6) Set(1,2,3,4,6). (Since both Set(1,2,3) and Set(1,2,3,4) are the subsets of Set(1,2,3,4,6), both are removed.)
And suppose that the elements of the set have order, which can be Int, Char, etc.
Is it possible to do it in a map-reduce way?
The reason to do it in a map-reduce way is that sometimes the group of Sets has a very large size, which makes it not possible to do it in the memory of a single machine. So we hope to do it in a map-reduce way, it may be not very efficient, but just work.
My problem is:

*

*I don't know how to define a key for the key-value pair in the map-reduce process to group Sets properly.

*I don't know when the process should be finished, that all the subsets have been removed.
EDIT:

*

*The size of the data will keep growing larger in the future.

*The input can be either a group of sets or multiple lines with each line containing a group of sets. Currently the input is val data = RDD[Set], I firstly do data.collect(), which results in an overall group of sets. But I can modify the generation of the input into a RDD[Array[Set]], which will give me multiple lines with each line containing a group of sets.

*The elements in each set can be sorted by modifying other parts of the program.

A: I doubt this can be done by a traditional map-reduce technique which is essentially a divide-and-conquer method. This is because:

*

*in this problem each set has to essentially be compared to all of the sets of larger cardinality whose min and max elements lie around the min and max of the smaller set.

*unlike sorting and other problems amenable to map-reduce, we don't have a transitivity relation, i.e., if A is not-a-subset-of B and B is-not-subset-of C, we cannot make any statement about A w.r.t. C.

Based on the above observations this problem seems to be similar to duplicate detection and there is research on duplicate detection, for example here. Similar techniques will work well for the current problem.

A: Since subset-of is a transitive relation (proof), you could take advantage of that and design an iterative algorithm that eliminates subsets in each iteration.
The logic is the following:
Mapper:
eliminate local subsets and emit only the supersets. Let the key be the first element of each superset.
Reducer:
eliminate local subsets and emit only the supersets.
You could also use a combiner with the same logic.
Each time, the number of reducers should decrease, until, in the last iteration, a single reducer is used. This way, you can define from the beginning the number of iterations. E.g. by setting initially 8 reducers, and each time using half of them in the next iteration, your program will terminate after 4 iterations (8 reducers, then 4, then 2 and then 1). In general, it will terminate in logn + 1 iterations (log base 2), where n is the initial number of reducers, so n should be a power of 2 and of course less than the number of mappers. If this feels restrictive, you can think of more drastic decreases in the number of reducers (e.g. decrease by 1/4, or more).
Regarding the choice of the key, this can create balancing issues, if, for example, most of the sets start with the same element. So, perhaps you could also make use of other keys, or define a partitioner to better balance the load. This policy makes sure, though, that sets that are equal will be eliminated as early as possible.
If you have MapReduce v.2, you could implement the aforementioned logic like that (pseudocode):
Mapper:
Set<Set> superSets;

setup() {
    superSets = new HashSet<>();
}

map(inputSet){
    Set toReplace = null;
    for (Set superSet : superSets) {
        if (superSet.contains(inputSet) {
            return;
        }
        if (inputSet.contains(superSet)) {
            toReplace = superSet;
            break;
        }
    }
    if (toReplace != null) {
        superSets.remove(toReplace);
    }
    superSets.add(inputSet);
}

close() {
    for (Set superSet : superSets) {
        context.write(superSet.iterator.next(), superSet);
    }
}

You can use the same code in the reducer and in the combiner.
As a final note, I doubt that MapReduce is the right environment for this kind of computations. Perhaps Apache Spark, or Apache Flink offer some better alternatives.

A: If I understand:

*

*your goal is to detect and remove subset of set in a large set of sets

*there are too sets to be managed altogether (memory limit)

*strategy is map and reduce (or some sort of)
What I take into account:

*

*main problem is that you can not managed everything at same time

*usual method map/reduce supposes to split datas, and treat each part. This is not done totally like that
(because each subset can intersect with each subset).
If I make some calculations:

*

*suppose you have a large set : 1000 000 of 3 to 20 numbers from 1 to 100.
you should have to compare 1000 Billions couples of sets

Even with 100 000 (10 billions), it takes too much times (I stopped).
What I propose (test with 100 000 sets) :
1 define a criterion to split in more little compatible sets. Compatible sets are packages of sets, and you are sure subsets of sets are at least in one same package: then you are sure to find subsets to remove with that method. Say differently: if set A is a subset of set B, then A and B will reside in one (or several) packages like that.
I just take: every subset which contains one defined element (1, 2, 3, ...) => it gives approximately 11 500 sets with precedent assumptions.
It become reasonable to compare (120 000 comparisons).
It takes 180 seconds on my machine, and it found 900 subsets to remove.

*

*you have to do it 100 times (then 18 000 seconds).

*and of course, you can find duplicates (but not too many: some %, and the gool is to eliminate).
2 At end it is easy and fast to agglomerate. Duplicate work is light.
3 bigger filters:
with a filter with 2 elements, you reduce to 1475 sets => you get approximately 30 sets to delete, it takes 2-3 seconds
and you have to do that 10 000
Interest of this method:

*

*the selection of sets on the criterion is linear and very simple. It is also hiearchical:
split on one element , on a second, etc.

*it is stateless: you can filter millions of set. You only have to keep the good one. The more datas you have,
the more filter you have to do => solution is scalable.

*if you want to treat little clouds, you can takes 3, 4 elements in common, etc.

*like that, you can spread your treatment among multiple machines (as many as you have).
At the end, you have to reconciliate all your datas/deleting.
This solution doesnt keep a lot of time overall (you can do calculations), but it suits the need of splitting the work.
Hope it helps.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Deploying .NET Core Web API to IIS Server I created my first .Net Core Web API and trying to deploy it to a remote IIS server. I use a create-react-app project for the front end.
When I debug locally and communicate with .Net Core WEB API, it works fine:

https://localhost:5001/api/notes

I use https://myapp.eastus.cloudapp.azure.com as my public URL (here myapp is an example), and everything looks fine on browser that the front end pages load correctly.
But when I testing backend APIs by fetching get on

https://myapp.eastus.cloudapp.azure.com/api/notes

I got 404.
My IIS configuration:

The web.config on .Net Core Web API build folder:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\myapp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>

  </location>

</configuration>

And React web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <remove fileExtension=".js" />
            <mimeMap fileExtension=".js" mimeType="application/javascript; charset=UTF-8" />
        </staticContent>
        <rewrite>
            <rules>

            </rules>
        </rewrite>
    </system.webServer>
</configuration>

UPDATED:
My DbContext EF Core instance:
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;

namespace Notes.DB
{
    public class AppDbContext : DbContext
    {
        protected readonly IConfiguration Configuration;
        public DbSet<Note> Notes { get; set; }

        public AppDbContext(IConfiguration configuration)
        {
            Configuration = configuration;
        }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer(
               Configuration.GetConnectionString("myDb1"));
        }
    }
}

And, appsettings.json in .Net Core Project:
{
    "AppSettings": {
        "Secret": ""
    },
    "Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft": "Warning",
            "Microsoft.Hosting.Lifetime": "Information"
        }
    },
    "AllowedHosts": "*",
    "ConnectionStrings": {
        "myDb1": 'I generated this string from Azure SQL Database'
    }
}

My Controller code:
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Notes.Core;
using Notes.DB;

namespace myApp.Controllers
{
    [ApiController]
    [Route("[controller]")]
    [Bind("Id,Username,Value")]

    public class NotesController : ControllerBase
    {

        private readonly ILogger<NotesController> _logger;
        private INotesServices _notesSerives;
        private readonly AppDbContext _context;

        public NotesController(ILogger<NotesController> logger, INotesServices notesSerives, AppDbContext context)
        {
            _logger = logger;
            _notesSerives = notesSerives;
            _context = context;
        }

        [HttpGet("", Name = "GetAllNote")]
        public IActionResult GetAllNote()
        {
            return Ok(_notesSerives.GetAllNote());
        }

    }
}

What I did wrong? How to debug this?

A: If you use HTTPS (using TLS for authentication), you will not receive any response if TLS fails. Therefore, the cause of this problem may be that the site you want to visit does not support HTTPS, or the URL does not exist.
You can try to use http access first, if http can be accessed successfully then this should be a certificate verification issue. If 404 still appears when using http, then .Net Core Web API should not be successfully deployed to IIS. It could also be because you used the wrong URL. For information about "Host ASP.NET Core on Windows with IIS", you can refer to this link: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-5.0


text:
Q: Load component and props with dynamic using memo in React/NextJS I need to get props in my component and render it only when specific state will change.
How can I pass state props to TestView component?
<MyAwesomeComponent props={data} /> don't work.
import dynamic from 'next/dynamic';

function MyAwesomeComponent() {
    const Test = React.useMemo(() =>  dynamic(
      () => import('./TestView'),
      { ssr: false, }
    ), [])
    return <Test />
  }

export default MyAwesomeComponent;


text:
Q: B+ trees insertion/search? I am looking for good material on how to insert and search in a B+ tree. I already googled, but the stuff I found were really poorly explained. Is there any other good source online? Any suggestions for data structure books that might be useful? Any video lectures of any university? UCBerkley and MIT did not have any.

A: I would try walking through the BTree slides found at the following page. I found them very helpful when learning the material.  The slides are from the January 25th lecture.
http://www.cs.washington.edu/education/courses/cse332/12wi/calendar/lecturelist.html

A: For B Tree - Introduction to Algorithms (CLRS) or Algorithms (Sedgewick & Wayne)
For B+ Tree - We have introductions to B tree in the above books just stating the difference in approaches.  But for better insight, we might have to go for DBMS books instead like - Database Management Systems (Ramakrishnan Raghu, Gehrke Johannes) or Fundamentals of database systems (Navathe)
Most algorithms and complexities are similar for both but with slight differences. So, understanding one can aid understanding other.


text:
Q: Gnome 3 Desktop Environment: Window size and position hot keys? I'm looking to migrate to ZorinOS, which uses Gnome 3 Desktop Environment for window management.  I understand that the super key can be easily used as a modifier key and want to duplicate Windows 10 functionality in regards to super key hotkeys for window size and position.
The positions would be:

*

*maximize (win+up)

*minimize (win+down)

*minimize all (win+m)

*restore all (win+shift+m)

*resize to right half of screen (win+right)

*resize to left half of screen (win+left)

It would also be nice to have AeroSnap functionality, but this is a different but similar question.
Is this possible given the Gnome 3 Desktop Environment?

A: The Aero Snap shortcuts are already present in a standard GNOME Shell environment. "Minimize" isn't really useful because GNOME Shell doesn't have a desktop.
That said, it still has the core functionality (e.g. "minimizing" a window hides it to the overview) and the shortcuts can be reassigned.


text:
Q: How do I darken behind my overlay panel in jQuery Mobile? I have taken the panel code from the jQuery Mobile website and incorporated it into my file. I would like to darken or blur the content behind the panel when it is on the screen. I have tried using filter:blur(5px) but to no avail. Am I using the correct syntax? Please see image for desired outcome.
HTML:

            Filter

Available job opportunities...

This will be the filter panel

CSS:
/* Subheader Filter Panel */

#filterPanel {
    background-color: #99c5cc;
    color: white;
    text-shadow: none;
}

A: You can only apply the filter property blur() to images or SVG: https://www.w3.org/TR/filter-effects-1/#funcdef-blur
In this situation where you want to blur HTML content the best thing to do would be to apply an opacity to the element that is positioned over the content. Looking at jQuery mobile when the side panel is opened it actually provides this type of overlay.
Try adding this CSS to your project:
.ui-panel-dismiss-open {
  background: rgba(0, 0, 0, 0.8) !important;
}

See screenshot of it working on the jQuery Mobile website (please notice the CSS in the console):


text:
Q: jQuery Droppable, get the element dropped A small question hopefully with a simple answer, I am using jQuery draggable and droppable to place items into a dock. Using the below code for the drop.
$("#dock").droppable({
            drop: function(event, ui) {
                //Do something to the element dropped?!?
            }
        });

However I couldn't find a way to get what element was actually dropped, so I can do something do it. Is this possible?

A: From the drop event documentation:

This event is triggered when an
accepted draggable is dropped 'over'
(within the tolerance of) this
droppable. In the callback, $(this)
represents the droppable the draggable
is dropped on. While ui.draggable represents
the draggable.

So:
$("#dock").droppable({
     drop: function(event, ui) {
               // do something with the dock
               $(this).doSomething();

               // do something with the draggable item
               $(ui.draggable).doSomething();
           }
});


text:
Q: can xquery be run practically from the CLI? How is this sample xquery executed from the CLI?
xquery version "1.0";
let $message := 'Hello World!'
return
<results>
   <message>{$message}</message>
</results>

Inspired from zx485's answer:

Check the separate libxslt page
XSL Transformations, is a language for transforming XML documents into
  other XML documents (or HTML/textual output).
A separate library called libxslt is available implementing XSLT-1.0
  for libxml2. This module "libxslt" too can be found in the Gnome SVN
  base.
You can check the progresses on the libxslt Changelog.
Daniel Veillard

http://xmlsoft.org/XSLT.html

A: You can do it with Saxon like in this extensive tutorial.
To summarize it, copy the XQuery code to a file (here named test.xq) and then execute it with (the current version of) Saxon:
java -cp saxon9he.jar net.sf.saxon.Query test.xq

The output in your sample case would be
<results>
    <message>Hello World!</message>
</results>

as desired.


text:
Q: Como colocar un evento para varios elementos? Tengo una duda.Bien.Tengo un un post en el que los usuarios publican comentarios y al lado de cada post tengo un boton perteneciente a cada uno de ellos.Bien,como hago para que cuando yo haga click en cada uno de esos botones me salga un popup.
Con que evento?.Un evento para varios elementos.Pero que sea el mismo para todos esos botones.
ahhh.Esos botones son generados o imrimido con php,cuando el usuario postea algo,ese algo tiene un boton.Ayuda!!!

A: Dado tus comentarios y tu comfirmación de ello, lo que quieres hacer es lo siguiente:

Aplicar a varios elementos un tooltip cuando se haga click

Esto se puede hacer muy fácilmente mediante clases o atributos en los elementos. A continuación, te muestro dos formas:

*

*Mediante click en el elemento

*Mediante hover en el elemento (no requiere JS)

Tooltip en click
Para esto vamos a utilizar atributos data- que me parecen más útiles que las clases en casos como éstos. Lo que haremos es lo siguiente:

*

*Todos los elementos que tengan atributo data-tooltip desplegarán un tooltip cuando se haga click sobre ellos. Para esto, es necesario usar los pseudoselectores before y after.

$('[tooltip]').on('blur', function() {
  $(this).removeAttr('tooltip-visible');
});
$('[tooltip]').on('click', function() {
  $(this).attr('tooltip-visible', true);
});
*,
*:before,
*:after {
  box-sizing: border-box;
}

body {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-flex-flow: row wrap;
      -ms-flex-flow: row wrap;
          flex-flow: row wrap;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
      -ms-flex-pack: center;
          justify-content: center;
  font-size: 62.5%;
  padding: 1.5rem;
  text-align: center;
}

.btn {
  background: -webkit-linear-gradient(top, #fbfbfb, #f5f5f5);
  background: linear-gradient(to bottom, #fbfbfb, #f5f5f5);
  border: 1px solid #ccc;
  border-radius: 2px;
  box-shadow: 0 1px 2px 0px rgba(0, 0, 0, 0.15);
  color: #222;
  font-family: 'segoe ui';
  font-size: .9rem;
  margin: 10px;
  padding: .5rem 1rem;
  -webkit-transition: box-shadow .2s ease;
  transition: box-shadow .2s ease;
}
.btn:hover {
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15), 0 5px 5px rgba(0, 0, 0, 0.12);
}
.btn:focus {
  outline: none;
}
.btn.green {
  background: #16a085;
  border-color: #16a085;
  color: #fff;
}
.btn.blue {
  background: #2980b9;
  border-color: #2980b9;
  color: #fff;
}
.btn.gold {
  background: #f39c12;
  border-color: #f39c12;
  color: #fff;
}
.btn.red {
  background: #c0392b;
  border-color: #c0392b;
  color: #fff;
}
.btn.blue {
  background: #2980b9;
  border-color: #2980b9;
  color: #fff;
}

[tooltip] {
  position: relative;
}
[tooltip]:before, [tooltip]:after {
  -webkit-transition: opacity .2s ease, -webkit-transform .2s ease;
  transition: opacity .2s ease, -webkit-transform .2s ease;
  transition: opacity .2s ease, transform .2s ease;
  transition: opacity .2s ease, transform .2s ease, -webkit-transform .2s ease;
  -webkit-transform: translateY(15px);
          transform: translateY(15px);
  pointer-events: none;
  z-index: 5;
}
[tooltip]:before {
  content: "";
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 9px solid rgba(0, 0, 0, 0.9);
  left: 6px;
  opacity: 0;
  position: absolute;
  top: 110%;
}
[tooltip]:after {
  background-color: rgba(0, 0, 0, 0.9);
  border-radius: 4px;
  color: #fff;
  content: attr(title);
  display: inline-block;
  left: 0px;
  padding: .3rem .4rem;
  opacity: 0;
  position: absolute;
  top: 130%;
  width: 125px;
}
[tooltip][tooltip-visible]:before, [tooltip][tooltip-visible]:after {
  opacity: 1;
  -webkit-transform: translateY(0px);
          transform: translateY(0px);
}

<button
  class="btn"
  tooltip
  title="Press me!"
>
  Normal
</button>
<button
  class="btn green"
  tooltip
  title="Confirm changes"
>
  Success
</button>
<button
  class="btn gold"
  tooltip
  title="Be careful!"
>
  Warning
</button>
<button
  class="btn red"
  tooltip
  title="Are you sure?"
>
  Danger
</button>
<button
  class="btn blue"
  tooltip
  title="Press me too!"
>
  Primary
</button>

Tooltip en hover (no requiere JS)
Para esta versión eliminamos el tooltip-visible y lo reemplazamos por hover para obtener el mismo efecto.

*,
*:before,
*:after {
  box-sizing: border-box;
}

body {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-flex-flow: row wrap;
      -ms-flex-flow: row wrap;
          flex-flow: row wrap;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
      -ms-flex-pack: center;
          justify-content: center;
  font-size: 62.5%;
  padding: 1.5rem;
  text-align: center;
}

.btn {
  background: -webkit-linear-gradient(top, #fbfbfb, #f5f5f5);
  background: linear-gradient(to bottom, #fbfbfb, #f5f5f5);
  border: 1px solid #ccc;
  border-radius: 2px;
  box-shadow: 0 1px 2px 0px rgba(0, 0, 0, 0.15);
  color: #222;
  font-family: 'segoe ui';
  font-size: .9rem;
  margin: 10px;
  padding: .5rem 1rem;
  -webkit-transition: box-shadow .2s ease;
  transition: box-shadow .2s ease;
}
.btn:hover {
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15), 0 5px 5px rgba(0, 0, 0, 0.12);
}
.btn:focus {
  outline: none;
}
.btn.green {
  background: #16a085;
  border-color: #16a085;
  color: #fff;
}
.btn.blue {
  background: #2980b9;
  border-color: #2980b9;
  color: #fff;
}
.btn.gold {
  background: #f39c12;
  border-color: #f39c12;
  color: #fff;
}
.btn.red {
  background: #c0392b;
  border-color: #c0392b;
  color: #fff;
}
.btn.blue {
  background: #2980b9;
  border-color: #2980b9;
  color: #fff;
}

[tooltip] {
  position: relative;
}
[tooltip]:before, [tooltip]:after {
  -webkit-transition: opacity .2s ease, -webkit-transform .2s ease;
  transition: opacity .2s ease, -webkit-transform .2s ease;
  transition: opacity .2s ease, transform .2s ease;
  transition: opacity .2s ease, transform .2s ease, -webkit-transform .2s ease;
  -webkit-transform: translateY(15px);
          transform: translateY(15px);
  pointer-events: none;
  z-index: 5;
}
[tooltip]:before {
  content: "";
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 9px solid rgba(0, 0, 0, 0.9);
  left: 6px;
  opacity: 0;
  position: absolute;
  top: 110%;
}
[tooltip]:after {
  background-color: rgba(0, 0, 0, 0.9);
  border-radius: 4px;
  color: #fff;
  content: attr(title);
  display: inline-block;
  left: 0px;
  padding: .3rem .4rem;
  opacity: 0;
  position: absolute;
  top: 130%;
  width: 125px;
}
[tooltip]:hover:before, [tooltip]:hover:after {
  opacity: 1;
  -webkit-transform: translateY(0px);
          transform: translateY(0px);
}
<button
  class="btn"
  tooltip
  title="Press me!"
>
  Normal
</button>
<button
  class="btn green"
  tooltip
  title="Confirm changes"
>
  Success
</button>
<button
  class="btn gold"
  tooltip
  title="Be careful!"
>
  Warning
</button>
<button
  class="btn red"
  tooltip
  title="Are you sure?"
>
  Danger
</button>
<button
  class="btn blue"
  tooltip
  title="Press me too!"
>
  Primary
</button>

Actualización
Veo que has editado otra vez tu pregunta. Espero que esta vez hayas dicho extactamente qué quieres hacer. Lo que deseas es mostrar un diálogo flotante, como una especie de modal. Ya que has puesto la etiqueta jQuery, te daré una respuesta en base a ella.
Lo que haremos será extender el prototipo de jQuery.

$.fn.extend({
  tooltip: function(settings) {
    return this.each(function() {
      // 40 -> para que no esté muy pegado
      var top = $(this).offset().top + 40;
      var left = $(this).offset().left;
      // diálogo objetivo
      var dialog = $($(this).attr('target'));
      // centrado horizontal:
      // originW -> ancho del disparador (botónn, link, etc)
      // dialogW -> ancho del dialogo objetivo
      originW = $(this).width();
      dialogW = dialog.width();

      // posiciona los dialogos. El centrado lo hace en base a:
      // [ancho_dialogo / 2] - (ancho_disparador / 2)
      var centerMargin = (dialogW / 2) - (originW / 2);
      top += $(this).height();
      var cssTop = (top + settings.extraMargin) + 'px';
      var cssLeft = (left - centerMargin) + 'px';
      dialog.css('transform', 'translate(' + cssLeft + ', ' + cssTop + ')');

      $(this).on('click', function() {
        var status = dialog.attr('status');
        // está oculto, se debe mostrar
        if(status === 'hidden') {
          showTooltip();
        } else {
          hideTooltip();
        }
      });

      var showTooltip = function() {
        var _cssTop = top + 'px';
        dialog.css('opacity', '1');
        dialog.css('visibility', 'visible');
        dialog.css('transform', 'translate(' + cssLeft + ', ' + _cssTop + ')');
        dialog.attr('status', 'visible');
      }

      var hideTooltip = function() {
        dialog.css('opacity', '0');
        dialog.css('visibility', 'hidden');
        dialog.css('transform', 'translate(' + cssLeft + ', ' + cssTop + ')');
        dialog.attr('status', 'hidden');
      }
    });
  }
});

$('[toggle="tooltip"]').tooltip({ extraMargin: 40 });
@import "https://fonts.googleapis.com/css?family=Lato:400,700";
*,
*:before,
*:after {
  box-sizing: border-box;
}

body {
  -webkit-box-align: center;
  -webkit-align-items: center;
      -ms-flex-align: center;
          align-items: center;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  height: 100vh;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
      -ms-flex-pack: center;
          justify-content: center;
  padding: 2rem;
}

.btn {
  background: -webkit-linear-gradient(top, #fbfbfb, #f5f5f5);
  background: linear-gradient(to bottom, #fbfbfb, #f5f5f5);
  border: 1px solid #ccc;
  border-radius: 2px;
  box-shadow: 0 1px 2px 0px rgba(0, 0, 0, 0.15);
  color: #222;
  cursor: pointer;
  font-family: 'lato';
  font-size: .9rem;
  padding: .5rem 1rem;
  -webkit-transition: box-shadow .2s ease;
  transition: box-shadow .2s ease;
}
.btn:hover {
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15), 0 5px 5px rgba(0, 0, 0, 0.12);
}
.btn:focus {
  outline: none;
}
.btn.rounded {
  border-radius: 100%;
  height: 40px;
  padding: .4rem 0;
  text-align: center;
  width: 40px;
}
.btn.green {
  background: #16a085;
  border-color: #16a085;
  color: #fff;
}
.btn.green.outline {
  background-color: #fff;
  border: none;
  color: #16a085;
  box-shadow: none;
  font-weight: 600;
  text-transform: uppercase;
}
.btn.green.outline:hover {
  box-shadow: none;
}
.btn.pink {
  background: #F62459;
  border-color: #F62459;
  color: #fff;
}

[tooltip] {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25), 0 2px 10px rgba(0, 0, 0, 0.1);
  display: inline-block;
  left: 0px;
  opacity: 0;
  position: absolute;
  top: 0px;
  -webkit-transition: opacity .2s ease, visibility .2s ease, -webkit-transform .2s ease;
  transition: opacity .2s ease, visibility .2s ease, -webkit-transform .2s ease;
  transition: transform .2s ease, opacity .2s ease, visibility .2s ease;
  transition: transform .2s ease, opacity .2s ease, visibility .2s ease, -webkit-transform .2s ease;
  visibility: hidden;
}
[tooltip] header {
  background-color: #f2f2f2;
  border-bottom: 1px solid #e8e8e8;
  padding: .25rem .8rem;
}
[tooltip] header p {
  color: #222;
  font-family: 'lato';
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
[tooltip] .body {
  padding: .7rem 1rem;
}
[tooltip] .body h3 {
  font-family: 'lato';
  font-size: 17px;
  font-weight: 400;
  text-align: center;
}
[tooltip] .body .buttons {
  margin-top: 30px;
  text-align: center;
}
[tooltip] .body .buttons * {
  margin: 0 10px;
}
[tooltip]:before {
  content: "";
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 9px solid #f2f2f2;
  left: 47%;
  opacity: 1;
  position: absolute;
  top: -9px;
}

<button
  class="btn pink rounded"
  toggle="tooltip"
  target="#hacer-algo">
  ★
</button>

Favoritos

      ¿Desea agregar a favoritos?

      <button class="btn outline green">
        Confirmar
      </button>

Para usar esta minilibrería, solo basta hacer:
$('[toggle="tooltip"]').tooltip({ extraMargin: 40 });

Donde extraMargin es el margin vertical extra que se le da al tooltip, para que pueda haber el efecto de trasladar verticalmente.

A: Si el botón se repite "x" veces pero la funcionalidad es la misma puedes usar una clase para identificarlos y con jquery en el evento click mostrar la ventana Modal.


text:
Q: Finding the first and second moments from mgf and finding general formula for nth moment Suppose that the random variable Y has the moment generating function:
$M_y(t) = \frac{1}{5}(e^{-2t} + e^{-t} + 1 + e^t + e^{2t})$
for all real t.
1) Find $E[Y]$ and $VAR[Y]$.
2) Give a general formula for calculating $E[Y^n]$ for all n.
For problem 1, I took the derivative of the mgf and set t=$0$ and got $E[Y] = 0$ and then I took the second derivative and got $VAR[Y] = 2$.
Then for problem 2, I tried taking the derivative a couple more times and what I got was:
$M_{y^n}(t) = \frac{1}{5}((-1)^n2n + (-1)^n + 1 + 2n)$.  This seemed to work whenever $t=0$ but I may be wrong.  Any insight is greatly appreciated.

A: Compute the successive derivatives of $e^{2t}$. We get $2e^{2t}, 4e^{2t}, 8e^{2t}$, and so on. The $n$-th derivative is $2^ne^{2t}$.
Similarly, the $n$-th derivative of $e^{-2t}$ is $(-2)^ne^{-2t}$, which perhaps looks better as $(-1)^n2^ne^{-2t}$. Thus the $n$-th derivative $M^{(n)}(t)$ of the moment generating function is given by
$$M^{(n)}(t)=\frac{1}{5}\left((-1)^n 2^n e^{-2t} +(-1)^ne^{-t}+e^t+2^n e^{2t}\right).$$
Evaluating at $0$, we get
$$M^{(n)}(0)=\frac{1}{5}\left((-1)^n 2^n +(-1)^n+1+2^n\right).$$
Note that the $n$-th derivative at $0$ is $0$ for all odd $n$. For even $n$, it is $\dfrac{2}{5}(2^n+1)$.


text:
Q: How to fix a class method function from a module giving a variable not defined error So I am trying to create a simpler logging module, but I keep getting errors that make no sense.
The module is located in %appdata%/python/site-packages/loggingLocal/__init__.py
The modules code is as follows:
class Logger:

    def __init__(self):

        pass

    @classmethod

    def llog(cls, file, typeM, message):

        llog_f = open(file, "a")
        llog_f.write("\n" + typeM + ": " + message)
        llog_f.close

The code that I am using to utilize the module is as follows:
import loggingLocal.__init__

logOb = Logger()

lfile = "logs/log.txt"

logOb.llog(lfile, "test", "testing testing 1 2 3")

I expect the file in logs/log.txt to contain test: testing testing 1 2 3 , but I get an error: Undefined variable 'Logger' on line three. This makes no sense as I am assigning logOb to the Logger class, not a variable.
I would like to note that I know I am not doing things in the most efficient way, but thats not what I am here for.

A: loggingLocal.py
class Logger:

    def __init__(self):

        pass

    @classmethod

    def llog(cls, file, typeM, message):

        llog_f = open(file, "a")
        llog_f.write("\n" + typeM + ": " + message)
        llog_f.close

main.py:
from loggingLocal import Logger

logOb = Logger()

lfile = "logs/log.txt"

logOb.llog(lfile, "test", "testing testing 1 2 3")

A: When you import a module, you get only the module's name added to your local namespace, not all of the contents of the module (though you can get that if you specifically ask for it).
So if you do import loggingLocal (the __init__ part is not needed, more about it below), you'll only get the name loggingLocal in your main module's namespace. To access the Logger class within it, you need to use loggingLocal.Logger.
Or you can specifically state specific names that you want to copy from the imported module into your own namespace, using the alternative import syntax from some_module import some_name. In your case, you'd probably want from loggingLocal import Logger. You can give multiple names if you want, or you can give a * instead of any names, in which case you'll get either whatever names are listed in the module's __all__ attribute, or every global variable in the other module that has a name that doesn't start with an underscore.
There are some other small errors in your code. One I alluded to above, where you're naming the __init__ part of the module name in your import statement. That's not needed. __init__.py is a filename used for the module that makes up the root part of a package. That is, foo/__init__.py becomes the foo module. If you don't need a package for some other reason (e.g. because you also have foo/bar.py and foo/baz.py, which can be imported as foo.bar and foo.baz), you probably shouldn't use that structure. Instead, just rename your localLogging/__init__.py file to localLogging.py and get rid of the subdirectory.
The other issue is in your implementation of Logger. When you try to close the file you've created in llog, you're not actually succeeding. You only reference the close method, but never actually call it (you probable wanted to do llog_f.close()). I'd recommend using a with statement to handle the opening and closing of the file instead:
with open(file, "a") as llog_f:
    llog_f.write("\n" + typeM + ": " + message)

This code will automatically close the file at the end of the indented block that follows the with statement. It will even close the file if there's an exception that causes the block to exit in an abnormal way.


text:
Q: INSERT IGNORE INTO producing error 1109 unknown table in WHERE clause I'm trying to create an INSERT IGNORE INTO statement, to pull user details from a new reglist table into an existing membership table, omitting rows where the email address is already in the membership table.
Here's what I have so far:
INSERT IGNORE INTO members (Email, FirstName, LastName, SectorName, ECR, Gender, UserLocation, JoinDate)
    SELECT Email, FirstName, LastName, SectorName, ECR, Gender, UserLocation, RegDate
    FROM reglist1 as r
    WHERE r.Email NOT IN (SELECT Email FROM members);

However, I am getting: "Error Code: 1109. Unknown table 'members' in where clause"
When I run SELECT Email FROM members; alone it works fine. So I can't figure out why the table is unknown when included in the INSERT statement.
I've tried aliasing members in the first line members m but that flags as an error even before attempting to run.
Thanks for your help.


text:
Q: jquery.toggle and layout issues when used in table I have a table. Each row is a record. If you click on a row (record), via jquery, I create a new TR below it, and then insert a new table (related sub-set of data pertaining to the above record) via AJAX. This is first loaded and then I expand the TR in a nice animated fashion.
It looks good.
Now that it's loaded and expanded, I want to easily toggle this TR so one can collapse them and expand them without reloading the content via AJAX.
The obvious/simplest option is to change the event handler for the trigger and give it a TOGGLE event.
Functionally, this works. Aesthetically, though, it's a completely mess.
When I first .toggle to close, the content of the new TR does collapse nicely, but the rest of the parent table doesn't follow until the TR is completely collapsed, then the parent table quickly collapses to fill the gap. This is jarring.
Then, on the next .toggle to open, the child table animates outside of the parent table, then quickly collapses its width. Also very jarring and now I'm left with a very narrow table compared to its parent.
If I omit the animation from the toggle event, it works fine, albeit without the nice transition. I'm guessing this is perhaps more CSS related the jQuery related? Any pointers as to what I might need to declare CSS-wise to keep this erratic visual behavior from happening?
EDIT: per matt's request, markup/script:

    link

        ... my nested table is here ...

The jquery I use for the toggle:
$("td a.expandable").click(function(){
    //jquery here that does the initial creation of the TR and loading of the AJAX...

    // after loading ajax, remove the event
    $(this).unbind('click');
    // and then attach the new toggle event
    $(this).closest("tr").next("tr.expandedContent").toggle("slow");

    return false;
});

A: Try to collapse/expand nested table rather it's container.

A: Animations on table (and tr) elements (especially height) are flaky, at best. Try writing your markup using div's and whatnot and you'll have much better luck.


text:
Q: True False Converging and Diverging Questions could I please get help with the following true/false questions? I have been trying to use the theorems in my textbook, but just don't feel too sure on where I'm at...

*

*(infinity upper bound, k=1 on the bottom)If ∑ak converges, then when k=10 it also converges. I said TRUE.

*(infinity upper bound, k=1 on the bottom)If ∑ak diverges, then when k=10 it also diverges. I said TRUE.

*If just ∑ak converges, then ∑(ak+.00001) also converges (I'm not sure)

*If ∑p^k diverges, then ∑(p+.001)^k diverges, for a fixed real number p. True? (not sure)

*If ∑k^-p converges, then ∑k^(-p+.001) converges. Again I feel like this is TRUE.

*If limit as k approaches infinity ak=0, then ∑ak converges. True (I feel fairly confident on this one)
Thank you to all who respond!!


text:
Q: Data is not getting retried using firebaseUI I am following a youtube video in which I was trying to retrieve data using FirebaseUI but I am not able to show any data in the recyclerview.
Here is the code
public class MemeFragment extends Fragment {
    RecyclerView recyclerView;
    FirebaseDatabase firebaseDatabase;
    DatabaseReference myref;
    FirebaseRecyclerAdapter<Datafileinfo, ShowDataViewHolder> firebaseRecyclerAdapter;
    FirebaseRecyclerOptions<Datafileinfo> options;

    public MemeFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_meme, container, false);
        firebaseDatabase = FirebaseDatabase.getInstance();
        myref = FirebaseDatabase.getInstance().getReference("memes");
        recyclerView = (RecyclerView) view.findViewById(R.id.recyc);
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        options = new FirebaseRecyclerOptions.Builder<Datafileinfo>()
                        .setQuery(myref, Datafileinfo.class)
                        .build();
        return view;
    }

    @Override
    public void onStart() {
        super.onStart();
        firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Datafileinfo, ShowDataViewHolder>
                (options) {
            @Override
            protected void onBindViewHolder(@NonNull ShowDataViewHolder holder, int position, @NonNull Datafileinfo model) {
                holder.ImageTitle(model.getTitle());
                holder.ImageUrl(model.getImage());
            }

            @Override
            public ShowDataViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.custo, parent, false);
                return new ShowDataViewHolder(view);
            }
        };
        recyclerView.setAdapter(firebaseRecyclerAdapter);
    }

    public static class ShowDataViewHolder extends RecyclerView.ViewHolder {
        private ImageView imageView;
        private TextView textView;

        public ShowDataViewHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.imageView);
            textView = (TextView) itemView.findViewById(R.id.textView);
        }

        private void ImageTitle(String title) {
            textView.setText(title);
        }

        private void ImageUrl(String url) {
            Glide.with(itemView.getContext()).
                    load(url).
                    into(imageView);
        }
    }
}

and datafileinfo is the getter and setter class I have also taken the internet permission.Note I am able to get the single value from firebase but for multiple values, I am facing a problem this is the database.
where I am doing wrong any idea??
Note I have followed and gone through all the tutorials and similar post.

A: Create a separate Class for your ViewHolder
    public class ShowDataViewHolder extends RecyclerView.ViewHolder{

    private ImageView imageView;
    private TextView textView;

    public ShowDataViewHolder (View itemView) {
        super(itemView);
        imageView = (ImageView)itemView.findViewById(R.id.imageView);
        textView = (TextView) itemView.findViewById(R.id.textView);
    }
 }

In your MenuFragment add
    DatabaseReference mDatabaseMemes= //your reference to memes node

    FirebaseRecyclerAdapter<yourModel, ShowDataViewHolder> adapter= new FirebaseRecyclerAdapter<yourModel, ShowDataViewHolder>(yourModel.class, R.layout.yourLayout,
    ShowDataViewHolder.class,mDatabaseMemes) {
        @Override
        protected void populateViewHolder(ShowDataViewHolder viewHolder, yourModel model, int position) {
            viewHolder.textView.setText(model.getTitle());
            Glide.with(context)
                    .load(model.getImage())
                    .fitCenter()
                    .into(viewHolder.imageView);

        }
    };
    recyclerView.setAdapter(adapter);
}

MAKE SURE your model class has String title and image same as your child names under memes node.


text:
Q: MYSQL SELECT - Can't select matching strings from joined tables I have a list of email addresses for registrants at an upcoming trade show. I created this table:
CREATE TABLE dolp21 (email VARCHAR(50) UNIQUE NOT NULL);

My contacts table contains a column: email VARCHAR(50) NOT NULL
I am trying to see which of these registrants is an existing client. Here is my query in workbench that returns 0 results and no errors even though I can immediately see several email addresses that I recognize as being existing clients:
SELECT CONCAT(c.firstName,' ',c.lastName) AS 'Contact'
FROM contacts c
JOIN dolp21 d ON TRIM(lcase(d.email))=TRIM(lcase(c.email))
ORDER BY c.lastName, c.firstName
;

Any idea why I'm not getting any matches?

A: When I exported the dolp21 table to CSV file and then opened the CSV file in Notepad++, I discovered that each email address was followed by two carriage returns inside the quotes and then of course a line feed at the end of each row like so:
"name@company.comCRCR"LF
"person@business.comCRCR"LF
I ran an update query to clean that up and now my select query works!


text:
Q: Can't add foreign key to a table I've checked that none of the two tables has any foreign keys. I've checked that they both have Id of type uniqueidentifier. I runt the script and get this eror.
ALTER TABLE [dbo].[Records]
ADD CONSTRAINT [FK_dbo.Records_dbo.Users_UserId]
FOREIGN KEY ([UserId])
REFERENCES [dbo].[Users] ([Id])
--ON DELETE CASCADE

The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_dbo.Records_dbo.Users_UserId". The conflict occurred in database "MyDb", table "dbo.Users", column 'Id'.

Not sure how to troubleshoot it... Tested both with and without the cascade...

A: Most likely you have a UserId in the Records table that does not exist in the Users table. This will certainly happen if you've been using 0 or some other value as a "default" value.

A: It must be something to do with the existing data.  There must be some records conflicting the foreign key creation.  Try to create the key on an empty schema to see if it works.  Use WITH NOCHECK to not to check existing rows at the time of foreign key creation, if you need that data.


text:
Q: An easy way to delete a file in Rhythmbox play queue When I listen music, I want to delete a file if the music in play queue is not good to me.
But there is only 'remove from play list'. This is not what I want. I want to delete the file.
Clicking property, and check it's location. Then open file explorer, and delete the file. This is what I'm doing for the deletion. It makes me crazy.
Is there an easy way to delete a file in Rhythmbox play queue.

A: You can not. From the play queue you can only remove the file from the queue since it is a temporary list of the songs you have chosen to listen. The real list of songs is in the Music Option
in this picture you see the Music section to the left. In the list below is where you can delete files. Right click on them and Move to trash for example. That will remove it. But to not have from the queue and remove you need to remove it from Queue and the delete like i said from the Music section.

A: By the way you ask your question, can I assume that the song you want to remove is the one currently playing? If that is the case, then you can press CTRL+J which makes the interface jump to the currently playing song. From there, moving to trash is a right-click away.

A: There is an extension which is devoted for this.
Rhythmbox song deleter
I have written it to solve this problem when  I didn't found anything that could solve this problem.
This is how it works:

You press a key and it shows you messagebox that song was trashed.

A: Fave a look here, it's exactly what you're looking for. It even has configurable keyboard shortcuts:
http://sourceforge.net/projects/rhythmboxdelete/


text:
Q: Farthest Smaller Element in an Array In an unsorted positive integer array, how to find out the farthest smaller element on the right side of each element in most efficient way?

Ex:
  Input:    6  3  1  8  2  9  7
  Output: 2  2 -1  7 -1  7 -1

Explanation:
For 6, the smaller elements on it's right side are [3, 1, 2]. Since the last smallest element is 2, it's the most farthest from 6.
Like wise for others.
If no such number exists answer is "-1"

A: One idea is:

*

*let us call the original array A

*keep an array min[] of size n of which min[i] means the minimum value of the sub-array A[i..n-1]. Obviously, min[i] <= min[i+1].

*now move from right to left on A. At every index i, do a binary search on min[i+1..n-1] to find the farthest smaller value.

Java code:
    int[] A = { 6, 2, 3, 10, 1, 8 };
    int n = A.length;
    // calculate min
    int[] min = new int[n];
    min[n - 1] = A[n - 1];
    for (int i = n - 2; i >= 0; i--)
        min[i] = Math.min(A[i], min[i + 1]);
    // calculate results
    int[] results = new int[n];
    results[n - 1] = -1;
    for (int i = n - 2; i >= 0; i--) {
        int left = i; // after the binary search, A[left] would be the answer
        int right = n - 1;
        while (left < right) {
            int mid = left + (right - left + 1) / 2;
            if (min[mid] < A[i])
                left = mid;
            else
                right = mid - 1;
            if (min[left] < A[i])
                results[i] = min[left];
            else
                results[i] = -1;
        }
    }

Space complexity O(n)
Time complexity O(nlogn) for all cases.
Compared to the solution from @vivek_23, the above algorithm would be better in the following worst case:
Imagine the case of A of n elements as follows
A = [ n/2 n/2 .. n/2 1 2 .. n/2]
If we use the stack solution suggested by @vivek_23,

*

*at the step to find the farthest smaller element of any of the first n/2 elements (which are all valued n/2), st1 should be now [1 2 .. n/2]

*for each element valued n/2, all st1 elements except n/2 will be transferred to st2 in order to find the farthest smaller element n/2 - 1. After that all elements in st2 will be transferred back to st1. This results in the worst case performance of O(n). As there are n/2 elements, the total worst time performance is O(n^2).

A: *

*The basic idea  behind the getting the answer quickly is to use a stack when moving from right to left in the array.

*We insert an element in the stack only in one of the below 2 conditions,

*

*If the stack is empty.

*If the current top element in the stack is greater than the current element in iteration.

*This would ensure us the correct results since a number greater than the current element in iteration will always be anyway greater than the current element at the top of the stack and current top at stack also wins over the farthest criteria.

*So, insert in stack only if less than the current top.

*However, it's quite possible that current element in iteration has many elements in stack smaller than itself. So, we need to go deep in stack till we find an element in stack greater than the current one.
Implementation(in java):
    int[] arr = {6,3,1,8,2,9,7};
    Stack<Integer> st1 = new Stack<Integer>();
    Stack<Integer> st2 = new Stack<Integer>();
    List<Integer> result = new ArrayList<>();

    for(int i=arr.length-1;i>=0;--i){
        while(!st1.isEmpty() && arr[(int)st1.peek()] < arr[i]){
            st2.push(st1.pop());
        }

        if(st2.isEmpty()) result.add(-1);
        else result.add(arr[(int)st2.peek()]);

        while(!st2.isEmpty()) st1.push(st2.pop());

        if(st1.isEmpty() || arr[(int)st1.peek()] > arr[i]){
            st1.push(i);
        }
    }

*

*The above implementation follows the explanation provided.

*We use 2 stacks to not lose the popped data as it would be useful for future elements.

*So, we revert all back to the main stack once the answer is found for the current element.

Demo: https://ideone.com/0oAasu
Note: You can directly store elements in the stack instead of indexes to make it more simpler.
Update: This solution's complexity is indeed O(n^2) for case where array could have elements in [ n/2, n/2 ,.. n/2, 1, 2, .. n/2] fashion for an array of size 10^5 or more. See Quynh Tran's answer for a better solution.

A:     int arr[]={6,3,1,8,2,9,7};
    for(int i=0;i<arr.length;i++){
        int min=-1;
        for(int j=i+1;j<arr.length;j++){
            if(arr[j]<arr[i]){
                min=arr[j];
            }
        }
        arr[i]=min;
    }


text:
Q: Use a div as a submit button I want to transform a div composed of image + text (for translation) in a submit button. Is it possible?
I managed to use the image as submit but the text is not a link and it gives a 'broken' feeling to the whole image + text

A: You can do it in two ways.

*

*You can use a button with type submit and use CSS to style it as a div

*Add an onClick on the div, and submit the form on the click event.

For method 2 you can either do it through jQuery or without, With plain js

<form id="myForm" ...>
    ....

        ...

    ...
</form>

Trevor's answer shows how to do it with jQuery.
In his example just replace the 'div' and 'form' with the ids of your div and form as this:
If ids of div and form are myDiv and myForm specify them as '#myDiv' and '#myForm', here # is used to specify the following string is an id of an element.

A:

A: Jquery usage.
$('div').click(function () {
    $('form').submit();
});


text:
Q: UTF-8 and PHP, mbstring.func_overload doesn't work  I have:
ini_set('mbstring.internal_encoding','UTF-8');
ini_set('mbstring.func_overload',7);

echo strlen("õôóõêç");

The strlen prints 12, instead of 6.
Any suggestion?
http://php.net/manual/en/mbstring.overload.php

A: mbstring.func_overload can only be set from php.ini (or httpd.conf), and not at runtime.


text:
Q: Plot result of a loop in same figure - heatmap i created a dataframe with random columns and values. now i am trying to interate with an loop over "time" window" (maybe there is a more elegant solution than mine). i try to plot the calculated correlations in a heatmap and then interate furhter and show the next result in the same figure. Like this
https://datasoaring.blogspot.com/2018/07/gdp-correlation-matrix-top-10-economies.html
The current code plot a new figure for each correlation...
Thanks for ideas and help!

Creates Dataframe

import pandas as pd
import numpy as np

%matplotlib inline
import matplotlib.pyplot as plt
import time

import seaborn as sns
sns.set_style('white')

plt.style.use('dark_background')

index = pd.date_range('01/01/2010',periods=num_days, freq='D')
data_KW = pd.DataFrame(np.random.randint(0,250,size=(250, 10)), columns=list('ABCDEFGHIJ'), index=index)

data_KW.head()

interate and plot (wrong :))

# Calculate the lenght of the Dataframe
end = 10 #len(data_KW.index)

# is the variable for the rolling window
var_start = 0
var_end = 5

#Set up the matplotlib figure
f, ax = plt.subplots(figsize=(5, 5))

while var_end <= end:
    window = data_KW.iloc[var_start : var_end]

    # Compute the correlation matrix
    corr = window.corr()

    # Generate a mask for the upper triangle
    mask = np.zeros_like(corr, dtype=np.bool)
    mask[np.triu_indices_from(mask)] = True

    # Generate a custom diverging colormap
    cmap = sns.diverging_palette(220, 10, as_cmap=True)

    # Draw the heatmap with the mask and correct aspect ratio
    sns.heatmap(corr, mask=mask, cmap=cmap, vmax=1, center=0,
                square=True, linewidths=.5, cbar_kws={"shrink": .5})

    #plt.pause(3)
    plt.show()
    time.sleep(2)

    #time.sleep(5)
    var_start = var_start + 1
    var_end = var_end + 1

    print(var_start)


text:
Q: Mechanical keyboard switches: linear, soft, click. What is the difference? I intend to buy a keyboard with mechanical switches.
Some are available with different types of switches.
Deck has linear and tactile.
Cherry has three different types which are sometimes referred to by their color:

*

*Linear = black

*Soft = brown

*Click = blue

I found enough technical information about the different types (even force-deflexion graphs), but
that doesn't really help to decide which fits me best.
As it's not easily possible to try all of them I'd like to know about your experiences.
If you have a mechanical keyboard and know what type of switches it contains, I'd like to hear your opinion.
I also would like to know which type of switches the 'Das Keyboard' uses. People seem to be happy with it so this type is probably OK.

A: I have always been an enormous fan of the IBM Model M keyboard, pictured here:

The Model M's keys use a buckling spring mechanism.  You will be absolutely certain when you have pressed a key.
Not only do you feel it, but also you hear it.  The Model M emits a loud click whenever a key is pressed or released.
The Model M has removable, swappable keycaps, is dishwasher safe, and is virtually bulletproof.
If you haven't tried using a Model M, then you're missing everything!

A: I believe that over the time, I've used all of them (keyboard switch types), and although one can feel the difference after switching from one to another, it hardly mattered in the long run. Key distribution was always more important.
I really can't see it making any difference that's worth fussing about.
The sound of the key upon pressing can be sometimes important. I'm still searching for a keyboard which will have that distintive feel upon pressing, while still being quiet (my home workdesk is in the bedroom, which can present problems if someone is sleeping). Same goes for the mouse.


text:
Q: Creating range from normal collection index and reversed collection index (Simplified example of a bigger problem. Yes, I know that this specific dumbed down example can be solved in much easier ways.)
I have a collection containing some ASCII code points of which I'd like to remove leading and trailing spaces.
func foo<T: BidirectionalCollection>(_ buffer: T) -> String
    where T.Iterator.Element == UInt8,
          T.SubSequence.Iterator.Element == T.Iterator.Element
{
    if let valueStart = buffer.index(where: { $0 != 0x20 /* SP */ }),
       let valueEnd = buffer.reversed().index(where: { $0 != 0x20 /* SP */ })
    {
        return String(bytes: buffer[valueStart ... valueEnd], encoding: .utf8)!
    } else {
        return ""
    }
}

However, I get this error:

error: binary operator '...' cannot be applied to operands of type 'T.Index' and 'ReversedIndex'

The documentation of BidirectionalCollection states:

If you need a reversed collection of the same type, you may be able to use the collection's sequence-based or collection-based initializer.

However, when I try embedding buffer.reversed() in a T(), I get this error:

error: 'T' cannot be constructed because it has no accessible initializers

Because, apparently, the initializers are defined somewhere else.
In the end, I don't need the whole reversed collection to be of a certain type. I just want to be able to build ranges from the original collection's indices and the corresponding reversed collection's indices.
What am I overlooking here?

A: In order to get the index for the underlying collection from a ReversedIndex, you can simply use its base property.
Although note that because of the way ReversedCollection is implemented, this will actually return the index above the given index in the base collection (as startIndex is mapped to endIndex – which is a 'past the end' index).
Therefore you can simply use a half-open range operator ..< in order to make this index the non-inclusive upper bound:
func foo<T: BidirectionalCollection>(_ buffer: T) -> String
    where T.Iterator.Element == UInt8,
    T.SubSequence.Iterator.Element == T.Iterator.Element
{
    if let valueStart = buffer.index(where: {$0 != 0x20}),
        let valueEnd = buffer.reversed().index(where: {$0 != 0x20})?.base
    {
        // goes without saying that this will crash if String(bytes:encoding:) returns nil.
        return String(bytes: buffer[valueStart ..< valueEnd], encoding: .utf8)!
    } else {
        return ""
    }
}

Or, in cases where you need to work with the index itself, you could use Optional's map(_:) method in conjunction with the collection's index(before:) method to get the index before:
let index = (buffer.reversed().index{ $0 != 0x20 }?.base).map{ buffer.index(before: $0) }


text:
Q: Objective-C blocks Trying to understand how blocks working in objective-c. Got next question while reading apple's docs (link)
Here is an example how we should no use blocks:
void dontDoThis() {
    void (^blockArray[3])(void);  // an array of 3 block references

    for (int i = 0; i < 3; ++i) {
        blockArray[i] = ^{ printf("hello, %d\n", i); };
        // WRONG: The block literal scope is the "for" loop.
    }
}

But how we could get 3 different blocks that will print "hello, 0", "hello, 1" and "hello, 2"? I tried many different ways but every time I got "hello, 2" three times.

A: A block starts out life on the stack and, thus, a block's lifespan is only as long as the scope it is declared in.
The body of a for() loop -- the body of the loop in the {}s -- is a scope in and of itself.  Thus, your code is putting a reference to something on the stack [the block] into a variable in the surrounding scope [the language array].
You need to copy the block to the heap to have it survive:
void dontDoThis() {
    void (^blockArray[3])(void);  // an array of 3 block references

    for (int i = 0; i < 3; ++i) {
        blockArray[i] = [^{ printf("hello, %d\n", i); } copy];
    }
}

If not using ARC, you would also need to -release the copied blocks at some point.
You might find this weblog post handy (I wrote it shortly after Blocks were made public).  This one goes into a few tips, tricks, and gotchas.

Wait -- yeah -- you're correct.  There is magic going on in the ARC compiler that is causing the blocks to seemingly be on the heap magically.   However, I can't find anything in the LLVM documentation that explicitly documents this behavior.   If you turn off ARC, you'll see the output be something like 2,2,2 instead of 0,1,2.
This is somewhat new behavior.   I wouldn't rely on this behavior until someone can find the explicit note in the compiler that defines exactly how this is supported.

@autoreleasepool {
    void (^blockArray[3])(void);  // an array of 3 block references

    for (int i = 0; i < 3; ++i) {
        void (^block)(void) = ^{ printf("hello, %d\n", i); };
        NSLog(@"%p", block);
        blockArray[i] = block;
        NSLog(@"%p", blockArray[i]);
    }

    for (int i = 0; i < 3; ++i) blockArray[i]();
}

Outputs:
2012-12-24 16:15:36.752 jkdfjkfdjkdfjk[70708:303] 0x7fff5fbff838
2012-12-24 16:15:36.755 jkdfjkfdjkdfjk[70708:303] 0x100108160
2012-12-24 16:15:36.758 jkdfjkfdjkdfjk[70708:303] 0x7fff5fbff838
2012-12-24 16:15:36.759 jkdfjkfdjkdfjk[70708:303] 0x100108000
2012-12-24 16:15:36.760 jkdfjkfdjkdfjk[70708:303] 0x7fff5fbff838
2012-12-24 16:15:36.760 jkdfjkfdjkdfjk[70708:303] 0x100102e70
hello, 0
hello, 1
hello, 2

Thus, the block is created on the stack and copied to the heap automatically on the assignment outside of the scope of the for() loop.
A similar test also reveals that the block will be copied when passed as an argument to NSArray's addObject:.

A: If you really wanted to get this to work you could use an NSMutableArray instead of a C array.

    NSMutableArray *blocks = [NSMutableArray array];
for (int i = 0; i <= 3; i++) {
  blocks[i] = ^{ printf("hello %d\n", i); };
}

By adding them to an NSMutableArray they will be copied off of the stack and onto the heap allowing them to outlive the scope of the for loop.
As @bbum points out the above does not work, I took the idea that blocks just work with ARC too far.
You would need to actively copy the blocks for them to work... so the following should work
NSMutableArray *blocks = [NSMutableArray array];

for (int i = 0; i <= 3; i++) {
  blocks[i] = [^{ printf("hello %d\n", i); } copy];
}


text:
Q: SQL Grammar Exception in persist() I'm trying to persist an entity, but I receive an error:
could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement

while executing
public void createTransaction(PositionTransaction account){
        em.persist(account);
        em.refresh(account);
    }

all account fields are filled (except id - it is an IDENTITY)

Here is my mapping of PositionTransaction:
@Entity
@Table(name = "POSITION_PROJ_TRANSACTION")
public class PositionTransaction {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ID", columnDefinition = "NUMERIC(15, 0)",unique = true,nullable = false)
private Long id;

@Column(name = "VALUE_DATE")
private LocalDate valueDate;

@Column(name = "AMOUNT")
private BigDecimal balance;

@Column(name = "COMMENT")
private String comment;

@Column(name = "STATUS")
private Integer status;

@ManyToOne
@JoinColumn(name = "PARENT_ID")
private FaAccount positionAccount;
public FaAccount getPositionAccount() { return positionAccount; }
public void setPositionAccount(FaAccount positionAccount) {
    this.positionAccount = positionAccount;
}

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public LocalDate getValueDate() {
    return valueDate;
}

public void setValueDate(LocalDate valueDate) {
    this.valueDate = valueDate;
}

public BigDecimal getBalance() {
    return balance;
}

public void setBalance(BigDecimal balance) {
    this.balance = balance;
}

public String getComment() {
    return comment;
}

public void setComment(String comment) {
    this.comment = comment;
}

public Integer getStatus() {
    return status;
}

public void setStatus(Integer status) {
    this.status = status;
}

@Override
public String toString() {
    return "PositionTransaction{" +
            "id=" + id +
            ", valueDate=" + valueDate +
            ", balance=" + balance +
            ", comment='" + comment + '\'' +
            ", status=" + status +
            ", positionAccount=" + positionAccount +
            '}';
}

@Override
public int hashCode() {
    return id != null ? id.hashCode() : 0;
}

}

Trace:
17:55:21.210 [http-nio-8081-exec-1] WARN  o.h.e.jdbc.spi.SqlExceptionHelper -  [] SQL Error: 210, SQLState: S0001
17:55:21.210 [http-nio-8081-exec-1] ERROR o.h.e.jdbc.spi.SqlExceptionHelper -  [] Conversion failed when converting datetime from binary/varbinary string.
17:55:21.215 [http-nio-8081-exec-1] ERROR r.c.i.a.a.a.PositionEndpoint -  [] X:
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:238) ~[spring-orm-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:221) ~[spring-orm-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417) ~[spring-orm-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59) ~[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) ~[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147) ~[spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653) ~[spring-aop-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at

After your comments, I've revised code, but here is another Exception:
18:41:01.389 [JavaFX Application Thread] ERROR io.datafx.core.ExceptionHandler -  [] DataFX Exception Handler
io.datafx.controller.flow.FlowException: java.lang.reflect.InvocationTargetException
    at io.datafx.controller.flow.action.FlowMethodAction.handle(FlowMethodAction.java:53) ~[flow-8.0.jar:na]
    at io.datafx.controller.flow.FlowHandler.handle(FlowHandler.java:231) [flow-8.0.jar:na]
    at io.datafx.controller.flow.FlowHandler.handle(FlowHandler.java:163) [flow-8.0.jar:na]
    at io.datafx.controller.flow.FlowHandler.handleActionWithExceptionHandler(FlowHandler.java:338) [flow-8.0.jar:na]
    at io.datafx.controller.flow.FlowHandler.lambda$attachEventHandler$8(FlowHandler.java:304) [flow-8.0.jar:na]
    at io.datafx.controller.flow.FlowHandler$$Lambda$88/186245904.handle(Unknown Source) [flow-8.0.jar:na]
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86) [jfxrt.jar:na]
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) [jfxrt.jar:na]
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) [jfxrt.jar:na]
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) [jfxrt.jar:na]
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) [jfxrt.jar:na]
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) [jfxrt.jar:na]
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) [jfxrt.jar:na]
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) [jfxrt.jar:na]
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) [jfxrt.jar:na]
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) [jfxrt.jar:na]
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) [jfxrt.jar:na]
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) [jfxrt.jar:na]
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) [jfxrt.jar:na]
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) [jfxrt.jar:na]
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) [jfxrt.jar:na]
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) [jfxrt.jar:na]
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) [jfxrt.jar:na]
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49) [jfxrt.jar:na]
    at javafx.event.Event.fireEvent(Event.java:198) [jfxrt.jar:na]
    at javafx.scene.Node.fireEvent(Node.java:8390) [jfxrt.jar:na]
    at javafx.scene.control.Button.fire(Button.java:185) [jfxrt.jar:na]
    at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182) [jfxrt.jar:na]
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96) [jfxrt.jar:na]
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89) [jfxrt.jar:na]
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218) [jfxrt.jar:na]
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80) [jfxrt.jar:na]
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) [jfxrt.jar:na]
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) [jfxrt.jar:na]
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) [jfxrt.jar:na]
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) [jfxrt.jar:na]
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) [jfxrt.jar:na]
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) [jfxrt.jar:na]
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) [jfxrt.jar:na]
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) [jfxrt.jar:na]
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) [jfxrt.jar:na]
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) [jfxrt.jar:na]
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) [jfxrt.jar:na]
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) [jfxrt.jar:na]
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) [jfxrt.jar:na]
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) [jfxrt.jar:na]
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) [jfxrt.jar:na]
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) [jfxrt.jar:na]
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) [jfxrt.jar:na]
    at javafx.event.Event.fireEvent(Event.java:198) [jfxrt.jar:na]
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3758) [jfxrt.jar:na]
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3486) [jfxrt.jar:na]
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762) [jfxrt.jar:na]
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2495) [jfxrt.jar:na]
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:350) [jfxrt.jar:na]
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:275) [jfxrt.jar:na]
    at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_45]
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$350(GlassViewEventHandler.java:385) [jfxrt.jar:na]
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$$Lambda$364/84707264.get(Unknown Source) [jfxrt.jar:na]
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:404) [jfxrt.jar:na]
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:384) [jfxrt.jar:na]
    at com.sun.glass.ui.View.handleMouseEvent(View.java:555) [jfxrt.jar:na]
    at com.sun.glass.ui.View.notifyMouse(View.java:927) [jfxrt.jar:na]
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) [jfxrt.jar:na]
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101) [jfxrt.jar:na]
    at com.sun.glass.ui.win.WinApplication$$Lambda$36/1596000437.run(Unknown Source) [jfxrt.jar:na]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
Caused by: java.lang.reflect.InvocationTargetException: null
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
    at io.datafx.controller.flow.action.FlowMethodAction.handle(FlowMethodAction.java:51) ~[flow-8.0.jar:na]
    ... 66 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
    at io.datafx.controller.injection.InjectionHandler$1.invoke(InjectionHandler.java:87) ~[injection-8.0.jar:na]
    at ru.com.isbank.adc.adc_front_office_app.loro_nostro.LoroNostroModel_$$_jvstd5e_6.getAddDate(LoroNostroModel_$$_jvstd5e_6.java) ~[classes/:na]
    at ru.com.isbank.adc.adc_front_office_app.loro_nostro.LoroNostroTrController.addTransaction(LoroNostroTrController.java:151) ~[classes/:na]
    ... 71 common frames omitted
Caused by: java.lang.NullPointerException: null
    at ru.com.isbank.adc.adc_front_office_app.loro_nostro.LoroNostroModel.getAddDate(LoroNostroModel.java:195) ~[classes/:na]
    ... 78 common frames omitted

What can be wrong? Any ideas? Thanks

A: Firstly, answering you comment above yes you should change LocalDate because currently is not supported by jdbc (someone inform me as well if i am wrong). Use java.sql.Date instead it is the simplest and faster sollution
Another sollution is this:
As stated by the stack trace, the problem is in LocalDate, if you need to use this type, I would have it as a property inside the object but not persistend. And have one more property with value of date and type of  java.sql.Date. to give you an example I would have it as follows (it may not compile exactly because I am not in my pc right now):
  @Column(name = "VALUE_DATE")
      private  java.sql.Date persistendDate;

      private LocalDate valueDate;

      public void setValueDate(LocalDate valueDate) {
            this.valueDate = valueDate;
            this.persistendDate = java.sql.Date.valueOf(valueDate);
        }


text:
Q: Application has triggered a breakpoint due to heap corruption My application throws an exception most probably due to heap corruption as the error code given is c0000374.
It does this when creating the object at line :
Library library2("2");

My code:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

class Book
{
private:
    char author[50];
    char bookid[10];
    char title[80];
public:
    Book(char* nid, char* ntitle, char* nauthor) {
        strcpy(author, nauthor);
        strcpy(title, ntitle);
        strcpy(bookid, nid);
    }
    Book() {
        strcpy(author, "\0");
        strcpy(title, "\0");
        strcpy(bookid, "\0");
    }

    void operator= (Book b) {
        strcpy(author, b.getAuthor());
        strcpy(title, b.getTitle());
        strcpy(bookid, b.getBookID());
    }

    friend ostream& operator<< (ostream& out, Book b) {
        out << b.title << "\t" << b.author << "\t" << b.bookid << endl;
        return out;
    }

    friend bool operator== (Book b1, Book b2) {
        return (strcmp(b1.bookid, b2.bookid));
    }

    char* getAuthor() {     return author;  }
    char* getBookID() {     return bookid;  }
    char* getTitle() {      return title;   }
};

class Library {
private:
    //libId: holds the library ID
    string libId;
    //Pointer to the array that holds the book objects
    Book* bookArr;
    //holds the number of books added in the array.
    int bookscount;

    void resizeBookArray(Book book) {
        bookscount++;
        Book* newBookArr = new Book[bookscount];
        for (int i = 0; i < bookscount-1; i++)
        {
            newBookArr[i] = bookArr[i];
        }
        delete[] bookArr;
        bookArr = new Book[bookscount];
        newBookArr[bookscount] = book;
        bookArr = newBookArr;
        newBookArr = nullptr;
    }
public:

    Library(string alibId) {
        libId = alibId;
        bookscount = 0;
        bookArr = new Book[bookscount];
    }
    void operator= (Library lib) {
        bookscount = lib.getBookNum();
        copyBookArray(lib.getBookArr());
    }

    void addBook(Book book) {
        if (!search(book)) {
            resizeBookArray(book);
        }
    }

    bool search(Book book)
    {
        for (int i = 0; i < bookscount; i++)
        {
            if (bookArr[i] == book)
            {
                return true;
            }
        }
        return false;
    }

    friend ostream& operator<< (ostream& out, Library lib) {
        for (int i = 0; i < lib.bookscount; i++)
        {
            out << lib.bookArr[i];
        }
        return out;
    }
    string getID() { return libId; }
    int getBookNum() { return bookscount; }
    Book* getBookArr() { return bookArr; }

    void copyBookArray(Book* bArr) {
        delete[] bookArr;
        Book* bookArr = new Book[bookscount];
        for (int i = 0; i < bookscount; i++)
        {
            bookArr[i] = bArr[i];
        }
    }
};

void readBooksItems(Library& lib) {
    ifstream fin("book.txt");
    if (fin.fail()) cout << "Input file error!";
    char author[50];
    char bookid[10];
    char title[80];
    while (!fin.eof())
    {
        fin >> bookid;
        fin.ignore();
        fin.getline(title, 80);
        fin.getline(author, 50);
        Book btemp(bookid, title, author);
        lib.addBook(btemp);
    }
    fin.close();
}
//getMoreBooks function, gets additional book from the user, and adds the book into the array
Library getMoreBooks(Library lib)
{
    char bId[10], btitle[80], bauthor[50];
    cout << "Enter book id:";
    cin.getline(bId, 10);
    cout << "Enter title: ";
    cin.getline(btitle, 80);
    cout << "Enter author: ";
    cin.getline(bauthor, 50);
    Book b(bId, btitle, bauthor);
    lib.addBook(b);
    return lib;
}

int main()
{
    int numvideos, numbooks;
    Library library1("1");
    readBooksItems(library1);
    Library library2("2");
    library2 = library1;
    int nbooks;
    cout << "How many new books to add in library 1: ";
    cin >> nbooks;
    cin.ignore();
    for (int i = 0; i < nbooks; i++)
    {
        library1 = getMoreBooks(library1);
    }
    cout << "How many new books to add in library 2: ";
    cin >> nbooks;
    cin.ignore();
    for (int i = 0; i < nbooks; i++)
    {
        library2 = getMoreBooks(library2);
    }
    cout << "=======Printing all books in library 1========= " << endl;
    cout << library1;
    cout << "=======Printing all books in library 2========= " << endl;
    cout << library2;
    return 0;
}

Input file book.txt:
111
Cloud Computing
John Rapheal
222
Programming 1
Sam Smiths
333
UML 2 for Dummies
Michael Jesse Chonoles

A: This line of code writes past the end of the array, which triggers undefined behavior.
        newBookArr[bookscount] = book;


text:
Q: Elasticsearch facet term versus label The object that I am indexing has both a UserId (a GUID) and a FullName property.  I would like to do a faceted search using the UserId but display the FullName so that it's readable.  I don't want to do the facet on the FullName since it technically doesn't have to be unique.
Right now I'm doing something like this:
{
    "query": {
        "match_all": {}
    },
    "facets": {
        "userFacet": {
            "terms": {
                "field": "userId"
            }
        }
    }
}

But then it is giving me the Guids in the response which I would need to hit the database to lookup the full name which is obviously not a real solution.
So how can I use one field to do the facets with and then a different field for the display values to use?

A: i am using the below line for displaying the fields.
It is working for grids only but not facets.
Still facet is taking from the id only not label.
fields: [{
    id: 'name_first',
    'label': 'First Name'
}]

A: Try adding a fields clause to your query, as follows:
{
    "query": {
        "match_all": {}
    },
    "facets": {
        "userFacet": {
            "terms": {
                "field": "userId"
            }
        }
    },
    "fields": [ "FullName" ]
}

Note that in order to return field values in search results, you need to actually store them in ES. So you need to either store the _source (this happens by default, unless you override it with "_source" : {"enabled" : false}, or set "store": "yes" for that field in your mapping.


text:
Q: Nothing execute when using Vector in C++ with VSCode The problem
I have a problem with Vector in C++.
When I try to do basic things with them, my program "doesn't works" anymore.
What I tried
Searching on Stack Overflow but didn't find something relevant.
But I don't know a lot on this topic so I'm kind of stuck with it.
Some code:
Example:
#include <iostream>
#include <vector>

int main(int argc, char ** argv){
    std::cout << "Hello world\n";
    std::vector< int > arr;
}

This program will outputs "Hello world" because I don't interact with the vector.
But if I do:
#include <iostream>
#include <vector>

int main(int argc, char ** argv){
    std::cout << "Hello world\n";
    std::vector< int > arr;
    arr.push_back(1);

}

for example, there is no STDOUT. Hello world is never "printed". And there are no errors.
I'm on Visual Studio code and I compile my program with
g++ -o progam -Wall main.cpp
When I run this on the "Terminal" of Visual Studio Code it doesn't works. But when I rut it on another shell it works.

A: The command g++ -o -Wall main.cpp will create an executable file called -Wall. Unless that's the program you're trying to run, it's not going to work.
Instead you would need something like g++ -o program -Wall main.cpp and then run program. Both of your examples do the right thing in that case.

A: I also encountered this issue (or a very similar one) with VSCode 1.72.2 and g++ 12.1.0.  My fix was to add "-static-libstdc++" to the compiler arguments in tasks.json.
Some extra breadcrumbs from tracking this down:
Running the compiled program from VSCode terminal or powershell quietly appeared to do nothing.  Executing it from Command Prompt gave a popup dialog: The procedure entry point _ZSt28__throw_bad_array_new_lengthv could not be located in the dynamic link library ...  Googling for that led to this thread where @Thinker-101 gave the helpful compiler argument.


text:
Q: Generar consultas SQL con distintos datos automáticamente Tengo una base de datos con una tabla usuarios de la cual quiero ejecutar varias consultas select con distintos mails (200 aprox),estos mails los tengo guardados en un documento .txt. Un ejemplo va a ser mucho mas claro:
SELECT * FROM Usuario WHERE email = 'ejemplo1@h.com'
SELECT * FROM Usuario WHERE email = 'ejemplo2@h.com'
SELECT * FROM Usuario WHERE email = 'ejemplo3@h.com'

Existe alguna herramienta que genere la consulta automáticamente copiando y pegando los mails? ya que hacerlo uno por uno es una tarea engorrosa y tardada.
EDIT: Lo que necesito es una herramienta en la cual yo pueda poner lo siguiente: "SELECT * FROM Usuario WHERE email = ''" y pegarle los 200 mails y me genere un txt (o cualquier formato) con las consultas armadas para pegarlo en SQL


text:
Q: How to search as you type in the File Dialog window in Ubuntu 13.04? I want to search as I type in the Browse File Dialog window opened when upload/save files with a Web Browser.
Is there a way to achieve this in Ubuntu 13.04?

A: Just be sure that the focus is set on the list with the files and 'the search as you type' procedure will work:


text:
Q: Initialise output directory in TestNG custom report We can customise TestNG report by implementing IReporter interface and overriding
generateReport(java.util.List<XmlSuite> xmlSuites, java.util.List<ISuite> suites, java.lang.String outputDirectory)

method. How can we initialise the outputDirectory. I can't find any documentation for that.
Note: I am not running TestNG programically. My question is how to configure outputDirectory in testng.xml

A: Yes, you can by using object injection mechanism provided by testng methods. Use any of the configuration methods like this:
@BeforeSuite
public void setupBeforeSuite(ITestContext context) {
    TestRunner testRunner = (TestRunner) context;
    testRunner.setOutputDirectory("path to your desired location");
}


text:
Q: Can't register MEX endpoint with multiple ServiceHost instances in code I wrote a class that I am using to create and open my ServiceHost instances for each service.  I want to allow them to add in a MEX endpoint.  Below is the code for the Register method which creates all the hosts.  When I later loop through the host list and call Open on all the hosts, the second host to be opened errors out with "Additional information: The ChannelDispatcher at '_THE_MEX_ADDRESS' with contract(s) '"IMetadataExchange"' is unable to open its IChannelListener."  If I remove the MEX code it runs fine and opens each host.  How do I fix this?
Edit: Added full class
Edit2: Keep in mind this is fully in code and not in app.config
public class ServiceHostMgr
{
    #region Constructor

    public ServiceHostMgr(string ip, int httpport, int nettcpport, bool discoverable)
    {
        _hosts = new List<ServiceHost>();
        _ip = ip;
        _httpport = httpport;
        _nettcpport = nettcpport;
        _discoverable = discoverable;
    }

    #endregion

    #region Fields

    private string _ip;
    private int _httpport;
    private int _nettcpport;
    private bool _discoverable;
    private bool _disc = false;

    #endregion

    #region Properties

    private List<ServiceHost> _hosts;
    public List<ServiceHost> Hosts
    {
        get { return _hosts; }
    }

    #endregion

    #region Methods

    public ServiceHostMgr Register(Type serviceType, Type implementedContract, string path)
    {
        string nettcpuri = "net.tcp://" + _ip + ":" + _nettcpport.ToString();
        string httpuri = "http://" + _ip + ":" + _httpport.ToString();

        List<Uri> baseAddresses = new List<Uri>();
        baseAddresses.Add(new Uri(nettcpuri));
        if (_discoverable)
            baseAddresses.Add(new Uri(httpuri));

        ServiceHost host = new ServiceHost(implementedContract, baseAddresses.ToArray());
        /*
        if (_discoverable)
        {
            ServiceMetadataBehavior smb = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
            // If not, add one
            if (smb == null)
                smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
            host.Description.Behaviors.Add(smb);
            host.AddServiceEndpoint(
              ServiceMetadataBehavior.MexContractName,
              MetadataExchangeBindings.CreateMexHttpBinding(),
              "mex"
            );
        }
        */
        if (_discoverable)
        {
            ServiceMetadataBehavior smb = host.Description.Behaviors.Find<ServiceMetadataBehavior>();

            // If not, create new one, set values, add to collection
            if (smb == null)
            {
                smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;

                // add to behaviors collection
                host.Description.Behaviors.Add(smb);

                // add service endpoint
                host.AddServiceEndpoint(
                       ServiceMetadataBehavior.MexContractName,
                       MetadataExchangeBindings.CreateMexHttpBinding(),
                       "mex"
                );
            }
        }

        NetTcpBinding nettcpbinding = new NetTcpBinding();
        host.AddServiceEndpoint(serviceType, nettcpbinding, nettcpuri + "/" + path);

        _hosts.Add(host);

        return this;
    }

    public ServiceHostMgr Open()
    {
        foreach (ServiceHost h in _hosts)
            h.Open();

        return this;
    }

    public ServiceHostMgr Close()
    {
        foreach (ServiceHost h in _hosts)
            h.Close();

        return this;
    }

    #endregion
}

Here is the calling code:
        ServiceHostMgr hostMgr = new ServiceHostMgr("localhost", 8012, 8002, true)
            .Register(typeof(IPurchaseOrderSvc), typeof(PurchaseOrderSvc), "PurchaseOrder")
            .Register(typeof(ILoginSvc), typeof(LoginSvc), "Login")
            .Open();

        Console.WriteLine("Running...");
        Console.ReadLine();
        hostMgr.Close();

A: Well, you are checking to see if the behavior already exists - that's good.
But even if it does already exist - you're trying to add it again - that's your problem.
ServiceMetadataBehavior smb = host.Description.Behaviors.Find<ServiceMetadataBehavior>();

// assume you found the ServiceMetadataBehavior... - you set new values
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;

// and now you're ADDING the already existing "smb" to the behaviors collection!
host.Description.Behaviors.Add(smb);

So I believe what you really want is more something like this:
ServiceMetadataBehavior smb = host.Description.Behaviors.Find<ServiceMetadataBehavior>();

// If not, create new one, set values, add to collection
if (smb == null)
{
   smb = new ServiceMetadataBehavior();
   smb.HttpGetEnabled = true;
   smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;

   // add to behaviors collection
   host.Description.Behaviors.Add(smb);

   // add service endpoint
   host.AddServiceEndpoint(
          ServiceMetadataBehavior.MexContractName,
          MetadataExchangeBindings.CreateMexHttpBinding(),
          "mex"
   );
}

Or if you really want to set the values of an existing behavior to your specific values, you'd have to check again before calling .Behaviors.Add(smb); and before host.AddServiceEndpoint to see whether you're dealing with an existing behavior (then don't add again!), or a new one