text:
Q: multithread server socket with delphi xe5 for android how can i make multithread socket with events (onread, onconnect,...) for ;
unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
  androidapi.JNI.JavaTypes, FMX.Layouts, FMX.Memo, IdBaseComponent, IdThreadComponent,
  Android.Soket;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    th: TIdThreadComponent;
    procedure Button1Click(Sender: TObject);
    procedure thRun(Sender: TIdThreadComponent);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  serversoket:JServerSoket;
  client:JSoket;
  output:JoutStream;
  input :JinStream;

implementation

{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
begin
  try
    serversoket:=TJServerSoket.JavaClass.init(8090);
    memo1.Lines.Add('listen, only 1 client');
  except
    on E:Exception do memo1.Lines.Add('Cant open port: '+E.Message);

  end;
  th.Active:=true;
  th.Start;
end;

procedure TForm1.thRun(Sender: TIdThreadComponent);
var msg:string;
begin
  client  :=serversoket.accept;
  if client.isConnected then
  begin
    if client.getInputStream.available>-1 then
    begin
      input:=tjinstream.JavaClass.init(client.getInputStream);
      output:=tJoutStream.JavaClass.init(client.getOutputStream)  ;
    end;
    while true do
     begin
      msg:=jstringtostring(input.readline);
      memo1.Lines.Add('Read: '+ msg );
      output.writeUTF(stringtojstring('msg: '+msg ) );
      memo1.Lines.Add('Write!' );
      output.flush;
     end;
  end;
end;

end.

android server socket api for delphi ( :P ) ;
unit Android.Soket;

interface

uses  Androidapi.JNIBridge, Androidapi.Jni,  androidapi.JNI.JavaTypes, androidapi.JNI.Net,
      Androidapi.JNI.Os, FMX.Helpers.Android, Androidapi.JNI.GraphicsContentViewText,System.SysUtils,
      System.Types, System.UITypes, System.Classes, System.Variants,FMX.Memo;

type

  ////////////////////////////soket/////////////////////////////

  [javaSignature('java/net/InetAddress')]
  JAdres=interface(JObject)
  ['{7A525333-38BC-4D2A-8160-D164D1CAA30E}']
    function getHostName:Jstring;cdecl;
    property Host:Jstring read getHostName;
  end;

  JAdresClass=interface(JObjectClass)
  ['{B34C47C9-7FC8-4120-B087-60F517A9323D}']
  end;
  TJAdres = class(TJavaGenericImport<JAdresClass, JAdres>) end;

 ////////////////out buffer////////////////////

  [javaSignature('java/io/OutputStream')]
  Jout=interface(jobject)
    ['{AC9EEC99-FF3A-46E4-AFC3-C4D3309D8C8E}']
  end;
  JoutClass = interface(JObjectClass)
    ['{46FBBEEE-22C7-45EA-BED3-A41BED01E500}']
    end;
  TJout = class(TJavaGenericImport<JoutClass, Jout>) end;

  [javaSignature('java/io/DataOutputStream')]
  JoutStream=interface(jobject)
    ['{A6421CC3-B76C-4124-AB2E-AEE0C4749E71}']
    procedure write(buffer:TJavaArray<byte>;offset,count:integer);cdecl;overload;
    procedure write(buffer:TJavaArray<byte>);cdecl;overload;
    procedure write(buffer:byte);cdecl;overload;
    procedure writeChars(str:jstring);cdecl;
    procedure writeUTF(str:jstring);cdecl;
    procedure close;cdecl;
    procedure flush;cdecl;
  end;
  JoutStreamClass = interface(JObjectClass)
    ['{83D69F8F-8833-4EF5-B00D-2EA45F58AC46}']
    function init(obj:Jout):JoutStream; cdecl;overload;//Deprecated
  end;
  TJoutStream = class(TJavaGenericImport<JoutStreamClass, JoutStream>) end;
  ///////////////////////input buffer/////////////////

  [javaSignature('java/io/InputStream')]
  Jin=interface(jobject)
    ['{50F3A57E-7E09-4727-954C-34298755D5ED}']
    function read(buffer:TJavaArray<byte>;offset:integer;count:integer):integer;cdecl;overload;
    function read(buffer:TJavaArray<byte>):integer;cdecl;overload;
    function read():integer;cdecl;overload;
    function available():integer;cdecl;
    procedure close;cdecl;
    procedure reset;cdecl;
  end;
  JinClass = interface(JObjectClass)
    ['{91C1D3F0-30FD-4961-9560-1B9045DBAC3B}']
    function init():Jin; cdecl;overload;//Deprecated
  end;
  TJin = class(TJavaGenericImport<JinClass, Jin>) end;
  /////////////////////////////////////////////////////
  [javaSignature('java/io/DataInputStream')]
  JinStream=interface(jobject)
  ['{839ACAEC-229A-4261-88B4-136173B6FCBF}']
    function available():integer;cdecl;
    function read(buffer:TJavaObjectArray<byte>;offset,count:integer):integer;cdecl;overload;
    function read(buffer:TJavaObjectArray<byte>):integer;cdecl;overload;
    function read():integer;cdecl;overload;
    function readUTF():jstring;cdecl;
    function readLine():jstring;cdecl;
    procedure close;cdecl;
    procedure reset;cdecl;
  end;
  JinStreamClass = interface(JObjectClass)
  ['{27B4071A-5BC8-4594-A701-DBB92DBEE45A}']
    function init(obj:Jin):JinStream; cdecl;overload;
  end;
  TJinStream = class(TJavaGenericImport<JinStreamClass, JinStream>) end;

 ////////////////client socket////////////////////
  [javaSignature('java/net/Socket')]
  JSoket=interface(jobject)
  ['{A8A35BE7-5562-44C5-B599-40B76AD30116}']
    procedure close;cdecl;
    function getOutputStream:Jout;cdecl;
    function getInputStream:Jin;cdecl;
    function isConnected:boolean;cdecl;

  end;

  JSoketClass = interface(JObjectClass)
  ['{E66CE6BA-9E0E-4ED0-A4B7-D683C8AB3597}']
    function init:JSoket;cdecl;
  end;
  TJSoket = class(TJavaGenericImport<JSoketClass, JSoket>) end;

////////////////server socket//////////////////////////

  [javaSignature('java/net/ServerSocket')]
  JServerSoket=interface(jobject)
    ['{56C0FCBB-AE14-4DCE-9E06-9CCC2DB73C5B}']
    function getLocalPort:integer;cdecl;
    procedure bind(localAddr:integer);cdecl;
    procedure close;cdecl;
    function getInetAddress:JAdres;cdecl;
    function accept():JSoket;cdecl;

    property Port: Integer read getLocalPort;
    property iNetAdres: JAdres read getInetAddress;

  end;

  JServerSoketClass = interface(JObjectClass)
  ['{8A35BED3-B8BB-4069-BEB9-2D859F6F74C1}']
    function init(port:integer):JServerSoket;
  end;
  TJServerSoket = class(TJavaGenericImport<JServerSoketClass, JServerSoket>) end;

implementation

end.

(these codes can read/write!)
screen image;
https://drive.google.com/file/d/0BxODt2IJsmR8ZktjNzF5VllzekE/edit?usp=sharing

A: TIdThreadComponent is a component of Indy, which has its own TIdTCPServer multithreaded component.  You should be using TIdTCPServer instead of TJServerSocket, which is a Java class wrapped by Delphi's JNI bridge layer, so it does not run "natively" on the CPU.  TIdTCPServer does, just like the rest of the Delphi RTL/FMX framework.
uses
  ..., IdTCPServer, IdContext;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    IdTCPServer1: TIdTCPServer;
    procedure Button1Click(Sender: TObject);
    procedure IdTCPServer1Connect(AContext: TIdContext);
    procedure IdTCPServer1Disconnect(AContext: TIdContext);
    procedure IdTCPServer1Execute(AContext: TIdContext);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  IdTCPServer1.DefaultPort := 8090;
  try
    IdTCPServer1.Active := True;
    memo1.Lines.Add('listening');
  except
    on E: Exception do memo1.Lines.Add('Cant open port: '+E.Message);
  end;
end;

procedure TForm1.IdTCPServer1Connect(AContext: TIdContext);
begin
  TThread.Synchronize(nil,
    procedure
    begin
      memo1.Lines.Add('connected');
    end
  );
end;

procedure TForm1.IdTCPServer1Disconnect(AContext: TIdContext);
begin
  TThread.Synchronize(nil,
    procedure
    begin
      memo1.Lines.Add('disconnected');
    end
  );
end;

procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var
  msg: string;
begin
  msg := AContext.Connection.IOHandler.ReadLn;
  TThread.Synchronize(nil,
    procedure
    begin
      memo1.Lines.Add('Read: '+ msg );
    end
  );
  AContext.Connection.IOHandler.Write('msg: '+msg, IndyTextEncoding_UTF8);
  TThread.Synchronize(nil,
    procedure
    begin
      memo1.Lines.Add('Write!');
    end
  );
end;

A: type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    th: TIdThreadComponent;
    th2: TIdThreadComponent; //for 2. client.
    procedure Button1Click(Sender: TObject);
    procedure thRun(Sender: TIdThreadComponent);
    procedure th2Run(Sender: TIdThreadComponent);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
......

procedure TForm1.thRun(Sender: TIdThreadComponent);
var msg:string;
  client:JSoket;
  input :JinStream;
  output:JoutStream;
begin
  client  :=serversoket.accept;
  if client.isConnected then
  begin
    if client.getInputStream.available>-1 then
    begin
      input:=tjinstream.JavaClass.init(client.getInputStream);
      output:=tJoutStream.JavaClass.init(client.getOutputStream)  ;
      ////////////////////////////////////////////////////////////
      th2.Active:=true;//2. thread start if 1. client connected!
      th2.Start;
      ////////////////////////////////////////////////////////////
    end;
    while true do
     begin
      msg:=jstringtostring(input.readline);
      memo1.Lines.Add('Read: '+ msg );
      output.writeUTF(stringtojstring('msg: '+msg ) );
      memo1.Lines.Add('Write!' );
      output.flush;
     end;
  end;
end;

......
procedure TForm1.th2Run(Sender: TIdThreadComponent);
var msg:string;
  client:JSoket;
  input :JinStream;
  output:JoutStream;
begin
  client  :=serversoket.accept;
  if client.isConnected then
  begin
    if client.getInputStream.available>-1 then
    begin
      input:=tjinstream.JavaClass.init(client.getInputStream);
      output:=tJoutStream.JavaClass.init(client.getOutputStream)  ;
     //if more client....
    end;
    while true do
     begin
      msg:=jstringtostring(input.readline);
      memo1.Lines.Add('Read2: '+ msg );
      output.writeUTF(stringtojstring('msg2: '+msg ) );
      memo1.Lines.Add('Write2!' );
      output.flush;
     end;
  end;
end;
........

screen image: https://drive.google.com/file/d/0BxODt2IJsmR8WVEzTUh3NXJtcjA/edit?usp=sharing
these codes worked. i was try.
i'm waiting answers/comments.
thanks you very much, especially @RemyLebeau


text:
Q: Application Pool, Worker Processes and web applications? can anybody explain these things in IIS??

A: Search a little bit before you ask questions ..
When you run IIS in worker process isolation mode, you can separate different Web applications and Web sites into groups known as application pools. An application pool is a group of one or more URLs that are served by a worker process or set of worker processes. Any Web directory or virtual directory can be assigned to an application pool.
Every application within an application pool shares the same worker process. Because each worker process operates as a separate instance of the worker process executable, W3wp.exe, the worker process that services one application pool is separated from the worker process that services another. Each separate worker process provides a process boundary so that when an application is assigned to one application pool, problems in other application pools do not affect the application. This ensures that if a worker process fails, it does not affect the applications running in other application pools.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Inner Joins in HQL I'm unable to execute this HQL command:
String hql = "select t.ticketName, t.idTicket, d.jour from Ticket as t inner join DateTraitement as d  on d.idTicket=t.idTicket where t.idTicket= 1";
Query query = getSession().createQuery(hql) ;
List<Abc> result = query.list();

i have this error :    org.hibernate.QueryException: could not resolve property: idTicket of: m.m.model.DateTraitement [select t.ticketName, t.idTicket, d.jour from m.m.model.DateTraitement as d, m.m.model.Ticket as t where d.idTicket = t.idTicket]
here is my DateTreatment class:
enter code here
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_date_traitement", unique = true, nullable = false)
private Integer idDateTrait;
@Column(name = "jour", length = 50)
private int jour;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_ticket")
private Ticket ticket;

public Integer getIdDateTrait() {
    return idDateTrait;
}

public void setIdDateTrait(Integer idDateTrait) {
    this.idDateTrait = idDateTrait;
}

public int getJour() {
    return jour;
}

public void setJour(int jour) {
    this.jour = jour;
}

public Ticket getTicket() {
    return ticket;
}

public void setTicket(Ticket ticket) {
    this.ticket = ticket;
}

}
I don't know what I'm missing. Your help is appreciated.

