text:
Q: How to skip the chooser dialog for sending mail in android I'm getting the pop-up for choosing the email client (Gmail, EMail, etc.), but I want to skip it and instead send it directly through GMail.
protected void sendEmail() {
   String[] recipients = { recieverId.getText().toString() };
   Intent email = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));

   email.setType("message/rfc822");

   email.putExtra(Intent.EXTRA_EMAIL, recipients);
   email.putExtra(Intent.EXTRA_SUBJECT, mailSubject.getText().toString());
   email.putExtra(Intent.EXTRA_TEXT, mailBody.getText().toString());

   try {
      startActivity(Intent.createChooser(email,
         "Choose an email client from..."));
   } catch (android.content.ActivityNotFoundException ex) {
      Toast.makeText(getApplicationContext(),
         "No email client installed.", Toast.LENGTH_LONG).show();
   }
}

A: Simply omit createChooser and hardcode Gmail intent, as described here:
public void sendGmail(Activity activity, String subject, String text) {
    Intent gmailIntent = new Intent();
    gmailIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
    gmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    gmailIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
    try {
      activity.startActivity(gmailIntent);
    } catch(ActivityNotFoundException ex) {
      // handle error
    }
}

A: @Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Intent emailIntent = new Intent();
    emailIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");// Package Name, Class Name
    emailIntent.setData(Uri.parse("mailto:"));
    emailIntent.setType("text/plain");
    emailIntent.putExtra(Intent.EXTRA_EMAIL, "Your Sender Mail ID");
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your Subject");
    emailIntent.putExtra(Intent.EXTRA_TEXT, "Body of the Email ");
    startActivity(emailIntent);
}

    You can get the Package name via adb shell Command:
    pm list packages -f

A: emailIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");// Package Name, Class Name

Setting class name in intent worked for me. No need to add chooser. For sending email through your office mailclient you can add From (for intent) or select from the list of mail ids from gmail account compose section (From).


text:
Q: .commitNow() vs .commit(), which is more adequate? I´m trying to clean up my code and I have a more basic question.
In my Activity, I'm just adding a Fragment ->
class OrderActivity : AppCompatActivity(), HasAndroidInjector {
    private lateinit var binding: ActivityOrderBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = DataBindingUtil.setContentView(this, R.layout.activity_order)
        if (savedInstanceState == null) {
            supportFragmentManager.beginTransaction().add(R.id.container, OrderFragment())
                .commitNow()
        }
    }
}

I´m using commitNow() only if the Activity is "new" ( asking for the bundle state ), as I read in Android´s Documentation, commitNow make the commit syncronously  -- >

Commits this transaction synchronously. Any added fragments will be initialized and brought completely to the lifecycle state of their host and any removed fragments will be torn down accordingly before this call returns. Committing a transaction in this way allows fragments to be added as dedicated, encapsulated components that monitor the lifecycle state of their host while providing firmer ordering guarantees around when those fragments are fully initialized and ready. Fragments that manage views will have those views created and attached.

Now, I just want to know if it is safe to replace commitNow for ".commit()".
I understand that commit can throw an exception if the Activity State was already saved, but, if I wrote it like this .. >
class OrderActivity : AppCompatActivity(), HasAndroidInjector {
    private lateinit var binding: ActivityOrderBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = DataBindingUtil.setContentView(this, R.layout.activity_order)
        if (savedInstanceState == null) {
            supportFragmentManager.beginTransaction().add(R.id.container, OrderFragment())
                .commit()
        }
    }
}

Is it safe?

A: This may not cause an error, but you are relying on an unrelated happen stance to manage your Fragment. When you could check if it already exists if not add it.
How to check if the fragment exists
And whether commit is safe or not is up to how you are using the Fragment.
Is the Fragment strongly coupled with the containing Activity i.e. does OrderActivity talk directly to the OrderFragment?
If so then you could talk to the Fragment before it has been added which is generally a no-no if it has anything to do with a view.
If the Fragment is independent and manages itself then you should be fine.
They can still be used together but it needs to be 1 way Fragment -> Activity and  NOT  Activity -> Fragment as again commit() is async and the containing Activity could be talking to something that isn't "there".

redpajama_set_name: RedPajamaStackExchange


text:
Q: Fixed banner on scrolling page with HTML and CSS I need to create a banner's placeholder that needs to scroll up together with a page until it reaches a browser's top edge and then it should be fixed at the top. When the page is scrolled down, the banner also needs to scroll with the page again. I'm not sure whether I'm clear enough so you can see the example at Watch Critic. You'll notice that the banner in the right column behaves just like I've described.
I don't have experience with JavaScript so can this be achieved with HTML and CSS only?

A: Living example: http://jsfiddle.net/KXXhQ/
You need to make use of the scroll event of jQuery and then add a new class to your header in order to fix it:
jQuery
  //by default, the static menu is hidden
  var showStaticMenuBar = false;

  //when scrolling...
  $(window).scroll(function () {

      //if the static menu is not yet visible...
      if (showStaticMenuBar == false) {
          //if I scroll more than 200px, I show it
          if ($(window).scrollTop() >= 200) {
              //showing the static menu
              $('#header').addClass('fixed');

              showStaticMenuBar = true;
          }
      }
      //if the static menu is already visible...
      else {
          if ($(window).scrollTop() < 200) {
              $('#header').removeClass('fixed');

              //I define it as hidden
              showStaticMenuBar = false;
          }
      }
  });

CSS
#header{
    display:block;
    width: 100%;
    height:50px;
    background: #ddff00;
}
#header.fixed{
    position:fixed;
    top: 0;  /*fixing it at the top*/
    z-index: 999;  /* over any other element*/
}

Living example: http://jsfiddle.net/KXXhQ/

A: This is how you can set the position to be fixed in CSS. If you want to achieve more behaviors you can define them as CSS classes and when you need to change behavior just add and remove classes with jQuery.


text:
Q: Best practice or any performance implication for assignment vs multiple returns During a code review, another dev and I had a small debate about the proper or correct way to handle multiple returns, and if assigning a pointer to null, and then setting it yields any difference compared to simply returning the value, an later returning null.
private ServiceParam getRequestServiceParam(SlingHttpServletRequest request) {
    ServiceParam sp = null;
    try {
        sp = new ServiceParam(IOUtils.toString(request.getReader()));
    } catch (IOException e) {
        LOGGER.error("IOException", e);
    }
    return sp;
}

vs
private ServiceParam getRequestServiceParam(SlingHttpServletRequest request) {
    try {
        return new ServiceParam(IOUtils.toString(request.getReader()));
    } catch (IOException e) {
        LOGGER.error("IOException", e);
    }
    return null;

}

Functionally they seem identical, but we don't know if one my be more correct than the other. Though I fear that this may just be a tabs vs spaces argument.

