text:
Q: Access objects by their identifier I'm fetching relational data from my sql database. This data has an identifier (unique/primary key). Sample:
[
   {id:1, value:"test", cat:2},
   {id:2, value:"test", cat:3},
   {id:3, value:"test", cat:4}, ...
]

As proposed on many sites, including Stackoverflow, you may use an array's find function to access the elements by their id:
Find object by id in an array of JavaScript objects
Sample to fetch the value of object with id 3:
  SomeVal = myArray.find(x => x.id === 3).value

However, I disagree with this approach. I don't see why you would search for an identifier, as you could just simply access the element directly via id, which really is the idea to use an identifier.
You may argue that the array's find function will just do the job as it's superfast, but that's not good enough in my case as performance has highest priority.
As result, I currently "misuse" the index of the array as identifier number to access the elements directly. Sample:
 SomeVal = myArray[3].value

However, I am looking for a more feasable approach in javascript/typescript to access the elements by id directly.
I do not need to create/update/delete the elements, I solely need to access them once fetched.
I must not use arrays at all if another data structure is better for this.
I am NOT proposing to replace an array's field search function such as find with the direct index access. And the core of the discussion shall not be which array element is accessed by 3, as this is a simple example. The main idea of the question is if it's feasible to use the index if an array like it was the identifier, hence to use index which directly correlates with the id field.

A:
However, I disagree with this approach. I don't see why you would search for an identifier, as you could just simply access the element directly via id, which really is the idea to use an identifier.

You can't directly access by ID with the structure you've shown. You need a different structure to do that.

As result, I currently "misuse" the index of the array as identifier number to access the elements directly. Sample:
SomeVal = myArray[3].value

That doesn't access the entry with id: 3. It accesses undefined (with your sample data). Indexes start at 0, not 1. Moreover, unless the underlying system guarantees it, you can't rely on the entries being in id order with no gaps, etc.
For access by id, convert the array to a Map or an object. Then you can reuse that map or object and benefit from the sublinear lookup time on the map key / object property name.
Map (I'd recommend this):

// Note that I've put them out of order to demonstrate we're really getting by id
const array = [
   {id:2, value:"test", cat:3},
   {id:1, value:"test", cat:2},
   {id:3, value:"test", cat:4},// ...
];

const map = new Map(array.map(entry => [entry.id, entry]));

console.log(map.get(1));

Object:

// Note that I've put them out of order to demonstrate we're really getting by id
const array = [
   {id:2, value:"test", cat:3},
   {id:1, value:"test", cat:2},
   {id:3, value:"test", cat:4},// ...
];

const obj = Object.fromEntries(array.map(entry => [entry.id, entry]));

console.log(obj[1]);

A: The reason you have to use find in this case is because you have an array of objects. So you cannot directly access the id key.
If you want to access the id key directly, then you need to convert your array to an object.

A: In my opinion, there are two approaches to do that.

*

*Using a data structure algorithm such as HashTable to find the element easily and in fast time.

*Create an object that id is key and its value is the entity object. something like this:

const myArray = [...];
const cachedMyArray = cacheData(myArray);

const anItem = cachedMyArray[3]

// Caching data to find elements fastest
interface MyArray {
  ...
}

function cacheData(array: MyArray[]) {
  const cached = {};

  array.forEach((item: MyArray) => {
    cached[item.id] = item;
  });

  return cached;
}


text:
Q: Programming language to write logic for SQL Server I've been using SQL Server to write queries. I was browsing online and I found that python and C# can be used to write query logic as well.
I was wondering is it more efficient to use another programming language instead of SQL for SQL Server?

A: Essentially any logic that happens in a C# or Python program will be sent back to the data layer, simplistically, using SQL queries. For some more complex processing or buisness logic it may be preferable to push this logic up to the business logic layer away from the data layer.
Making changes to SQL is easier that code as in the case of C# or Python a new version with updates to logic etc will require a new version of the software to be shipped. Whereas a DB change can happen behind the scenes.
It depends entirely on what you want to acheive.

A: SQL Server as of version 2005 offers the SQL CLR - basically a trimmed-down version of the .NET runtime.
This allows you to write .NET code (in C#, VB.NET or any other .NET language) and have this executed within SQL Server.
It's a compelling feature for some scenarios (especially areas where the "native" T-SQL is lacking - string manipulation, regex handling etc.) - but it's often a bit tricky and hard to convince your company's DBA's to enable this feature; DBA's often don't really like the idea of C# code being executed inside their "sacred" database environment...
Read more about the SQL CLR integration here:
https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql/introduction-to-sql-server-clr-integration

redpajama_set_name: RedPajamaStackExchange


text:
Q: Umbraco pagination First time Umbraco user.
I'm looking to add pagination to the following basic loop:
@foreach (var example in CurrentPage.Children.OrderBy("createDate descending").Take(8)){

   //Do Stuff//

}

Any ideas? Thanks

A: Phil's answer is great, but I would recommend putting the order on the items variable rather than the foreach - that way if any more complicated sorting is necessary it's being done before the pagination is implemented.
The updated code snippets would be:
@{
    var pageSize = 8;
    if(Model.Content.HasValue("numberOfItemsPerPage")){
    pageSize = Model.Content.GetPropertyValue<int>("numberOfItemsPerPage");}

    var page = 1; int.TryParse(Request.QueryString["page"], out page);
    var items = Umbraco.TypedContent(Model.Content.Id).Children.Where(x => x.DocumentTypeAlias == "exampleAlias" && x.IsVisible()).OrderByDescending(x => x.CreateDate);
    var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize);

    if (page > totalPages)
    {
        page = totalPages;
    }
    else if (page < 1)
    {
        page = 1;
    }

    foreach (var item in items.Skip((page - 1) * pageSize).Take(pageSize)
    {

@item.GetPropertyValue("example")

    }

   if (totalPages > 1)
   {

               @if (page > 1)
               {

Prev

               }
               @for (int p = 1; p < totalPages + 1; p++)
               {

                       @p

               }
               @if (page < totalPages)
               {

Next

               }

    }
}

A: After a good amount of work and research, here is my final code for pagination in umbraco. Replace the examples with your stuff, and pageSize is the amount of posts shown on each page.
@{
    var pageSize = 8;
    if(Model.Content.HasValue("numberOfItemsPerPage")){
    pageSize = Model.Content.GetPropertyValue<int>("numberOfItemsPerPage");}

    var page = 1; int.TryParse(Request.QueryString["page"], out page);
    var items = Umbraco.TypedContent(Model.Content.Id).Children.Where(x => x.DocumentTypeAlias == "exampleAlias" && x.IsVisible());
                var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize);

                if (page > totalPages)
                {
                    page = totalPages;
                }
                else if (page < 1)
                {
                    page = 1;
                }

            foreach (var item in items.Skip((page - 1) * pageSize).Take(pageSize).OrderBy("createDate descending"))
{

@item.GetPropertyValue("example")

}

if (totalPages > 1)
{

            @if (page > 1)
            {

Prev

            }
            @for (int p = 1; p < totalPages + 1; p++)
            {

                    @p

            }
            @if (page < totalPages)
            {

Next

            }

}
}

Hope this stops a headache for someone.

A: My 50 cents
Jeroen Breuer created a github project called Hybrid Framework in which he has added some route hijacking to an umbraco side to do paging and have strongly typed models. Take a look at it and i'm sure you will like it. It also uses caching i believe.
There was also a video about this i saw but i could not find it anymore.
Hope this helps people trying to implement Paging and some other nice stuff to you Umbraco projects.
UPDATE: found the video on GitHub in readme

A: These are all great answers, especially the pointer to Jeroen Breuer's library, but just in the name of being thorough and talking about all options -- if you are using jquery in your project and if you have relatively small result sets you could also go with a simple front end only solution.
You'd just bind the entire results list and then use a library like JPList (http://jplist.com ) as I have done here.  Go to http://www.charterpublic.org/find-a-school/ and type in city Denver for example.  You'll see there are 50+ results.  I bind the entire results list then use jplist to make it sortable/pageable etc.
@if (results.Any())
{

    @foreach (var result in results.OrderByDescending(r => r.Name))
    {

        //build your item

    }

}

        <button class="btn btn-primary dropdown-toggle"
                type="button"
                data-toggle="dropdown"
                id="dropdown-menu-1"
                aria-expanded="true">
            Items per Page

        </button>

                3 per page

                5 per page

                10 per page

                View All

Then at the bottom of your view...

There are other front end libraries that do this, but I found JPList the easiest to use for me.
The downside is it's not lazy loaded so it's a little heavier, but with smallish lists like mine here this was a great and simple solution.

A: I know that this is old , I used the Phil code recomendations and works very good.
But all the pages when incresing the pagination buttons works as infinite regeneration, what I mean is how can I do this as example:
Prev 123456789...Next and when is selected the page 5 for example shows like this:
Prev 5 6 7 8 9 10 11 12 13 ... Next and in the inverse or last page like this:
Prev ... 47 48 49 50 51 52 53 54 55
What I mean guys is to have just a 9 pages on click in the pagination buttons, but I need to implement with the same code that Phil Share :
@{
var pageSize = 8;
if(Model.Content.HasValue("numberOfItemsPerPage")){
pageSize = Model.Content.GetPropertyValue<int>("numberOfItemsPerPage");}

var page = 1; int.TryParse(Request.QueryString["page"], out page);
var items = Umbraco.TypedContent(Model.Content.Id).Children.Where(x => x.DocumentTypeAlias == "exampleAlias" && x.IsVisible());
            var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize);

            if (page > totalPages)
            {
                page = totalPages;
            }
            else if (page < 1)
            {
                page = 1;
            }

        foreach (var item in items.Skip((page - 1) * pageSize).Take(pageSize).OrderBy("createDate descending"))
{

@item.GetPropertyValue("example")

}

if (totalPages > 1)
{

        @if (page > 1)
        {

Prev

        }
        @for (int p = 1; p < totalPages + 1; p++)
        {

                @p

        }
        @if (page < totalPages)
        {

Next

        }

}
}

Just to have a limit of 9 pages with the (...) according the page position.
Help!


text:
Q: How can I return a list from an async method? So I've got this bit of code that Visual Studio doesn't complain about:
int fortyTwo = await CalculateAnswerAsync();
Debug.WriteLine(fortyTwo);

async public static Task<int> CalculateAnswerAsync()
{
    await Task.Delay(1000);
    return 42;
}

I'm returning a task, which encapsulates the int 42 that I'm returning after 1 second and accessing via await. All great.
Now when I try to apply this methodology to an area of my program dealing with Lists, I get an error:
public List<Payee> Payees { get; set; } = new();

var payeesTask = dataService.GetPayees();
List<Payee> payees = await payeesTask;
Debug.WriteLine(payees.ToString());

public Task<List<Payee>> GetPayees()
{
    //Payees is underlined with the red squiggle, boooo
    if(Payees.Count != 0) return Payees;
    Payees.Add(new Payee { Id = 0, Name = "Food Lion", DefaultCategoryId = 0, DefaultIsCredit = false });
    return Payees;
}

The error I get is Cannot implicitly convert type 'System.Collections.Generic.List<MyApp.Model.Payee>' to 'System.Threading.Tasks.Task<System.Collections.Generic.List<MyApp.Model.Payee>>'
Which I totally understand and agree with, except that my example with returning 42 doesn't error out. What gives?

