ERR_NAME_NOT_RESOLVED when create virtual host for wordpress website

Question: I try to create virtual host on ubuntu server, but I get the message like image.
Comment: did you add in the host file the name of this domain and the localhost as ip? This error is just because no DNS (starting from hosts file) have a clue on what that domain stands for. Also have you configured a virtual host for this site in apache?
Comment: Possible duplicate of [WordPress Installation Failed](https://askubuntu.com/questions/941928/wordpress-installation-failed)
Comment: Your image doesn't appear. Could you try again? Also could you list your ubuntu version please?
Answer: First of all you must register dpacam.live. It is not registered yet! After that, you must connect [redirect] the domain (dpacam.live) with [to] your static IP address. You can do that through the administrative panel of your DNS provider. About next steps please check my answer here.
Edit: I remember that I have two comments related to the current question:

https://askubuntu.com/a/824178/566421
https://askubuntu.com/a/811416/566421


Implementation of setting multiple values/objects as valid/invalid

Question:
I have some kind of modal where I need to show dates (each one is representing an object). Every date can be set as valid or invalid. I'm wondering how the UI should look like. I'm thinking about two options:

radio buttons:
transfer list:
 I am not sure what is the best solution here. Of course I am open to any other ideas. Any advice form the UX point of view? :)
Answer: Analysing both examples what I can say from an user perspective to perform the action it will take:

2 clicks using radiobuttons. One click to select the radiobutton and one click to 'Save/Confirm' the action.
3 clicks using the second option. One click to select the element, one click to 'move' it to the other container. And finally a third click to 'Save/Confirm' the action.

Looking at this, I would go to the radiobutton option. However, I would like to suggest other options for the same problem.
First, I would like to know the number of elements that you could list. Are they many? If so, maybe a scroll bar would be a good option. Not the best to be used in a modal, but much better than a pagination, in my opinion.

Agreeing with Aaron about the use of switch buttons.

Using checkboxes. It's cleaner for representing two possible states that are exclusive.
Comment: I thought about checkboxes also. But I think that is no perfect idea because as default I want to treat every date as valid so with checkboxes I would need to set a label 'invalid' and then checkbox true/false. It can be misleading a little bit.
And answering to your question about the number of dates. There can be up to 40 dates here...
Answer: I like the radiobuttons much more! Its super simple and clear! Radiobuttons sadly aren't all that 'stylisch' so i would suggest making an on/off switch or something in that branch. I've put an example below, the way I would do it. Good luck!
Answer: Along with the already given answers, the switch would be a good for the situation. I'd like to contribute the following format as a way to style the selections. Selecting the valid dates assumes the non selected dates are invalid.


Combining dataframes so that column entries in left side equal column entries in right side and if not return null

Question: so I have two data frames to start with in pandas.
One data frame has more columns than the other
In the larger one, some of those columns contain identical rows as those in the smaller frame.
I want to combine the two data frames so that the rows in both frames that are equal result in one row, and the rows that are NOT equal lead to a null.
Here is a picture of what I mean:

Setup
df1 = pd.DataFrame(
    [[1, 3, 'alpha'], [2, 4, 'beta']], columns=['a', 'b', 'features'])
df2 = pd.DataFrame([[5, 6], [1, 3]], columns=['u', 'v'])

How could this be done in pandas? How about in SQL?
Answer: use merge
df1.merge(df2, left_on=['a', 'b'], right_on=['u', 'v'], how='left')

It basically is a left join
Comment: Nice answer (-:
Comment: Here is great post regarding this type of operation: https://pandas.pydata.org/pandas-docs/stable/merging.html


Cannot make a static reference to the non-static method invalidate() from the type View MainActivity.java

Question: I'm getting an error in eclipse stating: "Cannot make a static reference to the non-static method invalidate() from the type View   MainActivity.java" and I'm not sure exactly what I can do to resolve this. How can I either make invalidate() static or make View non-static?
SOURCE:
public class MainActivity extends Activity {
    private TextView textView;
    private Handler handler;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = (TextView) findViewById(R.id.TextView01);
        handler = new Handler();
    }

    private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
        @Override
        protected String doInBackground(String... urls) {
           // perform HTTP client operation
        }

        @Override
        protected void onPostExecute(final String title) {

            handler.post(new Runnable() {
                    @Override
                    public void run() {
                        textView.setText(title);
                        View.invalidate();
                    }
            });
        }
    }

    public void onClick(View view) {
        DownloadWebPageTask task = new DownloadWebPageTask();
        task.execute(new String[] { "http://www.google.com" });

    }
}

XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <Button
        android:id="@+id/readWebpage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:onClick="onClick"
        android:text="Load Webpage" >
    </Button>

    <TextView
        android:id="@+id/TextView01"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Placeholder" >
    </TextView>

</LinearLayout>