A: Whether more than one return from a method is ok or not is a matter of opinion. But there are trade-offs here to talk about where some of the solutions are better than others. Sonarqube complaints are a good place to start, but there are larger issues.
Some people think it's bad to have more than one return and they want to follow the structured programming rules no matter what. Structured programming is better than using goto, and it does produce consistent-looking code.
Other people point out that enforcing one return makes control statement nesting deeper, resulting in code that is harder to read. In the case of the first example I find myself scanning up and down in the method looking for where the local variable gets a value assigned to it, and I think that's annoying.
(Sonarqube doesn't count cyclomatic complexity correctly when you have multiple returns, btw. So if it nags you to avoid that practice maybe there is an element of self-interest there; it's telling you, don't go writing code that we have trouble figuring out.)
Also there is no performance implication to any of this. It is just a matter of awkward coding and less-than-ideal exception-handling. When you return null you create an opportunity for the calling code to fail to check the reference for null, it would be better to let the exception get thrown.
I would not use Optional for this unless it looked like something I'd use in a monadic context where I'm chaining stuff together and using flatMap to handle the Optional empty cases for me. Otherwise it is annoying to have to wrap and unwrap this, it is a bit better than returning null, only because it forces the calling code to consider the empty case.
In this case the actual awkwardness is caused by reading from the httprequest, which is what throws the IOException. You could add throws IOException to the method and let the exception be thrown. But it would be better to move that code to whatever servlet or web controller is getting the httprequest, and have any IOException thrown by calling it get handled in the same way as whatever else the servlet or controller does gets handled.
Once you move that request-reading code there is no compelling reason for this method to exist at all. Deleting unnecessary code is a good thing.

A: I would follow @khelwood advice. Use Optional if you don't want to handle the raised exception outside of the function call as indicated by @ControlAltDel
private Optional<ServiceParam> getRequestServiceParam(SlingHttpServletRequest request) {
  try {
    return Optional.of(new ServiceParam(IOUtils.toString(request.getReader())));
  } catch (IOException e) {
    LOGGER.error("IOException", e);
    return Optional.empty();
  }
}

if you must use null I would prefer the second approach
private ServiceParam getRequestServiceParam(SlingHttpServletRequest request) {
  try {
    return new ServiceParam(IOUtils.toString(request.getReader()));
  } catch (IOException e) {
    LOGGER.error("IOException", e);
    return null;
  }
}

because I don't have to think twice everything is stated as is. So no unnecessary variable declaration, no need to remember what is in it. (This argument is also true for the Optional approach.)
Update 1: This is true for two, maybe three return statements in a single method, if there are several return statement other solutions must be considered.
Update 2: There is also a sonar rule squid:S1142
IMHO

A: Multiple returns are error-prone when it comes to code maintenance.  Multiple returns are not the easiest to read.
When it comes to choices like this I always choose the code that is easier to read by someone who didn't write it.
When someone else reads it a year from now they might be in a hurry, working on some emergency, and they want code they can understand fully at a glance.
I strive to write code that is super easy to read, i.e., less risky for someone else to refactor.

A: It is always good to avoid local variables where ever you can, for better performance. If you are too much concerned about readability, then go with Option 1, else go with Option 2. Have a look at this answer for details about assigning the result to a local variable before returning.


text:
Q: WPF Combox.FindName() doesn't work I've got two comboboxes. The items of the first one i'm filling in Xaml with:
<ComboBox Name="ddl_pageType" Width="200" BorderThickness="5">
                <ComboBoxItem Name="Website" Content="Webseite"/>
                <ComboBoxItem Name="CNIProg" Content="Seite"/>
</ComboBox>

and the function ddl_pageType.FindName("Website"); works.
The second combobox i'm filling with:
 ddl_cniProg.SetBinding(TextBlock.TextProperty, new Binding());
 ddl_cniProg.ItemsSource = progList;

where proglist is List. Here the function ddl_cniProg.FindName(string) doesn't work.
What do i have to do to get an item from dd_cniprog?

A: FrameworkElement.FindName searches for child elements via the Name attribute. (http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.findname.aspx) Unless  the ComboBoxItems you are generating from the databound list have the Name attribute set (which it doesn't look like from the small code snippet) then the function won't find them.
To find the element you're looking for using FindName, you'll need to set the Name attribute for each item, either via databinding or programmatically.

A: Since you don't specify any name for the items in the databound ComboBox, you can't use FindName...
If you want to retrieve the ComboBoxItem for a specific data item, you can use the ItemContainerGenerator :
ComboBoxItem comboItem = ddl_cniProg.ItemContainerGenerator.ContainerFromItem(item) as ComboBoxItem;


text:
Q: Collection was modified; enumeration operation might not execute even when validation is applied on row count? Hi I'm sorry I am a beginner at C# programming and although I know a lot of threads has been created on this issue, I can't seem to find one that is applicable to my case especially since I already applied this on other forms and it worked.
This solution tells me iterate it backwards, however I don't know how/where to apply it. I am getting the error at the in in
foreach (DataRow dataRow_AvailableEmp in AvailableEmp_dataTable.Rows)

here's the rest of the code.
    if (WithTasks_Datatable.Rows.Count > 0)
    {
        foreach (DataRow dataRow_WithTask in WithTasks_Datatable.Rows)
        {
            Booked_Initial = dataRow_WithTask["Assigned"].ToString();
            if (this_Initial != Booked_Initial) //di booked
            {
                //CHECK IF IN DATATABLE
                if (AvailableEmp_dataTable.Rows.Count > 0)
                {
                    foreach (DataRow dataRow_AvailableEmp in AvailableEmp_dataTable.Rows)
                    {
                        Available_Initial = dataRow_AvailableEmp["EmpID"].ToString();

                        if (this_Initial != Available_Initial) //NOT IN DB
                        {
                            //ADD

                            AvailableEmp_dataTable.Rows.Add(this_EmpID, this_Initial, PositionName, TeamName, TeamLead);
                        }
                    }
                }
                else
                {
                    //ADD
                    AvailableEmp_dataTable.Rows.Add(this_EmpID, this_Initial, PositionName, TeamName, TeamLead);
                }
            }
        }
    }

A: One simple solution is to put the rows you are iterating into a new list:
foreach (DataRow dataRow_AvailableEmp in AvailableEmp_dataTable.Rows.Cast<DataRow>().ToList())

A: You can't / shouldn't modify a collection accessed through an enumerator.
Basically Enumerators are find previous or next record, if you makea change to the collection which changes what the next or previous will be....
Two attacks for this access by index instead as suggested by @mhornfeck
Or you create an empty datatable(s), add to them.
Then append the added rows to the original collection.

A: To iterate backwards, use for instead of foreach:
for (int i = AvailableEmp_dataTable.Rows.Count - 1; i >= 0; --i)
        {
            DataRow dataRow_AvailableEmp = AvailableEmp_dataTable.Rows[i];
            Available_Initial = dataRow_AvailableEmp["EmpID"].ToString();

            if (this_Initial != Available_Initial) //NOT IN DB
            {
                //ADD
                AvailableEmp_dataTable.Rows.Add(this_EmpID, this_Initial, PositionName, TeamName, TeamLead);
            }
        }

From http://www.dotnetperls.com/foreach

The foreach loop construct provides a way to elegantly loop through
  elements, but it has the drawback of restricting any mutations made to
  the collection during the loop.

A: If you wanna use foreach (no reason you should), you will have to loop once to create a list of all the employees you wanna add. Iterate over the list of employees to add and add them to the database.

A: That solution applies to removing items from a collection and is used to keep your iteration  variable from skipping over items after an item in the middle is deleted (sort of like running away from a crumbling cliffside.  It will not work for adding items (nor will iterating forwards) as your Count will change periodically.
To iterate through the collection and add items based on what you find, add the items to a temporary List<DataRow> and then add them to the DataTable after the iteration is complete.


text:
Q: C# HtmlAgilityPack Html Load external I'm using HtmlAgilityPack to get html from a site and the requests from that site are made by XMLHttpRequest and the html are loaded in a DIV i can't get that html loaded external by request i tried, but i can't get the html
                HttpWebRequest getRequest = WebRequest.Create(Url) as HttpWebRequest;
            //
            getRequest.CookieContainer = cookieJar;
            getRequest.Method = WebRequestMethods.Http.Post;
            getRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:33.0) Gecko/20100101 Firefox/33.0";
            getRequest.AllowWriteStreamBuffering = true;
            getRequest.ProtocolVersion = HttpVersion.Version11;
            getRequest.AllowAutoRedirect = true;
            getRequest.ContentType = "application/x-www-form-urlencoded";

            Stream newStream1 = getRequest.GetRequestStream();
            newStream1.Close();
            HttpWebResponse getRequestResponse = (HttpWebResponse)getRequest.GetResponse();
            string source = "";

            using (StreamReader sr = new StreamReader(getRequestResponse.GetResponseStream(), Encoding.Default))
            {
                source = sr.ReadToEnd();
                //Console.WriteLine(source);
            }
            doc.LoadHtml(source);
            getRequestResponse.Close();

A: I would recommend updating your code to use the HttpClient class. This has support for async behaviour which can help with scalability of your application (in some cases).
MSDN HttpClient Docs
However, looking at the current implementation, if you are receiving a 405 error it may be because you are trying to POST to the URL. Since I can see no POST data in the code snippet you have shown, it might be better to use a GET request:
getRequest.Method = WebRequestMethods.Http.Get;


text:
Q: Yarn application failed due to Connection refused to port 49941 I'm having a failure with a Yarn application, and I can't find the issue.
Even though the logs aggregation is activated (yarn.log-aggregation-enable set to true) I can't see them with:
$HADOOP_INSTALL/bin/yarn logs -applicationId application_1426155045075_0001
15/06/15 14:50:16 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
15/06/15 14:50:16 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Logs not available at /tmp/logs/hadoop/logs/application_1426155045075_0001
Log aggregation has not completed or is not enabled.

The History server is up and running:
$ jps
1926 DataNode
2022 ResourceManager
3982 JobHistoryServer
4320 Jps
1843 NameNode
2272 NodeManager

Here the app Diagnostics information:
Application application_1426155045075_0001 failed 2 times due to Error launching appattempt_1426155045075_0001_000002. Got exception: java.net.ConnectException: Call From hadoop-server/192.168.2.72 to hadoop-server:49941 failed on connection exception: java.net.ConnectException: Connection refused; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.apache.hadoop.net.NetUtils.wrapWithMessage(NetUtils.java:783)
at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:730)
at org.apache.hadoop.ipc.Client.call(Client.java:1415)
at org.apache.hadoop.ipc.Client.call(Client.java:1364)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:206)
at com.sun.proxy.$Proxy77.startContainers(Unknown Source)
at org.apache.hadoop.yarn.api.impl.pb.client.ContainerManagementProtocolPBClientImpl.startContainers(ContainerManagementProtocolPBClientImpl.java:96)
at org.apache.hadoop.yarn.server.resourcemanager.amlauncher.AMLauncher.launch(AMLauncher.java:118)
at org.apache.hadoop.yarn.server.resourcemanager.amlauncher.AMLauncher.run(AMLauncher.java:249)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
    at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206)
    at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:529)
    at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:493)
    at org.apache.hadoop.ipc.Client$Connection.setupConnection(Client.java:606)
    at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:700)
    at org.apache.hadoop.ipc.Client$Connection.access$2800(Client.java:367)
    at org.apache.hadoop.ipc.Client.getConnection(Client.java:1463)
    at org.apache.hadoop.ipc.Client.call(Client.java:1382)
    ... 9 more
. Failing the application.

It sounds like a problem related to the ContainerManager. Is port 49941 specific to this (or other) service??