A: Short form: the GetPayees() method declaration is missing the async keyword.
Yeah, that's more of a comment. Let's see if I can expand on that a little...
The async keyword in a method definition causes the compiler to do a bit of work to create a task around your code: an IAsyncStateMachine implementation and code to create instances of that class, initialize it and create a Task<...> object to return. It's all quite interesting to look at, if a little convoluted.
Since you haven't declared the method as async none of that gets done. Instead you've declared a simple method that expects you to return a Task<List<Payee>> that you have manually created, or sourced elsewhere. Instead you're trying to return a raw List<Payee> without wrapping a task around it.
So the simple fix is to add async to your (currently synchronous) code:
public async Task<List<Payee>> GetPayees()
{
    // need to await something or the compiler complains
    await Task.Delay(1);
    // rest of your code here...
}

If you're just mocking something that is properly asynchronous in live code you can use Task.FromResult() to return a cut-down task that just holds a return value, or if you need to do something more interesting then you could wrap synchronous code in Task.Run() to have it run on a separate thread.
Task.FromResult():
public Task<List<Payee>> GetPayees()
{
    if(Payees.Count == 0)
        Payees.Add(new Payee { Id = 0, Name = "Food Lion", DefaultCategoryId = 0, DefaultIsCredit = false });
    return Task.FromResult(Payees);
}