A: Try this:
UPDATED AFTER NEW QUESTION:
String hql =
     "select d.ticket.ticketName, d.ticket.idTicket, d.jour
     from DateTraitment as d
     where d.ticket.idTicket = 1";

Query query = getSession().createQuery(hql) ;

List<Abc> result = query.list();

A: Error itself self explains the issue, Class DateTreatment should have property idTicket.
Looks like the Id you have defined is
@Column(name = "id_date_traitement", unique = true, nullable = false)
private Integer idDateTrait;

Either you can change this to idTicket or in your query use d.idDateTrait
Cheers !!


text:
Q: Functions and Lists - How to relate two lists using functions? This is my first time asking a question here, and I am new to programming so be gentle. I am attempting to create a code in which the user enters sales for each day of the week and the functions display the sales for each day and display the day with the highest sales/average sales/act.
The intended result would be something like:
Mondays sales: $200
Tuesdays sales: $100
Wednesday sales: $50
Thursday sales: $75
Friday sales: $100
Saturday sales: $250
Sunday sales: $75
Highest sales achieved on Saturday with $250

However, now the results are being printed 7 times each and I do not know how to reference the max value with the related day
Here is what I have so far:
days_week=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]

def fillList(salesList):
    for index in range(len(days_week)):
        user_input=int(input("Enter sales for "+ days_week[index]+": " ))
        salesList.append(user_input)

def showSales(salesList):
    for sales in salesList:
        for index in range(len(days_week)):
                print(days_week[index],"sales: $", sales)

def highestSales(salesList):
    print("Highest sales of the week was achieved on",max(salesList))

def main():
    salesList=[]
    fillList(salesList)
    showSales(salesList)
    highestSales(salesList)

main()

After making the recommended changes, the program now "works," displaying the day's sales as intended.
days_week=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]

def fillList(salesList):
    for day in days_week:
        user_input=int(input("Enter sales for "+ day+": " ))
        salesList.append(user_input)

def showSales(salesList):
    for num in range(len(days_week)):
        print(days_week[num],"sales: $", salesList[num])

def highestSales(salesList):
    print("Highest sales of the week was achieved on",max(salesList))

def main():
    salesList=[]
    fillList(salesList)
    showSales(salesList)
    highestSales(salesList)

main()

However, I am trying to display the day in which the most sales occured. Is it possible to append the two lists together? Or is there a simple way of displaying the day with the largest user input?

A: You are have an extra for loop in your showSales(saleslist). I presume you only have the inner for loop to get the index that you want for days_week.
The simplest fix to this is to use a counter while in your for loop, something like:
def showSales(salesList):
    i = 0;
    for sales in salesList:
        print(days_week[i],"sales: $", sales)
        i += 1

Python also has a built in function for this use case, enumerate. Enumerate returns the counter and your iterator, like so:
def showSales(salesList):
    for i , sales in enumerate(salesList):
        print(days_week[i],"sales: $", sales)

Though the first method is universal across languages, and will give you more clarity when learning - so I recommend explicitly using a counter.

A: Think carefully about what your loops are doing. Per your code, each item in the first list is being iterated over 7 times, then Python moves to the next item and repeats that 7 times, hence you are getting each result printed 7 times.
For the function showSales, try something like this:
def showSales(salesList):
    for num in range(len(days_week)):
        print(days_week[num],"sales: $", salesList[num])

As a side note, you can improve fillList as you don't need to create a range object for a list, it is already iterable. For example:
def fillList(salesList):
    for day in days_week:
        user_input=int(input("Enter sales for "+ day+": " ))
        salesList.append(user_input)

Now you will only loop through each day once.

A: Welcome to Stack Overflow @Jnoe.
So you have two questions.
First: Why the result is being printed 7 times?
As people mentioned you have two nested for's statements in showSales(salesList). To get the behavior I believe you want, you can remove the inner for and take advantage of the fact that each sale have the same index in the sales list as the day in wich the sales hapened has in the days_week list. To get this index you can use the list.index(value) function. This function returns the index of value in the list.
So, to clarify, in your example you have that:
salesList.index(75) will return 6 and days_week[6] is sunday, the day the 75 sale happened.
So your code should be like this:
def showSales(salesList):
    for sales in salesList:
        print(days_week[salesList.index(sales)],"sales: $", sales)

Second: How to reference the max value with the related day?
You should probably know the answer by now. You can use the same function used previously, but now to find the index in wich the max value ocurred in the sales list.
So your code should be something like this:
def highestSales(salesList):
    print("Highest sales of the week was achieved on", days_week[salesList.index(max(salesList))])

This means get the max value out of salesList, then get the index of salesList in wich this value happened, now get the days_week of this index.
Be careful!
Because list.index(value) returns the index of the first time the value you passed as argument appears in the list, if you have the same sale in different days you would probably get an undesirable behavior.
To adapt to that you could use a list comprehension but I believe it is out of the scope of your question.


text:
Q: SQL - Optimization - Select those that do and do not satisfy a condition into 2 separate tables To select those that do and do not satisfy a condition into 2 seperate tables I can use the following:
select * from myTable where someThing=value  into qMatchCondition
select * from myTable where someThing<>value into qNotMatchCondition

However I expect this would be a waste of time! I.E. When SQL interprates the code will it not do something like this:
results = []
database.getTable("myTable").records.foreach(record){
   if(record.someThing == value){
       results.push(record)
   }
}
QueryTable.new("qMatchCondition",results)
results = []
database.getTable("myTable").records.foreach(record){
   if(record.someThing != value){
       results.push(record)
   }
}
QueryTable.new("qNotMatchCondition",results)

When writing the algorithm manually I would do something akin to the following:
results1 = []
results2 = []
database.getTable("myTable").records.foreach(record){
   if(record.someThing != value){
       results1.push(record)
   } else {
       results2.push(record)
   }
}
QueryTable.new("qMatchCondition",results1)
QueryTable.new("qNotMatchCondition",results2)

I expect this would depend on the SQL engine you are using, but are there any ways to force the SQL engine to "compile" to an optimized algorithm? Or do SQL engines generally compile statements anyway?


text:
Q: Wrong Behavior with my JFrame and JDialog Login System I have implemented a basic login system that splits up a text file (first name : last name : City : username : password)

Harold : Fisher : San Francisco : hf45 : 1234