A: After digging I found that the problem was due to NodeManager not in a good health (I've seen local-dirs turned bad in the health report). To fix that I had to shutdown Yarn and restart all services.


text:
Q: Expanding the function $f(x) = 1, 0 < x < 1$ in a series of the eigenfunctions? I have a problem that asks me to expand the function $ f(x) = 1, 0 < x < 1$ in a series of the eigenfunctions of the given problem. For example, one given problem is $y'' + 2y' + ( \lambda + 1)y = 0, y(0) = 0, y(1) = 0$.
What is meant by this ("expand the function in a series of the eigenfunctions of the given problem")? I don't understand what it is asking to do?
Thanks for any help.

A: Generically, this sort of problem has a sequence of eigenfunctions $\{ f_n \}_{n=1}^\infty$; expanding a given function $f$ in terms of the eigenfunctions means determining scalars $c_n$ such that $f=\sum_{n=1}^\infty c_n f_n$. Strictly speaking this is an infinite linear system; to solve it, one should hope to find an orthogonal system of eigenfunctions with respect to some inner product $\langle \cdot,\cdot \rangle$, so that the $c_n$ are given by $\frac{\langle f,f_n \rangle}{\| f_n \|^2}$.

A: This is an eigenvalue/eigenfunction problem. Disregarding the endpoint conditions for the moment, the solutions of your problem have the form
$$
   y(x)=Ae^{-x}\cos(\sqrt{\lambda}x)+Be^{-x}\sin(\sqrt{\lambda}x).
$$
The solutions that satisfy $y(0)=y(1)=0$ are constant multiples of
$$
   y_n(x) = e^{-x}\sin(n\pi x),\;\; \lambda_n=n^2\pi^2,\;\;n=1,2,3,\cdots.
$$
In order to expand the constant function $f(x)=1$ in the eigenfunctions $\{ y_n \}$, you must find coefficients $C_n$ such that
$$
          1 = \sum_{n=1}^{\infty}C_n e^{-x}\sin(n\pi x) \\
        e^{x} = \sum_{n=1}^{\infty}C_n \sin(n\pi x).
$$
Using the orthogonality of the $\sin(n\pi x)$ functions on $[0,1]$ with respect to the integral gives $C_n$:
$$
      \int_{0}^{1}e^{x}\sin(n\pi x)dx = C_n\int_{0}^{1}\sin^2(n\pi x)dx \\
       C_n = \frac{\int_{0}^{1}e^{x}\sin(n\pi x)dx}{\int_{0}^{1}\sin^2(n\pi x)dx}.
$$
The series will converge to $1$ except at $x=0,1$, where it obviously converges to $0$.


text:
Q: Avoid an infinite loop but still ensure user validation As part of the system I'm building a registered user needs to validate his email address, By clicking on a link in the following format:
https://example.com/verification/${A key of 256 random characters}
i use crypto.randomBytes(128) to generate the key.
After creating the key, i check that the key is not already in use, The problem is that i have to limit the number of tests, and i don't want to get to the point where 2 users get the same key.
How to deal with this situation? Limit the number of tests to a high number like 10,000 for example or is there a better way?

A: The module crypto in NodeJs uses the method randomBytes(size[, callback]), where you can provide the value of the size in your case 265, and implement the callback method that will take two arguments the err and the buf which represents a Buffer object with the generated values. This is an example of using the method :
const {
  randomBytes,
} = await import('node:crypto');

randomBytes(256, (err, buf) => {
  if (err) throw err;
  // Rest of the code
});

Now, if you want to make an algorithm that generates 100% unique keys each time for each user, let me tell you that this is impossible. Check the Pigeonhole principle, for more information. However, you can follow one of the following 2 approaches:

*

*If you are sure that the number of the user won't be more than a number m, and that your algorithm can generate n keys, knowing that n>m then you can do it (Pigeonhole principle).

*You can follow an approach similar to a database unique id, where start with a number and increment it each time a new user is registered, and remove that key from your app after a certain period of time so you will not flood the server with useless data.


text:
Q: VS2008 C++ - afxglobals.h: No such file or directory We have a C++ MFC project that won't build under a fresh-install of Visual Studio 2008 Standard. I've tried:

*

*Revo Uninstaller to remove all previous versions of Visual Studio

*Fresh install of Visual Studio 2008 Standard (all options selected)

This is running Windows XP SP2. I don't have the file afxglobals.h, which to my knowledge should live in %PROGRAMFILES%\Microsoft Visual Studio 9.0\VC\afxmfc\include.
Hence, when I try to compile my source that #includes <afxglobals.h>, the build fails saying it cannot find the file.
I'm thinking this may be another corrupt installation, but I've already tried re-installing before. Any ideas?

A: Try this

*

*Remove Visual C++ from Visual Studio (or uninstall the whole Visual Studio if you want to be safe)

*go to %PROGRAMFILES%\Microsoft Visual Studio 9.0\ and delete the VC folder (if you uninstalled the whole VisualStudio, delete everything here)

*clean your "%temp%" folder and turn off any service/software that interfere with the installer, such as anti-virus

*Reinstall, install service pack and security patch,

A: Installing Visual C++ 2008 Feature Pack should help.


text:
Q: Excel : How to select cells with more than a number of characters? Only search one column, then highlight all cells in that column with more than (a number) characters, so i change the data one by one?
Thank you.
Its phone number, thousands of them, many are typed incorrectly, at least 100, i try to find them directly without going through all of them

A: If you want to highlight cells which contain more than X characters, you can use Conditional formatting and function LEN().
For example: You want to highlight all cells in column A containing more than X characters.

*

*Select column A

*Click on Conditional formatting button -> New rule

*In dialog chose last option (something like custom formula)

*Fill formula =LEN(A1)>X (X is any integer larger than 0)

*Set format for highlighting

See Excel help for better understanding.
PS: I don't have English version of the Excel, so some names can be little different.

A: My intepretation of your question is that you want to edit all the cells that have more than X number of characters.
The easiest way to do this, is in adjacent column use the LEN function to calculate the length of characters.
Then highlight both columns and click on filter (Data --> Filter).  Filter the second column to display only rows that have numbers greater than X.  For Excel 2010 this option is hidden under the Number Filters menu.
Finally, edit the first column as desired.

A: I have just done this and I think the top answer is correct but not well explained.
If you have a column (lets say "C") full of data starting at row 3, and you want all cells with more than 15 characters highlighted, select the first cell in the list and:

*

*Go to conditional formatting > new rule.

*Select "Use a formula to decide which cells to format"

*Type: =Len(C3)>15, choose a format (colour etc.)

*Hit "ok".

Then, select Cell C3 with right mouse click, drag down over the whole column of data and select "Fill Formatting".
That should do it.

A: I'm not aware of any straightforward solution, I'd do:
Calculate length of text in a new column then apply conditional formatting in the original column based on data in the new one.

A: As you want to "Select" those cells, here is an example ..
To find 6 or more character cells

*

*Press control + f (Find and replace dialog box).

*Type in Find What >>  ??????*

*Press alt + i (Find All)

*Press control + A (Select All)

*Press escape to close the dialog box

*Cells with 6 or more characters are selected.


text:
Q: Routing jQuery and Cache (M/Mumps) based html pages and React.js pages I'm working for a company right now and for their whole website they use Cache (language) to 'spit' out HTML onto the page to be rendered then JavaScript and jQuery (and CSS) is used for other things from there.
I've learned React and have been writing Components that I want to use and learned react-router to do my client side routing for me.
I don't know how to integrate the routing part of the webpage (the code essentially) that has been already created with Cache and JavaScript with the new React pages and react-router
The company has no routing whatsoever right now. It is a bunch of iframes like a tree type structure with  links so I really need to get it converted to a routing sort of setup.
Sorry It's so long, but now is my question:
Would I use a Node.js webserver and Express.js for the routing for the already build Cache/JavaScrip pages and then once I get that taken care of start using react-router from there to take care of all the new React Components?
Any help is appreciated

A: Take a look at EWD 3:
https://community.intersystems.com/post/announcing-ewd-3-integrating-javascript-nodejs-and-cache-communities
Also look for the postings in this forum on EWD 3 and React.js (and React Native):
https://groups.google.com/forum/#!forum/enterprise-web-developer-community


text:
Q: PHPOffice Word generator problem when opening file Whenever I try to download a file generated by PHPWord, this error pops up

A: You can download source from here - "https://github.com/PHPOffice/PHPWord" or also prefar this one 'https://buildmedia.readthedocs.org/media/pdf/phpword/latest/phpword.pdf'
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpword, 'Word2007');
$filename = 'helloWorld'.date("h:i:s").'.docx';
$objWriter->save($filename);

May be issue with your ms word. try with online view or other way.
Try also below one
1.Add setCompatibility() before createWriter()
\PhpOffice\PhpWord\Settings::setCompatibility(false);

2. Add exit; after the save()
// XML Writer compatibility
\PhpOffice\PhpWord\Settings::setCompatibility(false);

    // Saving the document as OOXML file...
    $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
    ob_clean();
    $objWriter->save('php://output');

    exit;

Just add ob_clean(); before output it!


text:
Q: geom_vline() with date gives Error: Discrete value supplied to continuous scale After getting Error: Discrete value supplied to continuous scale messages with ggplot and geom_vline() I did some experimenting and found the following surprise.
Here's a reproducible example that starts with some data:
require(lubridate)
require(ggplot2)
df <- data.frame(
  date=dmy(c("2/6/2014", "3/6/2014", "4/6/2014", "5/6/2014")),
  value=1:4
)

Let's plot that with a vertical line through "3/6/2014":
ggplot(data=df, aes(x=date, y=value)) +
  geom_line() +
  geom_vline(xintercept = as.numeric(dmy("3/6/2014")), linetype=4)

However, if we change the order of the geoms:
ggplot(data=df, aes(x=date, y=value)) +
  geom_vline(xintercept = as.numeric(dmy("3/6/2014")), linetype=4) +
  geom_line()

the following error message is produced:
Error: Discrete value supplied to continuous scale

A: Just convert date to Date class and add scale_x_date(), like this:
df$date <- as.Date(df$date)

ggplot(data=df, aes(x=date, y=value)) + geom_line() +
geom_vline(xintercept = as.numeric(as.Date(dmy("3/6/2014"))), linetype=4) +
scale_x_date()


text:
Q: How to find axes by YLabel string? I am creating a figure with multiple subplots and saving it to a file. like this:
fig = figure;
ax1 = subplot(2, 1, 1);
ax2 = subplot(2, 1, 2);
ylabel(ax1, 'First');
ylabel(ax2, 'Second');
savefig('myfigure.fig')

Later, I want to copy one of the subplots to a new figure without re-running the code that creates the figure. My current approach is to load the saved figure, locate the axes I want to copy by its YLabel, and then copying it to a new figure:
newfig = figure;
oldfig = openfig('myfigure.fig');
ylabel_obj = findobj(oldfig, 'String', 'First');  % This is not givng me what I expect
old_axes_obj = ylabel_obj.Parent;
new_axes_obj = copyobj(old_axes_obj, newfig);

The problem is that findobj above is not finding the YLabel. It just returns a 0x0 empty GraphicsPlaceholder array. Why isn't findobj finding my YLabel? Is there a better way to find the axes I want?

A: The handle visibility for the label text object is turned off, so it will not show up in the Children property of its parent axes, and therefore won't be found when using findobj. You can instead use findall to get around this limitation:
ylabel_obj = findall(oldfig, 'String', 'First');

Alternatively, you can set the root ShowHiddenHandles property to 'on' to list all object handles regardless of their HandleVisibility property setting, making findobj and findall equivalent.


text:
Q: Building a Rest Server I've learned how to send and handle Rest API requests, so am reasonably comfortable with how an outside user would submit requests to an API through methods such as opening a connection to the API, setting a request method and processing returned messages.
However the time has come to create my own Rest Web Service, and I'm a bit stuck as I'm not entirely familiar with just how the server will handle the communication.
I can set up a connection just fine to allow for communication, but I'm not particularly comfortable with the specifics of a connection.
Below is the method where I initialise the server, which will then wait until something connects and have a brief conversation until the client disconnects.
    public void Initialise(){
        try {
            ServerSocket s = new ServerSocket(21); //TODO: Change port?
            while(true){
                Socket incoming = s.accept();
                Runnable r = new ConnectionManager(incoming);
                Thread t = new Thread(r);
                t.start();
            }
        }
        catch(IOException e){
        e.printStackTrace();
        }
}

And the class handling the connection.
public class ConnectionManager implements Runnable{
private Socket incoming;

public ConnectionManager(Socket i){
    this.incoming = i;
}

@Override
public void run() {
    try{
        try{
            //Initialise IOStreams
            InputStream inStream = incoming.getInputStream();
            OutputStream outStream = incoming.getOutputStream();

            Scanner in = new Scanner(inStream);
            PrintWriter out = new PrintWriter(outStream, true);

            out.println("TODO: Change this message. Press Q to quit.");

            boolean done = false;
            while (!done && in.hasNextLine()){
                String line = in.nextLine();
                out.println("Echo: " +line);
                if (line.trim().equals("Q")){
                    done = true;
                }
            }
        }
        finally{
            incoming.close();
        }
    }
    catch (IOException e){
        e.printStackTrace();
    }
}

}
What I'm not sure of how to do, is how I start building an application that listens for Rest requests, and then processes them accordingly. I feel confident that upon examining the connection, I'd be able to engineer functionality to process the API request, however I do not know how to view the specifics of a Rest request sent by a user.
For example, if a user were to send a request, such as
GET exampleAPI/endpoint?params

How do I examine the request, and then subsequently process it accordingly?
For example, on the client side when you initiate the request, an approach such as the use of HttpURLConnection would allow you to follow the process of
HttpURLConnection c = (HttpURLConnection) targetURL.openConnection();
c.setRequestMethod("GET");