Task.Run:
public Task<List<Payee>> GetPayees()
{
    return Task.Run(() =>
    {
        // long-running synchronous code here
        Thread.Sleep(250);

        if(Payees.Count == 0)
            Payees.Add(new Payee { Id = 0, Name = "Food Lion", DefaultCategoryId = 0, DefaultIsCredit = false });
        return Task.FromResult(Payees);
    };
}

Assuming you're not testing how your code handles delays in fetching the payee list, Task.FromResult() is probably the better option.
(Incidentally... am I the only person who finds the idea of 'food lions' a little weird here?)


text:
Q: JsPDF generates a blank PDF I am using: jsPDF to generate pdf from html in the server side
I have installed the following packages:
"html2canvas": "^1.3.2",
"jspdf": "^2.3.1",

makePdf.ts
const { jsPDF } = require("jspdf");
const doc = new jsPDF();

doc.html('
Hola Mundo!
');
doc.save("export.pdf");

The issue is I am getting a blank pdf document and I don't know how to fix this issue.
When I write a plain text (i.e doc.text('Hola Mundo!', 10, 10)) it works fine.

A: you just need to replace ".html" with ".fromHTML". Therefore it will look something like this:

const { jsPDF } = require("jspdf");
const doc = new jsPDF();

doc.fromHTML('
Hola Mundo!
');
doc.save("export.pdf");


text:
Q: How to equate a text on left hand side to an inserted image on right hand side horizontally? I want the text in left hand side to be equated to an inserted image on right hand side as shown below:
Here, i wish the text in left hand side to be written in latex and equate it horizontally to an inserted image on right hand side. Also, how to insert text between images horizontally?

A: I am assuming by your use of the term "inserted image," that you have an external graphic.  You can use \includegraphics (also)  in math mode to insert images.  To get them vertically aligned with the math axis, the easiest way is to apply \vcenter{\hbox{...}} to the graphic.
\documentclass{article}
\usepackage{amsmath,graphicx}
\begin{document}
\[
\begin{aligned}
G\oplus H &= \vcenter{\hbox{\includegraphics[height=3em]{example-image-a}}}
\oplus \vcenter{\hbox{\includegraphics[height=3em]{example-image-b}}}\\
&= \vcenter{\hbox{\includegraphics[height=3em]{example-image-c}}}
\end{aligned}
\]
\end{document}

egreg suggests the even simpler construction, using the valign key of \includegraphics (adjustbox package required):
\documentclass{article}
\usepackage{amsmath,graphicx}
\usepackage[export]{adjustbox}
\begin{document}
\[
\begin{aligned}
G\oplus H &= \includegraphics[height=3em,valign=c]{example-image-a}
\oplus \includegraphics[height=3em,valign=c]{example-image-b}\\
&= \includegraphics[height=3em,valign=c]{example-image-c}
\end{aligned}
\]
\end{document}

A: You can do it with TikZ:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}

\tikzset{
  vcenter/.style={
    baseline={([yshift=-\the\dimexpr\fontdimen22\textfont2\relax]
                    current bounding box.center)},
  },
}

\begin{document}

\begin{equation*}
\begin{split}
G\oplus H &=
\begin{tikzpicture}[vcenter]
\coordinate (1) at (0,1);
\coordinate (2) at (0.866,0.5);
\coordinate (3) at (0,0);
\coordinate (c) at (1.732,0.5);
\fill (1) circle (1pt) node[above] {\tiny 1};
\fill (2) circle (1pt) node[left] {\tiny 2};
\fill (3) circle (1pt) node[below] {\tiny 3};
\fill (c) circle (1pt) node[right] {\tiny c};
\draw (1)--(2)--(3)--cycle;
\draw [red] (1)--(c);
\draw [red] (2)--(c);
\draw [red] (3)--(c);
\end{tikzpicture}
\oplus
\begin{tikzpicture}[vcenter]
\coordinate (a) at (0,1);
\coordinate (b) at (0,0);
\coordinate (c) at (0.866,0.5);
\fill (a) circle (1pt) node[above] {\tiny a};
\fill (b) circle (1pt) node[below] {\tiny b};
\fill (c) circle (1pt) node[right] {\tiny c};
\draw (a)--(b);
\draw [red] (a)--(c);
\draw [red] (b)--(c);
\end{tikzpicture}
\\
&=
\begin{tikzpicture}[vcenter]
\coordinate (1) at (0,1);
\coordinate (2) at (0.866,0.5);
\coordinate (3) at (0,0);
\coordinate (a) at (1.732,1);
\coordinate (b) at (1.732,0);
\coordinate (c) at (2.598,0.5);
\fill (1) circle (1pt) node[above] {\tiny 1};
\fill (2) circle (1pt) node[left] {\tiny 2};
\fill (3) circle (1pt) node[below] {\tiny 3};
\fill (a) circle (1pt) node[above] {\tiny a};
\fill (b) circle (1pt) node[below] {\tiny b};
\fill (c) circle (1pt) node[right] {\tiny c};
\draw (1)--(2)--(3)--cycle;
\draw (a)--(b);
\draw [red] (1)--(c);
\draw [red] (2)--(c);
\draw [red] (3)--(c);
\draw [red] (a)--(c);
\draw [red] (b)--(c);
\end{tikzpicture}
\end{split}
\end{equation*}

\end{document}

These are very simple diagrams and the code should be almost self-explaining. The style defined in the preamble is found in https://tex.stackexchange.com/a/302507/4427 and it copes with the alignment of the picture similar to the one suggested by Steven in his answer.
The idea is to define some coordinates and then use them for drawing circles and segments. Labels are placed as nodes next to the circles.


text:
Q: Slow count query with where clause I am trying to perform a count to get the total number of results in a pagination but the query is too slow 2.12s
+-------+
| size  |
+-------+
| 50000 |
+-------+
1 row in set (2.12 sec)

my count query
select  count(appeloffre0_.ID_APPEL_OFFRE) as size
from  ao.appel_offre appeloffre0_
inner join ao.acheteur acheteur1_
on appeloffre0_.ID_ACHETEUR=acheteur1_.ID_ACHETEUR
where
(exists (select 1 from ao.lot lot2_ where lot2_.ID_APPEL_OFFRE=appeloffre0_.ID_APPEL_OFFRE and lot2_.ESTIMATION_COUT>=1))
and (exists (select 1 from ao.lieu_execution lieuexecut3_ where lieuexecut3_.appel_offre=appeloffre0_.ID_APPEL_OFFRE and lieuexecut3_.region=1))
and (exists (select 1 from ao.ao_activite aoactivite4_ where aoactivite4_.ID_APPEL_OFFRE=appeloffre0_.ID_APPEL_OFFRE and (aoactivite4_.ID_ACTIVITE=1)))
and appeloffre0_.DATE_OUVERTURE_PLIS>'2015-01-01'
and (appeloffre0_.CATEGORIE='fournitures' or appeloffre0_.CATEGORIE='travaux' or appeloffre0_.CATEGORIE='services')
and acheteur1_.ID_ENTITE_MERE=2

explain cmd :
+----+--------------------+--------------+------+---------------------------------------------+--------------------+---------+--------------------------------+-------+--------------------------+
| id | select_type        | table        | type | possible_keys                               | key                | key_len | ref                            | rows  | Extra                    |
+----+--------------------+--------------+------+---------------------------------------------+--------------------+---------+--------------------------------+-------+--------------------------+
|  1 | PRIMARY            | acheteur1_   | ref  | PRIMARY,acheteur_ibfk_1                     | acheteur_ibfk_1    | 5       | const                          |     3 | Using where; Using index |
|  1 | PRIMARY            | appeloffre0_ | ref  | appel_offre_ibfk_2                          | appel_offre_ibfk_2 | 4       | ao.acheteur1_.ID_ACHETEUR      | 31061 | Using where              |
|  4 | DEPENDENT SUBQUERY | aoactivite4_ | ref  | ao_activites_activite_fk,ao_activites_ao_fk | ao_activites_ao_fk | 4       | ao.appeloffre0_.ID_APPEL_OFFRE |     3 | Using where              |
|  3 | DEPENDENT SUBQUERY | lieuexecut3_ | ref  | fk_ao_lieuex,fk_region_lieuex               | fk_ao_lieuex       | 4       | ao.appeloffre0_.ID_APPEL_OFFRE |     1 | Using where              |
|  2 | DEPENDENT SUBQUERY | lot2_        | ref  | FK_LOT_AO                                   | FK_LOT_AO          | 4       | ao.appeloffre0_.ID_APPEL_OFFRE |     5 | Using where              |
+----+--------------------+--------------+------+---------------------------------------------+--------------------+---------+--------------------------------+-------+--------------------------+

the index acheteur_ibfk_1 is a FK references table ENTITE_MERE because i have and acheteur1_.ID_ENTITE_MERE=2 in where clause.

A: You can have multiple conditions on your joins by using ON condition1 AND condition2 etc.
SELECT COUNT(appeloffre0_.ID_APPEL_OFFRE) as size
FROM  ao.appel_offre appeloffre0_
JOIN ao.acheteur acheteur1_ ON appeloffre0_.ID_ACHETEUR=acheteur1_.ID_ACHETEUR
JOIN ao.lot lot2_ ON appeloffre0_.ID_APPEL_OFFRE=lot2_.ID_APPEL_OFFRE AND lot2_.ESTIMATION_COUT>=1
JOIN ao.lieu_execution lieuexecut3_ ON appeloffre0_.ID_APPEL_OFFRE=lieuexecut3_.ID_APPEL_OFFRE AND lieuexecut3_.ID_ACTIVITE=1
JOIN ao.ao_activite aoactivite4_ ON appeloffre0_.ID_APPEL_OFFRE=aoactivite4_.ID_APPEL_OFFRE AND aoactivite4_.ID_ACTIVITE=1
WHERE appeloffre0_.DATE_OUVERTURE_PLIS>'2015-01-01'
AND (appeloffre0_.CATEGORIE='fournitures' OR appeloffre0_.CATEGORIE='travaux' OR appeloffre0_.CATEGORIE='services')
AND acheteur1_.ID_ENTITE_MERE=2;

A: You can try:
select count(aa.ID_APPEL_OFFRE) as size
from  (
select ID_APPEL_OFFRE, ID_ACHETEUR from ao.appel_offre appeloffre0_
inner join ao.acheteur acheteur1_
on appeloffre0_.ID_ACHETEUR=acheteur1_.ID_ACHETEUR
where appeloffre0_.DATE_OUVERTURE_PLIS>'2015-01-01'
and (appeloffre0_.CATEGORIE in ('fournitures','travaux','services'))
and (acheteur1_.ID_ENTITE_MERE=2)) aa
inner join ao.lot lot2_ on lot2_.ID_APPEL_OFFRE=aa.ID_APPEL_OFFRE
inner join ao.lieu_execution lieuexecut3_ on lieuexecut3_.appel_offre=aa.ID_APPEL_OFFRE
inner join ao.ao_activite aoactivite4_  on aoactivite4_.ID_APPEL_OFFRE=aa.ID_APPEL_OFFRE
where
aoactivite4_.ID_ACTIVITE=1
and lot2_.ESTIMATION_COUT>=1
and lieuexecut3_.region=1;

But I haven't seen your tables so I am not 100% sure that you won't get duplicates because of joins.
A couple of low-hanging fruits might also be found by ensuring that your appeloffre0_.CATEGORIE and  appeloffre0_.DATE_OUVERTURE_PLIS have indexes on them.
Other fields which should have indexes on them are ao.lot.ID_APPEL_OFFRE, ao.lieu_execution.ID_APPEL_OFFRE and ao.ao_activite.ID_APPEL_OFFRE, and ao.appel_offre.ID_ACHETEUR (all the joined fields).

A: I would have the following indexes on your tables if not already...  These are covering indexes for your query meaning the index has the applicable column to get your results without having to go to the actual raw data pages.
table           index
appel_offre     ( DATE_OUVERTURE_PLIS, CATEGORIE, ID_APPEL_OFFRE, ID_ACHETEUR )
lot             ( ID_APPEL_OFFRE, ESTIMATION_COUT )
lieu_execution  ( appel_offre, region )
ao_activite     ( ID_APPEL_OFFRE, ID_ACTIVITE )

Having indexes on just individual columns won't really help optimize what you are looking for.  Also,  I am doing count of DISTINCT ID_APPEL_OFFRE's in case any of the JOINed tables have more than 1 record, it does not create a Cartesian result count for you
select
      count(distinct AOF.ID_APPEL_OFFRE) as size
   from
      ao.appel_offre AOF
         JOIN ao.acheteur ACH
            on AOF.ID_ACHETEUR = ACH.ID_ACHETEUR
           and ACH.ID_ENTITE_MERE = 2
         JOIN ao.lot
            ON AOF.ID_APPEL_OFFRE = lot.ID_APPEL_OFFRE
           and lot.ESTIMATION_COUT >= 1
         JOIN ao.lieu_execution EX
            ON AOF.ID_APPEL_OFFRE = EX.appel_offre
            and EX.region = 1
         JOIN ao.ao_activite ACT
            ON AOF.ID_APPEL_OFFRE = ACT.ID_APPEL_OFFRE
           and ACT.ID_ACTIVITE = 1
   where
          AOF.DATE_OUVERTURE_PLIS > '2015-01-01'
      and (   AOF.CATEGORIE = 'fournitures'
           or AOF.CATEGORIE = 'travaux'
           or AOF.CATEGORIE = 'services')

A: Like @FuzzyTree said in his comment exists is faster than an inner join if it's not a 1:1 relationship because it terminates as soon as it finds 1 whereas the join will get every matching row.
But the solution is that We add in and not exists  :
where ( appeloffre0_.ID_APPEL_OFFRE IN (select lot2_.ID_APPEL_OFFRE from ao.lot lot2_
             where    lot2_.ESTIMATION_COUT>=1)
      )

So the query run very fast than exists or joins .
select  count(appeloffre0_.ID_APPEL_OFFRE) as size
from  ao.appel_offre appeloffre0_
inner join ao.acheteur acheteur1_
on appeloffre0_.ID_ACHETEUR=acheteur1_.ID_ACHETEUR
where
( appeloffre0_.ID_APPEL_OFFRE IN (select lot2_.ID_APPEL_OFFRE from ao.lot lot2_  where    lot2_.ESTIMATION_COUT>=1))
and (appeloffre0_.ID_APPEL_OFFRE IN (select lieuexecut3_.appel_offre from ao.lieu_execution lieuexecut3_  where  lieuexecut3_.region=1))
and (appeloffre0_.ID_APPEL_OFFRE IN (select aoactivite4_.ID_APPEL_OFFRE from ao.ao_activite aoactivite4_  where aoactivite4_.ID_ACTIVITE=1 ))
and appeloffre0_.DATE_OUVERTURE_PLIS>'2015-01-01'
and (appeloffre0_.CATEGORIE='fournitures' or appeloffre0_.CATEGORIE='travaux' or appeloffre0_.CATEGORIE='services')
and acheteur1_.ID_ENTITE_MERE=2


text:
Q: Can I use different power supply on my laptop? Battery on my laptop is 4%, I don't have original power supply at the moment and I have some work to do.
Is it safe to ask a friend to give me his power supply from another type of laptop?
What parameters to look for to see if this is possible?

A: One size does not fit all.
Buy something like the thing at picture below (would replace to CC version later), pick a matching connector, set a correct voltage.
Lower power (e.g. 60W instead of 90W) is OK, just the battery charge time will raise. Same for higher (used to feed 30W netbook with 110W supply). Voltage should be the same!

A: I have used a 90w power supply on my dell and it seems to charge much faster than my current 65w unit. Since my 65w unit blew it works very well with the 90w unit. Hope this helps!

A: Same power ( voltage and Amps )
Well its doesnt have to be perfect but similar..
As an example
(19.5V - 7.7A) 20V - 7.8A is fine..
Obviously the power adapter to connect should fit / be the same

A: Obviously, the connector must fit. Other than that, the voltages need to match. There is some tolerance, but it's hard to give a solid number of what will still work and what might even harm your computer. Lower voltages are safer, but 5% deviation will be fine either way.
Another thing to look out for is the polarity as reversing it could be damaging, probably isn't but a power supply with the wrong polarity definitely won't work. Luckily, it is very uncommon to find laptop power supplies that do not adhere to the rule of the inner terminal being positive.
Current is largely irrelevant. How many amps are supplied depends on the load, not on the PSU which simply specifies the maximum current it can handle. If your laptop draws more power than can be supplied, the machine will either shut down or draw power from the batteries. Worst case scenario for a current rating too low: you need to power the machine down and wait for the batteries to recharge. Worst case for 'too high' a current, the recharge crazy fast.

A: My Dell D510 is OK with another Dell power supply.  Original was 19.5v with 3.3 amp output.  The 'extra' power supply is 19.5v with 4.6 amp output.  Your mileage may vary. Take pictures of your laptop on fire if it doesn't work out, and let us know.  Since, I'm only supplying a single data point.  My guess is, that you can probably be within about 0.5v tolerance and 50% of the amp output... but I"m only guessing on that.  Oh yeah, you'll find that the physical connector varies among manufacturers, so you'll need a 100% match there.

A: Usually higher wattage power supplies for Dell will work replacing a lower wattage power supply.  Most power supplies are voltage regulated, so the output current is only what the laptop needs is provided.  So a higher wattage power supply of the same voltage shouldn't be a problem.  I have seen a Dell Latitude XT2 show an error using a higher wattage power supply, but this is a very rare case.  This information shouldn't matter even with other brands as long as the power supply is regulated (as far as I know all laptop manufacturers would be using voltage regulated power supplies.  Good news is that for nearly the past 10 years most manufacturers have started to use the same power supply connector and regulated voltage for their whole product line
Hope this helps.  I use Dell at work, and one of my home laptops is an ASUS that apparently isn't working, found this as I was searching.  Hope this comment is helpful to someone.


text:
Q: Regex for Valid Website Url in C# Hey I have tried a regex for valid website url, which is as below
@"(?:[A-Za-z0-9-]+\.)+[A-Za-z0-9]{1,3}:\d{1,5}"

But it didn't work, I tried a lot as well which doesn't work.
I am looking for something which will validate some cases like incomplete url's
like
 www.yahoo etc.,
 more over it should allow all the domians and it should accept url's starts with http or just www.
Please let me know if there is any work around.


text:
Q: Install tesseract for C++ on Windows 10 I am having problems while installing tesseract to develop in C++ on Windows 10.
Can anyone provide a guide to get:
1. Leptonica (required by tesseract) lib and includes
2. Tesseract lib and includes
3. Link both to project (e.g. Visual Studio)
so that example from https://github.com/tesseract-ocr/tesseract/wiki/APIExample works:
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>

int main()
{
    char *outText;

    tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
    // Initialize tesseract-ocr with English, without specifying tessdata path
    if (api->Init(NULL, "eng")) {
        fprintf(stderr, "Could not initialize tesseract.\n");
        exit(1);
    }

    // Open input image with leptonica library
    Pix *image = pixRead("/usr/src/tesseract/testing/phototest.tif");
    api->SetImage(image);
    // Get OCR result
    outText = api->GetUTF8Text();
    printf("OCR output:\n%s", outText);

    // Destroy used object and release memory
    api->End();
    delete[] outText;
    pixDestroy(&image);

    return 0;
}

A: I've been trying to link tesseract library to my c++ project in Visual Studio 2019 for a couple of days and I finally managed to do it.
Any thread that I found or even official tesseract documentation do not have full list of instructions on what to do.
I'll list what I have done, hopefully it will help someone. I don't pretend its the optimal way to do so.

*

*There are basic tips in official tesseract documentation.
Go to "Windows" section.
I did install sw and cppan but I guess it wasn't necessary.
The main thing here is installing vcpkg.
It requiers Git so I installed it.
then:
> cd c:tools (I installed it in c:\tools, you may choose any dir)
> git clone https://github.com/microsoft/vcpkg
> .\vcpkg\bootstrap-vcpkg.bat
> .\vcpkg\vcpkg install tesseract:x64-windows-static (I used x64 version)
> .\vcpkg\vcpkg integrate install
At this point everything should work, they said. Headers should be included, libs should be linked. But none was working for me.

*Change project configuration to Release x64 (or Release x86 if you installed x86 tesseract).

*To include headers: Go to project properties -> C/C++ -> General. Set Additional Include Directories to C:\tools\vcpkg\installed\x64-windows-static\include (or whereever you installed vcpkg)

*To link libraries : project properties -> Linker -> General. Set Additional Library Directories to C:\tools\vcpkg\installed\x64-windows-static\lib

*Project properties -> C/C++ -> Code Generation. Set Runtime Library to Multi-threaded(/MT). Otherwise I got errors like "runtime mismatch static vs DLL"

*Tesseract lib couldn't link to its dependcies, so I added all libs that I had installed to C:\tools\vcpkg\installed\x64-windows-static\lib.
Project properties -> Linker -> Input. I set Additional Dependencies to archive.lib;bz2.lib;charset.lib;gif.lib;iconv.lib;jpeg.lib;leptonica-1.80.0.lib;libcrypto.lib;libpng16.lib;libssl.lib;libwebpmux.lib;libxml2.lib;lz4.lib;lzma.lib;lzo2.lib;openjp2.lib;tesseract41.lib;tiff.lib;tiffxx.lib;turbojpeg.lib;webp.lib;webpdecoder.lib;webpdemux.lib;xxhash.lib;zlib.lib;zstd_static.lib;%(AdditionalDependencies)
And after that it finally compiled and launched.
But... api->Init returned -1. To work with tesseract you should have tessdata directory with .traineddata files for the languages you need.

*Download tessdata. I got it from official docs.
BTW, tessdata_fast worked better than tessdata_best for my purposes :)
So I downloaded single "eng" file and saved it like C:\tools\TesseractData\tessdata\eng.traineddata.

*Then I added environment variable TESSDATA_PREFIX with value C:\tools\TesseractData\tessdata. I also added C:\tools\TesseractData to Path variables (just in case)
And after all this it is finally working for me.

A: Install vcpkg ( MS packager to install windows based open source projects) and use powershell command like so .\vcpkg install tesseract:x64-windows-static. Dependency libraries like Leptonica will be auto installed for you.  The tesseract can be auto integrated to your VS project using .\vcpkg integrate install.

A: Additionally I found that you also have to install the lzo2.lib through:
./vcpkg install lzo:x64-windows-static.
And then pull in lzo2.lib as described by @Nick.
Some of the libraries listed above are no longer supported with the latest versions of Tesseract. VS19 will complain about it when you simply copy them; simply remove the ones that are no longer needed by cross-checking.
For example, tiffxx.lib, hashxx.lib and some others.


text:
Q: How do I edit an SVG to remove the empty space around the shape? I have this SVG of the number one.
I want the path element inside to expand to fill up the whole SVG element so I can treat it like a normal image (but with the vector scaling), but it behaves very awkwardly and I have to make the SVG really big.

<svg fill="#000" viewBox="0 180 600 600">
  <path d="M10.125 286.1719 Q10.125 243.7031 40.4297 213.2578 Q70.7344 182.8125 113.4844 182.8125 Q156.0938 182.8125 186.4688 213.2578 Q216.8438 243.7031 216.8438 286.1719 Q216.8438 329.3438 186.3984 359.6484 Q155.9531 389.9531 113.4844 389.9531 Q70.875 389.9531 40.5 359.5781 Q10.125 329.2031 10.125 286.1719 ZM131.625 356.7656 L131.625 213.3281 L109.4062 213.3281 Q104.625 226.9688 91.3359 236.8828 Q78.0469 246.7969 68.7656 249.6094 L68.7656 274.3594 Q89.5781 267.4688 104.2031 253.6875 L104.2031 356.7656 L131.625 356.7656 Z"/>
</svg>

A: I recommend reading up on how the viewBox works.
But briefly, it describes the area of the coordinate space that the contents of the SVG occupy.  The four values are minX, minY, width, and height.  In that order.
Your minX and minY were reasonable, but your width and height values were way too big.  I've reduced them from 600 to 220 in my example below.  If you need a tighter fit, you can tweak the values further.  Ie. increase minX and minY a bit, and reduce width and height a bit.

svg {
  background-color: red;
}
<svg fill="#000" viewBox="0 180 220 220">
  <path d="M10.125 286.1719 Q10.125 243.7031 40.4297 213.2578 Q70.7344 182.8125 113.4844 182.8125 Q156.0938 182.8125 186.4688 213.2578 Q216.8438 243.7031 216.8438 286.1719 Q216.8438 329.3438 186.3984 359.6484 Q155.9531 389.9531 113.4844 389.9531 Q70.875 389.9531 40.5 359.5781 Q10.125 329.2031 10.125 286.1719 ZM131.625 356.7656 L131.625 213.3281 L109.4062 213.3281 Q104.625 226.9688 91.3359 236.8828 Q78.0469 246.7969 68.7656 249.6094 L68.7656 274.3594 Q89.5781 267.4688 104.2031 253.6875 L104.2031 356.7656 L131.625 356.7656 Z"/>
</svg>

The red background was added just so you can see the margin better.


text:
Q: How to upload image, which is not saved on the device to the dropbox account?(IOS) Dropbox restClient saves only files. So i want to save the image in local folder first and then to upload it, as a result it saves file, but it is corrupted.
NSString *localPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
NSString *jpegFilePath = [NSString stringWithFormat:@"%@/test.jpeg",localPath];
NSData *data2 = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0f)];
[data2 writeToFile:jpegFilePath atomically:YES];