When the user inputs his/her user credentials, it will display a JFrame if credentials are entered correctly, otherwise a JOptionPane will appear instead informing the user that the credentials entered are incorrect.
Here is my code:
public class LoginFrame extends javax.swing.JFrame      {

/**
 * Creates new form LoginFrame
 */
String username;
String password;
String filePath = "UserDetails.txt";

public LoginFrame() {
    initComponents();

private void jButtonLoginActionPerformed(java.awt.event.ActionEvent evt) {

        username = jTextFieldUsername.getText();
        password = jTextFieldPassword.getText();
        verifyLogin();
}

public void verifyLogin()
{
   try {
       File f = new File("UserDetails.txt");
       Scanner fileRead = new Scanner(f);

       while(fileRead.hasNextLine())
       {
           String textLine = fileRead.nextLine();
           String[] userDetails = textLine.split(" : ");
           String tempUsername = userDetails[3];
           String tempPassword = userDetails[4];

           if(tempUsername.trim().equals(username.trim()) && tempPassword.trim().equals(password.trim()))
                   {
                       new LibraryCatalogFrame().setVisible(true);
                   }
           else
           {
               JOptionPanes.messageBox("Please re-enter your user details", "Incorrect Username or Password");
         }
        }
       }
       catch (FileNotFoundException e)
               {
               JOptionPanes.messageBox("Error", "FileNotFound");
          }
       }

The problem I am facing right now is that when the user correctly inputs his credentials, both the JFrame and JOptionPane are displayed. Also, when the user inputs his credentials incorrectly, the JFrame does not display (as intended), but the JOptionPane appears twice instead of just once.

A: I observed the behavior you explain when UserDetails.txt file has two lines. E.g.

Harold : Fisher : San Francisco : hf45 : 1234
  John : Snow : San Francisco : js45 : 5678

With above file with 2 lines, below "Program with the problem" outputs the behavior you explain (both "Show JFrame" and "Show dialog" are printed).
Problem is that, in the while loop, you try to show JFrame or dialog for every line in the file.
Try below "Fixed program". In that, I'm using a boolean variable matched to store whether a match is found. And then show the JFrame or dialog after the while loop.
Program with the problem:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class LoginFrame
{
  // Hardcode user entered username and password to simplify the program
  String username = "hf45";
  String password = "1234";

  public static void main(String[] args)
  {
    new LoginFrame().verifyLogin();
  }

  public void verifyLogin()
  {
    try {
      File f = new File("UserDetails.txt");
      Scanner fileRead = new Scanner(f);

      while(fileRead.hasNextLine())
      {
        String textLine = fileRead.nextLine();
        String[] userDetails = textLine.split(" : ");
        String tempUsername = userDetails[3];
        String tempPassword = userDetails[4];

        if(tempUsername.trim().equals(username.trim()) && tempPassword.trim().equals(password.trim()))
        {
          //new LibraryCatalogFrame().setVisible(true);
          System.out.println("Show JFrame");
        }
        else
        {
          System.out.println("Show dialog");
          //JOptionPanes.messageBox("Please re-enter your user details", "Incorrect Username or Password");
        }
      }
    }
    catch (FileNotFoundException e)
    {
      e.printStackTrace();
      //JOptionPanes.messageBox("Error", "FileNotFound");
    }
  }
}

Output:
Show JFrame
Show dialog
Fixed program:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class LoginFrame
{
  // Hardcode user entered username and password to simplify the program
  String username = "hf45";
  String password = "1234";

  public static void main(String[] args)
  {
    new LoginFrame().verifyLogin();
  }

  public void verifyLogin()
  {
    try {
      File f = new File("UserDetails.txt");
      Scanner fileRead = new Scanner(f);

      boolean matched = false;
      while(fileRead.hasNextLine())
      {
        String textLine = fileRead.nextLine();
        String[] userDetails = textLine.split(" : ");
        String tempUsername = userDetails[3];
        String tempPassword = userDetails[4];

        if(tempUsername.trim().equals(username.trim()) && tempPassword.trim().equals(password.trim()))
        {
          matched = true;
          break;
        }
      }

      if (matched)
      {
        //new LibraryCatalogFrame().setVisible(true);
        System.out.println("Show JFrame");
      }
      else
      {
        System.out.println("Show dialog");
        //JOptionPanes.messageBox("Please re-enter your user details", "Incorrect Username or Password");
      }
    }
    catch (FileNotFoundException e)
    {
      e.printStackTrace();
      //JOptionPanes.messageBox("Error", "FileNotFound");
    }
  }
}


text:
Q: Performace of BigDecimal vs. BigInteger and BigDecimal I was debating whether to use BigDecimal and BigInteger or only BigDecimal to make my life easier and less converting back and forth. Is there a downside to only using BigDecimal in regards to resources?
How about using only primitive data types and BigInteger or only BigInteger to make my life easier and less converting back and forth?

A: I know the title of your question states "Performace of BigDecimal vs. BigInteger and BigDecimal" but one of your questions states "How about using only primitive data types and BigInteger or only BigInteger to make ". Well here is what I recommend:
If you need accuracy, precision and you have large numbers to work with such as huge financial data then it may be best to use BigDecimal and BigInteger instead of primitive types. Few other characteristics of BigDecimal and BigInteger are also:

*

*Both are from immutable objects.

*Both extend from Number class and implement comparable interface

Now back to your main question in terms of performance, there is not much of difference in terms of performance between the two. If you can present your information in BigDecimal  just use that so you don't have to convert it over to BigInteger  but again look at the program and see if it does make sense to only use BigDecimal all the time.
The main difference between the BigInteger and BigDecimal is that BigInteger supports arbitrary-precision integers and BigDecimal is for arbitrary-precision fixed-point numbers.
Here are my sources and good luck :)
NY University
Colorado University

A: From: http://www.javamex.com/tutorials/math/BigDecimal_BigInteger_performance.shtml
Note that a BigDecimal is essentially a wrapper around a BigInteger that "remembers where the decimal point is".
Because of the way we are used to dealing with numbers, as humans, we may have to "think a bit more" when calculating with non-integers by hand compared to integers (e.g. we may have learnt the 7 times table by heart to speed up certain calculations, but probably not the .7 times table). But to a computer implementation, it is essentially no more effort to manipulate non-integers than it is integers, and so on the whole, methods on BigDecimal tend to perform similarly to analogous methods on BigInteger.

A: If you are developing a low-latency application and every microsecond matters, BigDecimal/BigInteger is not for you. Besides this fact BigDecimal/BigInteger has no visible impact.
BigDecimal does preform lower than long, double. The same apples to BigInteger and its corresponding primitives.

A: If you're worried much about performance with big numbers, I'd avoid Java's BigInteger and BigDecimal like the plague.
Both use slow (both asymptotically and on reasonably small inputs) algorithms for multiplication, division, and radix conversion.  You have no way to replace them with more efficient algorithms if it turns out to be a bottleneck, short of coding up your own BigInteger-compatible big-numbers and doing a big refactor.
You're probably much better off using a Java wrapper around GMP and MPFR if you're dealing with large integers.  "Large" here might be a couple hundred digits because of the things Java does when you call native methods.


text:
Q: Updating Post Meta with Backbone and the REST API I'm getting started with a project that is making use of Backbone and the WP REST API, but I"m having a little trouble.
Using the built in API JS for models and collections allows me to pretty easily update a post title or content. All I have to do is call:
this.model.set({title: 'New Title'});
this.model.save();

And everything works really well. But for post meta, there doesn't appear to be an easy way to update an entry to the database. Does anyone know how to go about taking a post model in Backbone, and updating it's meta data?

A: var parentId = 96; // the post id
var metaData = new wp.api.collections.PostMeta('', {parent: parentId});
metaData.fetch()
  .done(function(data) {
    var someKey = data.findWhere({key: 'someKey'});
    someKey.set('value', 'newValue');

    someKey.save({parent: parentId});
  });

A: Now you can use the models api as well:
var post = new wp.api.models.Post( { id: 1 } );
post.fetch();
post.setMeta('metaKey', 'metaValue');
// Or multiple metas at one time:
post.setMetas({metaKeyOne: 'metaValueOne', metaKeyTwo: 'metaValueTwo'});
post.save()

For this to work , the meta must be registered for REST API with register_post_meta and show_in_rest argument set to true.
Here is an example:
add_action(
    'init',
    function() {
        register_post_meta('my_post_type', 'my_meta_key', ['show_in_rest' => true, 'single' => true]);
    }
);


text:
Q: prepend without jQuery? How can i write this without using jQuery?
$('body').prepend('

' + titelN + '

');

A: You should first learn how to create an element without using any library. Basically, there are some method for you to create element and append element to the document. They are createElement, insertBefore, appendChild.
createElement ref: http://www.w3schools.com/jsref/met_document_createelement.asp
insertBefore ref: http://www.w3schools.com/jsref/met_node_insertbefore.asp
appendChild ref: http://www.w3schools.com/jsref/met_node_appendChild.asp
The code below should work for all browser. Try more and learn more.
var parent = document.createElement("div");
parent.id = "idC";
parent.style.display = "none";

var child = document.createElement("div");
child.id = "idA";
child.innerHTML = titelN;
parent.appendChild(child);

document.body.insertBefore(parent,document.body.childNodes[0]);

A: There is the insertAdjacentHTML method, but it does not work in older FF versions:
document.body.insertAdjacentHTML('afterbegin', '

' + titelN + '

');


text:
Q: passing data to partial express js hbs currently I am making a notification system with node/express/hbs and mysql. I can insert notification to the database properly , but I can't fetch it my partial file.
here is my code
  countNotification: async (req, res) => {
            await Notification.count({ where: { status: 'unread' } }).then((notification) => {
                if (notification) {
                    const dashNotification = req.notification;
                    return dashNotification;
                }
            });
        },

 app.use((req, res, next) => {
        res.locals.user = req.user;
        res.locals.notification = req.dashNotification;
        next();
    });

i have tried this like that but it is not working , anyone has any solution ?

A: You should use your middleware above the router:
     app.use((req, res, next) => {
            res.locals.user = req.user;
            res.locals.notification = req.dashNotification;
            next();
        });

    countNotification: async (req, res) => {
                await Notification.count({ where: { status: 'unread' } }).then((notification) => {
                    if (notification) {
                        const dashNotification = req.notification;
                        return dashNotification;
                    }
                });
            },


text: Q: How do you restore a user from windows.old? How do I take a user account from windows.old and make it usable on the version of Windows currently being booted? Both versions are Windows 10, though I doubt this affects it much.


text:
Q: read -a doesn't work in unix I'm trying to split a paramameter into array so that i can then assign into different variables, but somehow i get error saying 'read -a' doesn't work.
command:
bash-4.1$ ./sftpupstream.ksh CheckFile "aaa|bbbb|ccc|dddd"
aaa|bbbb|ccc|dddd
./sftpupstream.ksh[20]: read: -a: unknown option
Usage: read [-ACprsSv] [-d delim] [-u fd] [-t timeout] [-n count] [-N count] [var?prompt] [var ...]

Code:
RUN_MODE=$1
PARAMSTR=$2

echo $PARAMSTR
IFS="|" read -a arr <<< "$PARAMSTR"
for i in "${arr[@]}"; do
        echo "$i"
done

A: read -a is not a standardized option to the read builtin. See the POSIX standard for read at http://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html, and note that POSIX sh (the baseline specification for all POSIX shells) doesn't even specify arrays at all.
Rather, it's an extension, only available in specific shells. To get the extension, you must be using one of those specific shells. You can do that by:

*

*Explicitly starting your script with an extended shell (bash yourscript).

*Using a shebang indicating an extended shell (#!/bin/bash or #!/usr/bin/env bash as the first line of your script)

If your shell is ksh, the equivalent extension is read -A.


text:
Q: Trouble getting react to return data from Web Api I've followed some fairly basic tutorials to set up a basic Web Api service and a React TS app to consume this, but when my react component calls the WebApi service, I can see the Web Api gets stepped into and returns the data - as it does if I enter the API url in the browser, it returns the correct items JSON, but in the javascript code for React, the HTTP response doesn't appear to contain any data when the promise comes back from fetch, just an empty 200 response.
Ie response.data is undefined.
This must be something very basic I'm doing wrong - as like I mentioned when you enter the API url in the browser, you see the correct JSON in the browser. So why cant my react code understand the response?
My Web Api
 [EnableCors("*", "*", "*")]
    public class ItemsController : ApiController
    {
        private readonly Item[] _items = {
            new Item
            {
                ...
            },
            new Item
            {
                ...
            },
            new Item
            {
                ...
            },
        };

        public HttpResponseMessage Get()
        {
            return Request.CreateResponse(HttpStatusCode.OK, _items);
        }

        public HttpResponseMessage Get(long id)
        {
            var item= _items.FirstOrDefault(t => t.ItemId == id);
            if (item== null)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Not found");
            }

            return Request.CreateResponse(HttpStatusCode.OK, item);
        }
    }

My react component
import * as React from 'react';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
import '../../App.css';
import IStoreState from '../../interfaces/IStoreState';
import Item from '../../model/item';
import { getItemsReceivedAction } from './actions';

interface IItemsProps {
    items: Item[],
    itemsUpdated: (items:Item[]) => void
}

class Trades extends React.Component<IItemsProps> {
    constructor(props:IItemsProps) {
        super(props);
    }

  public componentDidMount() {
        fetch('http://localhost:58675/api/items', {
            headers: {
                Accept: 'application/json',
            },
            method: 'GET'
        }).then((t:any) =>
            {
                const results = t;
                this.props.itemsUpdated(results.data);
            }                        );
    }

    public render() {
        return (
            <div>
                {this.props.items} items displayed
            </div>
        );
    }

}

const mapDispatchToProps = (dispatch:Dispatch) => {
    return {
        itemsUpdated: (items:Item[]) => dispatch(getItemsReceivedAction(items))
    }
}

function mapStateToProps(state:IStoreState) {
    return {
        items: state.viewingItems
    }
}

export default connect(mapStateToProps, mapDispatchToProps)(Items);

Edit: javascript results object below
body: (...)
bodyUsed: false
headers: Headers {}
ok: true
redirected: false
status: 200
statusText: "OK"
type: "cors"
url: "http://localhost:58675/api/items"
__proto__: Response

A: It sees to me that the problem is in the fetch part of you react component. What you get in the first then callback is a Response object.
In order to get the data from it, you need to call one of it's methods (which return a promise). In your case, since the response contains json, you need to call the json() method. After that, you chain another then where you manipulate the parsed data:
fetch('http://localhost:58675/api/items', {
        headers: {
            Accept: 'application/json',
        },
        method: 'GET'
    }).then((t:any) =>
        {
            return t.json(); // <-- this part is missing
        }
    ).then((t:any) =>
        {
            const results = t;
            this.props.itemsUpdated(results.data);
        }
    )


text:
Q: RSS Feed description returns '<' I'm trying to parse rss data from this feed: http://fulltextrssfeed.com/feeds.bbci.co.uk/news/rss.xml, which was generated using using the FullTextRssFeed site. The only problem is that when I try to get the description, I receive '<', everything else is normal!. I've tried to use JSoup with this, but I'm not sure how to. Could you suggest how? The code I've used is the same as that used in this tutorial, but I've substituted the RSS URL used. Thanks again!

A: Your issue is because the description inside of your RSS feed contains html, rather than plain text. Here is the description content:

3 April 2013 Last updated at 23:25 ET
Mick and Mairead Philpott, and Paul Mosley, will be sentenced on Thursday

A couple convicted of killing six of their children in a house fire in Derby are due to be sentenced later.

Mick and Mairead Philpott will reappear at Nottingham Crown Court where they were found guilty of six counts of manslaughter, along with their friend Paul Mosley, on Tuesday.

The maximum sentence for the crime is life imprisonment.

Mrs Justice Thirlwall was due to pass sentence on Wednesday but needed more time to consider mitigation.

The court was told that Philpott, 56, was jailed for seven years in 1978 for attempting to murder a previous girlfriend and given a concurrent five-year sentence for stabbing the woman's mother.

In 1991 he received a conditional discharge for assault after he head-butted a colleague

And in 2010 he was given a police caution after slapping Mairead and dragging her outside by her hair.

When Philpott set fire to his house in Victory Road, Derby, he was also facing trial over a road rage incident in which he punched a motorist in the face.

He had admitted common assault in relation to the incident but denied dangerous driving.
 Rape allegation
Police have also confirmed that they intend to "thoroughly" investigate an allegation that Philpott raped a woman several years ago.

She made the allegation after the death of Philpott's children, but police decided to wait until the end of the manslaughter trial before investigating the complaint further.

On Tuesday the jury returned unanimous manslaughter verdicts on Philpott and Mosley, 46, while Mairead Philpott, 32, was convicted by a majority.

Jade Philpott, 10, John, nine, Jack, eight, Jesse, six, and Jayden, five, died on the morning of the fire on 11 May 2012.

Mairead Philpott's son from a previous relationship, 13-year-old Duwayne, died later in hospital.

You'll need to alter the parser in some way that it can ignore the  that are within the html content inside of description. Once you get the full html snippet out you can render it in a WebView. I think generally CDATA is used when there is some other type of XML content (in this case HTML) that is within an XML piece of data such as an RSS feed. Honestly though I am not to familiar with the ins and outs of it, I could be incorrect.

A: The HTML you get from myRssFeed.getDescription() looks something like this:

6 April 2013 Last updated at 08:57 ET

Nelson Mandela has been discharged from hospital after treatment for pneumonia, South Africa's government has said.

It said there had been "a sustained and gradual improvement in his condition".

The 94-year-old was admitted on 27 March for a recurring lung infection and had fluid drained at the undisclosed hospital.

Mr Mandela served as South Africa's first black president from 1994 to 1999 and is regarded by many as the father of the nation.

The presidency statement read: "Former President Nelson Mandela has been discharged from hospital today, 6 April, following a sustained and gradual improvement in his general condition.

"The former president will now receive home-based high care. President [Jacob] Zuma thanks the hard working medical team and hospital staff for looking after Madiba so efficiently."

Madiba is Mr Mandela's clan name.

The statement continued: "[Mr Zuma] also extended his gratitude to all South Africans and friends of the Republic in Africa and around the world for support."

Using Jsoup you can try this (untested):
Instead of
feedDescribtion.setText(myRssFeed.getDescription());

use this:
feedDescribtion.setText(extractDescriptionText(myRssFeed.getDescription());

with the following method:
private String extractDescriptionText(String description) {
    StringBuffer b = new StringBuffer();
    Document dom = Jsoup.parse(description);
    Elements paragraphs = dom.getElementsByTag("p");
    for (int i=1; i<paragraphs.size(); i++) { // start with 1 to skip the 'breaking news' paragraph
        Element p = paragraphs.get(i);
        b.append(p.text());
        b.append("\n"); // line-break after each paragraph
    }
    return b.toString();
}

This should work. Maybe some fine-tuning is necessary but that can be achieved quite easily with Jsoup's help.
EDIT:
This is what extractDescriptionText() gives for the example above:

Nelson Mandela has been discharged from hospital after treatment for
  pneumonia, South Africa's government has said. It said there had been
  "a sustained and gradual improvement in his condition". The
  94-year-old was admitted on 27 March for a recurring lung infection
  and had fluid drained at the undisclosed hospital. Mr Mandela served
  as South Africa's first black president from 1994 to 1999 and is
  regarded by many as the father of the nation. The presidency statement
  read: "Former President Nelson Mandela has been discharged from
  hospital today, 6 April, following a sustained and gradual improvement
  in his general condition. "The former president will now receive
  home-based high care. President [Jacob] Zuma thanks the hard working
  medical team and hospital staff for looking after Madiba so
  efficiently." Madiba is Mr Mandela's clan name. The statement
  continued: "[Mr Zuma] also extended his gratitude to all South
  Africans and friends of the Republic in Africa and around the world
  for support."

A: While searching the web for ideas on how to do this, I found out that doing this is actually illegal as it this method of getting content violates the terms of use of many of the web sources I was hoping to use. For now you will have to stick with short RSS feeds.

A: I would comment but I don't have enough points.
I would recommend using yahoo pipes to redirect your rss feeds. You can even choose it to be redirected as json rather than xml.
http://pipes.yahoo.com/pipes/
If your parser is working OK on most websites you visited this would be the easiest way to fix your problem.


text:
Q: mounting external drives to a Docker container I'm Dockerizing an application and I have data on an external file server. Normally, when not using Docker, I mount to my file server. Files is a directory within my docroot.
The way I'm currently set up with Docker, I'm accessing my docroot as a data volume from my container- the official version is on my host system. I'm not sure what the best way to access file server. Should I set somehow set up NFS in my container? use a plugin?


text:
Q: How to find Population proportion confidence interval when n*p is less than 5? I have been searching everywhere but haven't found any explicit information about this.
I have a total sample size of 15 weeks but only 3 of those weeks have the result i want. So p=3/15
But if I want to find a confidence interval for that, I checked n*p=15*3/15=3 which is less than 5. How would I be able to find the confidence interval of the population proportion?

A: The same way you do when $np ≥ 5$. You can use standard methods such as the Jeffreys interval or the Wilson score interval. The method based on a normal approximation is worse with smaller sample sizes, but there's no reason to use it even for larger samples, because the use of a normal approximation necessarily reduces accuracy.


text:
Q: Grub bootloader I have just switched to Linux and made a clean install of Ubuntu 20.04 over Windows 10 (no dual boot). I want to skip the grub bootloader screen which appears at the startup. I have already gone through several posts which are written on this, but I still have the same issue. I have changed the grub config file and after changing it I saved the changes through a command as instructed.
Here is the config file.
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT="Ubuntu"
GRUB_TIMEOUT_STYLE="hidden"
GRUB_TIMEOUT="0"
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL="console"

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE="640x480"

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID="true"

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

#GRUB_HIDDEN_TIMEOUT="0"
GRUB_DISABLE_OS_PROBER="true"
GRUB_SAVEDEFAULT="false"

export GRUB_COLOR_NORMAL="light-gray/magenta"
export GRUB_COLOR_HIGHLIGHT="black/black"

A: Summarizing what others wrote here:
You are about to shoot yourself in the foot. You need that menu in case something goes wrong; sooner or later that will happen. Don't attempt to get rid of the Grub menu completely; give yourself a chance to fix things in the worst case. It's okay to minimize the timeout to 2 seconds, but don't try to remove the menu completely.
Considering how long everything else takes at boot time (memory and hardware self-test etc., loading the kernel, initializing the system with all the various system services), those 2 seconds won't kill you; but not having the ability to fix your system by booting a previous kernel will.
Take this advice from someone who has been working with Linux since the late 1990s.

Also, from your comments it sounds as if you might not be aware that you need to run sudo update-grub after you edited that config file: Only then will the changes be propagated from /etc/default/grub which you edited to /boot/grub/grub.cfg which is generated from your configuration in /etc/default/grub plus kernels and other operating systems that are found (at that time) on your disks.
If your changes never seem to take effect, check where Grub is actually installed to; if you use the legacy MBR partitioning scheme, make sure you install it to the MBR of the disk you are booting from. If there is a previous install of Grub and your current one was installed to another boot sector, it might still boot your system, but any changes you make to your current Grub will only affect a Grub that is never used.
If you do that, please check the documentation exactly how to do it; it might be a dangerous operation.


text:
Q: join table and where column similar to other column, while changing column value SQL I have an issue with my code. This is an SQL issue.
I need to combine two tables. At present I have this code:
SELECT calldate,clid, '44'+dst AS      [NumberDialed],dstchannel,billsec,disposition,accountcode,uniqueid,cnam, callRateImport.Description, callRateImport.Code, callRateImport.Day FROM callLogImport
LEFT JOIN callRateImport ON callLogImport.dst LIKE callRateImport.Code + '%'
WHERE
callRateImport.Code(Select Code FROM callRateImport WHERE callLogImport.dst LIKE Code + '%' AND Len(Code) = (SELECT MAX(Len(Code)) FROM callRateImport WHERE callLogImport.dst LIKE callRateImport.Code + '%') )

This is combining fine. Now I need to match it to an altered result depending on what the original result is.
I have this code:
IF SUBSTRING (dst,1,2)=00

BEGIN

END

wrapping the current code. SQL is throwing errors - incorrect Syntax. I have an ELSE IF block of 3 components.

A: To modify values based on its current value, you should look at  CASE Statements.
For example:
USE AdventureWorks2012;
GO
SELECT   ProductNumber, Category =
    CASE ProductLine
       WHEN 'R' THEN 'Road'
       WHEN 'M' THEN 'Mountain'
       WHEN 'T' THEN 'Touring'
       WHEN 'S' THEN 'Other sale items'
       ELSE 'Not for sale'
    END,
 Name
FROM Production.Product
ORDER BY ProductNumber;
GO

or with searched case expressions:
USE AdventureWorks2012;
GO
SELECT   ProductNumber, Name, "Price Range" =
     CASE
        WHEN ListPrice =  0 THEN 'Mfg item - not for resale'
        WHEN ListPrice < 50 THEN 'Under $50'
        WHEN ListPrice >= 50 and ListPrice < 250 THEN 'Under $250'
        WHEN ListPrice >= 250 and ListPrice < 1000 THEN 'Under $1000'
        ELSE 'Over $1000'
     END
FROM Production.Product
ORDER BY ProductNumber ;
GO


text:
Q: Declare array insde a structure in c Hi i would like declare a array of size x, this size will be know at runtime (not a static declatrion). how to do that. An efficient way to do that.
I had structure like this
    #define SIZE 50
    struct abc {
                  int students[SIZE];
                  int age;
   }

i would like read SIZE from some point at run time, instead of predefining it.
Edit : can we allocate memory for entire structure including array dynamically.
        strcut abc {
                     int *students; // should point to array of SIZE.
                     int age;
       }s;

can we get sizeof struct = size of entire struct(including array); ?

A: If the size is known at runtime, you need to use dynamic allocation.
struct abc
{
  int *students;
  int age;
}

Then in code,
struct abc var;
var.students = malloc(size*sizeof(int));

and at the end of your code
free(var.students);

A: There are two maybe simpler solution possible. You can use a empty sized array at the end of the struct:
struct abc {
    int age;
    int students[];
};

unsigned count = 10;
struct abc* foo = malloc(sizeof(*foo) + (count * sizeof(foo->students[0])));

Here you need only one malloc() call if you want both, the struct and the array being allocated dynamically. And also only one free. For a 2d array you have to alloc it as a 1d array and calculate the indices for your own.
An other solution could be:
unsigned count = 10;
struct abcd {
    int age;
    int students[count];
};

Simple use a variable length array in the struct direct. Here you can use 2d as usual.


text:
Q: Dynamically flexible width & number items with flex I have a set of tags, that I want to show in the client. However, sometimes you might have too many tags and you want to show only one row of tags maximized to your body's width without setting a fixed number of columns or item width, and adding a show more button at the end of the tag list with the same style as a tag.
I have achieved this using Javascript in my Angular project by doing the following:

*

*Find out the width of your tags container dynamically, with ViewChild on my content container:

let contentWidth = this.contentContainer.nativeElement.clientWidth;

*Calculate the text width of the see more button and use it to calculate the new content width minus see more button width:

Calculating text function does the following:
  const canvas = document.createElement('canvas'); // create a canvas
  const context = canvas.getContext('2d'); // get the context
  context.font = '12px avertastd-bold'; // set up your font and size

And calculate the text width:
const seeMoreButtonWidth = context.measureText(seeMoreButtonText).width;

*

*Create a new array variable 'previewTags' which will hold the tags that are visible when the tags body is in collapsed state, and fill in as many tags as you can by calculating each tag's width with it's content text you receive from the API by checking if the next tag + its padding (static value) fits into the width.

(Not runnable here)

for (const tag of this.data.tags) {
    const width = context.measureText(tag).width;
    if (contentWidth - (width + this.tagsPadding) > 0) {
        previewTags.push({text: tag});
        contentWidth -= (width + this.tagsPadding);
    } else {
        break;
    }
}

*Push the see more button at the end of previewTags list:

previewTags.push({text: seeMoreButtonText, isButton: true});
And it looks like this in the html:
    <ng-container *ngFor="let tag of previewTags">

{{tag.text}}

    </ng-container>

Output:

Resize:

As you see, now the tags are flexiable (this code does not include the show more functionality).
After giving you this background and understanding of what I am doing, I would love to ask if this is possible to achieve with css or less JavaScript intervation?

A: Something like this could be a pure css solution if your tags have a constant height. I just let the flex-list wrap around and then don't show the overlap.

.content_wrapper {
  display: flex;
  justify-content: flex-start;
  flex-direction: rows;
}

.tag_wrapper {
  display: flex;
  justify-content: flex-start;
  flex-direction: rows;
  flex-wrap: wrap;
  width: 80%;
  height: 32px;
  overflow: hidden;
}

.tag_wrapper div {
  width:100px;
  height:30px;
  border: 1px solid black;
}

button {
  flex-grow: 4;
}

Tag1

Tag2

Tag3

Tag4

Tag5

Tag6

Tag7

Tag8

Tag9

<button>See more</button>

You could probably make the "See more" button solution more elegant, to not have as much white space but I'll leave that to you :)

A: Here is some javascript to remove the see-more button if it's not needed.
(OBS) this only works if all the tags are the exact same width and have the same margin. I did this to avoid looping through all values and checking their width individually.
(I know the list is in the wrong order, I made it like that to get the see-more button fit in well without having to tinker a bunch.

function getWidthWithMargin(elem) {
  var style = elem.currentStyle || window.getComputedStyle(elem)
  margin = parseFloat(style.marginLeft) + parseFloat(style.marginRight)
  return(elem.getBoundingClientRect().width + margin)
}

function handleWindowSizeChange() {
  let tags = document.getElementsByClassName("tag");
  if(tags.length != 0)
  {
    let tag_width = getWidthWithMargin(tags[0]);
    if(tags[0].parentElement.getBoundingClientRect().width/tag_width > tags.length) {
      document.getElementById("see-more-button").style.display = "none";
    }
    else{
      document.getElementById("see-more-button").style.display = "block";
    }
  }
}

window.onload = handleWindowSizeChange;
window.onresize = handleWindowSizeChange;
.content_wrapper {

}

.tag_wrapper {
  display: flex;
  justify-content: flex-start;
  flex-direction: row-reverse;
  flex-wrap: wrap;
  width: 100%;
  height: 32px;
  overflow: hidden;
}

.tag_wrapper div {
  min-width:100px;
  height:30px;
  border: 1px solid black;
  margin: 10px;
}

.tag_wrapper button {
  height:30px;
  flex-grow: 50;
}

  <button id="see-more-button">See more</button>

Tag1

Tag2

Tag3

Tag4

Tag5

Tag6

Tag7

Tag8


text:
Q: how to put png image with transparent background in QToolButton I want to put a png image as background in QToolButton. But I am not able to get the transparent portions in the button. The transparent portions are showing as white in my QToolButton. Can anybody suggest how to remove the white portions as transparent ?

A: I suppose there's something wrong with your png file. The following code:
QToolButton button;
button.setIcon(QIcon("E:/delete.png"));
button.setIconSize(QSize(256, 256));
button.show();

works fine for me (of course E:/delete.png have transparent background).
Make sure you save transparency for your png.


text:
Q: Why I use PDO to insert non-english char will become monster? This is what I do in php:
$dbhandler = new PDO('mysql:host='.domain.':'.port.';dbname='.dbName.';',db_user,db_password);

$stmt = $dbhandler->prepare("INSERT INTO ".myTable.
" (value) VALUES (:value)");
$stmt->bindValue(':value', "試打中文");

$stmt->execute();

This is what I get via phpMyAdmin:
試打中文

But I can manually insert chinese in phpMyAdmin, and it shows to monster char...
What did I do wrong? (The Collation of table field is : utf8_unicode_ci).
Thank you.

A: Change your code to:
$dbhandler = new PDO('mysql:host='.domain.':'.port.';dbname='.dbName.';',db_user,db_password, array(
  PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
));

A: Try also running:
SET NAMES utf8;
SET CHARACTER_SET utf8;

As queries after you make the database connection.


text:
Q: Decompiling a *.DLL to assembly for .net in delphi 4 I love my Delphi 4 but at the same time I see the need to talk to windows .net
This is a recompiled dll that I found on sourceforge.net/projects/delphinet/ (DelphiNet03.zip) by some nice people that fund the dll from some were.
   The real answer is to make this dll so that fits into Delphi as true Delphi code, and not a dll clip on. So we can make objects that use dot net in Delphi. Because I'm not an assembly freak, I'm freaking out a little with a wee sweek for help!
1/ How do I link the asm code with the data info at the bottom of this code. Can some one show me which calls to look for to make this link to data.
2/ I need to find the beginning of all the procedures and functions, but I cannot find a 'RET' statement. And what line is the beginning statement in this code.
3/ How do I identify were the jump statements go to, put them into Delphi format
In this code it looks I can do:-
         jle    402890h       \\1000:00402854 7e3a
         add    [eax], al       \\1000:00402856 0000
……………………………………………..
         or     ch, [edi+3eh]       \\1000:0040288d 0a6f3e
                        xrefs first: 1000:00402854 number : 1       \\;
         add    [eax], al       \\1000:00402890 0000

//*********************************************************
         jle    @@21       \\1000:00402854 7e3a
         add    [eax], al       \\1000:00402856 0000
……………………………………………..
         or     ch, [edi+3eh]       \\1000:0040288d 0a6f3e
                        xrefs first: 1000:00402854 number : 1       \\;

@@21 add    [eax], al       \1000:00402890 0000
Is that a correct conversion.
I think a
 xrefs first: 1000:004021d1 number : 1
is the best to follow
4/ I need a good reference on 8086 up assembly code that I can print out and get to learn properly.
I found this asm decomplier of  http://www.cronos.cc/ that is so similar to
Delphi that it only needs a little more convertion to get it into Delphi asm I think.
It's only taken me 3 hours to get the file into TMemo and to write a few lines to chop the line over in a stream and reload the memo.
?
                      xrefs first: 1000:004041ae number : 1       \\;
         dd     4190h       \\1000:00402000 90410000
         dd     00h       \\1000:00402004 00000000
         dec    eax       \\1000:00402008 48
         add    [eax], al       \\1000:00402009 0000
         add    [edx], al       \\1000:0040200b 0002
         add    [eax], al       \\1000:0040200d 0000
         add    [eax-2bffffd2h], al       \\1000:0040200f 00802e0000d4
         adc    al, [eax]       \\1000:00402015 1200
         add    [ecx], al       \\1000:00402017 0001
         add    [eax], al       \\1000:00402019 0000
         add    [eax], al       \\1000:0040201b 0000
         add    [eax], al       \\1000:0040201d 0000
         add    [eax], al       \\1000:0040201f 0000
         add    [eax], al       \\1000:00402021 0000
         add    [eax], al       \\1000:00402023 0000
         add    [eax], al       \\1000:00402025 0000
         add    [eax], al       \\1000:00402027 0000
         add    [eax], al       \\1000:00402029 0000
         add    [eax], al       \\1000:0040202b 0000
         add    [eax], al       \\1000:0040202d 0000
         add    [eax], al       \\1000:0040202f 0000
         add    [eax], al       \\1000:00402031 0000
         add    [eax], al       \\1000:00402033 0000
         add    [eax], al       \\1000:00402035 0000
         add    [eax], al       \\1000:00402037 0000
         add    [eax], al       \\1000:00402039 0000
         add    [eax], al       \\1000:0040203b 0000
         add    [eax], al       \\1000:0040203d 0000
         add    [eax], al       \\1000:0040203f 0000
         add    [eax], al       \\1000:00402041 0000
         add    [eax], al       \\1000:00402043 0000
         add    [eax], al       \\1000:00402045 0000
         add    [eax], al       \\1000:00402047 0000
         add    [eax], al       \\1000:00402049 0000
         add    [eax], al       \\1000:0040204b 0000
         add    [eax], al       \\1000:0040204d 0000
         add    [ebx], dl       \\1000:0040204f 0013
         xor    [eax+eax], al       \\1000:00402051 300400
         or     al, [ecx]       \\1000:00402054 0a01
         add    [eax], al       \\1000:00402056 0000
         add    [eax], eax       \\1000:00402058 0100
         add    [ecx], dl       \\1000:0040205a 0011
         push   cs       \\1000:0040205c 0e
         add    al, 50h       \\1000:0040205d 0450
         mov    gs, [ecx+05h]       \\1000:0040205f 8e6905
         push   eax       \\1000:00402062 50
         mov    gs, [ecx+2eh]       \\1000:00402063 8e692e
         add    eax, f938h       \\1000:00402066 0538f90000
         add    [ebx], al       \\1000:0040206b 0003
         jc     402070h       \\1000:0040206d 7201
         add    [eax], al       \\1000:0040206f 0000
         jo     40209bh       \\1000:00402071 7028
         add    al, [eax]       \\1000:00402073 0200
         add    [edx], cl       \\1000:00402075 000a
         sub    eax, 36f0408h       \\1000:00402077 2d08046f03
         add    [eax], al       \\1000:0040207c 0000
         or     ch, [ebx]       \\1000:0040207e 0a2b
         push   es       \\1000:00402080 06
         add    al, 6fh       \\1000:00402081 046f
         add    al, 00h       \\1000:00402083 0400
         add    [edx], cl       \\1000:00402085 000a
         adc    eax, [edi]       \\1000:00402087 1307
         push   ss       \\1000:00402089 16
         adc    ecx, [eax]       \\1000:0040208a 1308
         cmp    cl, cl       \\1000:0040208c 38c9
         add    [eax], al       \\1000:0040208e 0000
         add    [ecx], dl       \\1000:00402090 0011
         pop    es       \\1000:00402092 07
         adc    [eax], ecx       \\1000:00402093 1108
         callf  056f:060a9a08h       \\1000:00402095 9a0a066f05
         add    [eax], al       \\1000:0040209a 0000
         or     cl, [ebx]       \\1000:0040209c 0a0b
         push   es       \\1000:0040209e 06
         outsd         \\1000:0040209f 6f
         push   es       \\1000:004020a0 06
         add    [eax], al       \\1000:004020a1 0000
         or     al, [ebx]       \\1000:004020a3 0a03
         sub    [edx], al       \\1000:004020a5 2802
         add    [eax], al       \\1000:004020a7 0000
         or     bh, [ecx]       \\1000:004020a9 0a39
         movsd         \\1000:004020ab a5
         add    [eax], al       \\1000:004020ac 0000
         add    [edi], al       \\1000:004020ae 0007
         mov    gs, [ecx+0eh]       \\1000:004020b0 8e690e
         add    al, 50h       \\1000:004020b3 0450
         mov    gs, [ecx+40h]       \\1000:004020b5 8e6940
         cwde          \\1000:004020b8 98
         add    [eax], al       \\1000:004020b9 0000
         add    [edi], dl       \\1000:004020bb 0017
         or     al, 16h       \\1000:004020bd 0c16
         or     eax, 9072b2bh       \\1000:004020bf 0d2b2b0709
         callf  0000:076f9a09h       \\1000:004020c4 9a6f070000
         or     ch, [edi+08h]       \\1000:004020c9 0a6f08
         add    [eax], al       \\1000:004020cc 0000
         or     ch, [eax+ebx]       \\1000:004020ce 0a2c18
         push   cs       \\1000:004020d1 0e
         add    al, 50h       \\1000:004020d2 0450
         or     [edx+d72h], ebx       \\1000:004020d4 099a720d0000
         jo     402104h       \\1000:004020da 7028
         or     [eax], eax       \\1000:004020dc 0900
         add    [edx], cl       \\1000:004020de 000a
         add    dl, cs:[esi]       \\1000:004020e0 2e0216
         or     al, 08h       \\1000:004020e3 0c08
         sub    eax, 90c2b02h       \\1000:004020e5 2d022b0c09
         pop    ss       \\1000:004020ea 17
         pop    eax       \\1000:004020eb 58
         or     eax, 50040e09h       \\1000:004020ec 0d090e0450
         mov    gs, [ecx+32h]       \\1000:004020f1 8e6932
         int    08h       \\1000:004020f4 cd08
         sub    al, 5ch       \\1000:004020f6 2c5c
         push   ss       \\1000:004020f8 16
         adc    eax, [ebx+ebp]       \\1000:004020f9 13042b
         dec    esi       \\1000:004020fc 4e
         push   cs       \\1000:004020fd 0e
         add    al, 50h       \\1000:004020fe 0450
         adc    [edx+ebx*4], eax       \\1000:00402100 11049a
         jc     402112h       \\1000:00402103 720d
         add    [eax], al       \\1000:00402105 0000
         jo     402131h       \\1000:00402107 7028
         or     [eax], eax       \\1000:00402109 0900
         add    [edx], cl       \\1000:0040210b 000a
         xor    esi, [esi]       \\1000:0040210d 3336
         pop    es       \\1000:0040210f 07
         adc    [edx+ebx*4], eax       \\1000:00402110 11049a
         outsd         \\1000:00402113 6f
         pop    es       \\1000:00402114 07
         add    [eax], al       \\1000:00402115 0000
         or     ch, [edi+0ah]       \\1000:00402117 0a6f0a
         add    [eax], al       \\1000:0040211a 0000
         or     dl, [ebx]       \\1000:0040211c 0a13
         push   es       \\1000:0040211e 06
         add    eax, 9a041150h       \\1000:0040211f 055011049a
         sub    [ebx], cl       \\1000:00402124 280b
         add    [eax], al       \\1000:00402126 0000
         or     dl, [edx]       \\1000:00402128 0a12
         push   es       \\1000:0040212a 06
         adc    al, [c28h]       \\1000:0040212b 1205280c0000
                        xrefs first: 1000:00402107 number : 1       \\;
         or     ch, [edx+eax]       \\1000:00402131 0a2c02
         sub    ebx, [esi]       \\1000:00402134 2b1e
         push   cs       \\1000:00402136 0e
         add    al, 50h       \\1000:00402137 0450
         adc    [edi+eax], eax       \\1000:00402139 110407
         adc    [edx+ebx*4], eax       \\1000:0040213c 11049a
         outsd         \\1000:0040213f 6f
         pop    es       \\1000:00402140 07
         add    [eax], al       \\1000:00402141 0000
         or     ah, [edx+58170411h]       \\1000:00402143 0aa211041758
         adc    eax, [ecx+edx]       \\1000:00402149 130411
         add    al, 0eh       \\1000:0040214c 040e
         add    al, 50h       \\1000:0040214e 0450
         mov    gs, [ecx+32h]       \\1000:00402150 8e6932
         test   eax, 58170811h       \\1000:00402153 a911081758
         adc    ecx, [eax]       \\1000:00402158 1308
         adc    [eax], ecx       \\1000:0040215a 1108
         adc    [edi], eax       \\1000:0040215c 1107
         mov    gs, [ecx+3fh]       \\1000:0040215e 8e693f
         sub    al, ffh       \\1000:00402161 2cff
         db     ff       \\1000:00402163 ff
         jmp    [edx]       \\1000:00402164 ff2a
         add    [eax], al       \\1000:00402166 0000
         adc    esi, [eax]       \\1000:00402168 1330
         add    eax, 8100h       \\1000:0040216a 0500810000
         add    [edx], al       \\1000:0040216f 0002
         add    [eax], al       \\1000:00402171 0000
         adc    [edx+esi*2], eax       \\1000:00402173 110472
         xor    eax, [eax]       \\1000:00402176 3300
         add    [eax+28h], dh       \\1000:00402178 007028
         add    al, [eax]       \\1000:0040217b 0200
         add    [edx], cl       \\1000:0040217d 000a
         sub    al, 09h       \\1000:0040217f 2c09
         add    ebp, [eax]       \\1000:00402181 0328
         or     eax, a0a0000h       \\1000:00402183 0d00000a0a
         sub    eax, [edi]       \\1000:00402188 2b07
         add    al, 28h       \\1000:0040218a 0428
         push   cs       \\1000:0040218c 0e
         add    [eax], al       \\1000:0040218d 0000
         or     cl, [edx]       \\1000:0040218f 0a0a
         push   es       \\1000:00402191 06
         add    eax, f6f1717h       \\1000:00402192 0517176f0f
         add    [eax], al       \\1000:00402197 0000
         or     cl, [ebx]       \\1000:00402199 0a0b
         push   ss       \\1000:0040219b 16
         lea    eax, [edx]       \\1000:0040219c 8d02
         add    [eax], al       \\1000:0040219e 0000
         add    [esi+ecx], ecx       \\1000:004021a0 010c0e
         add    al, 2ch       \\1000:004021a3 042c
         push   cs       \\1000:004021a5 260e
         add    al, 8eh       \\1000:004021a7 048e
   c160d imul   edi, [eax+28dh], d160c01h       \\1000:004021a9 69b88d020000010c
         sub    edx, [eax]       \\1000:004021b3 2b10
         or     [ecx], cl       \\1000:004021b5 0809
         push   cs       \\1000:004021b7 0e
         add    al, 09h       \\1000:004021b8 0409
         callf  0000:106f9a09h       \\1000:004021ba 9a6f100000
         or     ah, [edx+d581709h]       \\1000:004021bf 0aa20917580d
         or     [esi], ecx       \\1000:004021c5 090e
         add    al, 8eh       \\1000:004021c7 048e
         imul   esi, [edx], 17202e9h       \\1000:004021c9 6932e9027201
         add    [eax], al       \\1000:004021cf 0000
         jo     4021dah       \\1000:004021d1 7007
         db     0f       \\1000:004021d3 0f
         add    al, 12h       \\1000:004021d4 0412
         add    ch, [eax]       \\1000:004021d6 0228
         add    [eax], eax       \\1000:004021d8 0100
                        xrefs first: 1000:004021d1 number : 1       \\;
         add    [esi], al       \\1000:004021da 0006
         pop    es       \\1000:004021dc 07
         or     [edi+11h], ch       \\1000:004021dd 086f11
         add    [eax], al       \\1000:004021e0 0000
         or     dl, [ebx]       \\1000:004021e2 0a13
         add    al, 11h       \\1000:004021e4 0411
         add    al, 0eh       \\1000:004021e6 040e
         add    al, 6fh       \\1000:004021e8 046f
         adc    al, [eax]       \\1000:004021ea 1200
         add    [edx], cl       \\1000:004021ec 000a
         adc    eax, [511002bh]       \\1000:004021ee 13052b001105
         sub    al, [eax]       \\1000:004021f4 2a00
         add    [eax], al       \\1000:004021f6 0000
         adc    esi, [eax]       \\1000:004021f8 1330
         add    eax, 4e00h       \\1000:004021fa 05004e0000
         add    [ebx], al       \\1000:004021ff 0003
         add    [eax], al       \\1000:00402201 0000
         adc    [ebx], eax       \\1000:00402203 1103
         outsd         \\1000:00402205 6f
         adc    [eax], al       \\1000:00402206 1000
         add    [edx], cl       \\1000:00402208 000a
         or     al, [8db8698eh]       \\1000:0040220a 0a058e69b88d
         add    al, [eax]       \\1000:00402210 0200
         add    [ecx], al       \\1000:00402212 0001
         or     edx, [esi]       \\1000:00402214 0b16
         or     al, 2bh       \\1000:00402216 0c2b
         db     0f       \\1000:00402218 0f
         pop    es       \\1000:00402219 07
         or     [106f9a08h], al       \\1000:0040221a 0805089a6f10
         add    [eax], al       \\1000:00402220 0000
         or     ah, [edx+c581708h]       \\1000:00402222 0aa20817580c
         or     [eb32698eh], al       \\1000:00402228 08058e6932eb
         add    al, [esi+eax]       \\1000:0040222e 020406
         lsl    edx, [edx]       \\1000:00402231 0f0312
         add    [eax], ebp       \\1000:00402234 0128
         add    [eax], eax       \\1000:00402236 0100
         add    [esi], al       \\1000:00402238 0006
         push   es       \\1000:0040223a 06
         add    al, 07h       \\1000:0040223b 0407
         outsd         \\1000:0040223d 6f
         adc    eax, [eax]       \\1000:0040223e 1300
         add    [edx], cl       \\1000:00402240 000a
         or     eax, 6f050309h       \\1000:00402242 0d0903056f
         adc    al, 00h       \\1000:00402247 1400
         add    [edx], cl       \\1000:00402249 000a
         adc    eax, [ebx+ebp]       \\1000:0040224b 13042b
         add    [ecx], dl       \\1000:0040224e 0011
         add    al, 2ah       \\1000:00402250 042a
         add    [eax], al       \\1000:00402252 0000
         adc    esi, [eax]       \\1000:00402254 1330
         add    eax, 7600h       \\1000:00402256 0500760000
         add    [eax+eax], al       \\1000:0040225b 000400
         add    [ecx], dl       \\1000:0040225e 0011
         add    al, 72h       \\1000:00402260 0472
         xor    eax, [eax]       \\1000:00402262 3300
         add    [eax+28h], dh       \\1000:00402264 007028
         add    al, [eax]       \\1000:00402267 0200
         add    [edx], cl       \\1000:00402269 000a
         sub    al, 09h       \\1000:0040226b 2c09
         add    ebp, [eax]       \\1000:0040226d 0328
         or     eax, a0a0000h       \\1000:0040226f 0d00000a0a
         sub    eax, [edi]       \\1000:00402274 2b07
         add    al, 28h       \\1000:00402276 0428
         push   cs       \\1000:00402278 0e
         add    [eax], al       \\1000:00402279 0000
         or     cl, [edx]       \\1000:0040227b 0a0a
         push   es       \\1000:0040227d 06
         add    eax, f6f1717h       \\1000:0040227e 0517176f0f
         add    [eax], al       \\1000:00402283 0000
         or     cl, [ebx]       \\1000:00402285 0a0b
         push   cs       \\1000:00402287 0e
         add    eax, 8db8698eh       \\1000:00402288 058e69b88d
         add    al, [eax]       \\1000:0040228d 0200
         add    [ecx], al       \\1000:0040228f 0001
         or     al, 16h       \\1000:00402291 0c16
         or     eax, 908102bh       \\1000:00402293 0d2b100809
         push   cs       \\1000:00402298 0e
         add    eax, 106f9a09h       \\1000:00402299 05099a6f10
         add    [eax], al       \\1000:0040229e 0000
         or     ah, [edx+d581709h]       \\1000:004022a0 0aa20917580d
         or     [esi], ecx       \\1000:004022a6 090e
         add    eax, e932698eh       \\1000:004022a8 058e6932e9
         add    cl, [esi]       \\1000:004022ad 020e
         add    al, 07h       \\1000:004022af 0407
         db     0f       \\1000:004022b1 0f
         add    eax, 1280212h       \\1000:004022b2 0512022801
         add    [eax], al       \\1000:004022b7 0000
         push   es       \\1000:004022b9 06
         pop    es       \\1000:004022ba 07
         push   cs       \\1000:004022bb 0e
         add    al, 08h       \\1000:004022bc 0408
         outsd         \\1000:004022be 6f
         adc    eax, [eax]       \\1000:004022bf 1300
         add    [edx], cl       \\1000:004022c1 000a
         adc    eax, [ecx+edx]       \\1000:004022c3 130411
         add    al, 14h       \\1000:004022c6 0414
         push   cs       \\1000:004022c8 0e
         add    eax, 146fh       \\1000:004022c9 056f140000
         or     dl, [ebx]       \\1000:004022ce 0a13
         add    eax, 511002bh       \\1000:004022d0 052b001105
         sub    al, [eax]       \\1000:004022d5 2a00
         add    [ebx], dl       \\1000:004022d7 0013
         xor    [eax+eax], al       \\1000:004022d9 300400
         jbe    4022deh       \\1000:004022dc 7600
                        xrefs first: 1000:004022dc number : 1       \\;

         add    fs:[esi+45h], cl       \\1000:004034fc 64004e45
         push   esp       \\1000:00403500 54
         dec    ecx       \\1000:00403501 49
                        xrefs first: 1000:004034b2 number : 1       \\;
         outsb         \\1000:00403502 6e
         jbe    403574h       \\1000:00403503 766f
         imul   esp, [ebp+43h], 6ch       \\1000:00403505 6b65436c
         popad         \\1000:00403509 61
         jnc    40357fh       \\1000:0040350a 7373
         dec    ebp       \\1000:0040350c 4d
         jz     403578h       \\1000:0040350d 657468
         outsd         \\1000:00403510 6f
         add    fs:[esi+45h], cl       \\1000:00403511 64004e45
         push   esp       \\1000:00403515 54
         push   ebx       \\1000:00403516 53
         jz     40355fh       \\1000:00403517 657445
         outsb         \\1000:0040351a 6e
         jnz    40358ah       \\1000:0040351b 756d
         push   esi       \\1000:0040351d 56
                        xrefs first: 1000:004034b7 number : 1       \\;
         popad         \\1000:0040351e 61
         insb          \\1000:0040351f 6c
         jnz    403587h       \\1000:00403520 7565
         add    [esi+45h], cl       \\1000:00403522 004e45
         push   esp       \\1000:00403525 54
         inc    edi       \\1000:00403526 47
         db     65      ;'e'       \\1000:00403527 65
                        xrefs first: 1000:004034be number : 1       \\;
         db     74      ;'t'       \\1000:00403528 74
         db     50      ;'p'       \\1000:00403529 50
         db     72      ;'r'       \\1000:0040352a 72
         db     6f      ;'o'       \\1000:0040352b 6f
         db     70      ;'p'       \\1000:0040352c 70
         db     65      ;'e'       \\1000:0040352d 65
         db     72      ;'r'       \\1000:0040352e 72
         db     74      ;'t'       \\1000:0040352f 74
         db     79      ;'y'       \\1000:00403530 79
         db     00       \\1000:00403531 00
         db     4e      ;'n'       \\1000:00403532 4e
         db     45      ;'e'       \\1000:00403533 45
         db     54      ;'t'       \\1000:00403534 54
         db     47      ;'g'       \\1000:00403535 47
         db     65      ;'e'       \\1000:00403536 65
         db     74      ;'t'       \\1000:00403537 74
         db     46      ;'f'       \\1000:00403538 46
         db     69      ;'i'       \\1000:00403539 69
         db     65      ;'e'       \\1000:0040353a 65
         db     6c      ;'l'       \\1000:0040353b 6c
         db     64      ;'d'       \\1000:0040353c 64
         db     00       \\1000:0040353d 00

could not fit the rest in because of Stack overflow limitions

A: First, you have decompiled an IL code .NET dll to raw x86 32bit assembly. I mean, the bytes inside the .dll are NOT for a 32bit x86, are for the .NET's VM.
Second, converting that dll it's a totally pointless faraonic task, no one is going to do that. More, let's say you convert the dll, who is going to convert also all the dependencies of that .NET dll? It lacks of sense.
Third, check out the CrossTalk project. It might help you.
Four, it's time to upgrade your Delphi 4 or to switch to FreePascal, there are a LOT of things very very cool you are missing.

A: You know, Win32 DLLs can be called by managed .NET code.  It's called P/Invoke.  Use it.


text:
Q: Conditional statement in R based on multiple rasters I have:

*

*raster_1: an integer raster with non-sequential values i (101, 130, 240, 323)

*i: a watershed discharging X of sediment in the environment

*raster_2: represents the water quality for each watershed i with values ranging from 0 to 100,000 - named plume_i
I have ~400 rasters representing the water quality of 400 watersheds.
I would like to build a loop to set the values in raster_1 to NA for each zone (defined by the values: 101, 130, 240, 323 in raster_1) when raster_2 for the corresponding value (e.g., plume_101) is 0, using R.
For instance,

*

*When raster_1 = 101 & plume_101 = 0, assign NA to raster_1 otherwise return raster_1 values

*When raster_1 = 130 & plume 130 = 0, assign NA to raster_1 otherwise return raster_1 values

*When raster_1 = 240 & plume 240 = 0, assign NA to raster_1 otherwise return raster_1 values
and so forth...

How can I do this?

A: If I understood, you will be overwriting raster_1, putting NA when the condition is met. Here, the key is get which fetches an object from the environment by a string name.
library(raster)

# we create some rasters with same extent
m = matrix(sample(c(101,130,240,323),100, replace = T), ncol = 10)
r = raster(m)
p_101 = matrix(sample(0:10, 100, replace = T), ncol = 10)
plume_101 = raster(p_101)
p_130 = matrix(sample(0:10, 100, replace = T), ncol = 10)
plume_130 = raster(p_130)
p_240 = matrix(sample(0:10, 100, replace = T), ncol = 10)
plume_240 = raster(p_240)
p_323 = matrix(sample(0:10, 100, replace = T), ncol = 10)
plume_323 = raster(p_323)

par(mfrow = c(2,2))
for(i in c(101,130,240,323)) {
  r[r[] == i & get(sprintf("plume_%s", i))[] == 0] = NA
  plot(r, main = i, col = c("gold", "blue","brown", "tomato", "green"))
}

In the plot you may see how subsequently NA are added in each iteration


text:
Q: AngularJS fire action on html tag change I'm writing an on-page JS app with angular which will be integrated into different pages on our main website.
The app is integrated on our page with the following code:

  <video-list id="video-list" data-level="5"></video-list>

data-level is used to filter the list. So far everything works fine.
Now I want to be able to change the level on the website (not inside the angular app!) without reloading the page.
$("#video-list").attr("data-level", "3");

This changes the DOM-Element as expected, but it's not recognized by angular. I tried attrs.$observe in the directive, but that didn't helped:
# CoffeeScript
angular.module('videoList').directive 'videoList', ($document, templateBase) ->
  restrict: 'E'
  replace: true
  templateUrl: templateBase + 'video_list.html'
  link: (scope, element, attrs) ->
    attrs.$observe 'level', (value) ->
      console.log 'level changed to ' + value

As we don't know by now who may implement our app as-well, I'm looking for a nice line of javascript like the one above!
Is there any way, that angular recognize a change of data-level, without calling a function like $apply() or $digest() with jQuery?

A: $digest cycle is the main thing which detects changes in scope variable and then updates the view any change in scope variable triggers it! you can read its details to understand why your view is not getting updated in your case i would suggest something like:-

 <video-list id="video-list" data-level="{{videoLevel}}"></video-list>

in directives
angular.module('videoList').directive 'videoList', ($document, templateBase) ->
restrict: 'E'
replace: true
templateUrl: templateBase + 'video_list.html'
link:function (scope, element, attrs) {
   if(!attrs.dataLevel){
scope.videoLevel="5"; //if your directive has isolated scope which doesnt seem to be the case here then use scope.$parent.videoLevel=5;
}

//your logic follows! and whenever you change the value of binded variable the changes will be reflected
}


text:
Q: does malloc guarantee to allocate only the assigned memory block? I have assigned memory only for 4 integer in below program but the program when compiled/built with gcc 7.4.0 is not crashing. Is it because memory next to those assigned 4*4 bytes were not being used when I ran the built exe?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int *p = malloc(4*sizeof(int)); //allocating for only 4 integers
    if(NULL != p)
    {
        p[0] = 13;
        p[1] = 24;
        p[2] = 35;
        p[3] = 46;
        p[4] = 57;
        p[76] = 67;
        p[100] = 32;
        printf("%d %d %d %d %d %d %d", p[0], p[1], p[2], p[3], p[4], p[76], p[100]); //no crash? why?
        free(p);
    }
    return 0;
}

A: When you read or write past the bounds of allocated memory, you trigger undefined behavior.
With undefined behavior, the C standard doesn't make any guarantees about what your program will do.  It might crash, it might output strange results, or (as in this case) it could appear to work properly.  In addition, making a seemingly unrelated change such as adding an unused local variable or a call to printf for debugging can change how undefined behavior manifests itself, as can compiling with different optimization settings.
Just because the program could crash doesn't mean it will.
All that being said, a particular implementation of malloc could set aside more memory than is requested, but again you can't rely on that.  The only guarantee you have is that you get exactly the number of bytes you asked for.


text:
Q: Align columns of a multiple flexbox rows I'm using flexbox for grid columns
In the first row I have three dr-col-1 and two dr-col-2 (total of 7 flex-grow steps).
In the second row I have all seven dr-col-1.
When I rendered it, I noticed that alignment it not precise:

How can I precisely align columns in both rows?

.dr-row {
  display: flex;
}
.dr-col-1 {
  flex-grow: 1;
  flex-basis: 0;
  border: 1px solid black;
}

.dr-col-2 {
  flex-grow: 2;
  flex-basis: 0;
  border: 1px solid black;
}

      one

      two

      three

      four

      five

      one

      two

      three

      four

      five

      six

      seven

Codepen

A: The flex-grow property is designed to distribute free space in the container. It's not designed for specific sizing of flex items (that would be flex-basis).
The columns aren't aligning because there are more vertical borders in the second row.
More specifically, there is 8px of border width in row one, and 12px of border width in row two (not including the edges).
This means there is more free space in row one, which results in the misalignment.
Instead of using flex-grow try using flex-basis:

.dr-row {
  display: flex;
}
.dr-col-1 {
  flex: 0 0 14.29%;
  border: 1px solid black;
  box-sizing: border-box;
}

.dr-col-2 {
  flex: 0 0 28.58%;
  border: 1px solid black;
  box-sizing: border-box;
}
body { margin: 0; }

one

two

three

four

five

one

two

three

four

five

six

seven

revised codepen
For more information see: flex-grow not sizing flex items as expected

A: When you have two .dr-col-1, there are 4 borders, 4 * 1px = 4px.
When you have one .dr-col-2, there are 2 borders, 2 * 1px = 2px.
So you need to compensate that difference of 2px, for example by increasing the flex-basis:
.dr-col-2 {
  flex-basis: 2px; /* flexFactor * borderWidth */
}

.dr-row {
  display: flex;
}
.dr-col-1 {
  flex-grow: 1;
  flex-basis: 0;
  border: 1px solid black;
}
.dr-col-2 {
  flex-grow: 2;
  flex-basis: 2px;
  border: 1px solid black;
}

one

two

three

four

five

one

two

three

four

five

six

seven

A: The border also takes some place
here is the same HTML/CSS, but I used outline instead of borders.
https://jsfiddle.net/nfo1pg9f/

.dr-row {
  display: flex;
  box-sizing: border-box;
}
.dr-col-1 {
  flex-grow: 1;
  flex-basis: 0;
  outline: 1px solid black;
}

.dr-col-2 {
  flex-grow: 2;
  flex-basis: 0;
  outline: 1px solid black;
}

      one

      two

      three

      four

      five

      one

      two

      three

      four

      five

      six

      seven

A: Here give this a try, not sure if it's the best resolve, but seems to align perfectly no matter the browser size
The border is seems to be off on the elements, adding a single pixel to the grow:2; seems to realign things again. I added some margin and padding for appearance purpose

.dr-row {
  display: flex;
  flex-flow: row wrap;
  justify-content: space-around;

}
.dr-row div{
  margin:5px;
  flex-basis: 0;
  border: 1px solid black;
}
.dr-col-1 {
  flex-grow: 1;
}

.dr-col-2 {
  flex-grow: 2;
  padding: 6px;
}

      one

      two

      three

      four

      five

      one

      two

      three

      four

      five

      six

      seven


text:
Q: Application crashes while fetching data from NSString I have an application in which I am converting UIImage to NSData an further NSData to Base64String using this https://github.com/nicklockwood/Base64 class....but the App crashes When I want to fetch the converted string to the other class.
It gives EXC_BAD_ACCESS error...
Is it possible that NSString can't handle such big strings or is there any other issue?
Here is my code....
image = [UIImage imageNamed:@"earring_hoops_small.jpg"];
    NSData *data = UIImageJPEGRepresentation(image, 0.1f);
    NSData *data2 = data;
    NSLog(@"BaseString=%@",data2);
    [Base64 initialize];
    strEncoded = [Base64 encode:data];
    NSLog(@"BaseString=%@",strEncoded);

and It gives exception while....
myString = strEncoded;


text:
Q: What would be a pratical example of sysroot and prefix options for Qt I'm looking at all the options that can be run for the configure script provided with Qt. (specifically qt-everywhere-opensource-src-5.2.0).
After considerable searching, I've determined this stuff is poorly documented at best so I was hoping I could get some help.  When I look at the descriptions for prefix and sysroot configuration options:

~/qt-everywhere-opensource-src-5.2.0$ ./configure -help | grep "sysroot"
      -extprefix <dir> ... When -sysroot is used, install everything to <dir>,
      -sysroot <dir> ...... Sets <dir> as the target compiler's and qmake's sysroot and also sets pkg-config paths.
      -no-gcc-sysroot ..... When using -sysroot, it disables the passing of --sysroot to the compiler
  ~/qt-everywhere-opensource-src-5.2.0$ ./configure -help | grep "prefix"
      -prefix <dir> ...... This will install everything relative to <dir>
      -extprefix <dir> ... When -sysroot is used, install everything to <dir>,
      -hostprefix [dir] .. Tools and libraries needed when developing

So I've used -prefix before, and it did exactly as described. It placed everything at the provided <dir>, then when I built my application using <prefix_dir>/bin/qmake and installed that on my target platform it wanted to find all the shared object libraries at <prefix_dir>/lib.
I'm under the impressions that if I use -sysroot it will install everything at <sysroot_dir> then when I install my application on the target platform it will search in /lib. At least I hope that's true.
Now if my assumption is correct... then what's the point of -extprefix? Are they saying that if I can redirect where things good if I use both -sysroot and -extprefix?
And what would be a reason why I would want to use -no-gcc-sysroot? If I wanted my Qt libs to be installed at "sysroot" why wouldn't I want gcc to use/know the same sysroot?
An explanation of some of these would be great, even better if I can get some practical examples of how to correctly use these options.

A: One practical example would be cross compiling Qt for Raspberry Pi and then creating a "sister" kit to add to Qt Creator.
The following command install Qt on the Pi after mounting the Pi's root filesystem:
    ./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=$RPI_TOOLCHAIN -sysroot $RPI_SYSROOT -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt-5.5.1-pi -skip qtwebkit

The following command then installs the binaries on the desktop by using Pi's root file system.
    ./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=$RPI_TOOLCHAIN -sysroot $RPI_SYSROOT -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -extprefix /usr/local/qt-5.5.1-pi -skip qtwebkit

Note that the only difference is the use of -extprefix instead of -prefix which directs the installation location.
Note: You can install Qt on host and target simultaneously by specifying both prefix and extprefix in the same line
Now you can add this kit to your Qt Creator by specifying your qmake path, device, compiler, debugger and sysroot. So you can create a qt project on your desktop and then build and run on either the desktop or the pi depending on the kit you choose.

A: These are options that are used when building embedded platforms.
Yes they are a royal mess. So here's only a partial answer:
-prefix

*

*tried and proven way to say /usr/lib instead of /usr/local/lib or similar for the entire installation of Qt

*when Qt is built for the platform it is currently running on (typical for desktop)

-sysroot /path

*

*intends to build Qt for a system which isn't installed at /

*for example -sysroot ~/mysystem where ~/myssytem contains
/lib /bin etc...

*will pass --sysroot to other tools, like gcc and pkg-config, so they will search for their dependencies in ~/mysystem/lib rather than /lib

-extprefix /b

*

*when using -sysroot /a, don't actually write to /a

*write qt to /b instead

*this is intended for cross-compiling against read-only sysroots

-no-gcc-sysroot

*

*very specific hack for compilers that can't find their own crt inside --sysroot

*passes sysroot to pkgconfig and others, but not to gcc

*so that gcc will be called with -L/sysroot/lib/ correctly, but doesn't try to find implicit paths (crt) here.

-hostprefix  /path

*

*when compiling for a different target than we are currently running on

*qmake will be the host architecture (for example x86) and qt itself will be the target architecture (lets say arm)

*so put qmake in /path instead of the target system specified by -sysroot. it won't be any useful on the target system

To add to the confusion:
-R /path

*

*sets the linkers runpath - which is where QtGui finds QtCore for example - independant of all the other options

Which flags you want to use when compiling for a target not your host, depends on a boatload of hardcoded assumptions inside configure.
generally -sysroot plus -prefix should work for most use cases.
i.e. when you have:
 $ ls ~/mytarget
 lib bin share dev

you could just use -sysroot ~/mytarget -prefix /


text:
Q: Hiding Google Analytics code based on theme options I'm doing up a WordPress theme at the moment, and I want users to be able to add Google Analytics to their site by just adding their tracking code -- you know, the UA-20149670-1 -type number thing.
At the moment I have all the Google Analytics JavaScript code sitting in the <head> of my pages, with the tracking code being set by the user via a theme option text input form.
However, if the user doesn't add a tracking code, then all the Google JavaScript is still left sitting in the <head>, without a tracking code, bloating up the header.
How can I code this so that the Google Analytics code only appears after the user puts in their tracking code?
Additionally, at the moment the Google Analytics code is all still in header.php -- ideally I'd like to move it instead to functions.php. How best would I do that?
Thanks.

A: Take the GA code from your header and wrap it in a function hooked to wp_head;
function __analytics_head()
{
    $options = get_option( 'themename_theme_options' );
    if ( !empty( $options['analytics'] ) ) :
    ?>
<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', '<?php echo esc_js( $options['analytics'] ) ; ?>']);
    _gaq.push(['_trackPageview']);
    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
</script>
    <?php
    endif;
}
add_action( 'wp_head', '__analytics_head', 100 );

Obviously, this is only guideline code - the way you retrieve your options may vary - but the idea is to check if a GA account has been set, and if so, proceed to print the script.

A: on a sidenote; the Analytics code should be sitting in the footer...


text:
Q: Visual Basic, why Nothing? In school, I worked primarily with Java, C, and Python. Now that I'm working, I am working with .Net all of the time. Occasionally I have to work on Visual Basic projects which has been an enjoyable learning experience but I seem to get hung up on a few things from time to time. One of my main problems comes from the fact that Visual Basic uses Nothing instead of null as in C# and F#.
Nothing and null, to me, seem to be basically the same with the exception that a non-nullable value type can be set to Nothing in Visual Basic and the value will be set to its default value (i.e. 0 for an Integer). In C#, if a non-nullable value type is set to null there will be a compile-time error. Having the default value of data types be  but making created types Nullable and setting values to DBNull.Value for working with databases throws me off. It's not intuitive switching to Nothing from null. I looked at the IL code of setting a string to null/Nothing in both C# and VB and each time it set the string to ldnull. So is there any underlying reason as to why Visual Basic uses Nothing instead of null as other .Net languages do?
tl;dr Why does Visual Basic use Nothing instead of null?

A: Remember that VB is based on the original Basic, which is intende to be truly BASIC, easily understood by someone who is not a programmer.
If you try to explain to a non-programmer that what a value is, which makes more sense.
"The value of X is Nothing"
or
"The value of X is null"  --> Leads to "Huh"? What the heck is NULL??

A: If you want to replicate the functionality of nothing in C# try using default(int) where int is the type of variable.
This is normally used with generics when the type is not known.

A: Nothing is the keyword that was used in VB6 and earlier versions of VB.  I don't no why they chose that term, but they kept it in .NET because it is part of the core VB language syntax and for backwards compatibility.  Perhaps the originally chose it because it was a simpler term for novices to understand?