FIRST SOLUTION ATTEMPT:
    public class MainActivity extends Activity {
    private TextView textView;
   // String response;
    public interface Callback {
        void onModifiedTextView(String value);
    }
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = (TextView) findViewById(R.id.TextView01);
    }

    public void onModifiedTextView(final String title) {
        runOnUiThread(new Runnable() {
            public void run() {
                textView.setText(title);
                textView.invalidate(); // not even necessary
            }
        });
    }

    public class DownloadWebPageTask extends AsyncTask<String, Void, String> {
        public DownloadWebPageTask(MainActivity mainActivity) {
            this.callback = mainActivity;
        }

        private MainActivity callback;

        public DownloadWebPageTask() {
            // TODO Auto-generated constructor stub
        }

        public DownloadWebPageTask(TextView textView) {
            // TODO Auto-generated constructor stub
        }

        @Override
        protected String doInBackground(String... urls) {
            String response = "";

            for (String url : urls) {
                DefaultHttpClient client = new DefaultHttpClient();
                HttpGet httpGet = new HttpGet(url);
                try {
                     Document doc = Jsoup.connect("http://google.com")
                                .userAgent("Mozilla")
                                .get();
                    // get page title
                    String title = doc.title();
                    System.out.println("title : " + title);

                    // get all links
                    Elements links = doc.select("a[href]");
                    for (Element link : links) {

                        // get the value from href attribute
                        System.out.println("\nlink : " + link.attr("href"));
                        System.out.println("text : " + link.text());

                    }

                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
            callback.onModifiedTextView(response);
            return response;
        }

        @Override
        protected void onPostExecute(final String title) {
            callback.onModifiedTextView(title);
        }
    }

    public void onClick(View view) {

        DownloadWebPageTask task = new DownloadWebPageTask(this);
        task.execute(new String[] { "http://www.google.com" });
    }
}

Comment: Why are you creating a `DownloadWebPageTask` in the `doInBackground` method of `DownloadWebPageTask`? You should be creating it in the `onClick` method by passing `this`, which is a `Callback`. Make your `MainActivity` implement `Callback`.
Comment: I updated my source above - does everything look correct to you?
Comment: Yes it seems fine, but the `interface Callback` is very useless, you aren't using it, you're using `MainActivity` directly. It should work, but you are going to very high coupling between your classes. Something to consider avoiding in the future (or once it works).
Comment: No errors at this point... but The textview still does not display the  data from the title tag off google.com
Comment: Can you check that the `onModifiedTextView` is actually called? If it is, I would think there is something wrong with the `TextView`.
Comment: I set a breakpoint at -  public void onModifiedTextView(String title) { and it is never called.
Comment: That should mean that `onPostExecute` is never called. Try putting the line `callback.onModifiedTextView(title);` before `return response` in
`doInBackground` method.
Comment: I did - it results in: title cannot be resolved to a variable
Comment: I'm defining it as String title; and testing it now
Comment: Use `response` instead of `title`. They should be the same.
Comment: I just tried it (updated source above) and ended up with a force close error
Comment: Actually check and do the same as I do in the `onModifiedTextView` method in my edit to my answer. The update to UI elements needs to happen on the UI thread.
Comment: I updated my source above with your suggestion - it results in:
Cannot refer to a non-final variable title inside an inner class defined in a different method on the line:    textView.setText(title);
Comment: Oh god, I keep forgetting stuff. Just make `title` a `final` variable. `final String title`.
Comment: Ok - I did - no errors: it simply does not update the textview
Comment: Is the `TestView` even visible on the main view?
Comment: Yes - when I first launch the application it has the text placeholder then once the "load webpage" button is clicked it disappears (instead of being updated with the new data)
Comment: Any other suggestions? (it's still not working)
Comment: Try setting the textView visibility `setVisibility(VISIBLE)`
Comment: No, call that method on the `textView`. http://developer.android.com/reference/android/view/View.html#setVisibility(int)
Comment: textView.setVisibility(VISIBLE); results in "VISIBLE cannot be resolved to a variable"
Comment: I understand you're new to this, but you have to help yourself. `VISIBLE` is a constant from the `View` class, see [here](http://developer.android.com/reference/android/view/View.html#VISIBLE)
Comment: Ok. Should:   public void onClick(View view) {
     textview.setVisibility(VISIBLE); work?
Answer: View is a class. invalidate() is an instance method. You need to call it on an instance.
However, you need to perform UI modifications on the UI thread. I would make your Activity class implement a Callback interface with a method like
public interface Callback {
    void onModifiedTextView(String value);
}

Your class then implements it as
public void onModifiedTextView(final String title) {
    runOnUiThread(new Runnable() {
        public void run() {
            textView.setText(title);
            textView.invalidate(); // not even necessary
        }
    });
}

Then pass that to DownloadWebPageTask. In other words, create a constructor that accepts a Callback instance
public DownloadWebPageTask(Callback callback) {
    this.callback = callback;
}

private Callback callback;

...

protected void onPostExecute(final String title) {
    callback.onModifiedTextView(title);
}

UI modifications need to be done of the UI thread. That's why you need the runOnUiThread() method.
Comment: It's actually a suggestion from another issue I'm having... this might shed a bit more light on the situation:

http://stackoverflow.com/questions/18728984/cannot-parse-html-data-using-android-jsoup
Comment: @OverflowCustodian That suggestion is bad and mine is just as bad. Create a callback so that the activity calls the invalidate() on the `TextView`, not the `DownloadWebPageTask`.
Comment: Thanks! I attempted to implement it (I updated my source above) but i'm getting an NPE on the line: callback.onModifiedTextView(title);
Comment: @OverflowCustodian You forgot to pass the Activity instance in your constructor, `DownloadWebPageTask task = new DownloadWebPageTask(this);` otherwise the `callback` field is initialized to `null`. Get rid of your no-args constructor.
Comment: I'm afraid I'm not sure exactly what you mean by get rid my no-args constructor
Comment: @OverflowCustodian You have a `DownloadWebPageTask` constructor that doesn't have any parameters. Remove it, you don't need it. This way you also can't confuse which constructor to use as there is only one.
Answer: Have a look at the Java tutorial on Instance and Class Methods, where this is explained thoroughly.
Also, see Another "Cannot make static reference..." Question, Java Error: Cannot make a static reference to the non-static method.
Answer: invalidate() is a non static method in the VIEW class. you need to invoke that method after creating any instance of View or any of its child . In this case you can try invalidating the textView  or  root view of your activity.


is there a way to group by two variables which interchange in R

Question: Say I have:
df<-data.frame(ID=c(102, 102, 167,143,143,148,148 ),
               ID2=c(167, 167, 102,148,148,143,143 ),
               group=c(1,1,1,2,2,2,2))

   ID ID2 group
1 102 167     1
2 102 167     1
3 167 102     1
4 143 148     2
5 143 148     2
6 148 143     2
7 148 143     2

usually I can use add_group_indices to group by ID and ID2, but in this case I want to group by the values within them (i.e. 102 always attaches to 167 and vice versa), same with 143 and 148. I want to identify these groupings by that group variable.
Answer: We can create two new variables based on pmin/pmax to get the group_indices
library(dplyr)
df %>%
  mutate(ID_new = pmin(ID, ID2), ID2_new = pmax(ID, ID2)) %>%
  mutate(group = group_indices(., ID_new, ID2_new)) %>%
  select(-ends_with('new'))
#    ID ID2 group
#1 102 167     1
#2 102 167     1
#3 167 102     1
#4 143 148     2
#5 143 148     2
#6 148 143     2
#7 148 143     2

In the devel version of dplyr, we can use cur_group_id after creating a group
library(stringr)
df %>%
    group_by(grp = str_c(pmin(ID, ID2), pmax(ID, ID2))) %>%
    mutate(group = cur_group_id()) %>%
    ungroup %>%
    select(-grp)

Answer: Here is an alternative dplyr/purrr solution
df %>%
    mutate(group = as.integer(factor(map2_chr(
        ID, ID2, ~paste(sort(c(.x, .y)), collapse = "_")))))
#   ID ID2 group
#1 102 167     1
#2 102 167     1
#3 167 102     1
#4 143 148     2
#5 143 148     2
#6 148 143     2
#7 148 143     2

Explanation: We use map2_chr to loop through columns ID and ID2, sort and concatenate entries to create a unique key; conversion to factor to integer then gives the group index.
Answer: Here is a base R solution
df$group <- as.numeric(factor(apply(df, 1, function(v) toString(sort(v)))))

such that
> df
   ID ID2 group
1 102 167     1
2 102 167     1
3 167 102     1
4 143 148     2
5 143 148     2
6 148 143     2
7 148 143     2


Grid items overlapping with position sticky

Question: I am having an issue with sticky items in a grid container in firefox.
I have created a grid container with 8 items of 100px each:

item 1 is sticky to the left side
item 8 is sticky to the right side of the container

When I scroll to the right of the grid container:

In Chrome (80.0.3987.122) everything is okay. item 7 and 8 and next to each other (and initial scrollWidth of the container was 800px)
In Firefox (73.0.1 (64-bit) however, item 7 and 8 are overlapping (and initial scrollWidth of the container was 700px)

Anyone has any idea how to solve that in Firefox?
See the attached snippet.
Thanks!

setTimeout(() => {
  console.log('container width', document.querySelector('#container-grid').scrollWidth + 'px');
}, 100)
#container-grid {
  width: 500px;
  background: silver;
  height: 100px;
  overflow-x: scroll;
}

.items {
  display: grid;
  grid-template-columns: 100px 100px 100px 100px 100px 100px 100px 100px;
}

.sticky-left {
  position: sticky;
  left: 0;
}

.sticky-right {
  position: sticky;
  right: 0;
}

item 1

item 2

item 3

item 4

item 5

item 6

item 7

item 8

Answer: Adding an extra item with a very small width seems to avoid the bug on firefox

setTimeout(() => {
  console.log('container width', document.querySelector('#container-grid').scrollWidth + 'px');
}, 100)
#container-grid {
  width: 500px;
  background: silver;
  height: 100px;
  overflow-x: scroll;
}

.items {
  display: grid;
  grid-template-columns: 100px 100px 100px 100px 100px 100px 100px 100px 0.3px;
}
.items::after {
  content:"";
}

.sticky-left {
  position: sticky;
  left: 0;
}

.sticky-right {
  position: sticky;
  right: 0;
}

item 1

item 2

item 3

item 4

item 5

item 6

item 7

item 8

Answer: I don't think there's a fix for this problem.
You're mixing cutting edge features (position: sticky and grid items), so the browsers probably just need some time to sort out the proper behavior.
Note that position: sticky doesn't yet have complete browser support.
I would try building the layout in a standard block formatting context (display: block or inline-block).


Define collectionView per collectionView.tag

Question: I want to edit a cell in a collectionView, however because this is a nested collectionView there are multiple instances of it.
So say we have indexPath [0, 1] then the line of code below will set the cell as the first cell in each instance of the collectionView.
if let cell = self?.collectionView.cellForItem(at: indexPath) as? myCustomCell {

So anything i do here will be done to indexOath [0, 1] in all instances of collectionView.
You can put data into the cells in any instance of the collectionView with collectionView.tag:
cell.image.image = myArray[collectionView.tag][indexPath.item].image

But how can i define the collectionView as per its tag so i can singularly access that instance.  I cant figure out the syntax for some ideal situation like this:
let myCVInstance = self?.collectionView.tag(1)
if let cell = myCVInstance.cellForItem(at: indexPath) as? myCustomCell {

So that we only access the first instance of the nested collectionView.
Thanks for tips
Answer: Dumbest question ive asked..
Just need to check the tag number then if its the one you want do stuff:
if self?.collectionView.tag == myTag {
// do stuff
}


pub get to install non-dart dependancies similar to NPM, pip, etc?

Question: When looking at the pub spec format, i was curious if I can install other packages with pub get.  My goal is to either install Ruby or some other tools.  Even if i have command line access I could run python scripts or similar to get the code.
How does the dart package manager work in this sense?  Would it be simpler to just wrap dart with npm or similar and then do all the installs in NPM and follow it up with pub get?
I am curious what the rest of the community is doing for non-dart dependency injection.
Part of me was thinking the executables flag, but i was not not sure.
Answer: There's no support for this.
I have a command line tool called scripts that you can use to run additional commands, but it's not an official Dart tool or anything.
https://pub.dartlang.org/packages/scripts
Comment: yeah, I am similar.  I write CLI tools in python to manage environment personally, but i was hoping there was a built in tool to accomplish this.  Maybe this could be a solid enhancement to the pubspec file?  I think so.


Why can the row in a HTML table not be read from code behind (vb.net)?

Question: I have an HTML table and insert a row using Javascript via the onclick event of a button.

This is my code.
HTML:

        ShipTo
        CustName
        Alamat
        Dari
        Ke

Javascript:
function AddRow(Shipid,custname, grup, valid, alamat)
{
    var temp11;
    valid = "YES";
    for (var i = 0; i < arrloc.length; i++)
    {
        temp11 = arrloc[i];
        if (Shipid == temp11){ valid = "No" };
    }
    if (valid == "YES"){
        var table = document.getElementById("PopTable");
        var row = table.insertRow(1);
        var cell1 = row.insertCell(0);
        var cell2 = row.insertCell(1);
        var cell3 = row.insertCell(2);
        var cell4 = row.insertCell(3);
        var cell5 = row.insertCell(4);
        var cell6 = row.insertCell(5);
        if (grup == "")
        {
            var element2 = document.createElement("select");
            var option1 = document.createElement("option");
            option1.innerHTML = "DK";
            option1.value = "1";
            element2.add(option1, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LK";
            option2.value = "2";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LJ";
            option2.value = "3";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LD";
            option2.value = "4";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LP";
            option2.value = "5";
            element2.add(option2, null); }
        else if (grup == "DK")
        {
            var element2 = document.createElement("select");
            var option1 = document.createElement("option");
            option1.innerHTML = "LK";
            option1.value = "1";
            element2.add(option1, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LJ";
            option2.value = "2";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LD";
            option2.value = "3";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LP";
            option2.value = "4";
            element2.add(option2, null);}
        else if (grup == "LK")
        {
            var element2 = document.createElement("select");
            var option1 = document.createElement("option");
            option1.innerHTML = "DK";
            option1.value = "1";
            element2.add(option1, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LJ";
            option2.value = "2";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LD";
            option2.value = "3";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LP";
            option2.value = "4";
            element2.add(option2, null);}
        else if (grup == "LJ")
        {
            var element2 = document.createElement("select");
            var option1 = document.createElement("option");
            option1.innerHTML = "DK";
            option1.value = "1";
            element2.add(option1, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LK";
            option2.value = "2";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LD";
            option2.value = "3";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LP";
            option2.value = "4";
            element2.add(option2, null);}
        else if (grup == "LD")
        {
            var element2 = document.createElement("select");
            var option1 = document.createElement("option");
            option1.innerHTML = "DK";
            option1.value = "1";
            element2.add(option1, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LJ";
            option2.value = "2";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LK";
            option2.value = "3";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LP";
            option2.value = "4";
            element2.add(option2, null);}
        else if (grup == "LP")
        {
            var element2 = document.createElement("select");
            var option1 = document.createElement("option");
            option1.innerHTML = "DK";
            option1.value = "1";
            element2.add(option1, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LJ";
            option2.value = "2";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LD";
            option2.value = "3";
            element2.add(option2, null);
            var option2 = document.createElement("option");
            option2.innerHTML = "LK";
            option2.value = "4";
            element2.add(option2, null);}

        var element3 = document.createElement("input");
        element3.type = "checkbox";

        cell5.innerHTML = grup;
        cell4.innerHTML = alamat;
        cell6.appendChild(element2);
        cell2.innerHTML = Shipid;
        cell3.innerHTML = custname;
        cell1.appendChild(element3);

        arrloc.push(Shipid);}
    }

In the code-behind I try to get the contents of the table:
For i = 0 To PopTable.Rows.Count

    shipid = PopTable.Rows(1).Cells(1).InnerText
    'shipid = PopTable.Rows(1).Cells(1).innerhtml -- i also try this

    stringsql = "insert into cs_graph_ubah_dklk_log (shipid, dklk_awal, dklk_ubah, tgl_ubah, user_name, flag_proses, mid ) values ('" & shipid & "', '" & dklk_awal & "','" & dklk_ubah & "', sysdate , '" & user & "', 1, cs_graph_ubah_dklk_seq.nextval ) "
    dtsql = SPKOraConnGetDataWS.CreateDataSet(stringsql)

Next

I try to insert the HTML table rows via Javascript, but in VB.NET the result is that rows.count only has 1 row, and the row is only the header. Why is this happening? On the client-side, Javascript successfully adds rows to the table.
Why does the code-behind only read the header row? What is missing?
Please ask if you need more information from me.
Comment: I can't help but notice that you are using `Rows(1)` rather than `Rows(i)` in the VB. Anyway, you can't change HTML with Javascript just like that; the changes won't be passed back to the server on submit. Put the data also in the value or a hidden input or something.
Comment: okay i will find another ways .. thanks.
Comment: I see I had a typo, I meant the value _of_ a hidden input of course. ``, and using Javascript fill its value attribute. (Don't use Javascript to create a new `` from scratch and give t a `runat` attribute.)
Comment: follow this post: [How to post table rows, added via Javascript, to the server in ASP.NET?][1]

  [1]: http://stackoverflow.com/questions/7638272/how-to-post-table-rows-added-via-javascript-to-the-server-in-asp-net
Answer: the main reason can be fured out by post in the comment by  Amir Sherafatian:
when the website is created, all html is rendered  - the elements that have runat="server" attribute have 1:1 objects generated sever side during page execution.
Mind you, page execution ends when the html is written to the client and then  unless you store some data in Cache /Session/ ViewState/ cookies or any other persistent storage all the data regarding the rendered page is lost on the web server.
when client clicks submit the state of the page is recovered from those persistent storages and inputs that are on the webpage (which is basically a form hence every postback sends ALL inputs / selects / hidden fields back to the server) Imagine, that the user modifies your page via own java script using console - it simply cannot be accepted bu the server. the html means nothing to the web server on postbacks. The only mean of communication is via postback attributes which are mapped from form fields.
any other objects that are not input fields / hidden fields are rebuild from the aspx/html (on your server) somewhere along begining page execution.
Your code behind sees only header row because only header row is defined in the table from which the state of the page is built.
if you want to achieve your goal, you need to define at least one hidden field with runat=server"  to which you'd add / remove data as you add / remove rows with JavaScript. Its data will then be sent as a form postback argument to the server. There you can access it just like accessing a hidden field (as i explained the hidden field value will be rebuild from postback arguments), read the data, parse it and do whatever you want.
If you want a sample code ( ASP.Net C#),  please shout :)


Multiple dex files define Android studio error when trying to import Google Maps into Google Maps project

Question: I'm having some problems with the latest version of Android studio, combined with a Facebook SDK (used only for logging in) and the Google Maps API.
I've set up a project in Android studio with the Facebook integration which works fine. But a colleague of mine created the Google Maps part, which I am trying to copy/paste into my project. I've set up it like the Google documentation tells me to. So that's not the problem.
I am only having problems with the build.cradle from my project and build.cradle file of the facebook library if I'm correct. The error is:

UNEXPECTED TOP-LEVEL EXCEPTION:
  com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
      at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
      at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
      at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
      at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
      at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
      at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
      at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
      at com.android.dx.command.dexer.Main.run(Main.java:230)
      at com.android.dx.command.dexer.Main.main(Main.java:199)
      at com.android.dx.command.Main.main(Main.java:103)
FAILED
FAILURE: Build failed with an exception.

What went wrong:
  Execution failed for task ':app:dexDebug'.
  com.android.ide.common.internal.LoggedErrorException: Failed to run command:
  C:\Program Files\android-studio\sdk\build-tools\android-4.4.2\dx.bat --dex --output D:\Armindo\Android studioProjects\Project4\app\build\dex\debug D:\Armindo\Android studioProjects\Project4\app\build\classes\debug D:\Armindo\Android studioProjects\Project4\app\build\dependency-cache\debug D:\Armindo\Android studioProjects\Project4\app\build\pre-dexed\debug\android-support-v13-f0554868bfbee0fc4abfdc11fd962734ae0c6d5f.jar D:\Armindo\Android studioProjects\Project4\app\build\pre-dexed\debug\android-support-v4-16277ee73bd8328d9fa6b95c79f131076fa8f4be.jar D:\Armindo\Android studioProjects\Project4\app\build\pre-dexed\debug\bolts-714d8ee0ce6246f4109e078b8cded1f42aea8693.jar D:\Armindo\Android studioProjects\Project4\app\build\pre-dexed\debug\classes-291c4de37af2df287d3f0bde38005eb4ecb484f4.jar D:\Armindo\Android studioProjects\Project4\app\build\pre-dexed\debug\classes-82c2a48def34cb7b1f99f973c27e1ef8562b4177.jar D:\Armindo\Android studioProjects\Project4\app\build\pre-dexed\debug\support-v4-19.0.1-9046a2105fe8ed5a830061a0f501bb9eb2dfd6b0.jar
  Error Code:
  2
  Output:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at com.android.dx.command.dexer.Main.main(Main.java:199)
    at com.android.dx.command.Main.main(Main.java:103)

My dependencies in my cradle files are looking like this:
project's build.cradle: (Note that the libs from the main project are imported in a folder, e.g. libraries/facebook
)

dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile project(':libraries:facebook')
      compile 'com.google.android.gms:play-services:+'
  }

facebook's build.cradle:

dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile files('libs/bolts.jar')
      compile files('libs/android-support-v4.jar')
  }

The error only occurs when I add compile 'com.google.android.gms:play-services:+' to the project's cradle.
I've tried almost all the topics about this on here already and also tried to import the same lib in both cradle's. Any ideas?
Edit1:
Tried what Scott said. But I believe it is caused by it still having 2 times Android-support. Using the latest 3.14.1 Facebook SDK.

Edit2:
Changed depency of facebook's build cradle:
compile - Classpath for compiling the main sources.
+--- Project4.libraries:facebook:unspecified
    |    \--- com.android.support:support-v13:13.0.+ -> 13.0.0
    |         \--- com.android.support:support-v4:13.0.0 -> 19.0.1
    \--- com.google.android.gms:play-services:+ -> 4.4.52
         \--- com.android.support:support-v4:19.0.1
So it looks like Facebook is still using v4 underneath..
Edit3:
After the comment, changed the buildToolsVersion again to 19.0.1 on both versions. Also changed facebook.cradle compile 'com.android.support:support-v4:19.0.1'.
The terminal now provides me with this:
+--- Project4.libraries:facebook:unspecified
    |    \--- com.android.support:support-v4:19.0.1
    \--- com.google.android.gms:play-services:4.4.52
         \--- com.android.support:support-v4:19.0.1
So I guess that that is correct now, but I am still receiving the same error. This is the full error log (i think it's the same as before. But just checking the walls).

Last and final edit: Fixed!
my application build.cradle:
dependencies {
    compile 'com.google.android.gms:play-services:4.4.52'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('build/libs/Parse-1.5.1.jar')
    compile project(':libraries:facebook')
}
my facebook's lib build.cradle:
dependencies {
    compile 'com.google.android.gms:play-services:4.4.52'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('build/libs/Parse-1.5.1.jar')
}
To fix it I just had to import the play services into BOTH the libraries, derp
Comment: Hmm, it's using both the v4 support library and the v13 support library. That's the new cause of the problem.
Comment: Any Idea how to fix this? I ain't saying that it has to import it anywhere. Any place where I'm not looking right?
Comment: From the command line, at the project root directory, you can run the command `gradlew -p app dependencies` and it should give you a dependency tree that will shed more light on where things are coming from. Get everything on the same version of the support library; if your minSDK is 13 or later, you can use the v13 support library; if it's < 13, then use v4.
Comment: It does give me what's up top in my firstpost back after changing the facebook's cradle to `compile 'com.android.support:support-v13:13.0.+'` because I'm using `minSdkVersion 15.
Comment: I amended my answer, have a look at the edit. I still think you don't have everything on consistent version numbers.
Comment: I see that you have edited the post. I have tested, but it still results in a negative compile of the code. See my amended first post.
Answer: Facebook shouldn't be including the v4 support library that way -- if you include it as a regular jar instead of using its Maven coordinates, the build system isn't able to disambiguate multiple copies of it (it's picking it up through its dependency on Play Services as well).
In Facebook's build file, change its dependencies to:
dependencies {
    compile files('libs/bolts.jar')
    compile 'com.android.support:support-v4:19.0.+'
}

Note that the directive to auto-include all jars from the libs directory is removed as well.
I think you're using an old version of the Facebook SDK; in v3.14.1 of the SDK, at least, this is fixed up.
EDIT:
When I first answered the question, I had a statement to use support-v4:13.0.+ of the library since that's what Facebook specifies in v3.14.1 of the SDK. However, I amended it to use support-v4:19.0.+. In your case, you're including Play Services, which depends on a later version of the support library. Perhaps getting everything on the same version of the v4 support library may help.
Also note that your dependencies show that you have a dependency on the v13 support library as well. Please be aware that there are two version numbers here; the v4 support library has a number of releases (13.0.0, 18.0.0, 19.0.0, 19.0.1, and 19.1.0), and there's a v13 support library, which has those same set of releases as well. Make sure you don't confuse the two different version numbers.
Comment: Thanks, I tried that. But it is not working. I was already thinking that is was working that way, but just kept it this way to be sure. I am now getting the same error, even when I use the Maven coordinates.
Comment: Fixed it Scott, see my latest edit! Fixed it by just importing the play services into both build.cradle files `compile 'com.google.android.gms:play-services:4.4.52'`
Answer: Fixed it by just importing the play services into both build.cradle files compile com.google.android.gms:play-services:4.4.52


How to use Maxima's diff in function definition?

Question: I want to use a function's derivative in an other function. How should this be done in Maxima?
E.g:
f(x) := 2*x^4;
g(x) := diff(f(x),x)-8;

Now g(x) yields 8x^3-8 as expected, but g(0) gives an error, since diff(f(0),0) doesn't make sense. But then how should I properly define g?
Answer: Note that quote-quote is only understood when the code is parsed. That's OK if you only work in the interpreter but if you put stuff into scripts, it is possible to have unintended effects.
Another way to do this. It works the same in the interpreter and in a script.
define (g(x), diff (f(x), x) - 8);

See 'define'.
Answer: Michael's answer is good, but it does the differentiation everytime g(x) is called. (Also, normally you see it wrapped in a block statement to ensure that y is properly localized).
There is a way to force the RHS to evaluate at the time of definition
and with the general x.
The syntax is
(%i1) f(x) := 2*x^4;
                                            4
(%o1)                            f(x) := 2 x
(%i2) g(x) := ''(diff(f(x), x) - 8);
                                          3
(%o2)                          g(x) := 8 x  - 8
(%i3) g(0);
(%o3)                                 - 8

Compare with the block construct:
(%i4) h(x) := block([y], subst([y = x], diff(f(y), y) - 8));
(%o4)        h(x) := block([y], subst([y = x], diff(f(y), y) - 8))
(%i5) h(0);
(%o5)                                 - 8

Notice (%o4) which shows that the RHS is unevaluated.
Ref: http://www.math.utexas.edu/pipermail/maxima/2007/004706.html
Comment: @shinjin: In order for the `:=` operator to evaluate the RHS, the whole right hand side has to be wrapped with `''`. I don't think that it parses the RHS to look for quoting until it is called. Also note that instead of the `g(x) := ''(...)` you could use the equivalent `define(g(x), ...)`.
Comment: What makes g(x) := ''(diff(f(x), x) - 8); work, but doesn't h(x) := ''diff(f(x), x) - 8; ? In h the diff doesn't get evaluated.
Answer: Not sure if this is the simplest answer, but it seems to do the right thing for me
(%i) g(x) := subst([y = x], diff(f(y), y) - 8);

(%i) g(x);
         8 x^3 - 8
(%i) g(0);
         -8
(%i) g(1);
         0

Answer: g(X) := at(diff(f(x),x)-8,x=X);


req.params not giving anything in express nodejs

Question: I am trying to use the following code to get Id in the url. The problem is that req.params is not giving anything from the route.
app.get("/getAllParcels/:Id",(req,res) => {
        custId = req.params.Id;
        res.send('this is parcel with id:', custId);
});

Answer: The Express version of res.send(), only takes one argument so when you do this:
app.get("/getAllParcels/:Id",(req,res) => {
        custId = req.params.Id;
        res.send('this is parcel with id:', custId);
});

it's only going to do this (only paying attention to the first argument):
res.send('this is parcel with id:');

Instead, change your code to this:
app.get("/getAllParcels/:Id",(req,res) => {
    const custId = req.params.Id;
    res.send(`this is parcel with id: ${custId}`);
});

Note, this properly declares the variable custId using const and it uses a template string (with backquotes) to efficiently incorporate the custId.
Comment: @syedhaseebahmad - Glad it worked for you.  Since it looks like you're new here, you can indicate to the community here that your question has been answered by clicking the checkmark to the left of whatever answer helped you the most or was the most comprehensive or clearest.  That will also earn you a few reputation points for following that part of the process.
Answer: Use this:

  res.send(`this is parcel with id: ${custId})`)

or this,

  res.json({
    message: `this is parcel with id: ${custId})`,
  });

You need to remember that res.send accepts a string. You can't use comma like that. If you want to contact your dynamic value with your string you can use + or template string.
Answer: First of all, you are missing Identifiers like let and const. Another thing, you have to now send the data with status.
Solution:

   app.get("/getAllParcels/:Id", (req, res) => {
  const custId = req.params.Id;
  res.send(`this is parcel with id: ${custId}`);
});
Comment: Your comments about `res.send()` being deprecated or requiring the status are just wrong.  This has nothing to do with nodejs version 18 as these are Express features.
Comment: Hey, My bad, FIxed it
Comment: Your comments about Express deprecating `res.send()` without status are still wrong.  It's all shown right [here](http://expressjs.com/en/4x/api.html#res.send) in the Express doc.
Comment: `res.send()` is not deprecated in express. In fact you're still calling it in your example! You're just chaining it off another method, which makes no difference and the `res.status()` is unnecessary anyway as the 200 status would be the default.


Weak convergence of a power nonlinearity

Question: Consider the following nonlinear partial differential equations, the "semilinear heat equation" : $$\partial _t u -\Delta u + u^p=0,$$ where $p \geqslant 2$ is an integer.
A standard way for obtaining some weak solutions is to approximate this equation, construct strong solutions, prove some energy bounds and then pass to the limit. Usually the nonlinear term is the more difficult and one often prove some strong compactness result which I want to avoid.
To be precise, let $(f_n)$ be a sequence of real-valued functions, and assume that this sequence is bounded in the space $L^2(\mathbb{R}^3)$. Then up to an extraction we can assume that $f_n \rightharpoonup f$ an $L^2$ function. Obviously this does not implies $f_n^p \rightharpoonup f^p$. In order to prove statements as $\int f_n^p \phi \rightarrow \int f^p\phi$, one often prove that $f_n \rightarrow f$ in $L^p$.
I find it quite unnecessary, so here is my question :

Let $(f_n)_{n \geqslant 0}$ be a bounded sequence of measurable functions over a space $L^2$ so that without loss of generality $f_n \rightharpoonup f$. What are the requirements to ensure that $f_n^p \rightharpoonup f^p$ in $L^2$-weak ?

I am looking for theorems that give some "minimal requirements", in the spirit of the Vitali's convergence theorem that gives a characteristion of sequences of functions $f_n \to f$ a.e for the convergence in $L^p$, but instead I want weak limits.
Thank you,
Answer: Such nonlinear functions are not weak continuous. Only $p=1$ works. Just take oscillating sequences $f_n=sign(\sin(\pi n x))+1$ on $(0,1)$, then $f\rightharpoonup 1$
in every $L^p(0,1)$, $p<\infty$. But $f_n^p\rightharpoonup 2^{p-1}$.
I am not aware of any assuptions that do not bring some compactness or strong convergence of $(f_n)$ like $f_n$ could be monotonically increasing sequence, or bounded in some $W^{1,p}$.
If you are dealing with nonlinear monotone equations, there is the so-called Minty trick, which cleverly avoid passing to the weak limit in nonlinear terms.
Comment: I am fully aware of such counter example, and this is why I am looking for nice caraterization that avoid strong compactness in $L^p$, or at least requires the minimal compactness.
Thanks for the minty trick I saw it one time but didn't remember !


Objective C - Split string into array

Question: How would I do this? I'm new to Objective-C but I can't find anything that would help me do this.
NSArray *splitLine = [currentLine componentsSeparatedByString:@":%@",notNumber];

Where notNumber is a string that represents anything that isn't a number. So I want to separate a string where there are colons separated by strings that aren't numbers. (I want to avoid splitting at times i.e. 3:00pm, but split at iCal parameters like DESCRIPTION: and LOCATION:.)
Comment: Does the colon after location and description have a space after it?
Comment: Unfortunately no! It will always be a string in the alphabet.
Comment: Okay. Because then you could have done @": " --- Can the time be any time, or is it always going to be on the hour?
Comment: The data varies. Sometimes it'll say "3pm" which is great, but other times it will say "3:00pm"
Comment: Ok. you could do something like (this is not code, just logic) if the number before the color's int value is not zero, because i believe letters have an int value of zero, and this may work because its never going to be zero o'clock
Answer: You can do this in several steps, like this. I have not compiled this code, but it should at least give you an idea of what to do.
1) Create a regex object to match your separators:
NSString *regexString = @"DESCRIPTION:\s|LOCATION:\s"; // or whatever makes sense for your scenario
NSRegularExpression *regex =
[NSRegularExpression regularExpressionWithPattern:regexString
                                          options:NSRegularExpressionCaseInsensitive
                                            error:nil];

2) Replace all the different separators matching your regex with just one separator:
NSRange range = NSMakeRange(0, string.length);
NSString *string2 = [regex stringByReplacingMatchesInString:string
                                                     options:0
                                                       range:range
                                                withTemplate:@"SEPARATOR"];

3) Split the string!
NSArray *elements = [string2 componentsSeparatedByString:@"SEPARATOR"];

Answer: Shortest solution for splitting string.
NSString *str = @"Please split me to form array of words";
NSArray *wordsArray  = [str componentsSeparatedByString:@" "];

Answer: You can use regular expressions!
Using the pattern (I believe this is the core of your question):
pattern = @"(?<=[^0-9]):(?=[^0-9])"

This pattern will only match ':' symbols not surrounded by numbers.
Then replace with a dummy value that won't show in your data
dummy = @"NEVERSEETHIS"

NSRegularExpressions *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:nil];
NSRange range = NSMakeRange(0, [string length])
NSString *modified= [regex replaceMatchesInString:yourString options:0 range:range withTemplate:dummy];

and finally, split
return [modified componentsSeparatedByString:dummy];

Objective C - Split string into array


Is C# a=b=c; equal to b=c; a=c; whereas C++ is b=c; a=b;?

Question: In another words, C# operator= will return the right value, isn't it? But C++ conventionally returns left value, right?
Comment: I avoid this syntax precisely for this reason - it should be immediately obvious what your code does.
Comment: @Kragen: 1) It doesn't happen like that.  2) Even it did, what different behavior could *possibly* result?
Comment: @Kirk What if A, B and C are **all** proprties and what if they are also different types with implictly overided casts - what getters / setters are called and what casts are invoked?  I'm not saying that you can't work it out (or even that its difficult), just that *two simple assignments shouldn't involve this sort of mental overhead*.  There are already 4 different answers to this question (one of which is wrong!)
Comment: @Kirk Dunno, but `a = c; b = c;` (when written on two lines) avoids even having to think about *any* possible ambiguity *and* makes it obvious that there are two assigments.
Comment: @Kragen, presumably two `=` suggests two assignments?  (and for what it's worth, the comparison should be with `b = c; a = b`.
Answer: No, the result of the assignment expression is the value assigned, not the expression on the right. So consider this:
    byte a;
    int b;
    byte c = 10;

    a = b = c; // Fails to compile

This fails to compile because although b = c is valid, it's an expression of type int, which then can't be assigned to a which is of type byte.
From the C# 4 language spec, section 7.17.1:

The result of a simple assignment expression is the value assigned to the left operand. The result has the same type as the left operand and is always classified as a value.

EDIT: Here's proof that it's the value which was assigned to b which is used, not the value of c:
using System;

class ACType
{
    public int Value { get; set; }

    public static implicit operator BType(ACType ac)
    {
        return new BType { Value = ac.Value / 2 };
    }
}

class BType
{
    public int Value { get; set; }

    public static implicit operator ACType(BType b)
    {
        return new ACType { Value = b.Value / 2 };
    }
}

class Test
{
    static void Main()
    {
        ACType a, c;
        BType b;

        c = new ACType { Value = 100 };
        a = b = c;

        Console.WriteLine(a.Value); // Prints 25
    }
}

The a = b = c; statement is equivalent to:
BType tmp = c;
b = tmp;
a = tmp;

So the value of b isn't read afterwards (it's not equivalent to b = c; a = b;) - so if b were actually a property, the behaviour of the property would be irrelevant other than for side-effects. It's whatever value was used in the assignment to b which is also used in the assignment to a.
In this case, the assignment to b requires a conversion from ACType to BType which creates a BType with Value=50. The assignment to a then requires a conversion from BType to ACType, which creates an ACType with Value=25.
Comment: ...although `a = b` is valid... You mean `b = a`?
Comment: @Hemant: Sorry, it was broken. Fixed - and reversed to make it more like the original.
Comment: The interesting thing about this is the overall value of the expression `a = b = c` may look nothing at all like the value of *any* of the variables here, which may not at all be equal. Part of this I knew, part of this you helped me learn, and most of it I hope to never ever really have to consider in my coding activities.
Comment: @Anthony: It's funny how this was today, and yesterday had another compound assignment question which wasn't as simple as it sounded: http://stackoverflow.com/questions/5577140/why-does-swapping-values-with-xor-fail-when-using-this-compound-form
Comment: I wonder why it is so complex, and the result of the assignment is not the left operand. Such behaviour would be "symmetric" to function chain calling.
Comment: @macias: I don't think it would be terribly obvious for the property to be read again, to be honest. I would avoid code like this to start with though :)
Comment: @Jon Skeet, I rephrase -- for me such equivalent is (seriously) obvious -- b = c; a = b; (I refer to your last example). Why this is obvious for me? Because methods work this way, the last result is passed to next call as "this". After reading your explanation (thank you!) I simply gave up using assignment chaining, because of the principle of least surprise.
Answer: No, it works the same in both languagues:  a = b = c; works like this: a = (b = c);.  The assignment operator works right-to-left, and the value returned is the result of the assignment, which is the left-hand-side.  So conceptually, a = b = c; is the same as:  b = c; a = b;.
For C#, the assignment operators and the conditional operator (?:) are right-associative, meaning that operations are performed from right to left. For example, x = y = z is evaluated as x = (y = z).  (Source)
Same for C++ (Source)
Comment: I know the right operator= will be evaluated at first definitely in either C# or C++. My question actually is, for a = (b = c), which value will be used assign to 'a'? 'b' or 'c'?
Comment: @Bob L: The value that was used to assign to `b`. I'm coming up with an example now.
Comment: you are contradicting yourself. In C# b will NOT be  assigned to a! And you said it works the same in both languages (it is not true). "a = b = c; is the same as: b = c; a = b;" In C# it is not.
Answer: A useful tidbit about the semantics of a = b = c is that a will indeed receive the same value (normally c*) that was assigned to b, the present value of b is not a factor.
Yes, that could be considered surprising. Consider the example:
class Foo
{
    private int _bar;
    public int Bar
    {
        get { return _bar; }
        set { _bar = value + 1; }
    }
}

...

Foo foo = new Foo();
int a, c;
c = 4;

a = foo.Bar = c; // is 'a' 4 or 5?

If the value passed through foo.Bar and the mutation follows into a, then a would be 5. However, that is not what happens. a and foo.Bar receive the same value, a does not receive the mutation from foo.Bar. It's not directly your question, but it's interesting enough to post considering some of the comments.

*Jon Skeet had an interesting observation about types that are implicitly convertible to one another but have data loss/modification in the conversion. In this case, the value may very well not be the original value of c, but the converted value, which may be different.
Comment: @Bob, consider the text posted in Jon Skeet's answer. *"The result of a simple assignment expression is the value **assigned** to the left operand."* It's not the value *of* the left operand, as that could have already mutated (as demonstrated above) and produce an unexpected result.
Comment: It won't always be the same value as `c`. Imagine two types which have implicit conversions to each other, but lose data, where `a` and `c` are one type, and `b` is the other type. The conversion from the type of `c` to the type of `b` would be performed, then the conversion back to the type of `a` would be performed.
Comment: @Jon... wow, yeah, just tested that. Might have a nightmare about this one.
Comment: Yes. I encountered something similar as your example though I used Indexer. The result of program doubts me so I posted this question. I am still learning C#, now I believe C#'s property and indexer are exceptions of returning left value of operator= rule...
Comment: @Jon, interesting point. I'll indeed test that scenario where a data loss occurs prior to the assignment.
Comment: @Anthony: I've just posted a short but complete program in my answer. Is that roughly what you tested? Hopefully my explanation at the bottom covers your property part too.
Comment: @Jon, yes, that's basically what I did, using classes *and* structs to cover my bases.


Variant of defining a namespace and the meaning of __visibility__

Question: Today, while seeing preprocessed code of <iostream> (g++ 4.4.1), I saw a line which is quite unusual for me syntactically.
namespace std __attribute__ ((__visibility__ ("default"))) {
// ...
}

I have questions for that particular line:

What's __attribute__ and what it's
doing after std ? (new syntax !)
How the double braces are coming ((
... )) in place and is it a new syntax ?
What's __visibility__ and what is
it setting as "default" ?
Answer: __attribute__ is a gcc-specific language extension.  It lets you alter the declaration of a function, namespace, or other entity in ways that aren't directly supported by the standard C++ language.
C++0x adds language support for attributes, though the syntax is different and most attributes are still implementation-specific.
Answer: It is a compiler-specific feature used by newer versions of gcc to control which symbols are exported from a shared object.  See http://gcc.gnu.org/wiki/Visibility for details.
Answer: As for your question (2)...
The double-parens syntax for __attribute__ is to let you #define it away on non-GCC compilers:
#ifndef __GNUC__
#define __attribute__(x)
#endif

The double-parens allow the stuff inside to be complicated (e.g., a comma-separated sequence of attributes) and still get picked up by the simple macro.
Comment: Did *not* know that!  It seems obvious now.  Well, that's all three answers then.
Comment: @andrewdski: Yup, I already voted the other two up.  Teamwork.  :-)


What's means SPI on Spring-Cache CacheManager

Question: <code>package org.springframework.cache;

/**
 * Spring's central cache manager SPI.
 * Allows for retrieving named {@link Cache} regions.
 *
 * @author Costin Leau
 * @since 3.1
 */
public interface CacheManager { ... }
</code>
what is means by SPI?
is that "https://en.wikipedia.org/wiki/Serial_Peripheral_Interface"?
Comment: Does this answer your question? [What is the full form of "SPI" in the Spring 3 type conversion system?](https://stackoverflow.com/questions/6898452/what-is-the-full-form-of-spi-in-the-spring-3-type-conversion-system)
Answer: SPI =: Service Provider Interface
from wikipedia:

Service Provider Interface (SPI) is an API intended to be implemented
  or extended by a third party. It can be used to enable framework
  extension and replaceable components.


Find frequency of array strings in a file sized string, using Python

Question: I've looked at a lot of answers, which are aimed at finding the occurrence of every word in the file, or big string or even arrays. but I don't want to do this, nor are my strings coming from a text file.
Given a big string, like a file sized string how would you count the frequency of each array element in the big string - including spaces within words?
def calculate_commonness(context, links):
    c = Counter()
    content = context.translate(string.maketrans("",""), string.punctuation).split(None)

    for word in content:
        if word in links:
            c[word] += 1
    print c

context = "It was November. Although it was November November November Passage not yet late, the sky was dark when I turned into Laundress Passage. Father had finished for the day, switched off the shop lights and closed the shutters; but so I would not come home to darkness he had left on the light over the stairs to the flat. Through the glass in the door it cast a foolscap rectangle of paleness onto the wet pavement, and it was while I was standing in that rectangle, about to turn my key in the door, that I first saw the letter. Another white rectangle, it was on the fifth step from the bottom, where I couldn\'t miss it."
links = ['November', 'Laundress', 'Passage', 'Father had']

# My output should look (something) like this:
# November = 4
# Laundress = 1
# Passage = 2
# Father had = 1

At the moment it's finding November, Laundress and Passage but not 'Father had'. I need to be able to find string elements with spaces. I know this is because I'm splitting the context by " " which is returning "Father" "had", so how do I split context appropriately or do I use this with regex findall?
EDIT:
Using context as a big string I have:
    for l in links:
        c[l] = context.lower().count(l)
    print c

returns:
Counter({'Laundress': 0, 'November': 0, 'Father had': 0, 'Passage': 0})

Comment: What if some of the links are substrings of (concatenation of) others? E.g. `links = ['day', 'mayday', 'today']`.
Comment: Then I shouldn't be counting them. So in that case day should be returned as once. It should match links exactly.
Comment: Maybe I gave a wrong example, what about `links = ['November', 'was November']`? Is the result `{November: 4, was November: 2}` or `{November: 2, was November: 2}`?
Comment: In that case it would be the second set of results. November: 2, was November 2.
This is counting how many times a term, being one word or multiple is being used as a link to somewhere specific in a document.
Answer: Have you tried
context.lower()
counts = {word: context.count(word)
          for word in links}

Note: leave context as a string.
Comment: Yes, because you still have upper case in your links. If case is important, remove `lower()`, otherwise make your links all lower case.
Comment: This is just test strings for a bigger project, so doing that means I would have to go through my database, and manually type each link that has multiple words.
Comment: No, you don't have to do it manually, that was just an example. I've updated my answer for a fuller demo.
Comment: I managed to get that to work better than what I had! But for every term in link it's returning 0. I've added an edit.
Comment: According to the comments under the OP, this works, but counts the substrings multiple times, which is not an expected result.
Comment: Yes, but they've accepted it! Not sure we yet have enough context to give a really good answer
Answer: Try this...
>>> import re
>>> for word in links:
    print word+ '=' + str(len([w.start() for w in re.finditer(word, context)]))

November=4
Laundress=1
Passage=2
Father had=1
>>>

you can use ignore case also
 for word in links:
         print word+ '=' + str(len([w.start() for w in re.finditer(word, context, re.IGNORECASE)]))

Answer: This is a implementation using regex findall.
import re
links = ['November', 'Laundress', 'Passage', 'Father had']
# Create a big regex catching all the links
# Something like: "(November)|(Laundress)|(Passage)|(Father had)"
regex = "|".join(map(lambda x: "(" + x + ")", links))

context = "It was November. Although it was November November November Passage not yet late, the sky was dark when I turned into Laundress Passage. Father had finished for the day, switched off the shop lights and closed the shutters; but so I would not come home to darkness he had left on the light over the stairs to the flat. Through the glass in the door it cast a foolscap rectangle of paleness onto the wet pavement, and it was while I was standing in that rectangle, about to turn my key in the door, that I first saw the letter. Another white rectangle, it was on the fifth step from the bottom, where I couldn\'t miss it."

result = re.findall(regex, context)
# Result here is:
# [('November', '', '', ''), ('November', '', '', ''), ('November', '', '', ''), ('November', '', '', ''), ('', '', 'Passage', ''), ('', 'Laundress', '', ''), ('', '', 'Passage', ''), ('', '', '', 'Father had')]

# Now we count regex matches
counts = [0] * len(links)
for x in result:
    for i in range(len(links)):
        if not x[i] == "":
             counts[i] += 1


odp net oracle parameter constructor with boolean object

Question: I am using the odp OracleParameter constructor:
public OracleParameter(string parameterName, object obj);

When i pass different types as objects like int or DateTime it works fine.
However when i use bool like this:
new OracleParameter("paramName", true)

it crashes with a "System.ArgumentException".
Why does this not work with bool values?
Are there known types where this does not work?
I am using Oracle ManagedDataAccess.dll v188.8.131.52
Comment: what you do in your constructor with the input values?
Comment: It is not my own constructor. It is from odp .NET [link](https://docs.oracle.com/database/121/ODPNT/OracleParameterClass.htm#i1011308)
Answer: Oracle does not support bool values as a DataType for it's columns. PL/SQL is another matter.
You first have to check the datatype of your bool field/parameter in Oracle.
If it's something like NUMBER use the following code:
new OracleParameter("paramName", OracleDbType.Int16, 1);

Here the third paremeter is the size of the NUMBER value.
As you mentionned in your comments, you can use this constructor:
public OracleParameter(string parameterName, OracleDbType type, object obj,
   ParameterDirection direction);

Which allows you to skip defining the size.

Otherwise I would convert it to NUMBER since the OracleDbType enum does not contain a value for BOOLEAN.
I always specify the OracleDbType when creating a new Oracle parameter. It makes things more explicit and prevent errors of the sort.
Comment: Thank you that was one part of the information I needed. Where do I get these information's other than stumbling upon them? Are there other types where this does not work?
Comment: @DanF As for other types where this does not work, I can't think of any right now. It's a good practice to specify the type for all parameters by the way and besides the bool type most are pretty self explanatory. If this solved your problem, please mark the answer as accepted. Thanks.
Comment: You posted the wrong constructor. The one needed ist this one [link](https://docs.oracle.com/database/121/ODPNT/OracleParameterClass.htm#i1011428)
Comment: @DanF I am currently using the constructor with the direction parameters only when I am using Out parameters. Otherwise, I use the one I posted in my answer for In parameter though there is no harm in using the one with the direction parameter for In parameters as well.
Comment: I tried the one you posted, but the third int parameter is marked as size by the oracle documentation [link](https://docs.oracle.com/database/121/ODPNT/OracleParameterClass.htm#i1011493). That is why I used the other one. The one you posted is not working within my projects. Maybe we use different libraries?
Answer: I am not going to go into redundancy explaining Oracle DB. But want you to understand that Oracle types don't natch .NET types like Sql Server types do match.
For example, to fit int value into Oracle, you need to create column NUMBER(10). This size however is larger than int and when you do Select col1. . . it returns long. So, you need to do Convert.ToInt32(reader["col1"]) to "fit" your data into int in your application.
Same thing with boolean here. There is no exact type. Sometimes people store fake booleans in Number(1), or even in Varchar2(1) as "Y"/"N" (for example). So, if your DB has some numeric data type, just do
bool val = GetVal();
var p = new OracleParameter("paramName", Convert.ToInt32(val))

It will give you 1 for true and 0 for false


Conditional statement for DropdownButtonFormFields in registeration form

Question: Still a newbie with flutter and was wondering if someone could help me with a problem I'm having. I am trying to create a registeration form with email, password, password confirmation, a county and a zip code. (County and zip code forms are the drop down button form fields) I have successfully coded all else except for the zip code drop down. I would need it to be conditional on the county selection. (In a way that if I select a specific county in cali, it would only display that selected county's zip codes and nothing else). Also if someone would know a quick fix to make the dropdown button form fields empty unless clicked on. My current adaptation on it isn't very functional, since you can just leave the option unanswered, when it's supposed to be mandatory. Thank you in advance :)
Existing code below
(I only have the string for one county zip codes) (Also deleted the irrelevant firebase related code for this post)
    class RegisterPage extends StatefulWidget {
      const RegisterPage({Key? key}) : super(key: key);

      @override
      State<RegisterPage> createState() => _RegisterPageState();
    }

    class _RegisterPageState extends State<RegisterPage> {

      // dropdown area
      _MyFormStateArea(){
  selectedArea = dropdownListArea[0];
  }
  var selectedArea = '';
  final dropdownListArea = <String>['', 'LA', 'San Francisco'...'Santa Barbara'];

  // dropdown zipcode
  _MyFormStateZip(){
  selectedZip = dropdownListZip[0];
  }
  var selectedZip = '';
  final dropdownListZip = <String>['', '90001', '90002', '90003',..., '91609'];

  // editing Controller
  final emailEditingController = new TextEditingController();
  final passwordEditingController = new TextEditingController();
  final confirmPasswordEditingController = new TextEditingController();

  @override
  Widget build(BuildContext context) {

    // email field
    final emailField = TextFormField(
      autofocus: false,
      controller: emailEditingController,
      keyboardType: TextInputType.emailAddress,
      validator: (value) {
        if (value!.isEmpty) {
          return ("Please enter email.");
        }
        // reg expression for email validation
        if (!RegExp("^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+.[a-z]")
            .hasMatch(value)) {
          return ("Please enter a working email.");
        }
        return null;
      },
      onSaved: (value) {
        emailEditingController.text = value!;
      },
      textInputAction: TextInputAction.next,
      decoration: InputDecoration(
        prefixIcon: Icon(Icons.mail_outline_outlined),
        contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
        hintText: "Email",
        border: OutlineInputBorder(
            borderRadius: BorderRadius.circular(10)
        ),
      ),
    );

    // password field
    final passwordField = TextFormField(
      autofocus: false,
      controller: passwordEditingController,
      obscureText: true,
      validator: (value) {
        RegExp regex = new RegExp(r'^.{6,}$');
        if (value!.isEmpty) {
          return ("A password required.");
        }
        if(!regex.hasMatch(value)) {
          return ("Please enter other password (Min. 6 characters)");
         }
        },
      onSaved: (value) {
        passwordEditingController.text = value!;
      },
      textInputAction: TextInputAction.next,
      decoration: InputDecoration(
        prefixIcon: Icon(Icons.lock_outlined),
        contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
        hintText: "Password",
        border: OutlineInputBorder(
            borderRadius: BorderRadius.circular(10)),
      ));

    // confirm password field
    final confirmPasswordField = TextFormField(
      autofocus: false,
      controller: confirmPasswordEditingController,
      obscureText: true,
      validator: (value)
      {
        if(confirmPasswordEditingController.text != passwordEditingController.text)
        {
          return "Passwords don't match";
        }
        return null;
      },
      onSaved: (value) {
        confirmPasswordEditingController.text = value!;
      },
      textInputAction: TextInputAction.next,
      decoration: InputDecoration(
        prefixIcon: Icon(Icons.lock_outlined),
        contentPadding: EdgeInsets.fromLTRB(20, 15, 20, 15),
        hintText: "Password again",
        border: OutlineInputBorder(
            borderRadius: BorderRadius.circular(10)
        ),
      ),
    );

    // area dropdown
    final areaField = DropdownButtonFormField(
        value: selectedArea,
        items: dropdownListArea.map((e) =>
            DropdownMenuItem(value: e, child: Text(e),)).toList(),
        onChanged: (String? value) {
          setState(() {
            if (value != null) {
              selectedArea = value;
            }
          });
        },
        decoration: InputDecoration(
          labelText: 'County',
          prefixIcon: Icon(Icons.location_city_outlined),
          contentPadding: EdgeInsets.fromLTRB(20, 10, 0, 10),
          border: OutlineInputBorder(
              borderRadius: BorderRadius.circular(10)),
        )
    );

    // zip code field
    final zipCodeField = DropdownButtonFormField(
        value: selectedZip,
        items: dropdownListZip.map((e) =>
            DropdownMenuItem(value: e, child: Text(e),)).toList(),
        onChanged: (String? value) {
          setState(() {
            if (value != null) {
              selectedZip = value;
            }
          });
        },
        decoration: InputDecoration(
          labelText: 'Zip Code',
          prefixIcon: Icon(Icons.location_on_outlined),
          contentPadding: EdgeInsets.fromLTRB(20, 10, 0, 10),
          border: OutlineInputBorder(
              borderRadius: BorderRadius.circular(10)),
        )
    );

    // sign up button
    final signUpButton = Material(
      elevation: 5,
      borderRadius: BorderRadius.circular(30),
      color: Colors.white,
      child: MaterialButton(
        padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
        minWidth: MediaQuery.of(context).size.width,
        onPressed: () {
          signUp(emailEditingController.text, passwordEditingController.text);
        },
        child: Text("Sign Up", textAlign: TextAlign.center,
            style: TextStyle(fontSize: 20,
                color: Colors.lightBlue[900],
                fontWeight: FontWeight.bold)
        ),
      ),
    );

    return Scaffold(
      backgroundColor: Color(0xFFAED8E6),
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        elevation: 0,
        leading: IconButton(
            onPressed: () {
              Navigator.push(context, MaterialPageRoute(builder: (context) => FrontPage()));
              },
              icon: Icon(Icons.arrow_back),
              color: Colors.lightBlue[900],
        ),
      ),
      body: Center(
        child: SingleChildScrollView(
          child: Container(
            color: Color(0xFFAED8E6),
            child: Padding(
              padding: const EdgeInsets.fromLTRB(36, 20, 36, 30),
              child: Form(
                  key: _formKey,
                  child:
                  Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[

                      SizedBox(
                          height: 170,
                          child: Image.asset("assets/AR_logoBold.png",
                              fit: BoxFit.contain
                          )),
                      SizedBox(height: 40,),
                      emailField,
                      SizedBox(height: 25,),
                      passwordField,
                      SizedBox(height: 25,),
                      confirmPasswordField,
                      SizedBox(height: 25,),
                      areaField,
                      SizedBox(height: 25,),
                      zipCodeField,
                      SizedBox(height: 35,),
                      signUpButton,
                      SizedBox(height: 15,),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Text("You already own an account? "),
                          GestureDetector(onTap: () {
                            Navigator.push(context, MaterialPageRoute(builder: (context) => LoginPage()));
                          },
                            child: Text("Login",
                                style: TextStyle(
                                    fontWeight: FontWeight.bold,
                                    fontSize: 15,
                                    color: Colors.lightBlue[900])
                            ),)
                        ],
                      )
                    ],
                  )),
            ),
          ),
        ),
      ),
    );
  }
}

Answer: First you should initalize the selectedArea and selectedZip with the first Entry of your List: = dropdownListZip.first and the first entry should not be an empty String
To get only zips that belong to the choosen area you need to know them. At the moment you have two independent lists.
Better you use a map like:
Map<String, List<String>> zipmap = Map('LA': ['9000','9001','9002], 'San Francisco': ['9003', '9004']);

Than you can only display zips that belong to the area quite easy.
Take a look at: Flutter Documentation for Map
Map<String, List<String>> zipmap = Map('LA': ['9000','9001','9002], 'San Francisco': ['9003', '9004']);

final areaField = DropdownButtonFormField(
        value: selectedArea,
        items: zipmap.keys.toList().map((e) =>
            DropdownMenuItem(value: e, child: Text(e),)).toList(),
        onChanged: (String? value) {
          setState(() {
            if (value != null) {
              selectedArea = value;
            }
          });
        },
        decoration: InputDecoration(
          labelText: 'County',
          prefixIcon: Icon(Icons.location_city_outlined),
          contentPadding: EdgeInsets.fromLTRB(20, 10, 0, 10),
          border: OutlineInputBorder(
              borderRadius: BorderRadius.circular(10)),
        )
    );

// zip code field
    final zipCodeField = DropdownButtonFormField(
        value: selectedZip,
        items: zipmap[selectedArea].map((e) =>
            DropdownMenuItem(value: e, child: Text(e),)).toList(),
        onChanged: (String? value) {
          setState(() {
            if (value != null) {
              selectedZip = value;
            }
          });
        },
        decoration: InputDecoration(
          labelText: 'Zip Code',
          prefixIcon: Icon(Icons.location_on_outlined),
          contentPadding: EdgeInsets.fromLTRB(20, 10, 0, 10),
          border: OutlineInputBorder(
              borderRadius: BorderRadius.circular(10)),
        )
    );

Comment: I'm sorry but I just can't seem to get it working. I don't know or seem to find anywhere how to implement the two strings from the map into two seperate dropdown button form fields :/
Comment: Hi. Because the cities are the keys of the map you can do it like: zipmap.keys.toList() and to get the zips you can do: zipmap['LA']
Comment: @Rasse I provided your code changed to my suggestions. It's not tested but you should be able to understand what I tried to explain. Maybe you need to create two variables keeping these lists because you can't reference a variable in an initializer. Therefore you can write a function and put it in the init() methode at the beginning of your stateful widget.


What happens when an event occurs while program is working

Question: I have a question regarding events in c#. What happens when program is working (for example a loop is executed and it takes a couple of minutes to finish) and an event occurs ( for example FileSystemWatcher will call "created" event ).
Event will be ignored?
FSW will not call the event, so creating new file will be ignored?
The code which has to be executed when event occurs will be executed after the loop ends?
Of course loop has nothing to do with this event, and no background workers or so are used.
Comment: FSW has a SynchronizingObject property.  It completely changes the way it works.  Instead of randomly starting another thread to tell you what happened, leaving it up to you to deal with the consequences of that, it will force FSW to wait until you are ready to receive the notification.   Later, when you are *not* busy doing something else.  Much, much easier to deal with.  But with strings attached, make sure that event doesn't fire too often.
Comment: Callbacks create their own thread, so the main calculation will not be interrupted, but you can call a routine to deal with whatever event you observed.
Comment: FSW calls the events on a separate thread
Answer: This depends a lot on the implementation. In the case of FileSystemWatcher I would expect that event to be raised on a worker thread created by the system - so it will happen concurrently with the loop. If it was a UI event, I would expect it to be appended to the message loop's queue, to be processed after any work currently blocking the UI thread (which you shouldn't do). It would be unusual for an event to just disappear into nowhere unless that was a deliberate design feature - which seems unlikely.
In the case of many other events that are caused by regular code - they are usually processed synchronously when encountered.
So we have 3 options:

processed synchronously by the causing thread
invoked on a worker thread
added to the UI thread's queue (typically via "sync-context")

In this case, I believe the answer is "invoked on a worker thread", but all 3 are possible for events more generally


If $R$ is a simple ring, is every corner $eRe$ simple?

Question: Assume that $R$ is a ring, not necessarily commutative nor unital. Let $e$ be an idempotent in $R$. Is there a correspondence between ideals of $R$ and ideals of the corner ring $eRe = \{ere : r\in R\}$? What if $e$ is full, i.e. $ReR=R$?
I'm hoping there is some kind of natural order-preserving bijection, at least one that would imply that if $R$ is simple then $eRe$ is simple.
I tried to use a matrix example, e.g. $R=M_2(\mathbf{C})$ and $eRe = \begin{bmatrix} 0 & \mathbf{C} \\ 0 & 0 \end{bmatrix}$. But these are both simple of course, and I don't know how to get (say) a $2$-dimensional corner in $M_n(\mathbf{C})$ which is not simple. The upper triangle $\begin{bmatrix} 0 & \mathbf{C} & \mathbf{C} \\ 0 & 0 & \mathbf{C} \\ 0 & 0 & 0 \end{bmatrix}$ is a nonsimple subalgebra, but it's not a corner since its Jacobson radical is not zero (which would be true for a matrix corner).
Answer: There are maps $\alpha:I\mapsto eIe$ from the set of ideals of $R$ to the set of ideals of $eRe$, and $\beta:J\mapsto RJR$ from the set of ideals of $eRe$ to the set of ideals of $R$. They aren't bijections, but $\alpha\circ\beta$ is the identity, so $\beta$ is injective, which is enough to deduce that $R$ simple implies $eRe$ simple.


Docker build command is throwing error in jenkins

Question: When i am running the jenkins pipline then "docker build -t " command written in jenkinsfile is giving me below the error.enter image description here
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /var/lib/snapd/void/Dockerfile: no such file or directory
Comment: Can you tell what is the path of your Dockerfile?
Answer: For dockerfiles
Some information on the purpose of a dockerfile,
Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.
More information with the arguments and how to use them in the Docker documentation,
https://docs.docker.com/engine/reference/builder/
For Docker build
Description
Build an image from a Dockerfile
Usage
docker build [OPTIONS] PATH | URL | -
Extended description
The docker build command builds Docker images from a Dockerfile and a "context". A build's context is the set of files located in the specified PATH or URL. The build process can refer to any of the files in the context. For example, your build can use a COPY instruction to reference a file in the context.
The URL parameter can refer to three kinds of resources: Git repositories, pre-packaged tarball contexts and plain text files.
More information from the Docker documentation,
https://docs.docker.com/engine/reference/commandline/build/
If you docker build successfully build after, but Jenkins stil reports the same error as before then,
you need to check the filepaths for /var/lib/snapd/void/Dockerfile on the Jenkins server running the job. In addition the jenkins build error, which reports the location, /var/lib/jenkins/workspace/docExp for the symlinks and the permissions which needs to be checked, for you to not receive any errors.
Comment: Hi thanks for your reply..but I didn't understand  I am new to this
Comment: I was watching a video about kubernetes before on YouTube, I see a Docker video by the same channel, TechWorld by Nana, for Docker, this should help you understand better, https://youtu.be/3c-iBn73dDE
Answer: docker build [OPTIONS] PATH | URL | -
in your case OPTIONS - -t <tag>(did you want add tag?)
PATH - folder with context which be passed to build process, must be exist
commonly you enter to directory to your folder with context and write something like:
docker build ./
it means that docker get current dir and pass as context
and Dockerfile must be exist in current folder
but you can pass in [OPTIONS] -f /path/to/Dockerfile
Comment: I did what you have mentioned but still getting the same error:- "unable to prepare context"                             Thanks for your early reply
Comment: try to enter to you work dir with Dockerfile and do `docker build ./`
Comment: I am writing these commands in Jenkinsfile . And I did use this command too...but getting the same issue. I watched lot of video don't know what am I doing wrong
Comment: Hi,I just reinstalled the docker and now it's working properly. Thanks for your suggestions.


pthread and private data

Question: How can I use pthreads in this situation? The code receives requests from stdin and return the results based on some rules. But when I create a thread, the value of id and url is shared by all the threads. Example:
void * filter(void * data){
        int id;
        char url[1024];
        sscanf((char *) data, "%d %1024s", &id, url);
        sleep(id);
        printf("%s\n", url);
}

while(fgets(line, BUFFER, stdin)!=NULL)
   pthread_create(&thread, NULL, &filter, (void *) line);

--- Received from stdin
1 one
2 two
3 three
4 four
5 five
--- Output
one
three
four
five
five
-- But the results must be
one
two
three
four
five
There is a way to solve it? Thank you!
Answer: As you have it, all the threads get passed a pointer to the same data, and fgets will overwrite that data each time it is called. So your output will be a bit random, and possibly corrupt.
You can hand a copy of the line read to each thread, and have each thread free it (for example).
while (fgets(...))
  pthread_create(..., (void*)strdup(line));

In the thread procedure, you should check that the passed in data is not null (could happen if strdup failed to allocate sufficient memory for the copy), and add:
free(data);

once you're done working with it.
Having a separate (static) buffer for each thread would work too, but you'd have to know how many you're going to be starting beforehand (or do some dynamic re-allocations or something like that).
Comment: +1 for elegant solution. The thread procedure should also check that the argument is not `NULL`, since `strdup` may have failed due to insufficient memory.
Answer: It's the line variable that is shared. You have a race condition where the line buffer is filled with the next line before the thread can process the buffer. You must allocate a new buffer to be passed to each thread.

pthread and private data


joda DateTimeFormat local timezone formatting question

Question: I'm starting with an org.joda.time.DateTime and I want to output it with a timezone offset equivalent to the local time zone.  It's really for the convenience of a user looking at the time with his eyes (rather than parsing it with a proper ISO8601 parser).
val tz = DateTimeZone.getDefault()
val formatter = JacksonJodaDateFormat(DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ").withZone(tz))

What I get out is this:
2020-02-01T05:00:00+0000

What I want is this:
2020-02-01T00:00:00-0500

What it's outputting is actually correct for my time zone, but I told it .withZone(tz) and I confirmed (through the debugger) that tz is in fact America/New_York.
I'm using jodatime 2.10.2.  I've also got jackson-format-jodatime in the mix here but I tried this with jackson out of the loop and it behaves the same.
The Documents say this:
When printing, this zone will be used in preference to the zone from the datetime that would otherwise be used.

The one that would otherwise be printed is UTC, but that's not what I want it to do.
Am I interpreting what the javadocs say incorrectly?
Comment: The good people behind Joda Time were instrumental in implementing `java.time`.  They recommend no longer using Joda Time.  See their notes [here](https://www.joda.org/joda-time/) (the "Why Joda Time" section).
Comment: Quick clarifications: (1) `val` is not a Java keyword - is that from Lombok? (2) What version of Java are you using? (From Java 8 onwards, `java.time` is preferred over Joda-Time - but migration may not be an option for you).
Comment: It's kotlin, sorry.  I go back and forth between java and kotlin without even thinking about it nowadays.  Yep I'm using GraalVM 11 so I definitely could use java.time instead, is that really considered preferred (i.e. joda is considered obsolete) by most people now?
Answer: If you don't object to a Java answer (perhaps your code snippet is Kotlin?), the following will format the date string as you want, and handle time zone shifts.
To keep things simple, I also did not use the Jackson library, as you mentioned.
You can obviously replace the timezone IDs below with whatever you need for your starting point - such as "UTC". Or for the system default, using Joda-Time:
DateTimeZone defaultZone = DateTimeZone.getDefault();

Joda-Time
//
// Using Joda-Time 2.10.2:
//

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.DateTimeFormat;

...

String pattern = "yyyy-MM-dd'T'HH:mm:ssZ";
String dateString;

DateTime dtOne = new DateTime("2020-02-21T09:30:45.678+00:00");
DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern);

DateTime dtTwo = dtOne.withZone(DateTimeZone.forID("America/New_York"));
dateString = fmt.print(dtTwo);   // "2020-02-21T04:30:45-0500":

DateTime dtThree = dtOne.withZone(DateTimeZone.forID("Europe/Paris"));
dateString = fmt.print(dtThree); // "2020-02-21T10:30:45+0100"

java.time
For Java 8 onwards, if you can use java.time, then withZoneSameInstant() shifts the date and time accordingly:
//
// Using java.time (Java 8 onwards):
//

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

...
String pattern = "yyyy-MM-dd'T'HH:mm:ssZ";
String dateString;

DateTimeFormatter format = DateTimeFormatter.ofPattern(pattern);
LocalDateTime localDateTime = LocalDateTime.parse("2020-02-21T09:30:45.123");
ZonedDateTime zonedDateTimeA = localDateTime.atZone(ZoneId.of("Europe/Paris"));

dateString = zonedDateTimeA.format(format); // "2020-02-21T09:30:45+0100"

ZonedDateTime zonedDateTimeB = zonedDateTimeA
        .withZoneSameInstant(ZoneId.of("America/New_York"));
dateString = zonedDateTimeB.format(format); // "2020-02-21T03:30:45-0500"

For the default timezone using java.time, it's ZoneId.systemDefault().
Also, this is an amazing overview.
Edit: Use java.time instead of Joda Time
The following was mentioned in the question's comments, but needs to be stated in this answer, also:
If you can, you absolutely should use java.time over Joda Time.
From the Joda Time homepage:

Note that from Java SE 8 onwards, users are asked to migrate to java.time (JSR-310) - a core part of the JDK which replaces this project.

And from Stephen Colebourne, one of the creators of Joda Time:

I use the phraseology that java.time is "inspired by Joda-Time", rather than an exact derivation, however many concepts will be familiar.


How is the push forward map constructed on smooth projective varieties?

Question: I am learning about De Rham cohomology cohomology on smooth complex projective varieties. If $\phi : X \rightarrow Y$ is morphism between two smooth projective varieties. I have seen that the push forward is defined and there exists the following map$P : H^{p,q}(X) \rightarrow H^{p - r,q - r}(Y)$, where $r = dim(X) - dim(Y)$. I haven't seen how it is exactly defined? For the sake of simplicity let us say $dim(X) = dim(Y)$. Can someone tell me how it is defined  (I am new to math stackexchange, so please be patient with me if I made any mistakes in how I phrased my question).
Comment: Shouldn't the $2r$ be just $r$? Then this is the Gysin map or integration over the fiber.
Comment: @TedShifrin Yeah. It should be r. That was a typo. Can you tell you tell me where I could find information about the exact definition using Gysin map or integration over the fiber? I prefer integration, that seems more algebraic and intuitive.
Comment: You can find information by searching here and on wikipedia. But, very simply, it's the result of interpreting the usual pushforward on homology via Poincaré duality (so cap with the fundamental class of the general fiber).
Comment: Ok. That makes sense. Ty!
Answer: Let $\dim_{\mathbb C}X = n$ and $\dim_{\mathbb C} Y = m$.
The map $\phi: X \to Y$ induces a pull-back morphism
$$\phi^*: H^k(Y, \mathbb C) \to H^k(X, \mathbb C), [\alpha] \mapsto [\phi^* \alpha].$$
On the other hand, the the pairing
\begin{align*}
H^k(X, \mathbb C) \otimes H^{n-k}(X, \mathbb C) \to \mathbb C \\
[\alpha] \otimes [\beta] \mapsto \int_X \alpha \wedge \beta
\end{align*}
is a perfect pairing (this is called the Poincaré duality theorem, see [1, Thm 5.30]), so that naturally $H^k(X, \mathbb C) \cong H^{n-k}(X, \mathbb C)^*$. Hence the dual map of $\phi^*$ gives a morphism
$$\phi_*: H^{2n-k}(X, \mathbb C) \to H^{2m-k}(Y, \mathbb C).$$
Set $2n - k = p+q$ to obtain
$$\phi_*: H^{p+q}(X, \mathbb C) \to H^{p+q - 2r}(Y, \mathbb C).$$
It remains to verify that this maps $H^{p,q}$ to $H^{p-r, q-r}$, which follows from the fact that pull-back preserves Hodge-type, i.e. $$\phi^*: H^{p,q}(Y) \to H^{p,q}(X).$$
[1] Voisin, Hodge Theory and Complex Algebraic Geometry


What do the golden puzzle pieces you get from the goat herder do?

Question: In Nitrome's latest Icebreaker game for iOS, there is a goat herder in some levels. If you manage to move all of the goats in those levels into his boat, you get a golden puzzle piece that moves to the top of the screen and stays there. Once you've completed the level, there is no sign that you ever collected one.
Is there any way to see the number of puzzle pieces you have collected? Is there a certain use for them, perhaps later in the game? They just seem to disappear.
Answer: It seems from this website that the golden pieces are used in gaining access to other parts of maps:

Completing sidequests gives a golden puzzle piece, granting access to another part of the map that is attached to that level. This part of the map is only accessible through the completion of this part of the sidequest.

You only seem to be able to collect only 1 at every point.
Comment: As it turns out, the first goat rescue grants access to an alternate path, and beyond that point the goats are needed to progress.