NSString *filename = @"test.jpeg";

NSString *destDir = @"/";
[[self restClient] uploadFile:filename toPath:destDir
                withParentRev:nil fromPath:localPath];

I am an idiot, solved
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[paths objectAtIndex:0] stringByAppendingString:@"test.jpg"];

NSData * data = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0f)];
[data writeToFile:path atomically:YES];
[self.restClient uploadFile:@"test.jpg" toPath:@"/" withParentRev:nil fromPath:path];

A: you  will have to call DBRestClient methods from the main thread or a thread that has a run loop. Otherwise the delegate methods will not be called.
what you will have to do is first alloc init yoir DBRestClient object then make it's delegate self and then you can easily upload your file.below is an example
NSString *destDir = @"/";
restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
restClient.delegate = self;

[restClient uploadFile:yourfilename toPath:destDir withParentRev:nil fromPath:sourcepath];

Happy Coding!!!!!!

A: You can't save into the bundle. You should use documents or cache folder:
 NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];


text:
Q: 'The ConnectionString property has not been initialized.' TO FIX I am currently getting the error:
System.InvalidOperationException: 'The ConnectionString property has not been initialized.'
I would like some help to fix this as I am trying to input data from a c#form (multiple textboxes) to an SQL data base form my current code is
 private void AcceptData()
    {
        using (Connection = new SqlConnection(connectionString))
        using (SqlDataAdapter adapter = new SqlDataAdapter("INPUT INTO Person", Connection))//, Connection
        {
            DataTable RegisterTable = new DataTable();
            adapter.Fill(RegisterTable); //System.InvalidOperationException: 'The ConnectionString property has not been initialized.' TO FIX

            string name = textBox1.Text;
            string organisation = textBox3.Text;
            DateTime Time = DateTime.Parse(textBox2.Text);
            string strDateTimeIn = Time.ToString("yyyy-MM-dd HH:mm:ss.ffff");
            string query = "INSERT INTO Person (Name,Organisation,TimeIn) VALUES('" + name + "','" + organisation + "','" +strDateTimeIn+ "')";
            SqlCommand SignIn = new SqlCommand(query,Connection);
            SignIn.ExecuteNonQuery();
        }

    }

