text:
Q: Bind Razor TextArea to Model class attribute I have an MVC app and one of the controllers lead with CRUD of class model (class A).
This class model have an attribute that is a list of others objects (object B) Each one of this objects only have a string name property.

I need to show the View with a textArea (and i do it this with success) and after user submits, I want to split the textarea input by comma, create objects of type B for each value and insert the results in the list attribute.
My point is I do not know how to do that. Can i get the user input in controller?
My textArea:
@Html.TextAreaFor(model => model.List, htmlAttributes: new { @class = "control-label col-md-2" })

A: There are ways of doing this with nicer UI (this might get you started:  Passing the collection of selected values from a Select2-Multi DropDownList to a Controller)
But to answer your exact question:  Use a string property in your ViewModel to "wrap" the List property.
public class MyViewModel
{
    public List<string> MyList { get; set; }
    public string MyListAsString
    {
        get
        {
            return string.Join(",", MyList);
        }
        set
        {
            MyList = value.Split(new char[] { ',' }).Select(x => x.Trim()).ToList();
        }
    }
}

In your razor view, don't use MyList anywhere -- use MyListAsString, which will get and set MyList when the ModelBinder does its things.
@Html.TextAreaFor(model => model.MyListAsString,
                  htmlAttributes: new { @class = "control-label col-md-2" })

(Best practises:  I have renamed your List property to MyList, so as not to reuse an existing identifier.  And you probably don't want to use "control-label" class on something that isn't a label.  Try "form-control")


text:
Q: How do I change the xmlns in a new StartElement in C# with XMLWriter? I need the following result:
<?xml version="1.0" encoding="utf-8"?>
<LIEFERUNG-AUSWI xmlns:aw="http://www.bundesbank.de/xmw/auswi/2003-01-01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bbk="http://www.bundesbank.de/xmw/2003-01-01" xsi:schemaLocation="http://www.bundesbank.de/xmw/auswi/2003-01-01 BbkXmwAuswi.xsd" version="1.0" erstellzeit="2013-11-06T15:36:44" stufe="Test" xmlns="http://www.bundesbank.de/xmw/auswi/2003-01-01">
  <ABSENDER xmlns="http://www.bundesbank.de/xmw/2003-01-01">
    <aw:FIRMENNR>00004711</aw:FIRMENNR>
...

My code is the following:
writer.WriteStartElement("LIEFERUNG-AUSWI", "http://www.bundesbank.de/xmw/auswi/2003-01-01");
writer.WriteAttributeString("xmlns", "aw", null, "http://www.bundesbank.de/xmw/auswi/2003-01-01");
writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
writer.WriteAttributeString("xmlns", "bbk", null, "http://www.bundesbank.de/xmw/2003-01-01");
writer.WriteAttributeString("xsi", "schemaLocation", null, "http://www.bundesbank.de/xmw/auswi/2003-01-01 BbkXmwAuswi.xsd");
writer.WriteAttributeString(null, "version", null, "1.0");
writer.WriteAttributeString(null, "erstellzeit", null, Dat_DatZeit);
writer.WriteAttributeString(null, "stufe", null, "Test");

// Start-Tag von Absender
writer.WriteStartElement("ABSENDER");
writer.WriteAttributeString("xmlns", "bbk", null, "http://www.bundesbank.de/xmw/2003-01-01");
writer.WriteElementString("aw", "FIRMENNR", null, "00004711");

But this gives me the following:
<?xml version="1.0" encoding="utf-8"?>
<LIEFERUNG-AUSWI xmlns:aw="http://www.bundesbank.de/xmw/auswi/2003-01-01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bbk="http://www.bundesbank.de/xmw/2003-01-01" xsi:schemaLocation="http://www.bundesbank.de/xmw/auswi/2003-01-01 BbkXmwAuswi.xsd" version="1.0" erstellzeit="2013-11-06T15:36:44" stufe="Test" xmlns="http://www.bundesbank.de/xmw/auswi/2003-01-01">
  <ABSENDER xmlns:bbk="http://www.bundesbank.de/xmw/2003-01-01">
    <aw:FIRMENNR>00004711</aw:FIRMENNR>

What do I have to change to make xmlns:bbk become only xmlns? I never did something in XML so I am actually just trying but all I tried didn't work, either I got an error message or the result was wrong... here is something different I tried:
// Start-Tag von Absender
writer.WriteStartElement("ABSENDER", "http://www.bundesbank.de/xmw/2003-01-01");

This gave me a wrong result...

A: You have to change the following line:
writer.WriteStartElement("ABSENDER");

to:
writer.WriteStartElement("", "ABSENDER","http://www.bundesbank.de/xmw/2003-01-01");

The next one is unnecessary.
I may add that your XML seems a little overcomplicated, with namespaces being often redefined. For example in you root tag, http://www.bundesbank.de/xmw/auswi/2003-01-01 is the default namespace, but it is also called aw, and the namespace that you called bbk is later used, without its name… Maybe you should consider simplifying your XML in the process.
Aside from that, not testing your code before posting will often get your question closed on SO. I recommend LinqPad for this. It's what I used to find your answer.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why isn't the action error message passed to the next page? I am developing a login function which authenticate users from data stored in DB, when I tried to display the login error message on the next JSP to be displayed, the message wasn't shown even though the login info didn't match.
struts.xml
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
  <constant name="struts.enable.DynamicMethodInvocation" value="false" />
  <constant name="struts.devMode" value="false" />
  <constant name="struts.custom.i18n.resources" value="ApplicationResources" />

  <package name="default" extends="struts-default" namespace="/">
    <action name="login" class="package1.LoginAction">
      <result name="success">MainPage.jsp</result>
      <result name="error">Login.jsp</result>
    </action>
  </package>
</struts>

ApplicationResources.properties
  label.username=User Name
  label.password=Password
  label.login=Login
  label.domain=Select Domain
  error.login=Invalid Username/Password. Please try again.

Login.jsp

<s:actionerror />

<s:form action="login.action" method="post">

<s:textfield name="uid" key="label.username" size="20" />

<s:password name="psw" key="label.password" size="20" />

<s:select name="domain"
                  key="label.domain"
                  headerKey="1"
                  headerValue="-- Please Select --"
                  list="#{'01':'Tutor','02':'Student'}" />

<s:submit method="execute" key="label.login" align="center" />

</s:form>

LoginAction.java
    try {
        Class.forName("com.informix.jdbc.IfxDriver");
        conURL = "jdbc:informix-sqli://*********/fxg:INFORMIXSERVER=" +
                "sgdbuat11;user=*****;password=******";

        conn = DriverManager.getConnection(conURL);
        stmt = conn.createStatement();
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
    stmt = conn.createStatement();
    String qstr = "SELECT * FROM tutor";
    rset = stmt.executeQuery(qstr);
    int count = 0;
    String msg = "";
    while (rset.next()) {
        String username = rset.getString("uid");
        if (this.uid.equals(username)) {
            count++;
            String password = rset.getString("psw1");
            if (this.psw.equals(password)) {
                msg = "success";
            } else {
                msg = "wrongpsw";
            }
        }
    }
    if (count == 0) {
        return "error";
    } else if (msg == "wrongpsw") {
        return "error";
    } else {
        return "success";
    }

A: I don't see you use the key error.login so how do you expect struts to display it? You need to put the error message yourself, e.g. by calling addActionError("your message here") in your action.

A: I am not able to see where you have added the addActionErrorbasically if you want to set any such Action level error all you need to do it to call addActionError() or ActionMessage once you set them than at your jsp page ypu need to show them using <s:actionerror/> or <s:actionmessage/>
yuo need to set something like in your action class
 if (count==0)
      {
             addActionError("Invalid Username/Password. Please try again");
             return "error" ;
       }
     else if (msg=="wrongpsw"){
         addActionError("Invalid Username/Password. Please try again");
        return "error";

     }
     else{
         return "success";
     }

additional its always better to check if there exist any error in the stack on your jsp
<s:if test="hasActionErrors()">

<s:actionerror/>

</s:if>

hope this will help


text:
Q: is there a way to create a trigger on adding columns? I'm using Postgres. I'm in the middle of the development. I need to create a replica of table ABC. I will name it as XYZ. I tried create table XYZ () inherits(ABC). It works ok but when I insert values on XYZ, table ABC is also populated (virtually). I am getting duplicate values when I run query something like this select * from ABC where id = 1. I get the correct record when I run query like this select * from only ABC where id = 1.
The this is, I don't want to use 'only'. So, I don't think inheritance is what I need. I just want to ask if there is a way to add column automatically on XYZ when I alter(add column) ABC?
I don't want to create two queries of alter for ABC and XYZ. I need the two tables to have the same columns always. Any idea?

A: The kind of trigger you're talking about is generally known as a DDL trigger.  In PostgreSQL, they're known as event triggers.  I'm not sure whether you can execute an alter table statement in a PostgreSQL event trigger, though.
I'm not confident that this is really the solution you're looking for, though.  I think you might be in the middle of an X-Y problem.


text:
Q: @font-face not working for Chrome and Firefox on iOS only Page URL: http://seasia.kinsta.cloud/static/home-free-subscriber.html
I have used custom fonts on this page using @font-face. It's working fine on all desktop browsers, and also on Android browsers. Fonts are not loading only on iOS (iPhone and iPad) on Firefox and Chrome browsers. Working fine on Safari on iOS.

I have tried adding .htaccess file as suggested here on another discussion.
Also tried font smoothing properties as suggested here: https://github.com/grillitype/web-fonts-guide#font-smoothing
But it didn't help.

Following is the code I have used in CSS for @font-face
@font-face {
font-family: "GT America Black";
src: url("../fonts/gt-america/GT-America-Standard-Black.eot");
src: local("GT America Black"),
     local("../fonts/gt-america/GT-America-Standard-Black"),
     url("../fonts/gt-america/GT-America-Standard-Black.eot?#iefix") format("embedded-opentype"),
     url("../fonts/gt-america/GT-America-Standard-Black.woff2") format("woff2"),
     url("../fonts/gt-america/GT-America-Standard-Black.woff") format("woff"),
     url("../fonts/gt-america/GT-America-Standard-Black.ttf") format("truetype");
font-weight: 900;
font-style: normal;
font-stretch: normal; }

@font-face {
font-family: "GT America Light";
src: url("../fonts/gt-america/GT-America-Standard-Light.eot");
src: local("GT America Light"),
     local("../fonts/gt-america/GT-America-Standard-Light"),
     url("../fonts/gt-america/GT-America-Standard-Light.eot?#iefix") format("embedded-opentype"),
     url("../fonts/gt-america/GT-America-Standard-Light.woff2") format("woff2"),
     url("../fonts/gt-america/GT-America-Standard-Light.woff") format("woff"),
     url("../fonts/gt-america/GT-America-Standard-Light.ttf") format("truetype");
font-weight: 100;
font-style: normal;
font-stretch: normal; }


text:
Q: How to work with physical addresses as a network and how does DMA connect to it? I am working on a network driver and am somewhat confused with the memory management.
On the TX path, i receive a skb, as the lower layer expects to get only physical addresses, I think I need to call *virt_to_phys* and send the return value to the lower layer.
(Does it make sense?)
Now, I know there are the functions *dma_map_single* and *dma_unmap_single*. I am still not sure how they come to the picture here. So the lower layer wants to work with DMA... Does it mean that I need to run the above commands (in the appropriate time) before dispatching the packet to the lower layer?
I also not sure I understand the meaning of the description of dma_map_single
Ensure that any data held in the cache is appropriately discarded or written back.
Would appreciate your help.

A: Physical addresses are not necessarily the same as I/O bus addresses, so you must always use the dma_map_ functions.
On many systems, DMA accesses go only to main memory, which would break if there were a copy of that memory's contents in the CPU cache.
On these systems, the dma_ functions take the appropriate architecture-dependent action to ensure that such conflicts do not happen.

A: The files DMA-API.txt and DMA-API-HOWTO.txt in the Documentation directory of the Linux sources document how to use these functions.
You can't use virt_to_phys() and the like to get DMA addresses. That worked a long time ago in simpler times. Linux supports a wide range of hardware architectures and buses and for many of those, the address space the devices see does not map 1:1 to the physical address space of the CPU. Then there are also IOMMUs that can change that mapping dynamically. All of this necessitates the use of the DMA API.


text:
Q: Unable to change my display name I recently completed the About Me section of my profile, and now I do not see any option to change my name or my profile details.

A: Click on your user picture up close to top right to load up your user profile. You should see an "Edit Profile and Settings option. If that is not there, maybe try logging out and back in again.


text:
Q: Bootstrapping in Matlab - how many original data points are used? I have data sets for two groups, with one being much smaller than the other. For that reason, I am using the MatLab bootstrapping function to estimate the performance of the smaller group. I have code that draws on my original data, and it generates 1000 'new' means. However, it is not clear as to how many of the original data points are used each time. Obviously, if all the original data was used, the same mean would continue to be generated.
Can anyone help me out with this?

A: Bootstrapping comes from sampling with replacement. You'll use the same number of points as the original data, but some of them will be repeated. There are some variants of bootstrapping which work slightly differently, however. See https://en.wikipedia.org/wiki/Bootstrapping_(statistics).


text:
Q: How to store big data for use in computation? I have recently started working on big data. Specifically, I have several GBs of data and I have to do computation (addition, modification) on it frequently. Since any computation on the data takes a lot of time, I been thinking of how to store the data for quick computation. Following are the options I have looked into:

*

*Plain text file: The only advantage of this technique is inserting data is very easy. Changes to existing data are pretty slow, since there is no way to search for records efficiently.

*Database: Insertion and modification of data are simplified. However, since this is a ongoing research project, schema may need to be updated frequently depending upon experimental results (this has NOT happened uptil now, but will definitely be something that may happen in near future). Besides, moving data around is not simple (as compared to a simple files). Moreover, I have noticed that querying data is not that quick as compared to when data is stored in XML.

*XML: Using BeautifulSoup, only loading the XML file containing all the data takes around ~15 minutes and takes up ~15GB of RAM. Since it is quite normal to run scripts multiple times in a day, ~15 minutes for every invocation seems awfully long. The advantage is once the data is loaded, I can search/modify elements (tags) fairly quickly.

*JSON and YAML: I have not looked into it deeply. They can surely compress the disk space needed to store the file (relative to XML). However, I have found no way to query records when data is stored in these formats (unlike database or XML).

What do you suggest I do? Do you have any other option in mind?

A: If you're looking for a flexible database for a large amount of data, MongoDB may be the technology you are looking for.
MongoDB belongs to the family of the NoSQL database systems and is:

*

*based on JSON-alike documents

*highly performant even with large amounts of data

*schema-free

*document-based

*open-source

*queryable

*indexable

It allows you to modify your schema in the future in a very flexible way, quite easy to insert data (1.), modify the data and its structure (2.), faster than XML (3.) and JSON-based for efficient storage (4.).

A: size of integer is 4,long long int is 8 byte and it can access about 19 digits data and for unsinged long long int size also 8 byte but handle larger value than long long int but this is less than 20 digits.Is there any way that can hangle over 20 digits data.
#include<iostream>
using namespace std;
int main()
{
    unsigned long long int a;
    cin>>a;
    if(a>789456123789456123123)//want to take a higher thand this digits
    {
        cout<<"a is larger and big data"<<endl;
    }
}

I searched about it for a while but didn't find helpful contents.all about is java biginteger..


text:
Q: Error in MySQL/PHP real_escape_string UPDATE function    $query = sprintf("UPDATE populationgender SET male='%s', female = '%s' WHERE popgenderid='4'",
             mysql_real_escape_string($male),
             mysql_real_escape_string($female));

Is this a valid sprintf code? because when i use this it does nothing hehe it is connected via googlemaps btw :) pls help thanks :)