Which would allow you to submit a Get request to the target URI.
Looking through the Java Documentation for Socket, I don't quite know how I can view incoming requests and active connections.
Am I missing something, or just doing things completely wrong?

A: As I mentioned in my comments, you can use Jersey/Spring/etc.. for this rather than you rewriting the logic for the whole server and handling multiple threads, etc..
Also, you should know that there is a JDK API called JAX-RS (specification plus implementation) for the same. you can look here
You can look here for Spring REST Controller or here for Jersey.
I recommend you go through JDK JAX-RS API first, then you may have a look at Spring and Jersey.
There are other vendors implementing JAX-RS, which you may be interested in, you can look here for comparison for JAX-RS implementations.
P.S.: You should also know that Spring does not compliant to JAX-RS API, rather they have got their own API.


text:
Q: Take the length of a string implicitly in templates Ok, suppose I have this magic template that takes a char array and turns it into a template parameter list.  For example: "thing" is translated to list<'t','h','i','n','g'>:
template<const char*, size_t>
ArrayToList;

You use it like this:
constexpr char string[] = "this is a test";
typedef ArrayToList<string,14> list;

Is there any way to somehow detect the string length implicitly so that all I have to do is:
typedef ArrayToList<string> list;

A: Unfortunately, it can't be done:
You would like to have a non-type template parameter (the string).  Syntactically speaking, the only way to specify a non-type template parameter is to declare its type, however, either the type depends on the length of the string itself and you need two template parameters (length and string), or if you convert the string to const char *, the length of the string is lost in the parameter.
There are proposals to allow the capture of non-type template parameters whose type itself requires a template parameter to prevent forcing the syntax of those extra template arguments, like in your case.
I had the same kind of problem trying to capture pointers to members, it is necessary to also say what is the aggregate.
One recommendation:  If you revert the order of the arguments to ArrayToList, I think you can simplify the code by capturing the non-type parameter with its length, as here:
template<char...> struct list {};

// just a declaration
template<char, typename> struct add_to_list;

// specializes for the case of a list of chars, to insert v
template<char v, char... pack> struct add_to_list<v, list<pack...>> {
  using type = list<v, pack...>;
};

// captures str[length - rindex] into the head of the list
template<unsigned rindex, unsigned length, const char str[length]>
  struct to_list {
    using type = typename add_to_list<
      str[length - rindex],
      typename to_list<rindex - 1, length, str>::type
    >::type;
  };

// base of the recursion
template<unsigned length, const char str[length]>
  struct to_list<1, length, str> {
    using type = list<>;
  };

template<unsigned string_length, const char str[string_length]>
  using ArrayToList =
    typename to_list<string_length, string_length, str>::type;

// now, an example
constexpr char str[] = "hello";

template<typename> struct show_type_in_error;
show_type_in_error<ArrayToList<sizeof(str), str>> error;


text:
Q: The expression contained mismatched brackets My program give me an error message: libc++abi.dylib: terminating with uncaught exception of type std::__1::regex_error: The expression contained mismatched ( and ) and I can't find how fix it. What the brackets?
#include <regex>
#include <iostream>
#include <string>
using namespace std;
using namespace regex_constants;

int main() {
  // here can be url, or hashtag or split string:
  // www.example.com or #followback or currentratesoughttogodown and output must be example or followback or currentratesoughttogodown.
  string input = "www.example.com";
  smatch m;
  regex_match ( input, m, regex ("(?<=www.|\\#)(\\w+)(?=\\.)?") );

  return 0;
}

I compile withgcc:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix

A:
C++11  uses ECMAScript's (ECMA-262) regex syntax, so it will not have look-behind (other flavors of regex that C++11 supports also doesn't have look-behind).