Any help would be appreciated thank you
The connection string used is :string connectionString = (@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Register.mdf;Integrated Security=True");

A: You need to open the connection
using (Connection = new SqlConnection(connectionString))
{
    connection.Open();

    using (SqlDataAdapter adapter = new SqlDataAdapter("INPUT INTO Person", Connection))//, Connection
        {
            DataTable RegisterTable = new DataTable();
            adapter.Fill(RegisterTable); //System.InvalidOperationException: 'The ConnectionString property has not been initialized.' TO FIX

            string name = textBox1.Text;
            string organisation = textBox3.Text;
            DateTime Time = DateTime.Parse(textBox2.Text);
            string strDateTimeIn = Time.ToString("yyyy-MM-dd HH:mm:ss.ffff");
            string query = "INSERT INTO Person (Name,Organisation,TimeIn) VALUES('" + name + "','" + organisation + "','" +strDateTimeIn+ "')";
            SqlCommand SignIn = new SqlCommand(query,Connection);
            SignIn.ExecuteNonQuery();
        }
}

A: "The ConnectionString property has not been initialized" clearly indicates that the connection string property for opening a SqlConnection has not assigned properly inside the method. To fix this issue, either assign the connection string in method body like this:
private void AcceptData()
{
    // assumed the connection string obtained from app.config or web.config file
    string connectionString = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString;
    using (SqlConnection Connection = new SqlConnection(connectionString))
    {
        Connection.Open(); // open the connection before using adapter
        using (SqlDataAdapter adapter = new SqlDataAdapter("INPUT INTO Person", Connection))
        {
            // other stuff
        }
    }

    // other stuff
}

Or pass the connection string as method argument:
private void AcceptData(string connectionString)
{
    using (SqlConnection Connection = new SqlConnection(connectionString))
    {
        Connection.Open(); // open the connection before using adapter
        using (SqlDataAdapter adapter = new SqlDataAdapter("INPUT INTO Person", Connection))
        {
            // other stuff
        }
    }

    // other stuff
}

References:
How to fix "The ConnectionString property has not been initialized"
C# Database The ConnectionString property has not been initialized


text:
Q: Overwrite default selinux fcontext rules I'm trying to overwrite default rule for public_html directory:
/home/[^/]*/((www)|(web)|(public_html))(/.+)?   unconfined_u:object_r:httpd_user_content_t:s0

Assigning the httpd_user_rw_content_t context
I tried to add another rule for the same path with:
semanage fcontext -a -t httpd_user_rw_content_t "/home/[^/]*/((www)|(web)|(public_html))(/.+)?"

But restorecon -R /home/user/public_html still assign httpd_user_content_t context.
Is there a way to overwrite the default rule? (Edit file_contexts.homedirs doesn't looks a good idea...)


text:
Q: SOAP Webservice result returns 500 error code I consumed a SOAP Webservice through Nodejs :
$(document).ready(function() {

    $.ajax({
            url: "/track/vehicule/getWebserviceRetourKYC",
            type: "POST",
            success : function(data, status, xhr) {
              console.dir(data);
            },
            error : function(xhr, status, error) {
              console.dir(error);
            }
          });

  });

var express = require('express');
var request = require("request");
var fs = require('fs');
var path = require('path');
var async = require('async');
var router = express.Router();
var db = require('./db');
var utils = require('./utils');
var connexion = db.getConnexion();

router.post("/getWebserviceRetourKYC", function(req, res) {
    var soap = require('strong-soap').soap;
    // wsdl of the web service this client is going to invoke. For local wsdl you can use, url = './wsdls/stockquote.wsdl'
    var url = "https://www.telma.net/sentimsa/mvola/wsdl.php?module=jWSDL&action=WSDL:wsdl&service=mvola~WSMVolaGetInfosKYC";

    var requestArgs = {
        module:'jWSDL',
        action:'WSDL:wsdl',
        service:'mvola~WSMVolaGetInfosKYC'
    };

    var options = {};
    soap.createClient(url, options, function(err, client) {
        var method = client['WSMVolaGetInfosKYCCtrl']['WSMVolaGetInfosKYCCtrlPort']['getInfosKYC'];
        console.dir(client);//here
        method(requestArgs, function(err, result, envelope, soapHeader) {
            //response envelope
            console.log('Response Envelope: \n' + envelope);
            //'result' is the response body
            console.log('Result: \n' + JSON.stringify(result));
        });
    });
    res.send();
});

module.exports = router;

At runtime the returned result is :
{
    "statusCode": 500,
    "body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client<\/faultcode><faultstring>Error cannot find parameter<\/faultstring><\/SOAP-ENV:Fault><\/SOAP-ENV:Body><\/SOAP-ENV:Envelope>\n",
    "headers":
    {
        "date": "Thu, 04 Jul 2019 05:51:26 GMT",
        "server": "Apache/2.2.3 (Red Hat)",
        "content-length": "294",
        "content-type": "text/xml; charset=utf-8",
        "content-language": "en",
        "connection": "close"
    },
    "request":
    {
        "uri":
        {
            "protocol": "https:",
            "slashes": true,
            "auth": null,
            "host": "www.telma.net",
            "port": 443,
            "hostname": "www.telma.net",
            "hash": null,
            "search": "?service=mvola%7EWSMVolaGetInfosKYC",
            "query": "service=mvola%7EWSMVolaGetInfosKYC",
            "pathname": "/sentimsa/mvola/soap.php",
            "path": "/sentimsa/mvola/soap.php?service=mvola%7EWSMVolaGetInfosKYC",
            "href": "https://www.telma.net/sentimsa/mvola/soap.php?service=mvola%7EWSMVolaGetInfosKYC"
        },
        "method": "POST",
        "headers":
        {
            "User-Agent": "strong-soap/1.20.0",
            "Accept": "text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8",
            "Accept-Encoding": "none",
            "Accept-Charset": "utf-8",
            "Connection": "close",
            "Host": "www.telma.net",
            "Content-Length": 396,
            "Content-Type": "text/xml; charset=utf-8",
            "SOAPAction": "\"https://www.telma.net/sentimsa/mvola/soap.php?service=mvola%7EWSMVolaGetInfosKYC&method=getInfosKYC\""
        }
    }
}

So what is wrong in my codes ?
------ edit ------ :
Here is an example of the envelope and the desired result :
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mvol="https://www.telma.net/sentimsa/mvola/">

   <soapenv:Header/>

   <soapenv:Body>

      <mvol:getInfosKYC soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

         <zSubscriberId xsi:type="xsd:string"> 0340017729</zSubscriberId>

      </mvol:getInfosKYC>

   </soapenv:Body>

</soapenv:Envelope>

Response :
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://www.telma.net/sentimsa/mvola/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">

   <SOAP-ENV:Body>

      <ns1:getInfosKYCResponse>

         <getInfosKYCReturn xsi:type="ns1:CCodeReponse">

            <oDataKYC xsi:nil="true" xsi:type="ns1:CKycInfos"/>

            <status_Code xsi:type="xsd:string">101</status_Code>

            <status_Reason xsi:type="xsd:string">Le numéro 0340017728 n'existe pas dans Sentinel.</status_Reason>

         </getInfosKYCReturn>

      </ns1:getInfosKYCResponse>

   </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

A: The error:
<faultstring>Error cannot find parameter<\/faultstring>

Suggests you're missing a required parameter from your request. Do you have documentation for the SOAP service you're consuming? Are module, action, and service the only required parameters?
Also, you've included those parameters in the URL string as well:
var url = "https://www.telma.net/sentimsa/mvola/wsdl.php?module=jWSDL&action=WSDL:wsdl&service=mvola~WSMVolaGetInfosKYC";

Not sure if this would cause a problem, but at the very least it shouldn't be required. I'd try removing those parameters from the URL string.


text:
Q: What is the difference between using brackets "[]" and parentheses "()" for "fields" in django-rest-framework I have seen fields in the django-rest-framework initialized/declared with parentheses () and brackets [] and I am wondering if there is a difference.
I have only been using () but I see [] in the documentation everywhere.
Say we have a model Dog.
class Dog(models.Model):
    favorite_food = models.CharField(max_length=255)

Now would it be correct to say that these two serializers below for this Dog model are the same? Even though the field is declared with different ASCII characters.
class DogSerializer(serializers.ModelSerializer):
     class Meta:
         model = Dog
         fields = ('id', 'favorite_food')

class DogSerializer(serializers.ModelSerializer):
     class Meta:
         model = Dog
         fields = ['id', 'favorite_food']


text:
Q: Run two ApplicationReadyEvents one after another after application startup I have two classes that implements ApplicationListener<ApplicationReadyEvent> as below. Since they both implement this interface they both run after startup but I  would like to always run ClassB after ClassA is run. I don't have control to modify ClassA. I can only make changes to classB. How can I make sure the ClassB always run after ClassA.
public class ClassA implements ApplicationListener<ApplicationReadyEvent> {
    public void onApplicationEvent(ApplicationReadyEvent event){
        // do something
    }
}

public class ClassB implements ApplicationListener<ApplicationReadyEvent> {
    public void onApplicationEvent(ApplicationReadyEvent event){
        // do something
    }
}

Thanks in advance.

A: Just out of the blue I would try it with annotating each listener with @Order.
Spring normally orders injected lists this way. Could also be the case here.

A: In case when you really don't have a possibility to control one of the listeners and enforce its order via an annotation or implementing the Ordered interface, I don't see any other option than to do it directly in the application context's listener registry after the context is fully loaded. (Although I'd really suggest arranging it so that you do have control of how and when the ClassA listener is registered.)
Here's what you can do to guarantee your ClassB listener is registered after the ClassA one:

*

*make sure the ClassB listener you have control of is not a @Component, not declared as a @Bean and is not registered as a listener programmatically

*create a separate listener for the ContextRefreshedEvent that registers your ClassB listener:

    @Component
    public class ContextRefreshedEventListener implements ApplicationListener<ContextRefreshedEvent> {
        public void onApplicationEvent(ContextRefreshedEvent event) {
            final ApplicationContext context = event.getApplicationContext();
            if (context instanceof ConfigurableApplicationContext) {
                final ConfigurableApplicationContext abstractApplicationContext = (AbstractApplicationContext) context;
                abstractApplicationContext.addApplicationListener(new ClassB());
            }
        }
    }


text:
Q: How do we make a website appear first in Google Search? Can we control this? Any thoughts on how this behavior can be obtained?

A: Try altering what you type into Google.  For instance, if your website is tomsfarmsupplies.com, type site:tomsfarmsupplies.com into Google

A: This is all done by SEO (Search engine optimization), not programmatical or any thing...


text:
Q: Анимация между активити Здравствуйте. Нужно сделать следующую анимацию между двумя активити.
Вторая активити выезжает слева направо, поверх первой. В конце метод finish().
Из второй активити нужно возвращаться в первую, сдвигом второй активити, поверх первой обратно(т.е. справа налево).
Вроде бы простая анимация, но т.к. первая активити уничтожается, не понятно как такое реализовать.

A: Если вы хотите задать собственную анимацию при переключении между активностями, то можете сделать это несколькими способами.
У класса Activity есть метод overridePendingTransition() и он должен идти сразу после вызова метода startActivity() или finish(). Метод принимает два параметра: ресурс анимации для запускающей активности и ресурс анимации для уходящей активности.
Таким образом вам нужно создать в папке res/anim два файла анимации и передать их идентификаторы в метод.
http://developer.alexanderklimov.ru/android/animation/overridependingtransition.php
P.s. По личному опыту , использование анимации для активностей является плохим тоном.
Обычно для этих целей используются фрагменты.


text:
Q: Writing facebook data on html I am retriving data from facebook which I can show on console but failed to show on html page.
I tried with:
$("#mydiv").text(data);

or
$("#mydiv").append(data);

Which show [object Object] on browser.
my code is:
<?php
session_start();
$appId = 'APPID';
$appSecret = 'APPSECRET'; // Facebook App Secret
$return_url = 'dev01.dev/FB/facebook-php-sdk/examples/';  //path to script folder
//$fbPermissions = 'publish_stream,email'; //more permissions : https://developers.facebook.com/docs/authentication/permissions/
?>
<!DOCTYPE html>

<title>JS/Ajax Facebook Connect</title>

<?php
if(!isset($_SESSION['logged_in']))
{
?>

    <button type="button" onclick="CallAfterLogin()" ?>Click Me!</button>

<?php
}
?>

A: You must parse/loop through the object to get the data you want.
You can do something like data.FirstName to get the value of the FirstName property. (I don't know what the object contains, it's just an example).
JSFiddle
Here is an example:
HTML

JavaScript
/* I just created a random object */
var myObject = {toaster: 'toasts',
                chocolate: 'hot, chocolate!'};

/* I get the DOMElement to dump data within it */
var output = document.getElementById('output');

/* I loop through each property of the object and add them to my DOMElement container */
for (var prop in myObject)
{
    output.innerHTML += "
"+ myObject[prop] +"
";
}

Output

*

*toasts

*hot, chocolate!

Also: .innerHTML vs .appendChild() vs $.append().


text:
Q: Laravel + Guzzle + MailChimp - 400 Bad Request I get a 400 Bad Request when I do the Guzzle request, its the first time using Laravel, Guzzle and Mailchimp so I'm close to bite my fingers off. I don't understand what I'm doing wrong on this one. Can somebody help me?
$mailchimp = new Client(['base_uri' => 'https://us14.api.mailchimp.com/3.0/']);

$checkEmail = $mailchimp->request('POST', 'lists/ID/members/', [
        'headers' => [ 'Authorization' => 'apikey ' . config('globals.mailchimp_key') ],
        'json' => [
            'email_address' => $this->email,
            'status' => 'subscribed'
        ]
    ]);
return $checkEmail;

A: I think your header isn't formatted correctly (see the docs).
Try this way rather:
            $client = new \GuzzleHttp\Client();
            $res = $client->request('POST',       'https://us8.api.mailchimp.com/3.0/lists/6f0984e55f/members/', [
            'auth' => ['apikey', 'xxxxxxxxxxxxxx-us14'],
                'json' => [
                    'email_address' => 'example@example.com',
                    'status' => 'subscribed'
                ]
        ]);
        echo $res->getStatusCode();
        echo $res->getBody();


text:
Q: Use of the Leibniz integral rule in Laplace transform proof My Laplace transform textbook presents the following theorem:

If $\mathcal{L}\{ F(t) \} = f(s)$, then $\mathcal{L}\{ t F(t) \} = - \dfrac{d}{ds}f(s)$ and in general $\mathcal{L}\{ t^n F(t) \} = (-1)^n \dfrac{d^n}{ds^n} f(s)$.

The proof then begins as follows:

Proof Let us start with the definition of Laplace transform
$$\mathcal{L}\{ F(t) \} = \int_0^\infty e^{-st} F(t) \ dt$$
and differentiate this with respect to $s$ to give
$$\begin{align} \dfrac{df}{ds} &= \dfrac{d}{ds} \int_0^\infty e^{-st} F(t) \ dt \\ &= \int_0^\infty -te^{-st} F(t) \ dt \end{align}$$
...

My understanding is that the author went from
$$\dfrac{d}{ds} \int_0^\infty e^{-st} F(t) \ dt$$
to
$$\int_0^\infty -te^{-st} F(t) \ dt$$
by using the Leibniz integral rule to change the ordinary derivative to a partial derivative.
However, as you can see from the Wikipedia page, the Leibniz integral rule is only valid for $\int_{a(x)}^{b(x)}, b(x) < \infty$, whereas the Laplace transform has $b(x) = \infty$. Doesn't this mean that the Leibniz rule is invalid?
I would greatly appreciate it if people could please take the time to clarify this.

A:
The Leibniz Rule for an infinite region
If there is a positive function $g(x, y)$ that is integrable, with respect to $x$, on $[0,∞)$, for each $y$, and such that $|\frac{∂f}{∂y} (x, y)| ≤ g(x, y)$ for all $(x, y)$, then
$$\frac{d}{dy}\int_{0}^\infty f(x,y)\,dx=\int_{0}^\infty \frac{\partial}{\partial y} f(x,y)\,dx$$

Ref.: https://math.hawaii.edu/~rharron/teaching/MAT203/LeibnizRule.pdf


text:
Q: How can I convert an animation in PowerPoint into an animated GIF? In Microsoft PowerPoint 2013, I have a single slide containing a fairly complex animation. I would like to convert this animation to an animated GIF file.
I have tried saving the animation directly from PowerPoint into an mp4 or wmv video file. Unfortunately, both of these formats use lossy compression. When converted to GIF (using FFmpeg and ImageMagick), the output file is larger than necessary because it faithfully reproduces all of the mp4/wmv compression artefacts.
Is there any way to get PowerPoint to save a lossless video of my animation? Converting a lossless video to GIF should result in a significantly smaller file, as well as slightly cleaner output.
If it is not possible to get such a lossless video, is there any other recommended way to create a GIF of my animation?

A: Try using ffmpeg to generate the GIF as well. It's a two step process.
Step 1 Generate a palette
ffmpeg -i ppt.mp4 -vf palettegen palette.png

Step 2 Generate the GIF
ffmpeg -i ppt.mp4 -i palette.png -filter_complex paletteuse out.gif

If the above doesn't produce an acceptable result, we can try using ffmpeg to screengrab the PPT animation and use that as the source.


text:
Q: Easy Python ASync. Precompiler? imagine you have an io heavy function like this:
def getMd5Sum(path):
    with open(path) as f:
        return md5(f.read()).hexdigest()

Do you think Python is flexible enough to allow code like this (notice the $):
def someGuiCallback(filebutton):
    ...
    path = filebutton.getPath()
    md5sum = $getMd5Sum()
    showNotification("Md5Sum of file: %s" % md5sum)
    ...

To be executed something like this:
def someGuiCallback_1(filebutton):
    ...
    path = filebutton.getPath()
    Thread(target=someGuiCallback_2, args=(path,)).start()

def someGuiCallback_2(path):
    md5sum = getMd5Sum(path)
    glib.idle_add(someGuiCallback_3, md5sum)

def someGuiCallback_3(md5sum):
    showNotification("Md5Sum of file: %s" % md5sum)
    ...

(glib.idle_add just pushes a function onto the queue of the main thread)
I've thought about using decoraters, but they don't allow me to access the 'content' of the function after the call. (the showNotification part)
I guess I could write a 'compiler' to change the code before execution, but it doesn't seam like the optimal solution.
Do you have any ideas, on how to do something like the above?

A: You can use import hooks to achieve this goal...

*

*PEP 302 - New Import Hooks

*PEP 369 - Post Import Hooks
... but I'd personally view it as a little bit nasty.
If you want to go down that route though, essentially what you'd be doing is this:

*

*You add an import hook for an extension (eg ".thpy")

*That import hook is then responsible for (essentially) passing some valid code as a result of the import.

*That valid code is given arguments that effectively relate to the file you're importing.

*That means your precompiler can perform whatever transformations you like to the source on the way in.

On the downside:

*

*Whilst using import hooks in this way will work, it will surprise the life out of any maintainer or your code. (Bad idea IMO)

*The way you do this relies upon imputil - which has been removed in python 3.0, which means your code written this way has a limited lifetime.

Personally I wouldn't go there, but if you do, there's an issue of the Python Magazine where doing this sort of thing is covered in some detail, and I'd advise getting a back issue of that to read up on it. (Written by Paul McGuire, April 2009 issue, probably available as PDF).
Specifically that uses imputil and pyparsing as it's example, but the principle is the same.

A: How about something like this:
def performAsync(asyncFunc, notifyFunc):
    def threadProc():
        retValue = asyncFunc()
        glib.idle_add(notifyFunc, retValue)
    Thread(target=threadProc).start()

def someGuiCallback(filebutton):
    path = filebutton.getPath()
    performAsync(
        lambda: getMd5Sum(path),
        lambda md5sum: showNotification("Md5Sum of file: %s" % md5sum)
    )

A bit ugly with the lambdas, but it's simple and probably more readable than using precompiler tricks.

A: Sure you can access function code (already compiled) from decorator, disassemble and hack it. You can even access the source of module it's defined in and recompile it. But I think this is not necessary. Below is an example using decorated generator, where yield statement serves as a delimiter between synchronous and asynchronous parts:
from threading import Thread
import hashlib

def async(gen):
    def func(*args, **kwargs):
        it = gen(*args, **kwargs)
        result = it.next()
        Thread(target=lambda: list(it)).start()
        return result
    return func

@async
def test(text):
    # synchronous part (empty in this example)
    yield # Use "yield value" if you need to return meaningful value
    # asynchronous part[s]
    digest = hashlib.md5(text).hexdigest()
    print digest


text:
Q: issue with javafx threads I am doing a javafx application and trying to work with threads. I did some research about similar questions on s.o but none of them answers exactly what I'm asking.
This is my first time working with threads in java fx.
This code downloads 2 images from internet and displays them into an ImageView, also returns some text and put it into a textArea. This piece of code executed with no threads would take about 15 seconds of total GUI freeze.
    Service<Void> service = new Service<Void>() {
        @Override
        protected Task <Void> createTask() {
            return new Task<Void>() {
                @Override
                protected Void call() throws Exception {

                    //Background work with long tasks

           return null;
            }

    };
                        Platform.runLater(new Runnable() {
                        @Override
                        public void run() {
                            try {

                                //Update GUI (short task)
                    });
                    return null;
                }
            };
        }
    };
    service.start();

But when I execute this code WITH the concurrency thread, the GUI does not get frozen anymore  (at least) but the code doesn't execute well (the images are not downloaded and therefore the GUI is not updated). What can I do in those cases?


text:
Q: rails validation of presence not failing on nil I want to make sure an attibute exists, but it seems to still slip thru and I'm not sure how better to check for it.
This should work, but doesn't.  It's a attr_accessor and not a real attribute if that makes a difference.
validates_presence_of :confirmed, :rooms

{"commit"=>"Make Booking",
 "place_id"=>"the-kosmonaut",
 "authenticity_token"=>"Tkd9bfGqYFfYUv0n/Kqp6psXHjLU7CmX+D4UnCWMiMk=",
 "utf8"=>"✓",
 "booking"=>{"place_id"=>"6933",
 "bookdate"=>"2010-11-22",
 "rooms"=>[{}],
 "no_days"=>"2"}}

Not sure why my form_for returns a blank hash in an array...
<% form_for :booking, :url => place_bookings_path(@place) do |f| %>
<%= f.hidden_field :bookdate, { :value => user_cart.getDate } %>
<%= f.hidden_field :no_days, { :value => user_cart.getDays } %>

<% for room in pricing_table(@place.rooms,@valid_dates) %>

  <%= select_tag("booking[rooms][][#{room.id}]", available_beds(room)) %>

<% end %>
<% end %>

A: Override validate method and write your custom validation check there. Something like
def validate
  if rooms.blank? || rooms.first.blank? # first because it seems to be an array that holds only one Hash.
    errors.add_to_base "Rooms can't be blank."
  end
end

By the way, why is rooms structured to be an array that holds a single hash? For a more sensible solution, you might want to explain that.

A: Building on Chirantan's answer, isn't rooms a child of the booking hash? So shouldn't it be:
def validate
  if booking[:rooms].blank? || booking[:rooms].first.blank?
    errors.add_to_base "Rooms can't be blank."
  end
end

A: validates_presence_of checks whether a field is blank. The validation would fail if your rooms array was empty (  set to []   ), but since your array contains a hash it is not empty, so the validation does not fail.
To demonstrate, try this from the console:
a = []
a.empty?

This will return true.
a = [{}]
a.empty?

Returns false.

A: Try removing a dimension from your array:
<%= select_tag("booking[rooms][#{room.id}]", available_beds(room)) %>

instead of
<%= select_tag("booking[rooms][][#{room.id}]", available_beds(room)) %>


text:
Q: Otp should not accessed after 4 hours I have written a code for verification through email by sending otp. I have to configure in such a way that if the user enters the otp after 4 hours it should not be accepted.
I have used date object with if conditions and it works fine but is there any way to achieve same in less coding.
Date dateFromDatabase=emailData.getBody().getUpdated();

if((dateFromDatabase.getYear()-date.getYear())==0){

    if((dateFromDatabase.getMonth()-date.getMonth())==0){

        if((dateFromDatabase.getDay()-date.getDay())==0){
            if((dateFromDatabase.getHours()-date.getHours())<=4){
                System.out.print("May Be Right otp");

                if( emailData.getBody().getHASHCODE().equals(fromotp)){
                    System.out.print("matched");
                    emails.setId(emailData.getBody().getId());
                    emails .setVERIFIED(1);
                    emails.setHASHCODE("");
                    emails.setEmails(To);
                    //updateEmails(emails);
                    String Subject="Pharmerz Thanknote";
                    String Acknowledge="Thank you for verifying on Pharmerz";
                    email.SendMail(To,Subject,Acknowledge);
                    Emails saveEmails =emailService.create( emails );
                    return new ResponseEntity<Emails>(emails,HttpStatus.OK);

                }else{
                    System.out.print("miss matched");
                    emailService.delete(emailData.getBody().getId());
                    return new ResponseEntity<Emails>(HttpStatus.BAD_REQUEST);
                }

            }else{
                System.out.print("Wrong or Old Otp");
                emailService.delete(emailData.getBody().getId());
                return new ResponseEntity<Emails>(HttpStatus.BAD_REQUEST);
            }
        }else{
            System.out.print("Wrong or Old Otp");
            emailService.delete(emailData.getBody().getId());
            return new ResponseEntity<Emails>(HttpStatus.BAD_REQUEST);
        }

    }else{
        System.out.print("Wrong or Old Otp");
        emailService.delete(emailData.getBody().getId());
        return new ResponseEntity<Emails>(HttpStatus.BAD_REQUEST);
    }

}
else{
    System.out.print("Wrong or Old Otp");
    emailService.delete(emailData.getBody().getId());
    return new ResponseEntity<Emails>(HttpStatus.BAD_REQUEST);
}

A: Try this :
Date currentDate = new Date();
Date dateFromDatabase = // get the date from the database

long duration  = dateFromDatabase.getTime() - currentDate.getTime();
long diffInHours = TimeUnit.MILLISECONDS.toHours(duration);

You can use the diffInHours variable and perform your business logic.

A: tl;dr
Duration.between(                      // Span-of-time unattached to timeline.
    myUtilDate.toInstant() ,           // Convert legacy java.util.Date object to modern java.time.Instant.
    Instant.now()                      // Get the current moment.
).compareTo( Duration.ofHours( 4 ) )   // Ask if the time span variance exceeds our limit of four hours.

Avoid legacy date-time classes.
I assume your Date object at top of code is a java.util.Date. That class is part of the troublesome old date-time classes that are now legacy, supplanted by the java.time classes.
Using java.time
Instant
Convert that Date to its modern equivalent: Instant. The Instant class represents a moment on the timeline in UTC with a resolution of nanoseconds (up to nine (9) digits of a decimal fraction).
Instant then = myUtilDate.toInstant();

Apparently you want to compare this against the current moment and look for a four-hour variance, though your Question is not clear.
Get the current moment is simple.
Instant now = Instant.now();

Duration
Represent a span of time unattached to the timeline as a Duration.
Duration variance = Duration.between( then , now );

Check for a negative duration, meaning the past moment is actually showing as future.
if( variance.isNegative() ) { … handle error condition … }

Compare that duration to our limit of 4 hours. If the time span between then and now is over four hours, compareTo returns a positive number (number greater than zero).
Duration limit = Duration.ofHours( 4 );
Boolean exceededLimit = ( variance.compareTo( limit ) > 0 ) ; // If the time span between then and now is over four hours, `compareTo` returns a positive number (number greater than zero).

About java.time
The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date, Calendar, & SimpleDateFormat.
The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.
To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.
Where to obtain the java.time classes?

*

*Java SE 8, Java SE 9, and later

*

*Built-in.

*Part of the standard Java API with a bundled implementation.

*Java 9 adds some minor features and fixes.

*Java SE 6 and Java SE 7

*

*Much of the java.time functionality is back-ported to Java 6 & 7 in ThreeTen-Backport.

*Android

*

*The ThreeTenABP project adapts ThreeTen-Backport (mentioned above) for Android specifically.

*See How to use ThreeTenABP….

The ThreeTen-Extra project extends java.time with additional classes. This project is a proving ground for possible future additions to java.time. You may find some useful classes here such as Interval, YearWeek, YearQuarter, and more.


text:
Q: Child class not found by the parent class I am experimenting with php class inheritance, I wrote the below code and got an uncaught error that the User class is not found. Please any help about where am going wrong will be fine.
the first block is the User class

         <?php
          class User{
                private $name;
                private $age;

                public function _construct($name, $age){
                $this->name = $name;
                $this->age = $age;
            }
        }
        ?>

below is the customer class that inherit the user class.
    <?php

    class Customer extends User{
        private $balance;

        public function __construct($name, $age, $balace) {
              parent::_construct($name, $age);
              $this->balance = $balace;
       }
         public function pay($amount){
        return $this->name ." paid $".$amount;
    }
    public function getBalance(){
        return $this->balance;
    }
}

$customer = new Customer("Matt", 23, 500);
echo $customer->getBalance();

A: I have checked your code by implementing it in a single file. It works fine.
If you are having 2 files for both classes, you need to include the User class file into the Customer class file like below.
require_once('User.php');


text:
Q: Spring Boot webserver works fine in Eclipse, fails to start on Server : missing EmbeddedServletContainerFactory bean Following the model of the Spring Documentation I created a very simple Hello World like application.  It spun right up on Eclipse and everything looked great.  Sweet!  I ran it and could browse to the URL.  Fastest development ever.
But this has to run on a server, and looking at the jar, it was only about 4K so I knew that it wasn't going to work without a bunch of classpath configuration. To avoid that, I figured I needed a jar-with-dependencies jar.
So this is my pom.xml, basically identical to that of the Spring example except adding the jar-with-dependencies goal for the assembly plugin.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.whatever</groupId>
    <artifactId>LoadTestController</artifactId>
    <version>1.0.0</version>
    <name>LoadTestController</name>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.0.RELEASE</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.whatever.LoadTestController</mainClass>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

But when I go to run the thing:
java -jar LoadTestController-1.0.0-jar-with-dependencies.jar

I get:

org.springframework.context.ApplicationContextException: Unable to
  start embedded container; nested exception is
  org.springframework.context.ApplicationContextException: Unable to
  start EmbeddedWebApplicationContext due to missing
  EmbeddedServletContainerFactory bean.

I don't think it should make any difference but here is the one (and only) class in this project:
package com.whatever;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@EnableAutoConfiguration
public class LoadTestController {

    @RequestMapping("/")
    public void simulator(HttpServletResponse response) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e1) {

        }
        response.setContentType("text/plain");
        response.setStatus(HttpServletResponse.SC_OK);
        try {
            response.getOutputStream().println("0");
            response.flushBuffer();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    /**
     * @param args
     */
    public static void main(String[] args) {
        SpringApplication.run(LoadTestController.class, args);
    }

What have I done wrong?

A: And the answer is ...
Don't use the maven-assembly-plugin.  Reading further on in the documentation, we see that Spring has made their own plugin for this, the spring-boot-maven-plugin.  Changing the pom.xml to remove the maven-assembly-plugin and use instead:
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <executions>
            <execution>
                <goals>
                    <goal>repackage</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

solves the problem.
I decided to leave this question up in case anyone else runs into this problem.  You think you know how to do something, but time marches on.


text:
Q: Weyl group of a non-symmetrizable Generalized Cartan Matrix Let $A$ be a generalized Cartan matrix on the index set $I$. Define the Weyl group of $A$ as the Coxeter group on the basis $I$ with $m(i,j)=2,3,4,6,\infty$ according to whether $A_{ij} A_{ji}$ is $0,1,2,3$ or bigger. It acts on ${\mathbb Z}[I]$ by $s_j(i) := i - A_{ij} j$.
Question: Is this action faithful?
If $A$ is symmetrizable then the above representation is just a ${\mathbb Z}$-form of the geometric representation of $W$, defined for any Coxeter group. As the latter is always faithful, so is our representation of $W$ on ${\mathbb Z}[I]$.
What happens if $A$ is not symmetrizable?
The motivation for the question comes from Kac-Moody algebras: If $({\mathfrak h},{\mathfrak h}^{\ast},\{\alpha_i\},\{h_j\})$ is a minimal realization of $A$, then the above action of $W$ on ${\mathbb Z}[I]$ occurs as the restriction of the action of $W$ on ${\mathfrak h}^{\ast}$ to the lattice ${\mathbb Z}[\{\alpha_i\}_{i\in I}]\subseteq{\mathfrak h}^{\ast}$ generated by the roots $\alpha_i$. I would like to know if this action is faithful. Again, if $A$ is symmetrizable, then one can introduce a non-degenerate bilinear form on ${\mathfrak h}^{\ast}$ such that the $s_i$ act as orthogonal reflections associated to the (anisotropic) roots $\alpha_i$, and one can show that for any $w\in W\setminus\{e\}$ with reduced expression $s_{i_n}\cdots s_{i_1}$ we must have $w(\alpha_{i_1})<0$. In particular, $w$ does not act trivially on ${\mathbb Z}[\{\alpha_i\}]$ in this case. However, I didn't manage prove the exchange lemma involved here without the description of the $s_i$ as orthogonal reflections. Specifically, how do I know that if $w(\alpha_i)=\alpha_j$, then $s_j = w s_i w^{-1}$ (on ${\mathfrak h}^{\ast}$)?
Thank you!


text:
Q: Error with MysqlDB python3 CentOS and _mysql Flask I am trying to get my python3 flask app to work on Centos. At first I was getting this error:
ImportError: this is MySQLdb version (1, 3, 10, 'final', 0), but _mysql is version (1, 2, 5, 'final', 1)
So I removed python-mysql (whatever it was named) and Now I am not sure what to install to get this working.


text:
Q: Limit problem: $\lim_{t\to1} \frac {\sqrt {2t^2-1}\sqrt[3]{4t^3-3t}-1}{t^2-1}$ Update:

$$\lim_{t\to1} \frac {\sqrt {2t^2-1}\sqrt[3]{4t^3-3t}-1}{t^2-1}$$

First of all, I am grateful to you for all the answers you have given me.
I want to ask MSE to confirm the correctness of the alternate solution and its mistake.
I worked so hard for solve this limit without L'Hôpital. I tried to solve this limit myself. Because, I like it.
And I trust MSE. Because, MSE is always the real teacher for me.
Please, teach me., my mistakes.

$$\begin{align}&\lim_{t \to 1}\frac {\sqrt{2t^2-1}×\sqrt[3]{4t^3-3t}-1}{t^2-1}\\\\&=\lim_{t \to 1} \frac {\sqrt[3]{4t^3-3t}-\frac{1}{\sqrt{2t^2-1}}}{\frac{t^2-1}{\sqrt{2t^2-1}}}\\\\&=\lim_{t \to 1}\frac{4t(t^2-1)+t-\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}}{(t^2-1)×\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\\\\&=\lim_{t \to 1}\frac{4t+\frac{t(2t^2-1)×\sqrt{2t^2-1}-1}{(2t^2-1)×\sqrt{2t^2-1}×(t^2-1)}}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\\\\&=\lim_{t \to 1}\frac{4t}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]
}\\\\&\qquad\qquad+\lim_{t \to 1}\frac{\frac{t(2t^2-1)×\sqrt{2t^2-1}-1}{(2t^2-1)×\sqrt{2t^2-1}×(t^2-1)}}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]
}\\\\&= \frac{4}{3}+\frac{1}{3}\lim_{t \to 1}\frac{t(2t^2-2)×\sqrt{2t^2-1}+t×\sqrt{2t^2-1}-1}{(t^2-1)×(2t^2-1)×\sqrt{2t^2-1}}\\\\&=\frac{4}{3}+\frac 13\lim_{t \to 1}\frac{2t}{2t^2-1}+\frac 13\lim_{t \to 1}\frac{t×\sqrt{2t^2-1}-1}{(t^2-1)(2t^2-1)\sqrt{2t^2-1}}\\\\&=\frac{4}{3}+\frac 23+\frac 13\lim_{t \to 1}\frac{2t^4-t^2-1}{(t^2-1)(2t^2-1)\sqrt{2t^2-1}×(\sqrt{2t^4-t^2}+1)}\\\\&=2+\frac 13 \lim_{t \to 1}\frac{(t^2-1)(2t^2+1)}{(t^2-1)(2t^2-1)\sqrt{2t^2-1}×(\sqrt{2t^4-t^2}+1)}\\\\&=2+\frac 13 \lim_{t \to 1}\frac{(2t^2+1)}{(2t^2-1)\sqrt{2t^2-1}×(\sqrt{2t^4-t^2}+1)}\\\\&=2+\frac 13×\frac{3}{2}=2+\frac 12=\frac 52.\end{align}$$