A: You have used escape in javascript as well as php.
Try using escape in javascript and unescape in php.
$myvar = urldecode($_GET["male"]);
this will work


text:
Q: How to modify regex for phone numbers and accept only digits I have this following regex method for the jquery validate plugin.
jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
    phone_number = phone_number.replace(/\s+/g, "");
    return this.optional(element) || phone_number.length > 9 &&
        phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, "Please specify a valid phone number");

Currently, its validating against phone numbers in this format : 203-123-1234
I need to change to validate like this: 2031231234
Does anyone have a quick and easy solution for me?

A: You can replace
phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);

with this
phone_number.match(/\d{10}/);

\d means match any digit
and
{10} means 10 times

A: Getting rid of all those -? sequences is probably the quickest way - they mean zero or one - characters.
That will reduce it to:
/^(1)?(\([2-9]\d{2}\)|[2-9]\d{2})[2-9]\d{2}\d{4}$/

whih can be further simplified to:
/^1?(\([2-9]\d{2}\)|[2-9]\d{2})[2-9]\d{6}$/

If you also want to disallow the brackets around area codes, you can further simplify it to:
/^1?[2-9]\d{2}[2-9]\d{6}$/

(and, technically, it won't match the literal 203-123-1234 since the character immediately after that first - has to be 2 thru 9, so I'm assuming you were just talking about the format rather than the values there).

A: I think better approach would be changing the whole expression with simpler version, something like this:
/^[0-9]{10}$/

Edited, Note (see comments):
This is just a limited example of how to validate a format: 111-222-3333 vs 1112223333, not proper US phone number validation.

A: If you just want ten digits, then
phone_number.match(/\d{10}/)
will do it. If you want to match any of the other conditions in there (eg match both 1-2031231234 and 2031231234), you will need to add more.
As a side note, what you currently have doesn't match 203-123-1234 because the first digit after the first hyphen is a 1, and it is looking for 2-9 in that spot.

A: ([0-9]{10}) this will match with 10 digit number.

A: You can use if you want to match all formats, including 203-123-1234 and 2031231234
EDIT : I'm no regex expert, but I added "1-" support
/^(?:1-?)?[(]?\d{3}[)]?\s?-?\s?\d{3}\s?-?\s?\d{4}$/

By the way, there's a really nice AIR tool for regex, it's called RegExr and you can get the desktop version here http://www.gskinner.com/RegExr/desktop/ or use the online version http://gskinner.com/RegExr/ . There's also a "community" section that contains a lot of useful working regex. That's where I took that one.


text:
Q: I would like a new text box comes out when someone clicks on others I have a form in access that dropdown box. Now what I want is when someone choose others from the dropdown box, a new text box shows up to allow the user to type. Anyone help please thank y ou

A: Assuming your DropDown is called Combo1 and on the same form you have a textbox called Text1 and the value of "Others" is also "others". Then you just need to code the Combo1's Change event like so
Private Sub Combo1_Change()

        Me.Text1.Visible = (Me.Combo1.Value = "others")

End Sub


text:
Q: Format file size in Dart How to format a file size in Dart?
Input: 1000000
Expected output: 1 MB
The input could be either an int or a double for ease of use, and the result should be a String with only one decimal.

A: I made an extension method for this:
extension FileFormatter on num {
  String readableFileSize({bool base1024 = true}) {
    final base = base1024 ? 1024 : 1000;
    if (this <= 0) return "0";
    final units = ["B", "kB", "MB", "GB", "TB"];
    int digitGroups = (log(this) / log(base)).round();
    return NumberFormat("#,##0.#").format(this / pow(base, digitGroups)) +
        " " +
        units[digitGroups];
  }
}

You will need to use the intl package for the NumberFormat class.
You can display bits or bytes using the boolean base64.
Usage:
int myInt = 12345678;
double myDouble = 2546;
print('myInt: ${myInt.readableFileSize(base1024: false)}');
print('myDouble: ${myDouble.readableFileSize()}');

Output:
myInt: 12.3 MB
myDouble: 2.5 kB

Inspired by this SO answer.


text:
Q: Как конвертировать id в viewkey? Имеется ссылка видео https://cv.phncdn.com/videos/201702/14/106201472/720P_1500K_106201472.mp4?a5dcae8e...
я из нее беру id видео на pornhub 106201472, с помощью этого id надо получить ссылку на страницу с видео, вида:
pornhub.com/view_video.php?viewkey=ph59b5c9dded69b

может кто знает, есть там возможность по id открыть видео, если нет viewkey


text:
Q: Integer.parseInt() method crashes with an empty string as the parameter https://youtu.be/LsKjw-IJQpI Hello everyone I have a question I was following a tutorial and I have a problem when I press the button and when it is empty edittext my application says stoped I wanted to know how to solve it?
this is the code

 buttonalarm = (Button) findViewById(R.id.buttonalarm);
    buttonalarm.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int hour = Integer.parseInt(houredit.getText().toString());
            int minute = Integer.parseInt(minuteedit.getText().toString());
            Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM);
            intent.putExtra(AlarmClock.EXTRA_HOUR, hour);
            intent.putExtra(AlarmClock.EXTRA_MINUTES, minute);

            if (hour <= 24 && minute <= 60) {
                startActivity(intent);

            }
        }
    });

and my logcat
   java.lang.NumberFormatException: Invalid int: ""
        at java.lang.Integer.invalidInt(Integer.java:138)
        at java.lang.Integer.parseInt(Integer.java:358)
        at java.lang.Integer.parseInt(Integer.java:334)
        at com.koko.myapp.alarma$2.onClick(alarma.java:72)
        at android.view.View.performClick(View.java:4780)
        at android.view.View$PerformClick.run(View.java:19866)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5254)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

A: This line is throwing the NumberFormatException:
Integer.parseInt(houredit.getText().toString());

Because houredit.getText().toString() return an empty string and you can't parse empty String into Integer.
Before you parse check that the houredit.getText().toString() don't return with empty string.

A: I know this is an old question, but the current answers didn't seem to have multiple answers or examples of how to fix it. The reason why you are getting this is because it is getting a NumberFormatException and because the string is empty it can't parse it and crashes, so there are two ways you can fix it.
The first way would be to check to see if the string is empty and if not then follow through with the parsing of the data.
if (!houredit.getText().toString().trim().equals("")){
 int hour = Integer.parseInt(houredit.getText().toString());
 int minute = Integer.parseInt(minuteedit.getText().toString());
 Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM);
 intent.putExtra(AlarmClock.EXTRA_HOUR, hour);
 intent.putExtra(AlarmClock.EXTRA_MINUTES, minute);

 if (hour <= 24 && minute <= 60) {
   startActivity(intent);
 }
}

The second way would be with a try/catch, which tells the app to try something and if it can't do it throw an error.
try{
 int hour = Integer.parseInt(houredit.getText().toString());
 int minute = Integer.parseInt(minuteedit.getText().toString());
 Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM);
 intent.putExtra(AlarmClock.EXTRA_HOUR, hour);
 intent.putExtra(AlarmClock.EXTRA_MINUTES, minute);

 if (hour <= 24 && minute <= 60) {
   startActivity(intent);
 }
}catch(Exception ignored){} // <- capture exception if you need, else you can ignore it


text:
Q: Getting actual type of Option[Any] I have the following code:
case class Property(name: String, value: Option[Any])