Lookahead ie (?=) is supported though
You can probably try (?:www\\.|\\#)(\\w+)(?=\\.)
and grab the group 1 though.Or you can Look into using Boost.Regex or Boost.Xpressive which supports lookbehind.


text:
Q: help with using etoolbox with docsvlist and listadd I am looking at etoolbox and not able to find why it gives this error. I am going over an example in the manual, which works. But when I made small change, I am getting an error.
This works:
\documentclass[10pt]{book}
\usepackage{etoolbox}
\begin{document}
\begin{enumerate}
  \renewcommand*{\do}[1]{\item #1}
  \docsvlist{{item1, 1},{item2, 2},{item3, 3}}
\end{enumerate}
\end{document}

But the above example has the list right there inline.  I wanted to first create the list outside, and then process it separately. I found the command listadd

So used it to make a list and then run the \begin{enumerate} on the list, I get an error:
\documentclass[10pt]{book}
\usepackage{etoolbox}
\begin{document}
\forcsvlist{\listadd\mylist}{ {item1, 1},{item2, 2},{item3, 3}}
\begin{enumerate}
  \renewcommand*{\do}[1]{\item #1}
  \docsvlist{\mylist}
\end{enumerate}
\end{document}

Error is
    Command \end{enumerate} invalid in math mode. \end{enumerate}

Here is the example I was trying

Question is: How can one create a list using listadd and process it separately using \docsvlist{\mylist} ?

A: You have to use \dolistloop to loop over the element of \mylist, not \docsvlist.  After you create it, \mylist is an internal list and no longer a comma separated list. The manual specifies that

These lists use a special character as internal list separator.

and footnote 3 specifies:

The character | with category code 3. Note that you may not typeset a list by saying \listname. Use \show instead to inspect the list.


text:
Q: How to Create dynamic query in mysql I am developing an Oracle ADF web application using jDeveloper. For that am using

*

*jDeveloper

*MySql database

*Integrated WebLogic (which came with jDeveloper)

So am trying to Create a Query-only Business Service Based on Parameters. For this I need to create a query which will take values at run time.
I am following a tutorial in that they gave(because tutorial followed oracle) oracle equivalent query
select first_name,last_name from employees where email=:p_mail

But I need mysql query equivalent to the above (because I am following MySql DB).

A: Same as Oracle your query will be :
$show_list = $bdd->prepare("SELECT first_name, last_name FROM employees WHERE email = :p_mail");
$show_list->execute(Array(':p_mail' => $user_email));
$show_list->fetchAll();


text:
Q: Method is not being added to Prototype I have js file which I am using to learn javascript. However when I run concatAll, it says :
Uncaught TypeError: movieLists.map(...).concatAll is not a function

Js File:
console.log(tryFun());

Array.prototype.concatAll = function() {
    var results = [];
    this.forEach(function(subArray) {
        results.push(subArray);
    });

    return results;
};

function tryFun() {
    var movieLists = [
        {
            name: "New Releases",
            videos: [
                {
                    "id": 70111470,
                    "title": "Die Hard",
                    "boxart": "http://cdn-0.nflximg.com/images/2891/DieHard.jpg",
                    "uri": "http://api.netflix.com/catalog/titles/movies/70111470",
                    "rating": 4.0,
                    "bookmark": []
                },
                {
                    "id": 654356453,
                    "title": "Bad Boys",
                    "boxart": "http://cdn-0.nflximg.com/images/2891/BadBoys.jpg",
                    "uri": "http://api.netflix.com/catalog/titles/movies/70111470",
                    "rating": 5.0,
                    "bookmark": [{ id: 432534, time: 65876586 }]
                }
            ]
        },
        {
            name: "Dramas",
            videos: [
                {
                    "id": 65432445,
                    "title": "The Chamber",
                    "boxart": "http://cdn-0.nflximg.com/images/2891/TheChamber.jpg",
                    "uri": "http://api.netflix.com/catalog/titles/movies/70111470",
                    "rating": 4.0,
                    "bookmark": []
                },
                {
                    "id": 675465,
                    "title": "Fracture",
                    "boxart": "http://cdn-0.nflximg.com/images/2891/Fracture.jpg",
                    "uri": "http://api.netflix.com/catalog/titles/movies/70111470",
                    "rating": 5.0,
                    "bookmark": [{ id: 432534, time: 65876586 }]
                }
            ]
        }
    ];

return movieLists.map(movieList=>
        movieList.videos.map(video=>video.id))
.concatAll();
}

Looks like I am missing some trick here.Thanks for looking into this.Should Javascript not add the function on its prototype which is defined at the beginning of the file?

A: You're calling tryFun before concatAll has been added. Add the method to the prototype before calling tryFun:

Array.prototype.concatAll = function() {
    var results = [];
    this.forEach(function(subArray) {
        results.push(subArray);
    });

    return results;
};

console.log(tryFun());

function tryFun() {
    var movieLists = [
        {
            name: "New Releases",
            videos: [
                {
                    "id": 70111470,
                    "title": "Die Hard",
                    "boxart": "http://cdn-0.nflximg.com/images/2891/DieHard.jpg",
                    "uri": "http://api.netflix.com/catalog/titles/movies/70111470",
                    "rating": 4.0,
                    "bookmark": []
                },
                {
                    "id": 654356453,
                    "title": "Bad Boys",
                    "boxart": "http://cdn-0.nflximg.com/images/2891/BadBoys.jpg",
                    "uri": "http://api.netflix.com/catalog/titles/movies/70111470",
                    "rating": 5.0,
                    "bookmark": [{ id: 432534, time: 65876586 }]
                }
            ]
        },
        {
            name: "Dramas",
            videos: [
                {
                    "id": 65432445,
                    "title": "The Chamber",
                    "boxart": "http://cdn-0.nflximg.com/images/2891/TheChamber.jpg",
                    "uri": "http://api.netflix.com/catalog/titles/movies/70111470",
                    "rating": 4.0,
                    "bookmark": []
                },
                {
                    "id": 675465,
                    "title": "Fracture",
                    "boxart": "http://cdn-0.nflximg.com/images/2891/Fracture.jpg",
                    "uri": "http://api.netflix.com/catalog/titles/movies/70111470",
                    "rating": 5.0,
                    "bookmark": [{ id: 432534, time: 65876586 }]
                }
            ]
        }
    ];

return movieLists.map(movieList=>
        movieList.videos.map(video=>video.id))
.concatAll();
}

But mutating the built-in objects is very bad practice - it would be better to call a standalone function, or use your own wrapper.

A: Ohh got it ! Its program flow, concatAll was never added.Just moving the call helps:
Array.prototype.concatAll = function() {
    var results = [];
    this.forEach(function(subArray) {
        results.push(subArray);
    });

    return results;
};

console.log(tryFun());

A: Generally related to what you're trying to implement, you can pretty easily get by without a .concatAll() function, since .concat() is variadic and will flatten Arrays automatically.
So with "spread syntax", you can do this:
return [].concat(...movieLists.map(
    movieList => movieList.videos.map(video => video.id))
);

Here's a live demo:

console.log(tryFun());

function tryFun() {
  var movieLists = [{
      name: "New Releases",
      videos: [{
          "id": 70111470,
          "title": "Die Hard",
          "boxart": "http://cdn-0.nflximg.com/images/2891/DieHard.jpg",
          "uri": "http://api.netflix.com/catalog/titles/movies/70111470",
          "rating": 4.0,
          "bookmark": []
        },
        {
          "id": 654356453,
          "title": "Bad Boys",
          "boxart": "http://cdn-0.nflximg.com/images/2891/BadBoys.jpg",
          "uri": "http://api.netflix.com/catalog/titles/movies/70111470",
          "rating": 5.0,
          "bookmark": [{
            id: 432534,
            time: 65876586
          }]
        }
      ]
    },
    {
      name: "Dramas",
      videos: [{
          "id": 65432445,
          "title": "The Chamber",
          "boxart": "http://cdn-0.nflximg.com/images/2891/TheChamber.jpg",
          "uri": "http://api.netflix.com/catalog/titles/movies/70111470",
          "rating": 4.0,
          "bookmark": []
        },
        {
          "id": 675465,
          "title": "Fracture",
          "boxart": "http://cdn-0.nflximg.com/images/2891/Fracture.jpg",
          "uri": "http://api.netflix.com/catalog/titles/movies/70111470",
          "rating": 5.0,
          "bookmark": [{
            id: 432534,
            time: 65876586
          }]
        }
      ]
    }
  ];

  return [].concat(...movieLists.map(
      movieList => movieList.videos.map(video => video.id))
  );
}

Or you could use .reduce() and put the .concat() in the callback.
  return movieLists.reduce(
      (res, movieList) => res.concat(...movieList.videos.map(video => video.id))
  , []);

A: Even more simple try below code.
Array.prototype.concatAll = function() {
    var results = [];
    this.forEach(function(subArray) {
        results.push.apply(results, subArray);
    });

    return results;
};
console.log(tryFun());


text:
Q: fullcalendar event sorting not working for me Using fullcalendar v3.8.2. I'm struggling with getting my events to sort. I've read (and re-read) the stackoverflow answer here. I'm using the evenOrder and have tried various options but always getting results like screenshot below. These are "all day" events. This is a boat launch calendar and I always want to show "put ins" before "take outs".
Cleary the events are not ordered by title, nor are they ordered by any of the eventOrder options that I've tried.

Currently my code looks like:
  $calendar.fullCalendar({
    eventOrder: function(e) {
      return e.miscProps.sort;
    },

With data that looks like:
{start: "2019-01-02", title: "30 put ins", className: "putin", sort: "0"}
{start: "2019-01-16", title: "1 take outs", className: "takeout", sort: "1"}

A "putin" event is always a sort:0 and a "takout" is always sort:1 The eventOrder: function() is being called and correctly returning either 0 or 1.
Thank you.

A: If you supply a function for eventOrder then, as the eventOrder docs you linked to state, it accepts two input parameters (the two events which need to be compared and sorted), and you are also told that it's supposed to return either -1, 0 or 1 as the result of the comparison - as an indication of which of the two input items should be placed first.
If the first event should be first in the list, then return -1. If the opposite, then return 1, if they're equal then return 0. The logic within it should be very similar to the sample code provided in the docs for the native JS array sort function - see here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Description
Your logic currently will just return the "sort" value for whichever event happens to be first in the un-sorted list. This is not doing any kind of comparison at all, and it also doesn't supply the full range of possible values the calling code expects (i.e. you only ever return 0 or 1, never -1 - but even if you did it wouldn't necessarily make sense).
A working comparison function would be:
eventOrder: function(a, b) {
  var result = 0;
  if (a.miscProps.sort < b.miscProps.sort) result = -1; //event a should be listed first
  else if (a.miscProps.sort > b.miscProps.sort) result = 1; //event b should be listed first
  return result;
},

Demo: http://jsfiddle.net/c9upo8w2/1/
But...actually you don't need to write a custom function for this as far as I can see, because you're ordering very straightforwardly on the ascending sequence of numbers in the "sort" field alone. There's no complex calculation to be done. Specifying the field on which to sort will do the job perfectly nicely - fullCalendar will do the rest. Again the documentation you linked you states that if you supply the name of a field as the "eventOrder" option then it will sort (otherwise equal) events in ascending order by that field. So:
eventOrder: "sort"

is the only thing you need to write.
Demo: http://jsfiddle.net/c9upo8w2/

P.S. Just as an aside, the sample data you've given above isn't much use because they're on different days anyway, so the custom sort won't apply. Obviously in this case I was easily able to change it in order to create the demos, but it would make more sense to supply an example which actually reproduces the issue :-)


text:
Q: Is there a way to get the Node/Element/HTMLElement from JSX before it's mounted? Is it possible to get the element object from JSX before it's mounted?
In the following code for example:
import React from 'react';
import ReactDOM from 'react-dom';
...
const container =
My simple div
;
const element = container.??? // Get Node/Element/HTMLElement from 'container'.

I know there is a ref attribute but this method doesn't seem to work. Also, I find it a bit cumbersome compared to something that's inline.
let element = null;
const container =
 {element = containerElement;}} />;

This probably doesn't work because the component isn't mounted yet (which is the use-case I'm looking for).

A: The real DOM element appears when the virtual React element is rendered, so you need to render container first and then use either ref:

const container =
 element = _element}>My simple div
;
let element;

ReactDOM.render(container, document.body);
alert(element);

Or a DOM query:

const container =
My simple div
;

ReactDOM.render(container, document.body);
const element = document.querySelector('#something');
alert(element);


text:
Q: Migration from wxWidgets 2.8.12 to wxWidgets 3.0.2 - features.h I have recently migrated my project from wxWidgets 2.8.12 to 3.0.2. I am using Eclipse as my IDE under Windows 7 OS. The GCC version is 4.6.2.
I have successfully compiled debug and release versions of wxWidgets 3.0.2 and integrated to Eclipse. I compiled my project and I got the error in features.h file saying missing ")". When I read the purpose of features.h, to my understanding it was meant for compatibility with previous versions of wxWidgets so I have deleted everything in features.h and then compiled my project and now it compiles with no errors and everything in my project functions fine when I run the binary.
By the way, I had the same problem with TDM compilers as well. I have also rebuild the index of Eclipse in case there were remnants from wxWidgets 2.8.12 which could confuse the compiler but the problem with features.h remained there until I deleted everything in features.h.
My question is: By deleting the features.h, am I going to run into a problem in the future or will wxWidgets function normally?
Best regards,

A: Don't do that.
Find out where the real problem lies. There are a lot of people that successfully build wxW with gcc.
The best and easiest test is to build wxW, then build 'minimal' sample. Any error when doing that?
features.h is there for a purpose; by deleting its contents, the symbols there may become wrongly [un-]defined. Further more, if you have deleted contents of features.h after you had compiled wxW but before compiling your project, then that is a completely wrong build.


text:
Q: Vuejs how to pass data prop from jquery I am using Laravel, vue and js in my project
I wanted to get the data passed in my class vueAddReview from
<div id="app-vue">
    <add-review class="vueAddReview"></add-review>
</div>

I am setting a data in the vueAddReview class by using jQuery
    $(document).on('click', '.writeReview', function(e) {
    e.preventDefault();

    var addReviewModal = $('.addReviewModal');
    addReviewModal.modal('show');

    var listingId = $('.writeReview').data('listing-id');

    $('.vueAddReview').data('listing-id', listingId);
});

My problem here is I don't know how to pass $('.vueAddReview').data('listing-id') into vue as a prop

A: I am not sure it work, you can initialize data in your root Vue component ( here, app-vue ) and pass it as a props
const app-vue = new Vue({
    el: '#app-vue',
    data: () => {
        foobar: $('.vueAddReview').data('listing-id')
    }
});

And then you can pass it as a props to his child component
<add-review :listing-id="foobar"></add-review>

( IMHO it is a bit awkward to init a Vue component with a DOM element data. The DOM should not be a source of truth for your model. Is there a way for you to not use a jQuery attribute to init your Vue Component ? )


text:
Q: Updated Record Not Showing Up in a Table After a Trigger Update I created a table, payment_detail, based on two other tables (customer and payment) as follows:
CREATE TABLE IF NOT EXISTS payment_detail AS
SELECT customer.customer_id,
   customer.first_name || ' ' || customer.last_name AS customer_name,
   to_char(payment_date, 'Mon YYYY') AS month_yr,
   SUM(payment.amount) AS total_amount,
   COUNT(payment.amount) AS payments_count
FROM payment
INNER JOIN customer ON payment.customer_id = customer.customer_id
GROUP BY 1,3
ORDER BY
   MAX(date_trunc('year', payment_date)) DESC,
   MAX(date_trunc('month', payment_date)) DESC,
   MAX(amount) DESC;

Goal: Create a trigger function to update the payment_detail table upon an UPDATE and an INSERT operation.
Trigger for the UPDATE operation:
CREATE OR REPLACE FUNCTION update_payment_detail()
   RETURNS TRIGGER LANGUAGE PLPGSQL AS
$$
BEGIN
   UPDATE payment_detail SET
   customer_id = NEW.customer_id,
   customer_name = first_name || ' ' || last_name,
   month_yr = to_char(NEW.payment_date, 'Mon YYYY'),
FROM
   customer
WHERE
   customer.customer_id = NEW.customer_id AND
   payment_detail.customer_id = OLD.customer_id;
RETURN NULL;
END;
$$

CREATE TRIGGER update_payment_detail
   AFTER UPDATE
   ON payment
   FOR EACH ROW
   EXECUTE PROCEDURE update_payment_detail();

The problem with the above Trigger is that, although it updates the payment table successfully, the updated record no longer shows up in the payment_detail table.
For instance, if I perform an UPDATE as follows:
UPDATE payment
SET amount = 9.00
WHERE customer_id = 60 AND payment_id = 32034;

The payment_detail table no longer shows the record for 'Mildred Bailey' as pictured above, in the first row of the table. But if I DROP TABLE payment_detail; and re-run the table creation, then the record appears.
How would I prevent this from happening? I think the answer is rooted in the condition of my WHERE clause, but I could use some guidance on this if that's the case.
Next, is the trigger for the INSERT operation:
CREATE OR REPLACE FUNCTION insert_payment_detail()
   RETURNS TRIGGER LANGUAGE PLPGSQL AS
$$
BEGIN
   INSERT INTO payment_detail (customer_id, month_yr, total_amount, payments_count)
   SELECT
      NEW.customer_id,
      to_char(NEW.payment_date, 'Mon YYYY') AS month_yr,
      SUM(NEW.amount) AS total_amount,
      COUNT(NEW.amount) AS payments_count
   FROM customer, payment
   WHERE customer.customer_id = NEW.customer_id AND
   to_chair(payment.payment_date, 'Mon YYYY') = to_char(NEW.payment_date, 'Mon YYYY');
RETURN NULL;
END;
$$

CREATE TRIGGER insert_payment_detail
   AFTER INSERT ON payment
   FOR EACH ROW EXECUTE PROCEDURE insert_payment_detail();

If I apply an INSERT as follows:
INSERT INTO payment (customer_id staff_id, rental_id, amount, payment_date)
VALUES (60, 2, 14741, 4.00, now());

I verify that the payment table holds the new record; however when I run SELECT * FROM payment_detail, it does not show the new record. So in both my UPDATE and INSERT trigger functions, the targeted table just omits the updated/inserted record, until I delete and recreate the table.
What am I doing wrong?

A: Trigger(s) for UPDATE
(a) You may have an error in your trigger function update_payment_detail(), try to replace
customer_name = first_name || ' ' || last_name

by
customer_name = NEW.first_name || ' ' || NEW.last_name

(b) The columns of the table payment_detail are copied from both tables customer and payment, so you probably need 2 different trigger functions for update :
CREATE OR REPLACE FUNCTION update_payment_detail()
   RETURNS TRIGGER LANGUAGE PLPGSQL AS
$$
BEGIN
   UPDATE payment_detail SET
--   customer_id = NEW.customer_id, -- NEW.customer_id is not possible here if it is a column of the table customer; NEW only refers to the columns of the table payment called by the trigger !
--   customer_name = NEW.first_name || ' ' || NEW.last_name, -- idem as above if these columns come from the table customer
   month_yr = to_char(NEW.payment_date, 'Mon YYYY')
--FROM
--   customer
WHERE
--   customer.customer_id = NEW.customer_id AND
   payment_detail.customer_id = OLD.customer_id ;
RETURN NULL;
END;
$$

CREATE TRIGGER update_payment_detail
   AFTER UPDATE
   ON payment
   FOR EACH ROW
   EXECUTE PROCEDURE update_payment_detail();

CREATE OR REPLACE FUNCTION update_customer_detail()
   RETURNS TRIGGER LANGUAGE PLPGSQL AS
$$
BEGIN
   UPDATE payment_detail SET
   customer_id = NEW.customer_id,
   customer_name = NEW.first_name || ' ' || NEW.last_name
--   month_yr = to_char(NEW.payment_date, 'Mon YYYY') -- NEW.payment_date is not possible here if it is a column of the table payment; NEW only refers to the columns of the table customer called by the trigger !
--FROM
--   customer
WHERE
   customer.customer_id = OLD.customer_id
--   payment_detail.customer_id = OLD.customer_id ;
RETURN NULL;
END;
$$

CREATE TRIGGER update_customer_detail
   AFTER UPDATE
   ON customer
   FOR EACH ROW
   EXECUTE PROCEDURE update_customer_detail();

Trigger for INSERT
(c) The reference to the table customer sounds like useless in this trigger function. You can try this :
CREATE OR REPLACE FUNCTION insert_payment_detail()
   RETURNS TRIGGER LANGUAGE PLPGSQL AS
$$
BEGIN
   INSERT INTO payment_detail (customer_id, month_yr, total_amount, payments_count)
   SELECT
      NEW.customer_id,
      to_char(NEW.payment_date, 'Mon YYYY'),
      SUM(amount),
      COUNT(*)
   FROM payment
   WHERE customer_id = NEW.customer_id AND
   to_char(payment_date, 'Mon YYYY') = to_char(NEW.payment_date, 'Mon YYYY');
RETURN NULL;
END;
$$

CREATE TRIGGER insert_payment_detail
   AFTER INSERT ON payment
   FOR EACH ROW EXECUTE PROCEDURE insert_payment_detail();

(d) Depending on the primary key of the table payment_detail, it is possible that you may have some conflicts when inserting 2 rows in table payment with the same customer_id and the same to_char(payment_date, 'Mon YYYY') value. In order to prevent any conflict, you can add the clause ON CONFLICT DO UPDATE ...
(e) Finally, the table payment_detail could be replaced by a view as proposed by @Adrian Klaver


text:
Q: Determine whether onPause() was fired by user navigation or by my activity launching another one How can I determine whether onPause() was fired because my activity launched a new one (e.g. a photo picker intent) or because the user navigated away from my activity (e.g. by pressing home)?

A: A simple solution is to have a state variable in the Activity with some fixed values:
final static int RUNNING = 0;
final static int CALLED_SOMETHING = 1;

int state = RUNNING:

Then, whenever you launch an activity:
state = CALLED_SOMETHING;

And when it returns:
state = RUNNING;

And in your onPause():
switch(state) {
     case RUNNING:
         // Do the stuff if Home etc were pressed
         break;
     case CALLED_SOMETHING:
         // Do the other stuff
         break;
     }

Obviously, you can extend this to further scenarios. You may also wish to catch onBackPressed() to make sure you handle the situation with as much understanding as possible.


text:
Q: Cannot change (add) an edit description after making the edit This seems like a bug to me, but it may be that I misunderstand the feature.
I recently made an edit to an answer (it was in fact a rollback that I deemed worthy), and as per usual I forgot to give a reason for my edit. Normally this wouldn't bother me as any edits I make are usually obvious as to why they have been made, but in this case (a rollback) I felt it important to give my reasons why.
So I clicked the "Edit" link under my rollback - which by the way had a current auto-generated description like "rollback to revision 2" - I added in my "Edit Summary" and then clicked "Save Edits". It submitted fine, but the description was not changed. I tried this a second time with the same results.
Is this the expected behavior for this action? In which case I assume it's because there is no change to the code/title/tags?
If it is working "as designed", then I would suggest that the user is notified with a warning that this edit will not have any effect, giving the reasons why.

I think the best way to replicate this issue/query is as follows:

*

*Go to the edit history for a post you have previously edited

*Click the "edit" link under the heading of your edit

*Change (or add) an "Edit Summary"

*Click "Save Edits"

It should appear successful (it submits fine), however no change will have been made


text:
Q: Child observable having no effect when called using tap operator I'm relatively new to RxJS so I'm trying to get a better grasp on how Observables work when they're chained together using operators. I can manage to get them working properly by chaining them using subscribe, but that's bad practice.
The code below is being used in an Angular application that involves displaying a form to the user that allows them to view and save settings for the application. The form first makes a GET request to an API to receive the saved settings represented in JSON format. Once this is returned the settings are displayed to the user. The user can then modify the settings and save them when happy.
The issue is that for some reason the final observable, the one inside the setSettings function does not seem to be working correctly. From my console logs I can see that the function is being called by the observable inside buildSettingsForm, however the commands inside the tap operator seem to be doing nothing.
The call to console.log(val) is never executed, but I know that the call to this.getSettingsFromSerial$ is definitely being called as I can see the logs for that. Therefore it seems like when the call to tap is executed something happens and none of the inner commands are actually being executed. This would make sense as the calls to this.addRange inside the for loop aren't being called either, which means my form is being left empty.
initSettings(){
    if(this.savedSettingsState !== undefined)
    {
        if(this.unsavedSettingsExist())
        {
          console.log("Unsaved settings exist");
          this.openUnsavedSettingsModal();
          return;
        }
    }

    this.getOrganisations$().pipe(
        exhaustMap((res: AdminOrganisation[]) => {
          this.organisations = res;
          this.currentOrganisationSerial = this.organisations[0].serialRef;
          this.currentOrganisationName = this.organisations[0].serialName;
          return this.buildSettingsForm(this.currentOrganisationSerial);
        })
    ).subscribe();
}

buildSettingsForm(serial: string) {
    this.ipRangeFormGroup = this.formBuilder.group(
        {
          ipRanges: this.formBuilder.array([])
        }
    );

    this.numArrayElements = this.ipRangeFormArray.length;

    return merge(
        this.ipRangeFormArray.valueChanges.pipe(
            tap(_ => {
              this.numArrayElements = this.ipRangeFormArray.length;
              console.log("numArrayElements: " + this.numArrayElements)
            })
        ),
        this.setSettings(serial)
    );
}

setSettings(serial: string) {
    console.log("setSettings");
    return this.getSettingsFromSerial$(serial).pipe(
        tap(val => {
          console.log("val");
          console.log(val);
          this.savedSettingsState = val;
          this.ipRestrictionEnabled = val.ipRestrictionSettings.ipRestrictionEnabled;
          for (const i of val.ipRestrictionSettings.ipRanges) {
            this.addRange(i.startRange, i.endRange, i.label);
          }
          this.displayForm = true;
        })
    );
  }

A: I worked up a blitz which shows that there isn't any issue in the code here:
https://stackblitz.com/edit/angular-v9x1js?file=src/app/app.component.ts
the issue is somewhere else in your pipeline causing an unhandled or swallowed exception, probably in whatever getSettingsFromSerial$ is doing.  adding an error handler to your subscribe and logging it might help figure out what is going on. I've also seen similar mysterious issues when someone has an interceptor swallowing all their http errors that they forgot about.


text:
Q: How can I map data to lower dimension? I am trying to learn data in higher space into lower space. To have a clue, I'd like to know how to transform the data in the image below into a lower dimension preserving the structure. Hope to hear some explanations and what should I study to learn mapping data to lower dimension?

A: You are looking for Multidimensional Scaling (MDS):

An MDS algorithm aims to place each object in N-dimensional space such that the between-object distances are preserved as well as possible. Each object is then assigned coordinates in each of the N dimensions. The number of dimensions of an MDS plot N can exceed 2 and is specified a priori. Choosing N=2 optimizes the object locations for a two-dimensional scatterplot.

There are many algorithms and libraries for many common software packages. This thread discusses MDS and PCA. Or you could browse through the multidimensional-scaling tag.

A: There are several ways you can project data into lower dimension. Few of them are:

*

*Perform Principal Component Analysis—take only the components where the variance is significant. It might not preserve the topology of the original space means points close to each other in the original space might not be close to each other in the reduced dimension space after PCA.

*Self organizing maps—This is another unsupervised method of training a grid of neurons in a lower dimensional lattice (preferably two dimension) so that each point maps to one of the neurons in the lower dimensional lattice. The good thing about self organizing maps is the topology of the original space is almost preserved in the lower dimensional space i.e points close to each other in the original space remains close to each other in the reduced lower dimensional lattice.


text:
Q: Create customized auto increment ID in SharePoint online I have a list in SharePoint where I need to have a auto incremented customized ID when an item is created. I know SharePoint list already has a default ID but I need my ID to be customized with a code.
Example: my ID should display as AMS-0001
I have a solution but it gives the same ID every time a new item is created.
Any idea on how to do this?

A: *

*Create a new column, such as : Increment Number in issue list with Number type. Make this column hidden in a view.

*Create another column, such as : Issue No. in issue list with Formula type and add the following formula = "AMS-00" & [Increment Number]. This Column will show the increment items' numbers in the list.

*Open SharePoint designer, create new list workflow (for issues list).

*Add a workflow action: "Update list Item" >> Current Item >> Add >> Set this field to your Target field (Increment Number), set value from Current Item:ID field (as below):

Reference:
How to Create an Auto-Incrementing Number Field in a SharePoint List


text:
Q: lines can be neither intersecting nor parallel. Why is that? There are two chords on the circle, $CD$ and $EF$. $CD$ is the diameter. $CD$ is not parallel to $EF$. When the radius of this circle tends to infinity, $CD$ and $EF$ tend to infinity, and $CD$ and $EF$ are straight lines (because their length tends to infinity). So lines can be neither intersecting nor parallel. Why is that?

A: Before you "reach infinity", they are never lines. They are only ever line segments. And there is nothing in Euclidean plane geometry that says non-parallel segments must intersect.
After you have passed to infinity, they will be lines, and at this stage they will either be parallel, or they will intersect.
There is no contradiction here. Some things change when you go from finite, bounded to infinite, unbounded, and some things are kept unchanged. Picking and choosing what gets kept and what gets changed so that you reach a seeming contradiction is not how it works.

A: No, $CD$ and $EF$ are line segments, not straight lines.  It is possible, depending on how you take the limit, that their limits are straight lines.  In that case those limiting straight lines are either parallel or intersect.

A: Assume that the stretching is standard euclidean scaling from the center $(0,0)$ by a factor $t\in[1,\infty[\>$. If we do this right in your figure then the line $C_t\vee D_t=C\vee D$ for all $t\geq1$, hence  remains the $x$-axis in the limit. But the line $E\vee F$ has no limiting line in the plane: All points $(u,v)$  of the initial line $E_1\vee F_1$ wander to infinity under our continuous stretching. Note that the line $E_1\vee F_1$ has a positive distance $\rho_1>0$ from $(0,0)$ at the start, and the distance of $E_t\vee F_t$ from $(0,0)$ will be $\rho_t=t\rho\to\infty$ when $t\to\infty$.

A: Lines in a plane must intersect or be parallel to one another. If neither are true, I would argue that we are not actually talking about lines. Suppose we change the figure to put point E on the origin, and fix it there. We can then enlarge the circle, moving toward the limit of infinite radius, while keeping E fixed on the origin. In this case, in the limit of infinite radius, CD becomes a line, but EF becomes a ray, not a line (because E is a fixed, immovable point). CD and EF are not parallel and do not intersect, even though they both have infinite length, because they are not both lines.
Under this construction, we remove the paradox entirely - we have a circle whose radius approaches infinity, and two chords whose length approach infinity. The chords are neither parallel nor intersecting, but because they are not both lines, we have no contradiction.
Admittedly, I'm not entirely sure how to reconcile this with the case of the center at the origin, in which case both chords do have infinite length and no fixed endpoint. I wonder if those conditions are indeed sufficient to define a line.

A: On larger circles, since $IL$ is parallel to $EF$, $EF$ will not be parallel to $CD$ when the radius of the circle tends to be infinite.

I use large and small circles to explain that they are still not parallel as the radius of the circle tends to infinity.


text:
Q: Google Big Query, UPDATE, when matching the first row I have this query
UPDATE `TABLE 1` A
SET A.zip_code=B.postalCode
FROM `TABLE 2` B
WHERE (A.business_identifier = B.namespace AND B.postalCode is not null)

I'm gettin this error
ERROR:
UPDATE/MERGE must match at most one source row for each target row

Because in Table 2 for namespace I have duplicate values:
Can I add something to the query so it can get the postalCode from the first namespace that matches ?
UPDATE : I USED THIS CODE AND IT WORKED
UPDATE `Table1` A
SET A.zip_code=B.postalCode
FROM (
   select ID, postalCode
    from (
    select *,
          row_number() over (partition by ID order by postalCode) as row_number
    from `TABLE 2`
    ) as row
    where (row_number = 1 AND postalCode is not null)
    ) B
WHERE (A.ID = B.ID AND B.postalCode is not null);

A: Try using a sub-select in your FROM like below:
UPDATE so_test.table_1 A
SET A.zip_code=B.postalCode
FROM (
    select postalcode, namespace
    from so_test.table_2
    where postalcode is not null
    qualify rank() OVER (partition by namespace order by postalcode) =1
) B
WHERE (A.business_identifier = B.namespace AND B.postalCode is not null);

You may need/want to change how you define the 'first' record by modifying the RANK conditions.
This successfully updates with the following sample data
CREATE OR REPLACE TABLE so_test.table_1
AS
SELECT 1 as zip_code, 'a' as business_identifier UNION ALL
SELECT 2 as zip_code, 'b' as business_identifier UNION ALL
SELECT 3 as zip_code, 'c' as business_identifier
;

CREATE OR REPLACE TABLE so_test.table_2
AS
SELECT 1 as postalcode, 'a' as namespace UNION ALL
SELECT 2 as postalcode, 'a' as namespace
;


text:
Q: Pull latest record from multiple condition case expression? I'm dealing with a situation where I need to pull only one record for a patient based on a specific diagnosis. In this instance, a patient can have multiple diagnoses, which are listed as current_icd10_list, and each diagnosis is done on a visit, which can be discerned by the contact date. In this case, a patient can be diagnosed with multiple diagnoses of similar types at different times, but I only need to pull the latest one. In my example, let's say I had a patient who was diagnosed with Dx 1 first and then Dx 2 at a later date. I only want to pull the latest diagnosis, which would be Dx 2. How would I do this?
select
CONTACT_DATE,
WHEN current_icd10_list LIKE '%E10.0%'
...
OR current_icd10_list LIKE '%E14.9%'
THEN 'Dx 1'

WHEN current_icd10_list LIKE '%E10.2%'
...
OR current_icd10_list LIKE '%E14.7%'
THEN 'Dx 2'
END AS 'Dx Group'

A:
I need to pull only one record for a patient based on a specific diagnosis [...] A patient can have multiple diagnoses [...] but I only need to pull the latest one.

You would use row_number() for this. Assuming that the id of the patient is stored in column patient_id and that the date of the visit is stored in contact_date:
select *
from (
    select
        t.*,
        row_number() over(partition by patient_id order by contact_date desc) rn
    from mytable t
) x
where rn = 1

A: Would you not be able to just pull using the max date function using your criteria of the current_icd10_list? For instance:
select max(CONTACT_DATE) as max_date,
case WHEN current_icd10_list LIKE '%E10.0%'
OR current_icd10_list LIKE '%E14.9%'
THEN 'Dx 1'

WHEN current_icd10_list LIKE '%E10.2%'
OR current_icd10_list LIKE '%E14.7%'
THEN 'Dx 2'
END AS 'Dx Group'

from mytable

group by
case WHEN current_icd10_list LIKE '%E10.0%'
OR current_icd10_list LIKE '%E14.9%'
THEN 'Dx 1'

WHEN current_icd10_list LIKE '%E10.2%'
OR current_icd10_list LIKE '%E14.7%'
THEN 'Dx 2'
END
 ;

A: So I solved this by separating the patients that had a Dx in 'Dx group' and used row_number to order them by contact_date. I then union'd it back to the rest of the data.


text:
Q: Android. Gradle build error: Error parsing XML: not well-formed (invalid token) How set "<" and ">" as text in my button?
My xml:
<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=">"
        android:id="@+id/button" />

Gradle build error:
Error:(59) Error parsing XML: not well-formed (invalid token)

A: Since the file is XML, you need to correctly escape the greater-than character in your attribute value:
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text=">"
    android:id="@+id/button" />

A: Certain charactes in XML cannot be used directly. This includes i.e. &, < and > which must be replaced by corresponding entities. So instead of
android:text=">"

you must write:
android:text=">"

A: instead of using > directly use > code.
refere this doc
use this to generate codes


text:
Q: Belief in consistency of extremely large cardinals One of the most common justifications for the consistency of large cardinals is the development of a coherent inner model theory for many large cardinal axioms. While the strength of this argument can be debated (has any axiom ever been shown to be inconsistent via the attempt to develop an inner model theory?), it appears to be pretty popular, e.g. it appears in Maddy's Believing the Axioms.
However, it is my understanding that assuming Woodin's HOD Conjecture, his Universality Theorem implies that given an extendible cardinal, there exists a weak extender model that reflects essentially all of the large cardinals that are currently studied.
If inner model theory can be extended so far in a single leap, can it still be used to justify the consistency of any particular large cardinal axiom stronger than a supercompact? If not, what is the replacement?
It's also my understanding that assuming the $\Omega$ Conjecture and a proper class of Woodin cardinals, the same class of large cardinal axioms can be ordered in consistency strength by the Borel degree of the initial segment of universally Baire sets $A$ for which they establish determinacy properties of $L(A, \mathbb{R})$. Would calibrating the place of a large cardinal axiom on this hierarchy replace other arguments for consistency?

A: There is another path that can be used to justify the existence of very large cardinals.  Consider, for example, the abstract to Magidor's paper, "On the Role of Supercompact and Extendible Cardinals in Logic" (Israel Journal of Mathematics, Vol. 10, 1971, pp. 147-157)  :

It is proved that the existence of supercompact cardinals is equivalent to a certain  Lowenheim-Skolem Theorem for second order logic, whereas the existence of [an] extendible cardinal is equivalent to a certain compactness theorem for that logic.  It is also proved that a certain axiom schema related to model theory implies the existence of many extendible cardinals.

Here the theorems:

Theorem 1.  There exists a supercompact cardinal iff there is a $\mu_0$ such that for all $R({\beta})$, $\beta$$\ge$$\mu_o$there is an $\alpha$$\lt$$\beta$ such that $<$$R({\alpha})$, $\epsilon$$>$ can be elementarily embedded in  $<$$R({\beta})$, $\epsilon$$>$.  The least such $\mu_0$ is the first supercompact cardinal.
Theorem 2.  The first supercompact cardinal is the first $\mu_0$ such that for every structure $A$ = $<$$M$, $R_1$,...,$R_n$ $>$ $|$$M$$|$$\ge$$\mu_0$ and every $\Pi^{1}_1$ sentence $\varphi$, such that $A$$\vDash$$\varphi$, there exists a substructure $A^{'}$ = $<$ $M^{'}$, $R_1$$|$$M$,..., $R_n$$|$$M$$>$ of $A$ with $|$$M^{'}$$|$$\lt$$|$$M$$|$ and $A^{'}$$\vDash$$\varphi$ [this is the "Lowenheim-Skolem Theorem" Magidor refers to in his abstract--my comment].
Definition.  Logic is called $\kappa$-compact iff for every set of formulae $A$ in this logic, if every subset of $A$ of cardinality $\lt$$\kappa$ has a model, then $A$ has a model.  The $\mathrm L^{n}_{\kappa}$ logic is like the $n$-th order logic, except that we allow conjunction and disjunction of less than $\kappa$ formulae.  The usual second order logic is of course $L^{2}_{\omega}$.
Theorem 4.  $\kappa$ is extendible iff $L^{2}_{\kappa}$ is $\kappa$-compact.  $\kappa$ is the first extendible iff it is the first $\alpha$ such that second-order logic [$L^{2}_{\alpha}$--my comment] is $\alpha$-compact.
...We shall now show that a certain axiom schema is a very strong axiom of infinity, namely, it implies the existence of many supercompact cardinals.  The axiom schema is:
($V$)  If $\varphi$(x)  defines a proper class of structures in the same language, then there exist two members of the class that one can be elementary embedded in the second...This axiom schema is called Vopenka's principle.
Let $V^{'}$ be the following axiom schema:  ($V^{'}$) if the formula $\tau$(x) defines a closed unbounded set of ordinals, then there is an extendible cardinal in this class (i.e. "the class of all extendable cardinals is 'stationary' ").
Theorem 3.  ($V$) implies ($V^{'}$) but is not equivalent to it.

Note that the forward implication '$\Rightarrow$' of Theorems 1, 2,  and 4 show that if the required large cardinal exists, the logic in question will have the required property.  This suggests to me the following 'formalist' justification of the existence of large cardinals:

If you want second-order logic to have certain model-theoretic   properties, hypothesize the appropriate large cardinals.

This also suggests the following research program:

Discover what model-theoretic properties of n'th-order logic the existence of large cardinals imply (from $I0$ on down the large cardinal hierarchy), if any.

Similarly, one can hypothesize the existence of certain Lowenheim-Skolem-Tarski numbers, as V$\ddot a$$\ddot a$n$\ddot a$nen shows in his paper, "Sort Logic and Foundations of Mathematics" ("Sort Logic...is a many-sorted extension of second-order logic."):

The canonical hierarchy $\Delta_n$ ($n$$\lt$$\omega$) inside sort logic climbs up the large cardinal hierarchy by reference to Hanf-, Lowenheim-, and [Lowenheim-Skolem-Tarski]-numbers, reaching all the way up to Vopenka's Principle [pg. 185].


text:
Q: Simple, cross-browser way to get the WHOLE page width in JavaScript, not just the viewport width? I've seen lots of posts that talk about the getting width of the browser viewport, but what I want to find is essentially the width of the browser viewport if it were just wide enough to avoid a horizontal scrollbar.
I'm using the Prototype JS framework and have looked at various options using that and using pure JavaScript.  For example:

*

*$(document.body).getWidth() and document.body.clientWidth return the viewport width excluding margins.

*document.documentElement.clientWidth and window.innerWidth return the viewport width including margins.

I've tried to be sneaky too: I absolutely-positioned a known-width DIV against the right-hand edge of the page (i.e. CSS right:0) with the intention of getting its left-edge position, but that actually gets aligned with the right-edge of the viewport.
The only thing I've found that works is to use JavaScript to scroll right until it won't scroll anymore (simply using scrollBy(1000000, 0) will usually be enough, but a while loop would obviously be more reliable), then get the horizontal scroll offset and add that to the viewport width.  But I don't want to scroll the window: I want to inspect it somehow!
Any suggestions appreciated, even jQuery ones as at least then I can see how jQuery does it.

Here's a simple example showing that document.body.scrollWidth doesn't work:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

document.body.scrollWidth =

This DIV is 2000px wide including padding.

The output of this should show that the width is 2000px, since that's the width of the widest part of the page.  It doesn't.

A: what about
window.screen.width;

document.body.style.width = (window.screen.width - 15) + 'px';

window.screen.width - 15 is enough to avoid horizontal scroll-bar. 15 is  vertical scrollbar width.

A: for width:
document.body.scrollWidth

for height:
document.body.scrollHeight

EDIT: for IE you'll have to specify position:relative for the body tag

A: Browsers don't treat html and body like ordinary elements. In particular many browsers are really buggy with respect to how they treat scrollWidth etc. on the body element.
The only real solution is to wrap all your content in one huge div for the entire page and use that. Because the div is an ordinary element it isn't affected by the bugs that cause the weird behaviour for body and html.


text:
Q: Django: Proper Way to Acess data from a One to Many Relationship? I am having issues with accessing data through a django one to many relationship. After 3 painstaking days I figured out a way to display the data from the relationship by overriding the get_context_data method. I was wondering if that was the proper way to do it. This works but I could imagine that there is a better way to do this that I missed in the documentation.
Here is the code for that:
class QuestionDetailView(DetailView):
    model = Question

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['answers'] = Answer.objects.filter(firm=context['object'])
        return context

Here is the code for the models:
 class Question(models.Model):
    text = models.CharField(max_length=120, unique=True)

class Answer(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)

Here is the code in my template:
    {% extends "base.html" %}
    {% block body %}

{{ object.text }}

Answers:

        {% for answer in answers %}

 {{ answer }}

        {%empty%}

No answers

        {% endfor %}

    {% endblock %}

A: Add a related_name to your question field.
class Answer(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE, related_name="answers")

Or, just use the default that Django gives: answer_set
Then in your template, you can do:
{% for answer in object.answers.all %}

 {{ answer }}

{% empty %}

No answers

{% endfor %}

No need to override get_context_data unless you want to do something more specific with the queryset.


text:
Q: Resolve without Type information in unity Unity supports resolve based on types
T obj = container.Resolve<T>("id");
that means without knowing T, I can not resolve, I am writing some extension methods for my unity container where I want to add Resolve method which would return object type.
 object obj = container.Resolve("id");
because when registering I already know T so I can keep type in a dictionary with "ID". This is unreliable as unity can itself resolve some types(even when not registered) Is there a simpler and reliable way to do resolve using only the Id for resolving?
This is diffrent from calling generic method from reflection due to performance issues and also since the resource is already registered with unity for DI hence i want to use existing solution to keep it consistent.

A:
Now if i can resolve something by ID and return object or dynamic i can use type converters internally to convert it to expected type later. Upfront i do not know type which has to be used.

If object is your interface, you can use that, of course:
container.RegisterType<object, ObscureService>( "service" );
container.RegisterType<object, SecretPlugin>( "plugin" );

object unknown = container.Resolve<object>( "service" );
object anotherUnknown = container.Resolve<object>( "plugin" );

This has very limited (sensible) use, though. I'd say you should only use this if you act on direct request from the user and the resolved unknown is some kind of view model that's only used to be presented back to the user.
If code requests the object, there's no reason why that code should not somehow be able to know what it's requesting.


text:
Q: Visual Studio 2012 Editor Formatting I am using Visual Studio 2012 to develop c# codes. Also using Resharper from JetBrains.
I was wondering if there is a way (or a plugin) that will allow me to define some custom formatting for my code.
public void foo()
{
   //do some stuff
}

One example is that I want to turn bold the member declaration like this:
public void foo()
I believe this would be easier to read.
Please help.

A: I don't think this can be done with ReSharper or with any other Visual Studio extension I know of. If your code is well formatted and your methods short then it is quite easy to read their declarations without making them bold. If you just want to see a list of your methods then try using ReSharper's File Structure window (Ctrl+Alt+F or Resharper->Windows->File Structure). You could also try the Spade option in the CodeMaid VS Extension. There are quite a few VS Extensions you can try out that may make your code easier to read.


text:
Q: create a session using local storage in react js i am using local storage to set up a session in react js
localStorage.setItem("token", response.data.token);// in login page set token in localstorage
in class componet if token exist show the data
componentDidMount() {
   const config = {
     headers: {
       Authorization: `token ` + localStorage.getItem("token"),
     },
   };

   axios
     .get(
       "url" ,
       config
     )

in Funtional  componet if token exist show the data

useEffect(() => {
   const config = {
     headers: {
       Authorization: `token ` + localStorage.getItem("token"),
     },
   };

   axios
     .get(
       "url",
       config
     )
     .then((res) => {
       console.log(res.data.Diet);

i want if the local storage to act as session variable  and if local storage is empty re-direct to login page and say "login first"

A: You can check if the item exists in the local storage and redirect if not like so :
   if (localStorage.getItem("token") === null) {
  //your redirection code here
}


text:
Q: Is $x=\frac{1}{2}$ the solution of this equation $\zeta(2)= 1+{{{{x}^{x}}^{x}}^{x}}^{\cdots } $? I would like to study the irrationality of  ${{{{x}^{x}}^{x}}^{x}}^{\cdots } $
for $x=\frac{1}{2} $ using the irrationality of $\zeta(2)$ .
Some computations in wolfram alpha show to me that :
$${{{{x}^{x}}^{x}}^{x}}^{\cdots } $$ converge to $0.64...$ for $x=\frac{1}{2} $.
My Question here is: Is $x=\frac{1}{2}$ the solution of this equation  $\zeta(2)= 1+{{{{x}^{x}}^{x}}^{x}}^{\cdots } $ and does ${{{{x}^{x}}^{x}}^{x}}^{\cdots } $  irrational for  $x=\frac{1}{2}$ ?.

A: A solution of $a = 1/2^a$ is transcendental.  First note that $a$ is not an integer.  It can't be a non-integer rational, because $2^a$ for positive rational $a$ is an algebraic integer, and the only algebraic integers that are rational are the ordinary integers.  It can't be an irrational algebraic number by the Gelfond-Schneider theorem.

A: Expanding on some of this...
I suppose it makes no sense unless $x$ is between 0 and 1.  And in this case...
Define $y =x^{x^{x^{\cdots}}}$.  Then we have $y= x^y$.  For any fixed $0<x<1$, this defines a unique positive value for $y$ (intermediate value theorem will imply $y$ is between 0 and 1).
So that's one way to define it in the range we want.  It seems to me that solving the above equation gives us:
$$x = e^{\log(y)/y} = y^{1/y}$$
or
$$ 1/x = (1/y) ^{1/y}.$$
This can be written in terms of the Lambert W function to give:
$$y = e^{-W(-\log(x))} = \dfrac{W(-\log(x))}{-\log(x)}.$$
We won't get more explicit than that.
But your situation is much easier since you already know $y$.  So your question is the same as "is $y= \zeta(2)-1$ a solution to $y^{1/y} = 1/2$."  (No.)


text:
Q: Codeigniter Subdomain folder added to end of Url If my root website www folder is /
and the subdomain folder is /subdomain
I can either get to the the address using one of the following

*

*http://subdomain.website.com/

*http://www.website.com/subdomain
Now if I access the site using the http://subdomain.website.com, The codeigniter treats the base_url() as http://subdomain.website.com/subdomain is there away of stripping the subdomin from the end if the subdomain segment has the same name?
I could strip it on a case by case basis, but I'm hoping there is a way to do this using one of the system configuration files.

A: Whatever you are asking, has something to do with setting up dynamic base url in codeigniter. They have been answered here and also here.
Hope you find it helpfull.