I doubt that I have correctly applied the limit rules. Did I apply all the limit rules correctly  and is the solution correct..?
Thank you!

A: $$=\frac{\sqrt{2t^2-1}-1}{t^2-1}\sqrt[3]{4t^3-3t}+\frac{\sqrt[3]{4t^3-3t}-1}{t^2-1}$$ now multiply by conjugates and you get the right answer.
As for the second part is possible that the other value of $t$ gives the same value as the limit to 1.

A: Elegant, I do not know, but a possible solution.
Let $t=x+1$ making the expression to be
$$A=\frac{\sqrt{2 x^2+4 x+1} \sqrt[3]{4 x^3+12 x^2+9 x+1}-1}{x (x+2)}$$ Now, using Taylor around $x=0$ or binomial expansion
$$\sqrt{2 x^2+4 x+1}=1+2 x-x^2+2 x^3+O\left(x^4\right)$$
$$ \sqrt[3]{4 x^3+12 x^2+9 x+1}=1+3 x-5 x^2+\frac{67 }{3}x^3+O\left(x^4\right)$$
$$\sqrt{2 x^2+4 x+1} \sqrt[3]{4 x^3+12 x^2+9 x+1}=1+5 x+\frac{34 x^3}{3}+O\left(x^4\right)$$ making
$$A=\frac{5}{2}-\frac{5 }{4}x+O\left(x^2\right)$$
Concerning the second point, may I suggest you plot thr function for $-1 \leq t \leq 2$ ? You should understand why this number.