class PropertyType[+T <: Any: ru.TypeTag] {
  def isValidType(property: Property): Boolean = {
    property.value match {
      case None => true
      case Some(value) => ru.typeOf[T] == getTypeTag(value)
    }
  }

  private def getTypeTag[TT: ru.TypeTag](obj: TT) = ru.typeTag[TT]
}

case object StringPropertyType extends PropertyType[String]

Of course, StringPropertyType.isValidType(Property("test", Some("test))) returns false, because getTypeTag(Property.value.get) returns Any.
I wonder how I could make it works, because getClass on value returns String:
scala> Property("test", Some("test")).value.get.getClass
res4: Class[_] = class java.lang.String

How can i get the actual value type of Option[Any].get?

A: *

*You trying to compare Type and TypeTag

*Scala runtime reflection info provided by compiler, so you need to add this type information to Property
import scala.reflect.runtime.{universe => ru}
case class Property[T](name: String, value: Option[T])

class PropertyType[+T <: Any: ru.TypeTag] {
  def isValidType[S: ru.TypeTag](property: Property[S]): Boolean = {
    property.value match {
      case None => true
      case Some(value) => ru.typeTag[S].tpe <:< ru.typeOf[T]
    }
  }
}

case object StringPropertyType extends PropertyType[String]

println(StringPropertyType.isValidType(Property("test", Some("test")))) // true


text:
Q: Is it allowed in iOS to redirect user to website for payment? I asked this question at stack exchange but couldn't get any reply therefor posting it here so that I can get some help.
I am developing an iOS app for selling physical goods and for that, I want to redirect my user to my website for checkout and payment process. I want to confirm if that is allowed by apple guidelines. I tried to check with apple support but couldn't get a satisfactory answer. I am not asking about redirecting the user to the PayPal/stripe website but my own website where I have Authorize.net/Paypal integration and want my user to make payment there and then I will take him back to my app. As per my understanding, external payment is allowed for physical goods but I want to check if my use case is acceptable or not.

A: External payment is required for physical goods, you can't pay physical goods using your iTunes account. The only allowed way to pay for physical goods using the Apple infrastructure is using Apple Pay if it's available in your country:
(Excerpt taken from App Store Review Guidelines)

3.1.5(a) Goods and Services Outside of the App: If your app enables people to purchase goods or services that will be consumed outside of the app, you must use purchase methods other than in-app purchase to collect those payments, such as Apple Pay or traditional credit card entry.

Anyway Apple is quite picky about privacy, security and user experience, so try not to take the user out of the application and make the paying process as secure as you can. I would try to integrate whatever payment gateway you are using inside your app, or at least open a web view inside the app instead of sending the user to Safari with an external URL.

A: Check this documentation of apple . May be you get some help from this
https://developer.apple.com/documentation/uikit/inter-process_communication/allowing_apps_and_websites_to_link_to_your_content


text:
Q: Running Wordpress PHP from command line - specifically for Plesk scheduled task I need to develop a script using Wordpress PHP that will run with the Plesk Scheduled task.  I've seen a few topics with this on stackoverflow and the web, but I can't seem to get the wordpress or script to work.  I'm fairly new to this, so I need a good step-by-step guide.
Basically, I want to run a PHP Script using the command line. (what's the command to do this?... I had "php -q /path/to/file.php" but not sure if that's it.)
Secondly, with this script, I need to be able to use Wordpress commands such as query_posts, add_post_meta, get_post_meta, etc.
I've seen elsewhere that I need the following at the top of the php file:
#!/usr/bin/php
<?php

$_SERVER = array(
  "HTTP_HOST" => "http://example.com",
  "SERVER_NAME" => "http://example.com",
  "REQUEST_URI" => "/",
  "REQUEST_METHOD" => "GET"
);

require_once('/wp-load.php');
require_once('/wp-blog-header.php');

Is that it, or do I need more?  I assume I can place the PHP script in my root Wordpress directory and run it from there?
I've got the entire PHP part working, and can run it if I include it in a Wordpress page and simply load that page.  So I know the Wordpress part works.
I just need that other portion to get it working with the scheduled tasks.
Thanks in advance for all your help.

A: Yes that's it. Actually, all you need to do is set HOST_NAME.


text:
Q: Linking the section text to the TOC I'd like the section headings in running text to link to their "line" in the Table of Contents so as to get "two-way" navigation, eg: a user looks in the Table of Contents for a section title, jumps there, reads a couple of lines, clicks on the section title again and gets taken to the section's entry in the Table of Contents once more.
Any ideas? :)
(Somewhat related to this question)

A: I wrote a very simple example of myself.
\documentclass{article}
\usepackage{lipsum}
\usepackage{hyperref}

\let\oldsection\section
\renewcommand\section[1]{%
    \addtocontents{toc}{\protect\hypertarget{#1}{}}
    \oldsection{\texorpdfstring{\protect\hyperlink{#1}{#1}}{#1}}
    } %%

\let\oldsubsection\subsection
\renewcommand\subsection[1]{%
    \addtocontents{toc}{\protect\hypertarget{#1}{}}
    \oldsubsection{\texorpdfstring{\protect\hyperlink{#1}{#1}}{#1}}
    } %%

\begin{document}
{
    \let\section\oldsection
    \pdfbookmark{Contents}{Contents}
    \vspace*{.5cm}
    \tableofcontents
}
\clearpage

\section{First section}
\lipsum[1]
\subsection{my sub section}
\lipsum[1]

\section{Second section}
\lipsum[2]

\clearpage

\section{Third section}
\lipsum[3]
\end{document}

A: Here's another approach, using the titlesec package and the \hypertarget, \hyperlink mechanism from hyperref. A little example showing the necessary settings for \chapter, \section, \subsection and their starred versions:
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{hyperref}

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{\chaptertitlename\ {\fontfamily{cmr}\selectfont\thechapter}}{20pt}{\hyperlink{chap-\thechapter}{\Huge#1}
\addtocontents{toc}{\protect\hypertarget{chap-\thechapter}{}}}
\titleformat{name=\chapter,numberless}
  {\normalfont\huge\bfseries}{}{-20pt}{\Huge#1}
\titleformat{\section}
  {\normalfont\Large\bfseries}{\thesection}{1em}{\hyperlink{sec-\thesection}{#1}
\addtocontents{toc}{\protect\hypertarget{sec-\thesection}{}}}
\titleformat{name=\section,numberless}
  {\normalfont\Large\bfseries}{}{0pt}{#1}
\titleformat{\subsection}
  {\normalfont\large\bfseries}{\thesubsection}{1em}{\hyperlink{subsec-\thesubsection}{#1}
\addtocontents{toc}{\protect\hypertarget{subsec-\thesubsection}{}}}
\titleformat{name=\subsection,numberless}
  {\normalfont\large\bfseries}{\thesubsection}{0pt}{#1}

\begin{document}

\tableofcontents

\chapter{Numbered test chapter one}

\section{Test section one}

\subsection{test subsection one one}

\subsection{test subsection one two}

\chapter*{Unnumbered test chapter one}

\section*{Unnumbered test section}

\subsection*{Unnumbered test subsection}

\end{document}

A: This solution sets up \hypertargets in the toc by renewing the \contentsline command. It links back to the toc by setting the section headings as \hyperlinks using the titlesec package. Note that each of the new \hypertarget start with the word 'toc'
You can easily copy this approach for chapters etc.
\documentclass{article}
\usepackage{lipsum} % sample text
\usepackage[explicit]{titlesec} % to change headings
\usepackage{hyperref}

% renew \contentsline for toc to include hypertarget
\let\oldcontentsline\contentsline%
\renewcommand\contentsline[4]{%
\hypertarget{toc#4}{}%
\oldcontentsline{#1}{#2}{#3}{#4}}

% renew \section to link to the toc
\titleformat{\section}
{\normalfont\Large\bf}
{{\thesection} \hyperlink{tocsection.\thesection}{#1}}
{1pc}
{}

% renew \subsection to link to the toc
\titleformat{\subsection}
{\normalfont\bf}
{{\thesection} \hyperlink{tocsubsection.\thesubsection}{#1}}
{1pc}
{}

\begin{document}
\tableofcontents

\clearpage

\section{First section}
\lipsum[1]
\subsection{my sub section}
\lipsum[1]

\section{Second section}
\lipsum[2]

\clearpage

\section{Third section}
\lipsum[3]
\end{document}

Explanation
Note that if you look at the .toc file for the above example you'll see the following entries
\contentsline {section}{\numberline {1}First section}{2}{section.1}
\contentsline {subsection}{\numberline {1.1}my sub section}{2}{subsection.1.1}
\contentsline {section}{\numberline {2}Second section}{2}{section.2}
\contentsline {section}{\numberline {3}Third section}{3}{section.3}

The \contentsline takes four arguments, the fourth of which will uniquely identify each entry. I used this unique entry combined with the string 'toc' as the \hypertarget{toc#4}{}; it would not work without the additional string 'toc' (or something similar), as it would result in a duplicated identifier which would be ignored.


text:
Q: Testing Server & Client I want to start testing my server with a couple of clients before moving onto higher numbers.
The current plan right now is just to run tests to check/test latency by writing a script that takes in X amount of seconds that will determine how long the test runs. The script will launch the server and clients. On their end the ping testing code is already in place.
My problem is that while the server is easy to just launch it via a bash script, I don't know any easy way to also launch Chrome and have it go to the webpage.  (the client)
Hoping this is an easy script, my scripting experience is limited :]

A: Chrome will accept URL's on its command-line, like so:
chrome http://www.google.com/


text:
Q: The event clicking on node in d3.js in JSP I am using D3 Javascript library in a JSF application. I am presenting a graph of nodes in a JSP page. What I am trying to do is when I click on one the nodes, I am expecting to send the id of that node to Managed Beans as a request and the Managed Beans class connects to the server to search for its children. The D3 Javascript code is in a JSP file. Here is my code:
.
.
<body>
<f:view>
node.enter().append("circle")
  .attr("class", "node")
  .attr("cx", function(d) { return d.x; })
  .attr("cy", function(d) { return d.y; })
  .attr("r", function(d) { return Math.sqrt(d.size) / 10 || 4.5; })
  .style("fill", color)
  .on("click", click)
  .call(force.drag);
  .
  .
  function click(d) {
    // This is for clicking on a node and sending the id of the node to the Managed beans
      }
  update();
  }
  }
.
.
<body>
<f:view>

My question is: Normally, in JSP, you can do something similar to this code:
<h:inputText  value="#{managedBeans.bean}"></h:inputText>
<h:commandButton action="#{managedBeans.action_1}" value="value_X"></h:commandButton>

or something similar to this:
<button type="button" onclick="">Click me </button>

In case of clicking on one of nodes in a D3 graph, how can I send the id of the node (such as: name) to the Managed beans as a request? I do now know how to get that clicking event on the node in Javascript within JSP code. Your help would be very much appreciated.


text:
Q: Smooth scroll to the top of page script after form validation error I have a long form and I would like to scroll up to the top of the page using my jquery smooth-scroll-to-the-top-of-page script.
Is it possible to scroll to the top of page if the validation script finds errors?

A: Just make your smooth scroll a function that can be called onError i.e
function SmoothScroll(){
 $('a.scrollToTop').click(function () {
   $('html, body').animate({
    scrollTop: 0
   }, 2500);
  return false;
 });
}

and
    onError: function () {
        if ($('#input_2     input').hasClass('error-input')) {
            $('#r2 div, #r2 input').css('background-color', '#C1272D').css('color', '#FFF');
            $("#error-div").show();
            SmoothScroll();
        }
    }


text:
Q: How can I successfully login with root after running mysql_secure_installation? I am currently unable to login as root on mysql and I am not quite sure about what's going on. Here's what happened:
I ran mysql_secure_installation as recommended, to secure my mysql installation. Afterwards, I typed the default root password that was asked and then I entered:

*

*No to setting a password for root

*Yes on removing anonymous users

*Yes on disallowing remote root login

*Yes on removing the test database and access to it

*Yes on reloading privilege tables

After completing this process, I tried accessing mysql with mysql -u root -p (entered the default password) and received this message:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Do you have any ideas on what might have went wrong?
I also tried resetting the root password by starting mysql with --skip-grant-tables, but I am still not able to login.
I am using Ubuntu 14.04 and mysql 14.14 (LAMP stack).

A: I know this is an old post but the main answer is outdated and did not solve my issue.
Below my steps for future reference if anybody is having similar problems.
Stop mysql if it's running
$ sudo service mysql stop

Start mysql in safe mode
$ sudo mysqld_safe --skip-grant-tables --skip-syslog --skip-networking

If you get the error
"mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists"
Just create that folder:
$ mkdir -p /var/run/mysqld
$ chown mysql:mysql /var/run/mysqld

Open a new terminal window and log into mysql service + select mysql database:
$ mysql -u root
mysql> use mysql;

Set new password for root user:
mysql> update user set authentication_string=password('new-password') where user='root';

Flush privileges and exit mysql:
mysql> FLUSH PRIVILEGES;
mysql> exit;

Stop the safemode mysql (from the second terminal, you will see it stop in the first terminal)
$ mysqladmin -u root -p shutdown

Restart mysql
$ sudo service mysql start

You should be able to use the root user with password now to login to mysql/phpmyadmin

A: CentOS/Redhat:
From what I read in docs, when you run mysql_secure_installation, a temporary root password is generated and is stored in some log file.
sudo grep 'temporary password' /var/log/mysqld.log

Debian/Ubuntu:
During the packages installation, you get a prompt asking for the root password. If you don't set it up, MySQL's root user is created without a password. We can read the following line in package installation output:
Shell

2016-05-16T07:27:21.532619Z 1 [Warning] root@localhost is created with
  an empty password ! Please consider switching off the
  --initialize-insecure option.

but it is configured with the auth_socket plugin. You will only be able to connect using the UNIX socket, therefore any attempt to connect using your local IP or the network fails. Later on, you can change the password to allow connections from the network (as explained in this blog post).
Source
All we can do now is to see the root password. Lets change the root password since you cannot understand hashed password even if we can see it:
sudo service mysql stop
sudo mysqld_safe --skip-grant-tables --skip-syslog --skip-networking

then run mysql in a new terminal
mysql -u root

and run the following query, after changing the password
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
FLUSH PRIVILEGES;

quit the mysql safe mode and start mysql service by
mysqladmin shutdown
sudo service mysql start

A: just run this script by root , you need custormize you password
mysqlpassword=password
/usr/bin/mysqladmin -u root password "$mysqlpassword"
#configure mysql login privileges
echo "grant all privileges on *.* to root@\"localhost\" identified by \"$mysqlpassword\";show databases;" |mysql -u root  -p$mysqlpassword


text:
Q: Windows Azure Active Directory Bearer Authentication I'm trying to wrap my head around how to secure Web API resources with Azure Active Directory. Currently, I have an angular 2 app that is redirecting the user to the Azure AD login page, and receives an id_token in return. This id token is used in subsequent calls as a bearer token, and it seems to be working. My question is here.
    public void ConfigureAuth(IAppBuilder app)
    {
        app.UseWindowsAzureActiveDirectoryBearerAuthentication(
            new WindowsAzureActiveDirectoryBearerAuthenticationOptions
            {
                TokenValidationParameters = new TokenValidationParameters
                {
                    ValidAudience = ConfigurationManager.AppSettings["ida:ClientId"],
                    ValidateIssuer = true
                },
                Tenant = ConfigurationManager.AppSettings["ida:TenantId"]
            });
    }

It seems that here is where we do our validation of the bearer token. What I don't really understand is how it works. Is it communicating with Azure AD on every API call? If so, is this the ideal approach (in terms of performance)? If not, how does this stop someone from just creating their own token and hacking into the API?
I'm sure there's some vital piece of knowledge I'm missing to understand that, so if you have any resources I should read to understand this better, please suggest.
Thanks!

A: You can define what attributes you want to be validated via TokenValidationParameters and/or you can create a notification to implement your own validator.
In the case of the code above you defined that ValidateIssuer = true - which means that the Issuer will be validated - or else, the middleware will check if the Issuer (iss claim in the token) matches the Tenant Id on which the app was registered (for example, if the application was registered on tenant contoso.com, the parameter validates if the token was actually issued by tenant contoso.com) - blocking a token generated by another tenant.
The ValidAudience = true tells the middleware to validate if the token generated was actually generated to your application. So there is no need to communicate against Azure AD every time.
See this MSDN article for more options for token validation.
Please also see below a great post about token validation:
http://www.cloudidentity.com/blog/2014/03/03/principles-of-token-validation/


text:
Q: Filepath of EXTERNAL_CONTENT_URI in Android I was following this tutorial to create a music player but have hit an obstacle.
I can load up the application all well and good. However, the list is not populated with any music files despite there being music files present in the "music" folder on my SD card inside my phone.
ContentResolver musicResolver = getContentResolver();
Uri musicUri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
Cursor musicCursor = musicResolver.query(musicUri, null, null, null, null);

Where is the line of code Uri musicUri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; pointing to in terms of filepath?
I've looked it up online but have not found any information on this, just saying that it searches for music files in the external SD card, which is clearly not the case.
Thanks.

A: It seemed that everything was working and it was a silly oversight on my part.
The ListView was not visible in the phone's screen.


text:
Q: Android Hybrid application using Native Android functions Currently i am developing an Android Hybrid application. I am pretty new to Android development but picking up new things pretty much every day. This Hybrid application is build upon the Sencha Touch 2.3.1 framework. The project consists out of the following of main goals.
Functionality:

*

*Getting the current GPS location. (Backed by 2G/3G or WiFi if needed)

*Reading the current accelerometer values. (Used for a fall-detection algorithm)

*Scanning QR codes. (I will probably use a library for this function)

*Setting a timer and let it run in the background.

*All of the above should 'run' in the Native part of the application.

General question: What would be the best way of doing this, in terms of architecture/base structure?

To get a little more specific on the answer i would like to get, here is some more information.
Currently the native part (Activity) of the application looks somewhat like this. It declares and initializes the WebView and loads the URL which refers to the host where my Sencha Touch application is hosted. So far this is the only Activity/Class i have. And also works properly.
I am using the following bridge to communicate back and forth between the hybrid and native part of the application. In the example on GitHub they stuffed all of the functionality in one Java class. (Activity)
In my case this would mean for my project, that all of the Hybrid to Native function calls, like getting the current GPS status, set a timer in the background or start the camera will reside in the main Activity. Thus getting quite big in time, i could imagine.

Sub question: Is this the way to go, or should i split up all of the core functionality in separate classes?

Scenario:
The GPS sensor takes quite some time to get a fix, so the user should not be interrupted while the GPS keeps searching for the current coordinates. (Again this can be backed by 2G/3G or WiFi if needed and available)

Sub question: Should this or any other background functionality be handled in a separate thread? Or in the same Activity where the WebView resides? Or can i just simply create a new thread within the Activity that handles the GPS and/or other functionality that require to run on the background?

As you can see i am trying to figure out the best way of structuring the application on the Native side.

For the threading part (Functionality that runs in the background, such as a timer or GPS that waits for the correct coordinates) i wanted to use IntentService, because the functionality has to keep running and also finishing their tasks, even when the application is not active/minimized. Plus the same task is bound to be handled again. (Re-using the thread?) So when i speak of threading or threads in this question, i mean using the IntentServices.

I hope i was clear enough. Thanks for reading so far.
(Pseudo)Coding answers are appreciated, but showing me the best/correct structure (Image or 'just in words' -like) would be preferred. Then again, do as you prefer.


text:
Q: Magnetic field due to a charge having uniform velocity Faraday's law states that "Any change in electric field induces a magnetic field and vice versa".
I don't see exactly where these fields are induced, but I assume that these fields are induced at each and every point in space.
Now, let us consider a charge Q, moving with a uniform Velocity V. Obviously this movement of the charge creates a change in the electric field everywhere. As such it should induce a magnetic field.
Subsequently, this change in the magnetic field should also bring about an electric field, an induced one, owing to further changes induced in the magnetic field.
Apparently this machinery seems to be similar to an EM radiation. But we know that an EM radiation can only be produced by charges in accelerated movement.
Why this chain of events can't be seen as an EM wave propagation?

A: I am trying here to answer your comment "I guess, if fields are undergoing a wave-like change in one frame of reference, they must undergo the same kind of change in any other frame of reference."
It's a legitimate remark and I would formulate it even more clearly: in a frame of reference where the charge is at rest it doesn't emit e.m. waves. But it can't be possible that in one frame we have an e.m. wave, and in another one we haven't.
Now, let me show you that although the e.m. field produced by the moving charge is time-dependent, it isn't similar to the e.m. waves which travel with the light velocity. For avoiding solving the equations in my previous answer, I'll use another procedure here. I will consider two frames of coordinate. A frame $O$ where the charge is at rest and in the origin of coordinates, s.t. we have only the Coulomb field,
$$\vec E = \frac {Q}{4\pi\epsilon_0} \frac {\vec r}{r^3}, \ \ \text {and} \ \ \vec B = 0, \tag{i}$$
and a frame $O'$ moving with a velocity $v$ in the direction $-z$. That means, in the frame $O'$ the charge moves with the velocity $v$.
Now, we can apply the special relativity transformations for the space and time
$$\begin{cases}
t = \gamma \left(t' + \frac {\vec r' \cdot \vec v}{c^2}\right) \\
\vec {r} = r'_{\perp} + \gamma \left(r'_{\|} + \vec v t' \right).
\end{cases} \tag{ii}$$
For the electric and magnetic field we have, by taking in consideration that in $O$ there is no magnetic field,
$$\begin{cases}
\vec {E'} = \gamma \vec E + (1 - \gamma) \frac {\vec E \cdot \vec v}{v^2} \vec v \\
\vec {B'} = -\gamma \frac {\vec v \times \vec E}{c^2}.
\end{cases} \tag{iii}$$
Let's introduce $\text {(i)}$ in $\text {(iii)}$.
$$\begin{cases}
\vec {E'} = \gamma \frac {Q}{4\pi\epsilon_0} \left[\frac {\vec r}{r^3} + (\gamma ^{-1} - 1) \frac {r_{\|}}{r^3} \frac {\vec v}{v}\right] \\
\vec {B'} = -\gamma \frac {Q \mu_0}{4\pi} \ \vec v \times \frac {\vec r}{r^3}.
\end{cases} \tag{iv}$$
The final thing is to replace $\vec r$ by the expression in $\text {(ii)}$,
$$\begin{cases}
\vec {E'} = \gamma \frac {Q}{4\pi\epsilon_0} \frac {\vec {r'_{\perp}} + \left[\gamma + (1 - \gamma)\frac {\vec v}{v}\right]\left(\vec {r'_{\|}} + \vec v t' \right)}{\left[ r'^2_{\perp} + \gamma^2 \left(r'_{\|} + v t' \right)^2\right]^{3/2}} \\
\vec {B'} = -\gamma \frac {Q \mu_0}{4\pi} \ \frac {\vec v \times \vec {r'_{\perp}}}{\left[r'^2_{\perp} + \gamma^2 \left(r'_{\|} + v t' \right)^2\right]^{3/2}}.
\end{cases} \tag{v}$$
As one can see, these are not travelling waves of type ~ $e^{i(kr - \omega t)}$ with $\omega = ck$. The formulas $\text {(v)}$ represent just a Coulomb field, that in the frame $O'$ appears as dragged after the charge $Q$, however, when expressing the position dependence of the field in terms of the coordinates of the frame $O'$ according to the special relativity, dependence of time enters into play. And, as we know, the moving charge produces also a magnetic field. But we have no e.m. waves.

A: I might elaborate upon Sofia's excellent answer in two respects.
Not all changing EM fields are wave like. Maxwell's equations have lots of solutions involving changing E and M fields. These can be broken down into two components, the "near field" and the "far field". The difference is that the far field components have a classical wave solution, and hence fall off according to a square law rule. The "near field" is changing E and M components which do not propagate. A charge moving at a constant speed produces only near field solutions - yes there are E and M fields, but they don't propagate and hence do not take energy away from the system.
Secondly, as others have alluded to, magnetism is not considerd a "real" force in Special Relativity. This was spelled out by Einstein in his original paper on SR, hence its title "On the electrodynamics of moving bodies". Consider a reference frame where the charged particle is at rest. Clearly it can't emit radiation. But as the choice of reference frame is arbitrary, a particle moving at constant speed cannot emit radiation. Einstein argued that you only see a magnetic field around a charged particle if it is moving relative to the observer. But all observers should see the same thing. He concluded (and demonstrated) that the magnetic field is a "virtual force" (like centrifugal force) that derives from your choice of what you consider "at rest", an artefact of your coordinate system. This is why the magnetic field exists in some frames of reference but not in others - in SR, the magnetic field doesn't really exist at all, it is a consequence of relativistic effects applied to electric fields. The net result is that all observers see the same thing; observers at rest interpret the repulsion of fixed charges as due to electric fields, observers in motion interpret this as a combination of electric and magnetic fields, and the numbers always end up being the same (as Einstein showed). Its just as easy to assume magnetism doesn't exist at all, and it is simply a virtual force. This may help explain why different observers see different strengths of magnetic fields around moving particles - the magnetic field is a computational byproduct of measuring the electric field in different reference frames.


text:
Q: How to create a tooltip behind a customizer setting label? I would like to show a tooltip after a setting label in customizer which on hover will show the help-text. I should be able to send the help-text from the control or setting registration like this:
$wp_customize->add_control( 'ghoul_test', array(
    'type'      => 'text',
    'label'     => __( 'Title', 'ghoul' ),
    'section'   => 'colors',
    'help-text' => __( 'This is help text.', 'ghoul' ),
) );

I can add the tooltip icon and worked out the hover part. But I am stuck on sending the help-text data.
Is this possible in core controls or not?
Anyone help is very much appreciated.

A: You can send the data via input_attrs parameter of add_control. However with that you can add attributes to the input field only.
Iam using Tipr here for the tooltips. You can find it here.
But you can also use other scripts or also the default bundled jQuery-UI.
Default WP scripts in the codex.
Also with this way no custom control is needed.
I created a new customizer section and add a setting and control to it:
//Add new section
$wp_customize->add_section( 'my_custom_section' , array(
    'title'      => __( 'My Section Name', 'textdomain' ),
) );

//Add new setting
$wp_customize->add_setting('text_setting', array(
    'default'        => 'Some default value',
) );
$wp_customize->add_control('text_setting', array(
    'label'   => __( 'My Setting', 'textdomain' ),
    'section' => 'my_custom_section',
    'type'    => 'text',
    'input_attrs' => array(
        'class' => 'has-tooltip', // add class to input element
        'data-tip' => 'My custom tooltip!', // add 'data-tip' attribute to input element
        'data-mode' => 'above', // add 'data-mode' attribute to input element
    ),
) );

Take a look at the 'input_attrs' parameters of add_control.
Iam adding 3 different attributes to the input field, that means that the markup of the input field will be:
<input class="has-tooltip" data-tip="My custom tooltip!" data-mode="above" value="Some default value" data-customize-setting-link="text_setting" type="text">

After that we enqueue the tooltip scripts and style to the customizer via customize_controls_enqueue_scripts:
function custom_customizer_enqueue() {

    //Enqueue Tipr JS and CSS
    wp_enqueue_script( 'tipr-js', plugins_url('/tipr/tipr.min.js', __FILE__) );
    wp_enqueue_style( 'tipr-css', plugins_url('/tipr/corso.css', __FILE__) );

    //Enqueue custom script to initialize the tooltips
    wp_enqueue_script( 'my-init-script', plugins_url('/customizer.js', __FILE__), '', false, true );

}
add_action( 'customize_controls_enqueue_scripts', 'custom_customizer_enqueue' );

Now we just need to initialize the tipr tooltip in the customizer.js file:
jQuery(document).ready(function($){
    $('.has-tooltip').tipr();
});

In the customizer this will look like this:

If it is not what you are looking for, feel no pressure to not accept it as an answer ;)


text:
Q: Why I can't get the link to have actual content through CURL PHP rather than to visit it manually? I am trying to extract data from a site but it seems that when I visit the site manually so I get the contents of the site but when I try to visit  the site through CURL and want to retrieve that data so instead I get something else and I am not getting the site content at all so what would be causing that to happen?
Here is the site Link as :
The Content which I am getting when used curl is something like this as follows :

{"ct":"F8WpFx0ojTx8r3KnG\/+3r1awNaWXVxuscAZUk\/UzDKHAKCPDFaTDfBXxQI6jCbvTOkRRdmORMzZGQffGW14m0Z2v53m0kldAyyMrByjAVX0k9UOla+VseAw6b+XRLZ4Jfd5EErjcjw+txG7nIPmGoP\/eC4lIZsNc63Zt5utbylIGF6x+Z+yneF1VqB65f5u\/IIds04HB6CZlpG9Ii5n0XrybFFN6yM4C1gWsf2TlFNQD3GHYeAbadQ3m4AOLc5X1zyOmz6Z3\/RIVu1Xy6KdA+tmLACgZ0iPchD1eAnhVn+2yNGA1aSAjb47FwqU2Tnpzp\/6Ha9ZLoFYTch3fgtLnfRm1ds3CmrIrgTsEMRGxtAJAkDSDTTTdNeS1\/V6UUTq\/si2KHeNv\/qOKWa\/Rmm7TU9kh7q0jQGY4QMBQUx7OQOqxwk6H7BhQd\/wOAT94qiW\/x+ika0V70oKE3\/EMGbngxexMoqpJ1Q8VEGJahCMl2aUg9Za4PmrqjEuTW5bK22tZeovKkOK\/3Tjdc2WFA+yVFLZXmxb89QOv6C1x79Cr4S+OnTebyd7PJxekvo0hqzcT6Le6e3WjUKNp1wBtL9QHCzlHWQmjnvvcKxOdsultuG7TP2I3sWlpROCRUm5kkEaH38kWiSuA6484rRoRbDLHkkdY1Ylt2zV0\/RX2gMmNQP3dSdlkdGZGkaXn6fjVkoSLtLfUiAyhtpc4wHG3zkwyE4aepQDR0xC+PFVOdiGHpKwhXUyUOCtHf9wU65thKjA6lvxW4D335jzCPz7lZ4P\/lrzMl9gU3moaoLQJs7HpN473ZxkgaibYc93YVUkHKHUId1KYxT1IJtMzFbg90drrnYDLxzIi8DYUuW+dmbrpV5WVyHcpng3RjWehetL62PheG5ToHX9Qfz3CpSrnbea\/BkXBML\/+UCR7purvYAdZup\/W8E107TYPHaXTzIbshtgEmJueJccUp7xDa+qE3VxDdsidLoUMXpX5IdPpgvfkgCrJn72ZPqPSq+R+ZrnAYeWWU+iBb31efMhziplzFkmlcLvh6yQwCpa8GrXFkNxuIiQKPJ2J6wPJcXxHuN0d9SfLyotFUe4AhPCPaJ\/QnTXB2UTvdsduM0blswoJbslAH51xuFjR89xho22hrnr08QVc68WhAIQKgru4MvXKsjYvoMC6YvTZCZ7xBVlsOu+snPDTUlNUp4+0twEfmtwaL5MHnV2sNY5\/TAFwmZfgnlAhnGc8+8DytuHHRyX2DIgsH45YBb4tAn0VpzUtZFdwDfJ7Dlwkq9oFoI\/HBhV5DsZ1MIlrx76A2Bqih3FQfjZRkEohQdV6YOPUUO7lRS+kC9Tyd4NI+q4HwQ2oYCMDhStGeOyMYq\/06E9a5MAMlxywQaKiS+FgyXk7sBO9bIGnlVHqjGDG0o7bQDtl6XjnAZ+su9tf5Dl9KkcG5cRfnUn5JTgg18jBkYJBMG5ygiDcfgrY4pPS56whxSJZ6aCjabJ9XvlDXLvIiXHcoBrfwPy9BEF75qXJflmvrNR4KyxOrU5zT3t\/v9RjdFapvxW1ZkQEWQsJJIHCOo+tYckPyIiVuASJzPw9aA22F8rF\/OhvMQ2k0QHy9\/95u+CjEJ8Jr0roF5lVHWxZS3CpzhgeuxPEouhO+CaatthxwQlcGJpff1DdCVkNWiie02Us6s8wq0NC7\/il04gYYcy7Q9b7Qqx4PqmrJRWKoIe7TsMHCYezrTGKKWDTNbPWAor3TnHO7sEqRbjE7p0LM7WF7KWOaxHVPR1uo\/v25fP638eU6+V7K4j4alQY7ut9PlMdQQVe1Wy7E\/xYv85LYXpPvOoaotHHydH6FFqrMq\/6Qe2KAaCvG6rusIYeTUyB379fzgulYQ1H8gkoE6axwiEv9+MqZG1jKLGNV2\/xfJ7ttTm+wUa2jR0R\/UE\/BO1YF7sFHtGey54KArO81\/Z0eksDuIkYSir+IxpP8pCpPewQPmQbD+UcSzr96qOLx\/SwQNVJ5JnQK0ozubBWLlFqktgpk7bIc\/PQ+afpGhFds3+tz4RtkjRmo4borOkLnb\/VdZ1LIE0zqb3YPahmO3UW8Cm3n6wSZgIj0aSZW0iiC4D\/NvPblBuiSYA45wiYx4cgv21boUxF7Q815n26K6+W3Se74EAngsh+qa4VNwJzTz5t78MI9QU\/5W03JLfh\/SUwCPyld60V0hvi610BSLHiadRRSPawp8xTRdXaQYY4wD46R\/xuN0fS22ycfvMI7x9qfdFiRpL+uUELAwS3mY+Xwu1TxhNdVTy1MCLclmLEZpCDwSx5gLFfbPcgTle\/ZuK4ljxpXsMWG1act2q3kP51Up3vwFARMx2VPnp29oMxgFPxyocc2AQLxSTFixtp3rBXlQEdyqHf25NL44jPiXHeXjoSX8w8KuVbSOOZFvUC4qZpssoB51HF7bAlrcUalKKL+DdDZwJjoYIh88YgwsG2MSlUHusVxDSJ76Lwf9oTPLEMU6VFlxcouvXrTNI21Gs8FqGMMVFh+gZcabzIKUM12bY0Uruuzt6MMuAi+zSiXOlc9LRPT581GLsfAc4q9dEhbyQPD\/LEm90nKEOJqmRhb\/gfqdth1eo0v6YHb+8yu7fEY6ZlpWlPA1Jh\/Zu+pPIKjJMQahCmHK883bObE3ahZLgehFQJ7wZCgmSzu9biNdOYGFK6kiwr7aSeJQSUoZdR5AjV2oUrk3WYPJ27wOES2raxnfTMwB1BTzDMGvGLdoD2PyjD5XU68uJimBWj5eVK7Ug1jH\/lv2OmobN7KPz3iXzH\/8RYV7gBVcFOHAKx4dZqyvshH0KOsVvInymD87\/ScG5Nz+\/HW7f1VmvvONq8xs4xjIRyeyj1CNCrM1f1Gffwku\/PM3KI171U+bs+AfSxuET7UXzczmz+8iR17I5T0fVdQRmej+14aC0\/2FU6+5Dx2ypK0KWSmlj5Z2gRT3ft1sxppzlc0IRtiDToXmnxaXqpdrfj+wNITSiBH\/mVTAGeWrfizjkA9hkmPlGZ2xY1PyD3Sjxs3kpwtepic5ucyl6wyTvK2gLho264iuSg+brSEzGuGb20GIVjVGcEAPQ3okbyc3isUXD1Z0UVG\/evse\/42iNko+yooyeyXtE2GzK0rxVgpnwQC\/TbJ7YegMZhj7kK0+OlX772ELCIaESc2pnZsvZTGELQ2nKefvJFATLl+NSJiYH9HF14s+c9mxzAOqpX\/gXHRzXRo2Wd9+Zk6PBN9KYREqBMUXzjNUM1fNnzlqfBUCsSQXMA\/xia+RyY0HG7GMLmguA\/aR8NsoiFhLakANK4Q0HQf+tf5NT3\/rTrMyz+nNsNPyWLoljcQrCWoTBjbkIKA\/+Rz6+z\/RJyghm3PNN2fYl5D4Y0LHKyjV6gAWbrm7Bt15YQs4Qb+tGcZwICvOvpjy1zHGqxl\/wVoKGjlDHSM67VuPV44nfaxNMwG5ar0BoLzkFkzEkhBPYo\/oRdJur67lOw6GVvUNJ8VULBNBz0XUo5CPXjFsEEcV5NB\/ZeUBt8eOcLRY4hv2bYHP3gy2uIRnTbzPw0fdwnkSu16wzbpUJe90jPLCtWQHXQTGF3SZdxxIqMyveWHHkqAORsEIsvyxTzUfgJ77u4xY\/C1qFtTBrTsy3ahh3oYb1cE93PAWvQUT7ycsQ0FUEcFqU6BjVflwcL2UtmeCdzuGKSWrMNhLB+TB5\/vFgk4qP20RQk+EN7YtXPiTu2SA7EqDaqCxwTbY8XoMRv6\/drlxRrMnu8Ogdr2CmNdceWN9DydNENOEKD8v2ne4uCr4wCu82dyvZkNe0jPiiPkDcQabx\/e9TnQlEf0hHlFM7Udee7nEZVuO4iTGPPwXPv+tTj2mOn2d4x0zvfUaSAy3tUNME2ukqrC4htykV+mWLlFlL\/fKDpkv4tnw+Odc2VWnCDvHEFVhePZJH8qfS3dgl17vp3uUqV15uBIABv2FF2CaSu2Hr7SJsret6M4IIGjGuZeVnJBPLMNZiA5DT5tradwKDR0Vkh4iGPssR3PoyMCq2+ZyzGBGy1rtk+6UCW6NjMIVIUGiwNiNNtPOEMf09XFN0+lOxYiyQwTJoH1Ipwq51\/yiuyG+V0Jn+xfUWjcXUaNwQ8QhScMnbcWd\/FMEeNtI1a+fvjJhwyEj206x6jZYX\/","s":"5e8c43f3cf7698f5"}

While the content which I am getting upon manual visit of the site is as follows as :

                    ExtraTorrent.cc > Popular Torrents > All Popular TV Torrents

All Popular TV Torrents (159 torrents)

                                    See also:

                                        Today Torrents

                                        Yesterday Torrents

                        1 2 3 4 > >>>

                    Torrents per page: <select name="torr_cat" onchange="Change(this);">
                        <option value="10">
                            10
                        </option>
                        <option value="25">
                            25
                        </option>
                        <option selected="selected" value="50">
                            50
                        </option>
                        <option value="100">
                            100
                        </option>
                    </select>

                                         TV torrents

                        Added

                        Size

                        S

                        L

                    Health

                            2

 Designated.Survivor.S01E11.HDTV.x264-LOL[ettv] 7.50 in Other, by

ettv

                    5h
                    241.45 MB
                    23624
                    20275

I am supposed to think that the following script which can be found at the end of the page does the decryption of the HTML data as the contents are being loaded encrypted so then the javascript decodes it back again.so how to reverse engineer to make it decrypt the code at anywhere??? cuz it' now just decrypting the code at the site only when visited manually through browser??

My CURL Code :
$url = "http://extratorrent.cc/view/popular/TV.html?page=1&srt=seeds&pp=50&order=desc";

 $ch = curl_init();

    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3");
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);

    $data = curl_exec($ch);
    curl_close($ch);

print_r($data);

A: You could probably use a headless browser like PhantomJS to programmatically retrieve the page contents while allowing the JavaScript to do its thing.

A: It could be that this website looks at the User-Agent HTTP-header. Try setting a different User-Agent, with the -A-parameter, like this:
curl -A "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3" http://yahoo.com

Or using PHP:
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3");

cURL does not execute JavaScript.
Update:
And it seems JavaScript does need to be executed to 'unpack' the content. So a headless browser as suggested by one of the other answers is more appropriate!
Addendum to klumme's answer
A code example to fetch the 'unpacked' version of a document using JavaScript in a PhantomJS environment:
(taken from: https://stackoverflow.com/a/12469284/694400)
var page = require('webpage').create();
page.open('http://google.com', function () {
  console.log(page.content);
  phantom.exit();
});

Or using http://jonnnnyw.github.io/php-phantomjs/ (which just uses the PhantomJS executable actually) (example taken from jonnnnyw's GitHub-page):
<?php

use JonnyW\PhantomJs\Client;

$client = Client::getInstance();

/**
 * @see JonnyW\PhantomJs\Http\Request
 **/
$request = $client->getMessageFactory()->createRequest('http://jonnyw.me', 'GET');

/**
 * @see JonnyW\PhantomJs\Http\Response
 **/
$response = $client->getMessageFactory()->createResponse();

// Send the request
$client->send($request, $response);

if($response->getStatus() === 200) {

    // Dump the requested page content
    echo $response->getContent();
}


text:
Q: C# - mciSendString, any solution to get the buffer (array)? I'm creating a reader / recorder using MCI through the DllImport of winmm.dll: mciSendString see here.
It works for many things, recording, playing, that's pretty cool. I would like to do some processing on it now but I did not find any proper way, method, trick to get the buffer during the recording (array)? (without saving to a WAV file first).
Any idea?
"Provide a code sample that shows which buffer you want to get. – JeffRSon yesterday"
=> I want to perform a fft on this buffer (would say a Single[] precision array), I already implemented a fft to do this. The fact is that I have no idea to get any direct information except that by save the record into a file and then process it.
=> I would like to perform a "real-time" audio processing, or a least figure out how to set an event to get every 4000 bytes the buffer containing the data (I guess there is one, but the MCI document is not quite clear enough for me)...
Edit II: I found a partial solution here (still with MCI): see here
and here: see here
I will try to put an answer as soon as possible, I do not agree with the idea, that, as long as you get some sources related to the topic the answer is provided in. I prefer to put my own code and showing that it works.


text:
Q: ngClass with multiple conditions false condition not working I'm trying to use [ngClass] with multiple conditions to change the caret of a open/close panel.
Currently the down arrow works flawlessly.
When I click the arrow and the condition changes to false, it changes the icon to a empty box and is not recognizing the correct class name.

The section4Click() changes isActive4 to true/false depending on what it was before.
When I inspect element of the box that shows up after I click the down caret (which works), I get the following class name...
fa-caret-up
instead of...
fa fa-caret-up pull-right
Anyone know why this occurs?  It seems like its doing half the job...
I've also tried just doing isActive4 and !isActive4, and the same happens.

A: It's hard to tell from looking at your code. But you can try this:

I would also recommend printing the values to see what you get:

{{ isActive4 === true }}

A: This will work.


text:
Q: Connect 90w charger in a laptop in which the charger was 130w Is there any permanent damage on the battery or another part if i used a 90w charger on a 130w laptop?
I need to do this, because my new 130w charger arrives only day 9 and I must continue using the laptop.
130W
INPUT: 100-240 V - 2.5 A
OUTPUT: 19.5 V - 6.7 A
90W
INPUT: 100-240 V - 1.5 A
OUTPUT: 19.5 V - 4.62 A

A: it shouldn't cause any damage if it is only used to charge your battery. However, if you plug it in and it is supplying power to your laptop and charging it at the same time, depending on the power consumption of your laptop, it might overload the charger and damage it if there isn't any protection in the charger.

A: First, it is not CHARGER, it is an AC-DC adapter.
Then, if the 90-W adapter is of the same brand as the original 130-W adapter, and all are for the same laptop brand and have interchangeable barrel plug, the laptop must be able to detect the adapter properties, and scale down its consumption, and likely limit internal charging rate and limit any turbo modes the laptop can execute. This is the normal case scenario.
Usually a normal laptop will report what kind of power adapter is connected, somewhere in general properties of "ACPI battery", or through some laptop-specific applet.
In worst case your "a laptop" will determine that the 90-W power of this adapter is insufficient and won't accept any charge. Your laptop will operate on internal battery and drain it totally, eventually.
From your comment it looks like you have the normal scenario, so you should be just fine.

A: The laptop might throw you an error and go in an super energy saving mode. That is, lowest cpu and gpu clock possible, which is very slow.

If it doesn't. you might go over the rating of the adapter when using the laptop to it's full potential, while charging the battery.
Charging when turned off is not a problem.

A: If the laptop power supply doesn't get too hot and is rated for the same voltage (which it is) then its ok use. If its starts to get too hot you may wish to remove it for a while and perhaps allow the charger to cool down to avoid potential damages.
Perhaps best to charge for smaller periods.


text:
Q: MSXML2.ServerXMLHTTP with SSL3? Using VBScript, want to talk to a HTTPS website but it fails with:

The client and server cannot
  communicate, because they do not
  possess a common algorithm

Found out this is because it needs to use SSL3. How can I tell it to use SSL v3?
Thanks

A: ServerXmlHTTP relies on WinHTTP, which supports SSLv3. See the WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 in the documentation. What version of MSXML are you using? You may want to try using one of the later versions. See the documentation on ProgID information.


text:
Q: Filtering distance matrix with R I converted a distance matrix to a two column data.frame, I want to filter out the "diagonals" and ">0" values, keeping identical objects.
I have a distance matrix like
mat<-c(0,0.5,0,0.5,0,0.3,0,0.3,0)
dim(mat)<-c(3,3)
rownames(mat)<-c("A","B","C")
colnames(mat)<-c("A","B","C")

I tried
df = as.data.table(mat)
df1 <- stack(df)
setDT(df1)
df1[, pp := colnames(df)]
setkey(df1, values)

Which gives
    values ind pp
1:    0.0   A  A
2:    0.0   A  C
3:    0.0   B  B
4:    0.0   C  A
5:    0.0   C  C
6:    0.3   B  C
7:    0.3   C  B
8:    0.5   A  B
9:    0.5   B  A

What I need:
    values ind pp
1:    0.0   A  C

A: Here is one way to do it :
mat <- c(1,0.5,0,0.5,1,0.3,0,0.3,1)
dim(mat) <- c(3,3)
rownames(mat) <- c("A","B","C")
colnames(mat) <- c("A","B","C")

cond <- mat == 0 & upper.tri(mat, FALSE)
pos <- which(cond, arr.ind = TRUE)
data.frame(values = mat[pos], ind = rownames(mat)[pos[,1]], pp = rownames(mat)[pos[,2]])

cond is a boolean matrix of your condition, values equals to 0, not diagnonal and upper triangular matrix to remove duplicated index of the symetric matrix.


text:
Q: JVM crashes when running Spring Boot web app My Spring boot 2.0.3 web app runs fine on Eclipse, with Java 1.8-1.4.1 and the embedded Tomcat.  But when I build my war file (using mvn package) and deploy it to linux  (uname -mrs gives Linux 4.9.77-31.58.amzn1.x86_64 x86_64), and run it (  same java version) on a external Tomcat 9.0.10, the JVM crashes when it connects to Oracle. The code where the crash occurs is:
@Repository
public class ReadFromDb {

    @Autowired
    private NamedParameterJdbcTemplate  jdbcTemplate;

    public TspsPatent readTspsPatent(TspsPatent tspsPatent)
    {
        System.out.println("DSxxx1");

        // Next line crashes
        List<TspsPatent> tspsPatents = jdbcTemplate.query("select 3 patent_sk from dual",
                (rs, rowNum) -> new TspsPatent (rs.getString("patent_sk")));

        System.out.println("DSxxx2");
        if (tspsPatents.size() == 0) {return null;}
        return tspsPatents.get(0);
    }
}

ie the DSxxx1 line is printed in catalina.out, but DSxxx2 isn't.
The full catalina.out is here:
catalina.out
If examine the jni connections using:
-Xcheck:jni

in setenv.sh, then in catalina.out I get:
catalina-jni.out
When the JVM crashes it creates a log file hs_err_pid40342.log, which is here:
hs_err_pid40342.log
This log file contains , on lines 508 - 518 a group of java/lang/ClassNotFoundException one of which is:
Event: 18.567 Thread 0x00007fe844620000 Exception <a 'java/lang/ClassNotFoundException': com/clarivate/dataviewer/model/TspsPatentCustomizer> (0x000000059e3dd210) thrown at [/HUDSON3/workspace/8-2-build-linux-amd64/jdk8u141/9370/hotspot/src/share/vm/classfile/systemDictionary.cpp, line 210]

I wrote the package:
com/clarivate/dataviewer/model
but there is no class called TspsPatentCustomizer
I have 2 classes with similar names in this package:
TspsPatent and TspsPatentNumberChange
but they are both just plain pojo's.
Why is the JVM looking for a class called TspsPatentCustomizer when this class has never existed?
The NamedParameterJdbcTemplate class handles the dB connections. It is in :
spring-jdbc-5.0.7.RELEASE.jar

and this jar is in my war file
My application.properties has:
logging.level.root=INFO
server.port=8090
server.servlet.path=/

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

spring.datasource.initialization-mode=always
spring.datasource.url=jdbc:oracle:oci:@myDataBase

spring.datasource.username=myUser
spring.datasource.password=myPassword

spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

My pom.xml file contains:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.clarivate</groupId>
<artifactId>dataviewer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>DataViewer</name>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <start-class>com.clarivate.dataviewer.DvMain</start-class>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- DS may need to remove for tomcat installation -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j2</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-slf4j-impl</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

   <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.1.0</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.apache.tomcat</groupId>
                <artifactId>tomcat-jdbc</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
    </dependency>

</dependencies>

   <!-- Required to find ojdbc6, because Oracle don't make it available to maven-->
    <repositories>
        <repository>
          <id>codelds</id>
          <url>https://code.lds.org/nexus/content/groups/main-repo</url>
        </repository>
      </repositories>

<build>
    <finalName>DataViewer</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <!--  <mainClass>com.clarivate.dataviewer.DvMain</mainClass>-->
                  <executable>true</executable>
            </configuration>
        </plugin>
    </plugins>

</build>

<description>TSPS data viewer</description>

One query is this dependency:
<dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.1.0</version>
</dependency>

My $ORACLE_HOME is not part of my war file, it's on linux at:
/oracle/app/oracle/product/11.2.0/client_1
which can't be changed.
So the version numbers are slightly different, does this make a difference and if so how do I change my maven version?
The strange TspsPatentConversion reference is a sideline, my main concern is to get the app running. Have I missed out any Oracle related settings or dependencies?
Any help or suggestions greatly appreciated

A: The answer was slightly mismatched version in the Oracle client see:
Oracle community
In my war file I had ojdbc6-11.2.0.1.0.jar, my Oracle client in $ORACLE_HOME on Linux was 11.2.0, these 2 versions are not identical and this incompatability caused the jvm crash. The solution was to remove ojdbc6-11.2.0.1.0.jar from the war to force  my app to use ojdbc6.jar in $ORACLE_HOME. To do this you add ojdbc6 scope "provided" to the pom.


text:
Q: Does Android provide a Zip File System Provider to use with java.nio.file? I am trying to use Java NIO's Zip File System on Android (API Level 30). I basically tried to implement the example found here.
The result is a java.nio.file.ProviderNotFoundException: Provider "jar" not found.
I know that it's possible that Android just does not offer this file system provider. Six years ago someone tried the same and failed because java.nio.file.Path was not a part of Android's implementation (which it now is!).
But since I did not find a definite answer during my research I still wonder whether I did something wrong. I tried comparing the Oracle docs to the Android docs but did not find anything suspicious which is missing on Android.
Is it possible to use Java NIO's Zip File System on Android? Or do we have keep using the old school way?


text:
Q: How to understand the two sentences about "Covariance" and "Contravariance"? I'm reading the first section of "Scala in depth", there are two sentences in the first section about "covariance" and "contrvariance":

Covariance (+T or ? extends T) is when a type can be coerced down the inheritance hierarchy.
Contravariance(-T or ? super T) is when a type can be coerced up the inheritance hierarchy.

I have read some documents about "Covariance" and "Contravariance", but I can't understand the word "coerced down" and "coerced up" here in this context.

A: [TOP / ABSTRACT]

Thing
  ↓
Animal
  ↓
Human
  ↓
Programmer
  ↓
Scala Dev

[BOTTOM / SPECIFIC]
Covariance: Accept T or lower.
I asked for a [+Human], I will accept any of these: [Human, Programmer, Scala Dev].
Contravariance: Accept T or higher.
I asked for a [-Human], I will accept any of these: [Thing, Animal, Human].
Inariance: Accept T and only T.
Coercion.
Coercing a type up/down the type hierarchy means checking that a type's super/sub type passes type constraints. For example, a covariant function needs a Human but we've only got a Programmer, that's ok, the compiler can coerce the Programmer into Human to satisfy typing constraints.

A: In this case coerced means the compiler can treat the type as a type further up/down the inheritance hierarchy.
Think of it as upcasting or downcasting except the compiler is doing it automatically, so it is not a cast (which could suggest that explicit code was required to perform it).

A: This response is taken from lectures given by Martin Odersky (the creator of Scala) on Coursera. We note:
S<:T means: S is a subtype of T, and
S>:T means: S is a supertype of T, or T is a subtype of S.

Say C[T] is a parameterized type and A, B are types such that A<:B.
In general there is three possible relationships between C[A] and C[B]:
C[A]<:C[B] ---------> C is covariant
C[A]>:C[B] ---------> C is contravariant
neither C[A] nor C[B] is a subtype of the other ---------> C is nonvariant

Scala lets you declare the variance of a type by annotating the type parameter:
class C[+A] { ... }  ---------> C is covariant
class C[-A] { ... } ----------> C is contravariant
class C[A]  { ... } ----------> C is nonvariant

Hope this might help!


text:
Q: Extreme UDP packet loss at 300Mbit (14%), but TCP > 800Mbit w/o retransmits I have a linux box I use as the iperf3 client, testing 2 identically equipped Windows 2012 R2 server boxes with Broadcom BCM5721, 1Gb adapters (2 ports, but only 1 used for the test). All machines are connected via a single 1Gb switch.
Testing UDP at e.g. 300Mbit
iperf3 -uZVc 192.168.30.161 -b300m -t5 --get-server-output -l8192

results in the loss of 14% of all packets sent (for the other server box with exact same hardware, but older NIC drivers, loss is around 2%), but loss occurs even at 50Mbit, albeit less severely. TCP performance using equivalent settings:
iperf3 -ZVc 192.168.30.161 -t5 --get-server-output -l8192

yields transmission speeds north of 800Mbit, with no reported retransmissions.
The server is always started up using the following options:
iperf3 -sB192.168.30.161

Who's to blame?

*

*The linux client box (hardware? drivers? settings?)?
Edit: I just ran the test from one Windows server box to the other and the UDP packet loss at 300Mbit was even higher, at 22%

*The windows server boxes (hardware? driver? settings?)?

*The (single) switch that connects all test machines?

*Cables?

Edit:
Now I tried the other direction: Windows -> Linux. Result: Packet loss always 0, while throughput maxes out at around

*

*840Mbit for -l8192, i.e. fragmented IP packets

*250Mbit for -l1472, unfragmented IP packets

I guess flow control caps throughput, and prevents packet loss. Especially the latter, unfragmented figure is nowhere near TCP throughput (unfragmented TCP yields similar figures to fragmented TCP), but it's an infinitely huge improvement over Linux -> Windows in terms of packet loss.
And how to find out?
I did follow the usual advice for driver settings on the server to maximize performance and tried to enable/disable/maximize/minimize/change

*

*Interrupt Moderation

*Flow Control

*Receive Buffers

*RSS

*Wake-on-LAN

All offload features are enabled.
Edit I also tried to enable/disable

*

*Ethernet@Wirespeed

*The various offload features

*Priority&VLAN

With similar loss rates.

The full output of a UDP run:
$ iperf3 -uZVc 192.168.30.161 -b300m -t5 --get-server-output -l8192
iperf 3.0.7
Linux mybox 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt4-3 (2015-02-03) x86_64 GNU/Linux
Time: Wed, 13 May 2015 13:10:39 GMT
Connecting to host 192.168.30.161, port 5201
      Cookie: mybox.1431522639.098587.3451f174
[  4] local 192.168.30.202 port 50851 connected to 192.168.30.161 port 5201
Starting Test: protocol: UDP, 1 streams, 8192 byte blocks, omitting 0 seconds, 5 second test
[ ID] Interval           Transfer     Bandwidth       Total Datagrams
[  4]   0.00-1.00   sec  33.3 MBytes   279 Mbits/sec  4262
[  4]   1.00-2.00   sec  35.8 MBytes   300 Mbits/sec  4577
[  4]   2.00-3.00   sec  35.8 MBytes   300 Mbits/sec  4578
[  4]   3.00-4.00   sec  35.8 MBytes   300 Mbits/sec  4578
[  4]   4.00-5.00   sec  35.8 MBytes   300 Mbits/sec  4577
- - - - - - - - - - - - - - - - - - - - - - - - -
Test Complete. Summary Results:
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  4]   0.00-5.00   sec   176 MBytes   296 Mbits/sec  0.053 ms  3216/22571 (14%)
[  4] Sent 22571 datagrams
CPU Utilization: local/sender 4.7% (0.4%u/4.3%s), remote/receiver 1.7% (0.8%u/0.9%s)

Server output:
-----------------------------------------------------------
Accepted connection from 192.168.30.202, port 44770
[  5] local 192.168.30.161 port 5201 connected to 192.168.30.202 port 50851
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  5]   0.00-1.01   sec  27.2 MBytes   226 Mbits/sec  0.043 ms  781/4261 (18%)
[  5]   1.01-2.01   sec  30.0 MBytes   252 Mbits/sec  0.058 ms  734/4577 (16%)
[  5]   2.01-3.01   sec  29.0 MBytes   243 Mbits/sec  0.045 ms  870/4578 (19%)
[  5]   3.01-4.01   sec  32.1 MBytes   269 Mbits/sec  0.037 ms  469/4579 (10%)
[  5]   4.01-5.01   sec  32.9 MBytes   276 Mbits/sec  0.053 ms  362/4576 (7.9%)

TCP run:
$ iperf3 -ZVc 192.168.30.161 -t5 --get-server-output -l8192
iperf 3.0.7
Linux mybox 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt4-3 (2015-02-03) x86_64 GNU/Linux
Time: Wed, 13 May 2015 13:13:53 GMT
Connecting to host 192.168.30.161, port 5201
      Cookie: mybox.1431522833.505583.4078fcc1
      TCP MSS: 1448 (default)
[  4] local 192.168.30.202 port 44782 connected to 192.168.30.161 port 5201
Starting Test: protocol: TCP, 1 streams, 8192 byte blocks, omitting 0 seconds, 5 second test
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   109 MBytes   910 Mbits/sec    0   91.9 KBytes
[  4]   1.00-2.00   sec  97.3 MBytes   816 Mbits/sec    0   91.9 KBytes
[  4]   2.00-3.00   sec  97.5 MBytes   818 Mbits/sec    0   91.9 KBytes
[  4]   3.00-4.00   sec  98.0 MBytes   822 Mbits/sec    0   91.9 KBytes
[  4]   4.00-5.00   sec  97.6 MBytes   819 Mbits/sec    0   91.9 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
Test Complete. Summary Results:
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-5.00   sec   499 MBytes   837 Mbits/sec    0             sender
[  4]   0.00-5.00   sec   498 MBytes   836 Mbits/sec                  receiver
CPU Utilization: local/sender 3.5% (0.5%u/3.0%s), remote/receiver 4.5% (2.0%u/2.5%s)

Server output:
-----------------------------------------------------------
Accepted connection from 192.168.30.202, port 44781
[  5] local 192.168.30.161 port 5201 connected to 192.168.30.202 port 44782
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-1.00   sec   105 MBytes   878 Mbits/sec
[  5]   1.00-2.00   sec  97.5 MBytes   818 Mbits/sec
[  5]   2.00-3.00   sec  97.6 MBytes   819 Mbits/sec
[  5]   3.00-4.00   sec  97.8 MBytes   820 Mbits/sec
[  5]   4.00-5.00   sec  97.7 MBytes   820 Mbits/sec

A: There is no problem.  This is normal and expected behaviour.
The reason for the packet loss is that UDP doesn't have any congestion control.  In tcp when congestion control algorithms kick in, it will tell the transmit end to slow down the sending in order to maximise throughput and minimise loss.
So this is entirely normal behaviour for UDP actually.  UDP doesn't guarantee delivery if the receive queue is overloaded and will drop packets.  If you want higher transmit rates for UDP you need to increase your receive buffer.
The -l or --len iperf option should do the trick.  And possibly the target bandwidth setting -b on the client.

-l, --len n[KM]
                set length read/write buffer to n (default 8 KB)

8KB?? that's a little on the small side when there is no congestion control.
e.g. on the server side.
~$ iperf -l 1M -U -s

This is what I get Linux to Linux
Client connecting to ostore, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.107 port 35399 connected with 192.168.0.10 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.10 GBytes   943 Mbits/sec

But for UDP using the default settings I get only
~$ iperf -u -c ostore
------------------------------------------------------------
Client connecting to ostore, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:  208 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.107 port 52898 connected with 192.168.0.10 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.25 MBytes  1.05 Mbits/sec
[  3] Sent 893 datagrams
[  3] Server Report:
[  3]  0.0-10.0 sec  1.25 MBytes  1.05 Mbits/sec   0.027 ms    0/  893 (0%)

WT?
After some experimentation I found I had to set both the length, and the bandwidth target.
~$ iperf -u -c ostore -l 8192 -b 1G
------------------------------------------------------------
Client connecting to ostore, UDP port 5001
Sending 8192 byte datagrams
UDP buffer size:  208 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.107 port 60237 connected with 192.168.0.10 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.12 GBytes   958 Mbits/sec
[  3] Sent 146243 datagrams
[  3] WARNING: did not receive ack of last datagram after 10 tries.

Server side:
~$ iperf -s -u -l 5M
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 5242880 byte datagrams
UDP buffer size:  224 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.10 port 5001 connected with 192.168.0.107 port 36448
[ ID] Interval       Transfer     Bandwidth        Jitter   Lost/Total Datagrams
[  3]  0.0-10.1 sec  1008 KBytes   819 Kbits/sec   0.018 ms    0/  126 (0%)
[  4] local 192.168.0.10 port 5001 connected with 192.168.0.107 port 60237
[  4]  0.0-10.0 sec  1.12 GBytes   958 Mbits/sec   0.078 ms    0/146242 (0%)
[  4]  0.0-10.0 sec  1 datagrams received out-of-order

To demonstrate packet loss with small buffers.  Which to be honest isn't as extreme as I was expecting.  Where is a reliable source for iperf3 I can test against between Linux/Windows?
~$ iperf -u -c ostore -l 1K -b 1G
------------------------------------------------------------
Client connecting to ostore, UDP port 5001
Sending 1024 byte datagrams
UDP buffer size:  208 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.107 port 45061 connected with 192.168.0.10 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   674 MBytes   565 Mbits/sec
[  3] Sent 689777 datagrams
[  3] Server Report:
[  3]  0.0-10.0 sec   670 MBytes   562 Mbits/sec   0.013 ms 3936/689776 (0.57%)
[  3]  0.0-10.0 sec  1 datagrams received out-of-order

Server side:
~$ iperf -s -u -l 1K
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1024 byte datagrams
UDP buffer size:  224 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.10 port 5001 connected with 192.168.0.107 port 45061
[ ID] Interval       Transfer     Bandwidth        Jitter   Lost/Total Datagrams
[  3]  0.0-10.0 sec   670 MBytes   562 Mbits/sec   0.013 ms 3936/689776 (0.57%)
[  3]  0.0-10.0 sec  1 datagrams received out-of-order

Have you also looked at the iperf3 github page readme?

Known Issues
UDP performance: Some problems have been noticed with iperf3 on the ESnet 100G testbed at high UDP rates (above 10Gbps). The symptom
  is that on any particular run of iperf3 the receiver reports a loss
  rate of about 20%, regardless of the -b option used on the client
  side. This problem appears not to be iperf3-specific, and may be due
  to the placement of the iperf3 process on a CPU and its relation to
  the inbound NIC. In some cases this problem can be mitigated by an
  appropriate use of the CPU affinity (-A) option. (Issue #55)

You're using a slower NIC but I wonder if it's related.

A: You completely missed out on the most obvious culprit - the adapters, and then the drivers (you state that using a different version drivers yields different results).
Try turning all offload capabilities off.


text:
Q: Can I validly expand the odds ratio analogously to the relationship between relative risk & the incidence rate ratio? I am involved in a nested Case-Control study that involves cohorts of cases and controls entering a program, with the outcome of failure by six months.  Cases and controls are individually matched on month / year of entry.  I have a lot (>10,000) of both.
A primary risk factor of interest is receiving a medical diagnosis (psychiatric, musculoskeletal, respiratory) after entry and before 6 months.  I have the person-time at risk for cases and controls to develop this risk factor, and can directly measure the incidence density of onset of risk factor in each cohort.
Now, for background:
The relative risk (RR) is defined as:
$$
\frac{\left(\frac{N_\text{Cases exposed}}{N_\text{population exposed}}\right)}{\left(\frac{N_\text{cases unexposed}}{N_\text{population unexposed}}\right)}.
$$
The incidence rate ratio (IRR)  is defined as:
$$
\frac{{\left(\frac{N_\text{Cases exposed}}{\text{Person-time exposed}}\right)}}{\left(\frac{N_\text{cases unexposed}}{\text{Person-time unexposed}}\right)}.
$$
The odds ratio (OR) is defined as:
$$
\frac{N_\text{cases exposed}*N_\text{controls unexposed}}{N_\text{controls exposed}*N_\text{cases unexposed}}.
$$
Under the rare disease assumption the OR approximates the RR.
My Questions:
Can I validly expand on the odds ratio using person-time:
$$
\frac{N_\text{cases exposed}*\text{Person-time unexposed}}{N_\text{controls exposed}*\text{Person-time exposed}}
$$

*

*to approximate the IRR?

*If not, why not, and what alternative would you suggest?

*If I can do this, would logistic regression would be appropriate?

*What other analytic approaches would you suggest?

A: This link provides a decent discussion of this: https://www.ctspedia.org/do/view/CTSpedia/SampleIncidence
Your answer is yes, conditionally. If you are using incidence density sampling (that is that controls are sampled from the risk set each time a case is diagnosed) which effectively matches cases and controls for time at risk, you are indeed estimating the incidence rate ratio. This article might also be of interest.
Yes, if you can do this, logistic regression would be appropriate.

A: I'm not sure that your approach would give a valid $IRR$ approximation. First, you would be "looking into the future" to determine the person-time at risk through this approach, since you know cases/controls. Generally speaking, looking into the future like that causes all sorts of problems. Second, there is a stipulation to the rare-disease assumption, and that is that every strata is rare (generally defined as 10%). That means each strata of month/year (along with any other variables you stratify by) would need to satisfy the assumption. Third, if the rare-disease assumption is met, then the $RR$ will approximate the $IRR$ following from $RR \le IRR \le OR$ when $RR \ge 1$.
Instead of the above approach, I would recommend revising the control selection procedure since you have a nested case-control study. Depending on how controls are selected, the case-control $OR$ (abbreviated $ccOR$ hereafter) can approximate different cohort measures. There are three approaches I will briefly detail; case-cohort, density, and cumulative control sampling. (note: case-cohort and density sampling require careful determination of what the start time is)
For case-cohort sampling, controls are sampled from baseline of the cohort study irrespective of later case status. Under this scenario $ccOR$ is the cohort $RR$
For density sampling (this is the one you will want to use), controls are selected at every time point when a case occurs, irrespective of later case status. As an example, consider case-1 occurs at $t=0.5$. From all individuals who are not cases at $t \le 5$, you randomly select a control from that group. In this way, the control selection mimics person-time in the cohort study, and $ccOR$ approximates the $IRR$
Lastly, is cumulative sampling where controls are selected at the final follow-up time, where controls cannot be cases. In this scenario, the $ccOR$ approximates the cohort $OR$, which under the rare disease assumption the cohort $OR$ approximates the cohort $RR$
Finally, based on the matching procedure you would need to use conditional logistic regression. However, I would forgo matching since it will not necessarily improve efficiency and you will still need to include the matching criteria in your regression model despite matching. I would skip matching and directly include month/year of entry in the conditional logistic model
Sources / Further Reading
Case-control selection:
Modern Epidemiology 3rd Edition pg 121-126
Matching in case-control:
Pearce 2016,
Mansournia 2018