A: You did a hard work, but it should be better to add some justifications when you use
$$\lim_{t\to 1}(f(t)+g(t))=\lim_{t\to 1}f(t)+\lim_{t\to 1}g(t)\tag1$$
$$\lim_{t\to 1}f(t)g(t)=\lim_{t\to 1}f(t)\lim_{t\to 1}g(t)\tag2$$
since these do not always hold.

$$\begin{align}\lim_{t \to 1}\frac {\sqrt{2t^2-1}×\sqrt[3]{4t^3-3t}-1}{t^2-1}&=\lim_{t \to 1} \frac {\sqrt[3]{4t^3-3t}-\frac{1}{\sqrt{2t^2-1}}}{\frac{t^2-1}{\sqrt{2t^2-1}}}\\\\&=\lim_{t \to 1}\frac{4t(t^2-1)+t-\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}}{(t^2-1)×\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\\\\&=\lim_{t \to 1}\frac{4t+\frac{t(2t^2-1)×\sqrt{2t^2-1}-1}{(2t^2-1)×\sqrt{2t^2-1}×(t^2-1)}}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\end{align}$$

This is correct. (It seems that you used $a-b=\frac{a^3-b^3}{a^2+ab+b^2}$)

$$\begin{align}&\lim_{t \to 1}\frac{4t+\frac{t(2t^2-1)×\sqrt{2t^2-1}-1}{(2t^2-1)×\sqrt{2t^2-1}×(t^2-1)}}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\\\\&=\lim_{t \to 1}\frac{4t}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\\\\&\qquad\qquad\quad+\lim_{t \to 1}\frac{\frac{t(2t^2-1)×\sqrt{2t^2-1}-1}{(2t^2-1)×\sqrt{2t^2-1}×(t^2-1)}}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\\\\&=\frac{4}{3}+\frac{1}{3}\lim_{t \to 1}\frac{t(2t^2-2)×\sqrt{2t^2-1}+t×\sqrt{2t^2-1}-1}{(t^2-1)×(2t^2-1)×\sqrt{2t^2-1}}\end{align}$$

This is correct, but it should be better to add some explanations about why you can use $(1)(2)$ here. I think using $(1)(2)$ without any justifications is not good.

You can avoid using $(1)(2)$.
Using your manipulations, we have
$$\begin{align}&\lim_{t \to 1}\frac{4t+\frac{t(2t^2-1)×\sqrt{2t^2-1}-1}{(2t^2-1)×\sqrt{2t^2-1}×(t^2-1)}}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\\\\&=\lim_{t \to 1}\frac{4t+\frac{t(2t^2-2)×\sqrt{2t^2-1}+t×\sqrt{2t^2-1}-1}{(t^2-1)×(2t^2-1)×\sqrt{2t^2-1}}}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\\\\&=\lim_{t \to 1}\frac{4t+\frac{2t}{2t^2-1}+\frac{t×\sqrt{2t^2-1}-1}{(t^2-1)(2t^2-1)\sqrt{2t^2-1}}}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\\\\&=\lim_{t \to 1}\frac{4t+\frac{2t}{2t^2-1}+\frac{2t^4-t^2-1}{(t^2-1)(2t^2-1)\sqrt{2t^2-1}×(\sqrt{2t^4-t^2}+1)}}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\\\\&=\lim_{t \to 1}\frac{4t+\frac{2t}{2t^2-1}+\frac{(t^2-1)(2t^2+1)}{(t^2-1)(2t^2-1)\sqrt{2t^2-1}×(\sqrt{2t^4-t^2}+1)}}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\\\\&=\lim_{t \to 1}\frac{4t+\frac{2t}{2t^2-1}+\frac{(2t^2+1)}{(2t^2-1)\sqrt{2t^2-1}×(\sqrt{2t^4-t^2}+1)}}{\left[ \frac{\sqrt[3]{(4t^3-3t)^2}}{\sqrt{2t^2-1}}+\frac{\sqrt[3]{4t^3-3t}}{2t^2-1}+\frac{1}{(2t^2-1)×\sqrt{2t^2-1}}\right]}\\\\&=\frac{4+2+\frac 32}{1+1+1}=\frac 52\end{align}$$

A: The expressions suggest setting $t = \cos x$. The limit transforms to
$\displaystyle \lim_{x \rightarrow 0} \dfrac{1-\sqrt{\cos 2x } \sqrt [3] {\cos 3x }}{\sin^2 x}  = \lim_{x \rightarrow 0} \dfrac{1-\sqrt{\cos 2x} +\sqrt{\cos 2x} - \sqrt{\cos 2x } \sqrt [3] {\cos 3x }}{\sin^2 x}$
Now, $\dfrac{1-\sqrt{\cos 2x}}{\sin^2 x} = \dfrac{1-\cos 2x}{\sin^2 x (1+\sqrt{\cos 2x})} = \dfrac{2}{1+\sqrt{\cos 2x}} \rightarrow 1$ as $x \rightarrow 0$
and  $\dfrac{\sqrt{\cos 2x} - \sqrt{\cos 2x } \sqrt [3] {\cos 3x }}{\sin^2 x} = \dfrac{\sqrt{\cos 2x} \left(1-\sqrt [3] {\cos 3x } \right)}{\sin^2 x}$
$=\dfrac{\sqrt{\cos 2x} \left(1-\cos 3x \right)}{\sin^2 x \left(1+\sqrt [3] {\cos 3x }+ \left(\sqrt [3] {\cos 3x } \right)^2 \right)}$
$=\dfrac{2 \sqrt{\cos 2x} \sin^2 \dfrac{3x}{2} }{\sin^2 x \left(1+\sqrt [3] {\cos 3x }+ \left(\sqrt [3] {\cos 3x } \right)^2 \right)}$
$=\displaystyle \lim_{x \rightarrow 0} \dfrac{1-\cos 2x \cos 3x }{\sin^2 x (1+\sqrt{\cos 2x \cos 3x })} \rightarrow \dfrac{3}{2}$ as $x \rightarrow 0$
Hence the limit equals $1+\dfrac{3}{2} = \dfrac{5}{2} $

A: Using the equality
$$
x-1=\frac{x^6-1}{1+x+x^2+x^3+x^4+x^5},
$$
we get (using Wolfram Alpha to expand and then to divide)
\begin{align}
\frac{\sqrt {2t^2-1}\sqrt[3]{4t^3-3t}-1}{t^2-1}&=\frac {({2t^2-1})^3({4t^3-3t})^2-1}{(t^2-1)\sum_{k=0}^5( {2t^2-1})^{k/2}({4t^3-3t})^{k/3}}\\ \ \\
&=\frac{-1 - 9 t^2 + 78 t^4 - 268 t^6 + 456 t^8 - 384 t^{10} + 128 t^{12}}{(t^2-1)\sum_{k=0}^5( {2t^2-1})^{k/2}({4t^3-3t})^{k/3}}\\ \ \\
&=\frac{1 + 10 t^2 - 68 t^4 + 200 t^6 - 256 t^8 + 128 t^{10}}{\sum_{k=0}^5( {2t^2-1})^{k/2}({4t^3-3t})^{k/3}}\\ \ \\
\end{align}
For $t=1$ we get
$$
\frac{1 +10-68+200-256+128}{(1+1+1+1+1+1)}=\frac{15}{6}=\frac52.
$$

A: Let's set:
$$\frac {\sqrt {2t^2-1}\sqrt[3]{4t^3-3t}-1}{t^2-1} \quad t=\cos x \quad x\to0$$
$$\frac {\sqrt {2\cos^2x-1}\sqrt[3]{4\cos^3 x-3\cos x}-1}{-\sin^2x} = \frac {\sqrt {\cos 2x}\sqrt[3]{\cos x(2\cos 2x-1)}-1}{-\sin^2x}$$
By Taylor series we have:
$$\cos x=1-\frac{x^2}{2}+o(x^2)$$
$$(1+x)^n=1+nx+o(x)$$
Thus:
$$=\frac {\sqrt {1-2x^2+o(x^2)}\sqrt[3]{(1-\frac{x^2}{2}+o(x^2))(1-4x^2+o(x^2))}-1}{-x^2+o(x^2)}=$$
$$=\frac {\sqrt {1-2x^2+o(x^2)}\sqrt[3]{(1-\frac{9x^2}{2}+o(x^2)}-1}{-x^2+o(x^2)}=$$
$$=\frac {{(1-x^2+o(x^2)}{(1-\frac{3x^2}{2}+o(x^2))}-1}{-x^2+o(x^2)}=\frac {-\frac{5x^2}{2}+o(x^2)}{-x^2+o(x^2)}\to \frac52$$
NOTE
$$\frac {\sqrt {2t^2-1}\sqrt[3]{4t^3-3t}-1}{t^2-1}=\frac 52 \Rightarrow t≈-0.849620116911296$$

it's a solution of the equation thus the value of $t$ belong to the domain of the function whereas the limit is calculated for a point for which the function is not defined

A: Let
$t = 1+x$.
Then
$\begin{array}\\
\dfrac {\sqrt {2t^2-1}\sqrt[3]{4t^3-3t}-1}{t^2-1}
&=\dfrac {\sqrt {2x^2+4x+1}\sqrt[3]{4 x^3 + 12 x^2 + 9 x + 1}-1}{x^2+2x}\\
&=\dfrac {(1+2x+O(x^2))(1+3x+O(x^2))-1}{x^2+2x}\\
&=\dfrac {1+5x+O(x^2)-1}{x^2+2x}\\
&=\dfrac {5+O(x)}{x+2}\\
&=\dfrac52+O(x)\\
\end{array}
$

A: Limits to infinity are easier, so:
$$\lim_{t\to1} \frac {\sqrt {2t^2-1}\sqrt[3]{4t^3-3t}-1}{t^2-1} =$$
$$\lim_{u\to0} \frac {\sqrt {2(u+1)^2-1}\sqrt[3]{4(u+1)^3-3(u+1)}-1}{(u+1)^2-1} =$$
$$\lim_{u\to0} \frac {\sqrt {2(u^2+2u+1)-1}\sqrt[3]{4(u^3+3u^2+3u+1)-3(u+1)}-1}{u^2+2u+1-1} =$$
$$\lim_{u\to0} \frac {\sqrt {2u^2+4u+1}\sqrt[3]{4u^3+12u^2+9u+1}-1}{u^2+2u} =$$
$$\lim_{z\to\infty} \frac {\sqrt {2/z^2+4/z+1}\sqrt[3]{4/z^3+12/z^2+9/z+1}-1}{1/z^2+2/z} =$$
$$\lim_{z\to\infty} \frac {\sqrt {2+4z+z^2}\sqrt[3]{4+12z+9z^2+z^3}-z^2}{1+2z} =$$
$$\lim_{z\to\infty} \frac {\sqrt {4+4z+z^2}\sqrt[3]{27+27z+9z^2+z^3}-z^2}{2z} =$$
$$\lim_{z\to\infty} \frac {(z+2)(z+3)-z^2}{2z} =$$
$$\lim_{z\to\infty} \frac {z^2+5z+6-z^2}{2z} =$$
$$\lim_{z\to\infty} \frac {5z+6}{2z} =\frac52.$$


text:
Q: assert that an object is an integer number Using should.js, I am currently doing:
ordinal.should.be.a.Number().and.equal(Math.floor(ordinal));

… is there a more concise way to require that a given object be an integer?

A: You can use Number.isSafeInteger (to test for 64-bit integers) and Number.isInteger.  To use with Should.js:
should.ok(Number.isSafeInteger(ordinal));

I generally recommend using Number.isSafeInteger...unless you know you're dealling with potentially really large integer values that have to be stored as floating-point.