text:
Q: R XML : Error in UseMethod("xmlNamespaceDefinitions") I'm trying to scrape XML data on R and encountering following error
XML link : http://data.gov.in/sites/default/files/Arecanut(Betelnut_Supari)_2005.xml
Code:
library(RCurl);
library(XML)
test <- readHTMLTable(doc="http://data.gov.in/sites/default/files/Arecanut(Betelnut_Supari)_2005.xml")

Error:
Error in UseMethod("xmlNamespaceDefinitions") :
  no applicable method for 'xmlNamespaceDefinitions' applied to an object of class "NULL"

A: The file was not "easy" to get and, since it's >3MB in size, it's best practice to download the file first then process it. Next, you aren't parsing HTML, you're reading an XML SOAP response, so you would not have gotten far with readHTMLTable even without the namespace issues. The records you are trying to extract look like:
<diffgr:diffgram>
  <NewDataSet>
    <Table diffgr:id="Table1" msdata:rowOrder="0">
      <State>Assam</State>
      <District>Barpeta</District>
      <Market>Howly</Market>
      <Commodity>Arecanut(Betelnut/Supari)</Commodity>
      <Variety>Other</Variety>
      <Arrival_Date>18/06/2005</Arrival_Date>
      <Min_x0020_Price>5000</Min_x0020_Price>
      <Max_x0020_Price>8000</Max_x0020_Price>
      <Modal_x0020_Price>6500</Modal_x0020_Price>
    </Table>
    …

Since the diffgram node has a namespace (diffgr) you need to extract the nodes with said namespace in mind then turn the children nodes into data frame rows. Further explanation is inline with the solution:
library(XML)
library(data.table)

# be kind to data providers + have the file in case the Internet is down or they
# move the file and, finally, speed up processing later on by having it local
#
# download.file("http://data.gov.in/sites/default/files/Arecanut(Betelnut_Supari)_2005.xml",
#                destfile="arecanut_2005.xml")

dat <- xmlTreeParse("arecanut_2005.xml", useInternalNodes=TRUE)

# There are namespaces in the XML file, so we need to extract them
nsDefs <- xmlNamespaces(dat, recursive=TRUE)
ns <- structure(sapply(nsDefs, function(x) x$uri), names = names(nsDefs))

# the "table" nodes use diffgr:diffgram, so we need to make sure we include
# the diffgr namespace which is ns[9]

nodes <- getNodeSet(dat ,"//diffgr:diffgram/NewDataSet/Table", ns[9])

# we then loop through the nodes, converting each set of values to a
# data frame then using data.table's rbindlist with `fill=TRUE` just in
# case some records have greater or fewer fields.

tmp <- rbindlist(lapply(nodes, function(x) {
   as.data.frame.list(xmlApply(x, xmlValue))
}), fill=TRUE)

str(tmp)

## Classes 'data.table' and 'data.frame':  8127 obs. of  9 variables:
##  $ State            : Factor w/ 9 levels "Assam","Goa",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ District         : Factor w/ 30 levels "Barpeta","Darrang",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Market           : Factor w/ 50 levels "Howly","Kharupetia",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Commodity        : Factor w/ 1 level "Arecanut(Betelnut/Supari)": 1 1 1 1 1 1 1 1 1 1 ...
##  $ Variety          : Factor w/ 26 levels "Other","Supari",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Arrival_Date     : Factor w/ 323 levels "18/06/2005","19/06/2005",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ Min_x0020_Price  : Factor w/ 1923 levels "5000","1000",..: 1 1 1 1 1 1 2 2 2 2 ...
##  $ Max_x0020_Price  : Factor w/ 2394 levels "8000","1250",..: 1 1 1 1 1 1 2 3 3 3 ...
##  $ Modal_x0020_Price: Factor w/ 2385 levels "6500","1100",..: 1 1 1 1 1 1 2 2 2 3 ...
##  - attr(*, ".internal.selfref")=<externalptr>

head(tmp)

##     State District Market                 Commodity Variety Arrival_Date Min_x0020_Price Max_x0020_Price Modal_x0020_Price
## 1: Assam  Barpeta  Howly Arecanut(Betelnut/Supari)   Other   18/06/2005            5000            8000              6500
## 2: Assam  Barpeta  Howly Arecanut(Betelnut/Supari)   Other   19/06/2005            5000            8000              6500
## 3: Assam  Barpeta  Howly Arecanut(Betelnut/Supari)   Other   20/06/2005            5000            8000              6500
## 4: Assam  Barpeta  Howly Arecanut(Betelnut/Supari)   Other   21/06/2005            5000            8000              6500
## 5: Assam  Barpeta  Howly Arecanut(Betelnut/Supari)   Other   22/06/2005            5000            8000              6500
## 6: Assam  Barpeta  Howly Arecanut(Betelnut/Supari)   Other   24/06/2005            5000            8000              6500

If you're going to continue to work with these types of files, it would be in your best interest to read up a bit on XML processing in R.


text:
Q: Why does my Android App Force Closes but there is no clear error that is causing it? I have an android application that connects to a remote Apache server on another laptop and it connects just fine for the first few times. Then now I get a force close window but nothing has been changed.
Here is the activity that force closes
package com.thesis.menubook;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.thesis.menubook.JSONParser;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class ChooseTable extends Activity {

    DBConnect db = new DBConnect(this);

    EditText tableNumber;
    Button btnGo;
    String table_ID;
    String table_availability;

 // Progress Dialog
    private ProgressDialog pDialog;

    // JSON parser class
    JSONParser jsonParser = new JSONParser();

    // JSON Node names
    private static final String TAG_SUCCESS = "success";
    private static final String TAG_TABLE = "tabledb";
    private static final String TAG_TABLE_ID = "table_ID";
    private static final String TAG_TABLE_STATUS = "table_status";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_choose_table);

        btnGo = (Button) findViewById(R.id.check_in_button);
        tableNumber = (EditText) findViewById(R.id.table_number);

        btnGo.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
              table_ID = (tableNumber).getText().toString();
              new GetTableDetails().execute();
              Log.d("Table Status", table_availability);
              if(table_availability == "AVAILABLE")
              {
                  Toast.makeText(ChooseTable.this, table_availability, Toast.LENGTH_LONG).show();
                  Intent i = new Intent (ChooseTable.this, ChooseOrdersMenu.class);
                    startActivity(i);
              }
            }
        });

    }

    /**
     * Background Async Task to Get complete product details
     * */
    class GetTableDetails extends AsyncTask<String, String, String> {

        /**
         * Before starting background thread Show Progress Dialog
         * */
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(ChooseTable.this);
            pDialog.setMessage("Checking Table Availability. Please wait...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();
        }

        /**
         * Getting product details in background thread
         * */
        protected String doInBackground(String... params) {

            // updating UI from Background Thread
            runOnUiThread(new Runnable() {
                public void run() {
                    // Check for success tag
                    int success;
                    try {
                        // Building Parameter
                        List<NameValuePair> params = new ArrayList<NameValuePair>();
                        params.add(new BasicNameValuePair(TAG_TABLE_ID, table_ID));
                        //ipaddress of server
                        String ipaddress = "";
                        try
                        {
                            db.open();
                            ipaddress=db.getIP();
                            Log.d("IP Address", ipaddress);
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }
                        finally
                        {
                            db.close();
                        }

                        if(ipaddress != "-1")
                        {
                        // single table url
                        String url_table_details = "http://"+ipaddress+":80/MenuBook/checkTable.php";
                        Log.d("URL", url_table_details);
                        // getting product details by making HTTP request
                        // Note that product details url will use GET request
                        JSONObject json = jsonParser.makeHttpRequest(
                                url_table_details, "GET", params);

                        // check your log for json response
                        Log.d("Check Table", json.toString());

                        // json success tag
                        success = json.getInt(TAG_SUCCESS);
                        if (success == 1) {
                            // successfully received table details
                            JSONArray tableObj = json
                                    .getJSONArray(TAG_TABLE); // JSON Array

                            // get table availability from JSON Array
                            JSONObject table = tableObj.getJSONObject(0);
                            table_availability = table.getString(TAG_TABLE_STATUS);

                        }else{
                            table_availability = "TABLE NOT FOUND";
                        }
                        }
                        else
                        {
                            table_availability = "FAILED TO RETRIEVE SERVER IP ADDRESS";
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            });

            return null;
        }

        /**
         * After completing background task Dismiss the progress dialog
         * **/
        protected void onPostExecute(String file_url) {

            pDialog.dismiss();

        }
    }

}

Here is the activity that calls the previous activity
package com.thesis.menubook;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class IPAddress extends Activity {

    DBConnect db = new DBConnect(this);
    String ip;
    Boolean next = false;

    EditText ipaddress;
    Button connect;

    // Progress Dialog
    private ProgressDialog pDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ipaddress);

        connect = (Button) findViewById(R.id.connectBtn);

        connect.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                    ipaddress = (EditText) findViewById(R.id.ipAddress);
                    ip = ipaddress.getText().toString();
                    new InsertIPAddress().execute();
                    if(next == true)
                    {
                        Intent i = new Intent (IPAddress.this, ChooseTable.class);
                        startActivity(i);
                    }
                }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_ipaddress, menu);
        return true;
    }

     /**
     * Background Async Task to Insert IP address
     * */
    class InsertIPAddress extends AsyncTask<String, String, String> {

        /**
         * Before starting background thread Show Progress Dialog
         * */
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(IPAddress.this);
            pDialog.setMessage("Connecting to Server. Please wait...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();
        }

        /**
         * Inserting IPAddress in background thread
         * */
        protected String doInBackground(String... params) {

            runOnUiThread(new Runnable() {
                public void run() {

                    pDialog.setMessage("Saving IP Address. Please wait...");
                    long id = 0;
                    if((ip == "") || (ip.contains(" ") == true))
                    {
                        Toast.makeText(IPAddress.this, "Please enter the server IP address and/or remove spaces.", Toast.LENGTH_LONG).show();
                        next = false;
                    }
                    else
                    {
                        try
                        {
                            db.open();
                            id = db.insertIPAddress(ip);
                        }
                        catch (Exception e)
                        {
                            e.printStackTrace();
                        }
                        finally
                        {
                            db.close();
                        }
                        Toast.makeText(IPAddress.this, "Inserted at row "+id , Toast.LENGTH_LONG).show();
                        next = true;
                    }
                }
            });

            return null;
        }

        /**
         * After completing background task Dismiss the progress dialog
         * **/
        protected void onPostExecute(String file_url) {
            pDialog.dismiss();
        }
    }

}

And here is my LogCat :
01-31 21:30:59.082: W/KeyCharacterMap(588): No keyboard for id 0
01-31 21:30:59.082: W/KeyCharacterMap(588): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
01-31 21:31:20.982: D/AndroidRuntime(588): Shutting down VM
01-31 21:31:20.982: W/dalvikvm(588): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-31 21:31:20.991: E/AndroidRuntime(588): FATAL EXCEPTION: main
01-31 21:31:20.991: E/AndroidRuntime(588): java.lang.NullPointerException: println needs a message
01-31 21:31:20.991: E/AndroidRuntime(588):  at android.util.Log.println_native(Native Method)
01-31 21:31:20.991: E/AndroidRuntime(588):  at android.util.Log.d(Log.java:122)
01-31 21:31:20.991: E/AndroidRuntime(588):  at com.thesis.menubook.ChooseTable$1.onClick(ChooseTable.java:60)
01-31 21:31:20.991: E/AndroidRuntime(588):  at android.view.View.performClick(View.java:2408)
01-31 21:31:20.991: E/AndroidRuntime(588):  at android.view.View$PerformClick.run(View.java:8816)
01-31 21:31:20.991: E/AndroidRuntime(588):  at android.os.Handler.handleCallback(Handler.java:587)
01-31 21:31:20.991: E/AndroidRuntime(588):  at android.os.Handler.dispatchMessage(Handler.java:92)
01-31 21:31:20.991: E/AndroidRuntime(588):  at android.os.Looper.loop(Looper.java:123)
01-31 21:31:20.991: E/AndroidRuntime(588):  at android.app.ActivityThread.main(ActivityThread.java:4627)
01-31 21:31:20.991: E/AndroidRuntime(588):  at java.lang.reflect.Method.invokeNative(Native Method)
01-31 21:31:20.991: E/AndroidRuntime(588):  at java.lang.reflect.Method.invoke(Method.java:521)
01-31 21:31:20.991: E/AndroidRuntime(588):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-31 21:31:20.991: E/AndroidRuntime(588):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-31 21:31:20.991: E/AndroidRuntime(588):  at dalvik.system.NativeStart.main(Native Method)
01-31 21:31:23.643: I/Process(588): Sending signal. PID: 588 SIG: 9

A:
01-31 21:31:20.991: E/AndroidRuntime(588): FATAL EXCEPTION: main 01-31
  21:31:20.991: E/AndroidRuntime(588): java.lang.NullPointerException:
  println needs a message

this tells you, what it is caused by

A: You cant log a null
change this line
Log.d("Table Status", table_availability);

to
 Log.d("Table Status", table_availability+"");

or make an if condition
if( table_availability!=null){
 Log.d("Table Status", table_availability);
}

A: The Problem is here :
DBConnect db = new DBConnect(this);

this doesn't initialize before onCreate() function, you can define your DBConnect in your class body but initialize it on onCreate() function

A: How is this not a clear error?
It literally says that you have a println or log, where the message is not known / null.
I'd guess in
Log.d("Table Status", table_availability);

table_availability is null

redpajama_set_name: RedPajamaStackExchange


text:
Q: Open Another Page - HTML/Javascript This is my whole html code,
I do not understand why it does not open "example.html" page.
if someone can help me understand why.
I would like to make sure that when the credentials are correct and I press the login button it directs me to a new file (in this case "example.html"), but I do not know why nothing happens

    <title>Login</title>
    <link rel="stylesheet" href="css/css1.css">

LOGIN

            <form>
                <input type="text" placeholder="Username" name="username">

                <input type="password" placeholder="Password" name="password">

                <input type="submit" onclick="check(this.form)" name="btn_submit" value="Login">
            </form>

A: When you click the submit button, your form is submitted and the browser reloads the page (because you don't specify an action in your form).
You need to either prevent the submission viq JavaScript (check out Event.preventDefault()
), or turn you submit input into a button with type button, so that clicking it does not submit the form.

var message = "Right Click Disabled!";

function rtclickcheck(keyp) {
  if (navigator.appName == "Netscape" &&
    keyp.which == 3) {
    alert(message);
    return false;
  }
  if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) {
    alert(message);
    return false;
  }
}
document.onmousedown = rtclickcheck;

function check(form) {

  if (form.username.value == "admin" && form.password.value == "123") {
    window.open("example.html")
  } else {
    console.log("Username Or Password Doesn't Match!");
  }
}

LOGIN

      <form>
        <input type="text" placeholder="Username" name="username">

        <input type="password" placeholder="Password" name="password">

        <button type="button" onclick="check(this.form)" name="btn_submit">button</button>
      </form>

A: Form submission cancels the redirect and vice versa.
Use the below code instead:

  <title>Login</title>
  <link rel="stylesheet" href="css/css1.css">

LOGIN

        <form onsubmit="return check(this);">
           <input type="text" placeholder="Username" name="username">

           <input type="password" placeholder="Password" name="password">

           <input type="submit" name="btn_submit" value="Login">
        </form>

A: It is working fine.
Please make sure that example.html is also in the same path your login html page is located. Also check for popup blocker as mentioned by @Andrew_CSE


text:
Q: Alternative to views in Xcode I'm an Xcode noob; I have created a view-based Xcode project. In the first view, the user has to choose an option from a list (in the list there are more than 200 options). In the second view, he has to choose a sub-option, and even this list is really long. Each sub-option should have its own view, but since it's impossible to create more than 20,000 views in Xcode, I should use an alternative method. Can you help me please?

A: So to check this over, you are looking for not one but two UITable view's both of which have lots of data.
First you need to decide and figure out, how will you store this data of information in the app: IE: core data,  plist, arrays, server end (json,xml) etc...    secondly, how much information will be displayed at once?  just a picture and maybe two liens of text ? or do you want something more custom ??
once you have decided that you can actually start to begin a basic project (Navigation Based Application)(would be easiest for a new user) or starting with Blank Project (Single Based View Controller) and  in IB (Interface Builder) addend a UITableView along with a UITableView Cell.
Here is some basic tutorials for designing UITableViews. :-)
Step 1 - Learn The Basics of UITable View -
Basic UITableView with NSArray TUTORIAL
Step 2 - Learn how to make your own UITableViewCell - Custom Cell Tutorial (Storyboard) - Xcode 4.6
Any questions just ask, hope that helps :-)
A book might be a good place to start as well, I learned my many of my first UITableView off of a book. Beginning iPhone Development: Exploring the iPhone SDK [Paperback]
Dave Mark


text:
Q: QAxWidget.dynamicCall works for pyqt5.5.1, but not for qt5.7(c++) Currently, I have an 'xyz.ocx' file and want to call its functions.
As I mentioned in the title, I succeeded calling its function using PyQt5.5.1 and Python 3.4.4.
Here's the following code.
from PyQt5.QAxContainer import QAxWidget
from PyQt5.QtWidgets import QApplication
if __name__ == "__main__":
    app = QApplication([])
    ocx = QAxWidget("myclsid....")  # ActiveXControl Object
    ocx.dynamicCall("somemethod()") # It worked. Some dialog opened by this function.
    app.exec_()

However, when I do the exactly same thing with Qt5.7.0 and VS2015, I get nothing(no error, no proper execution of function, just nothing). Here's the following code I tried.
#include <QAxWidget.h>
#include <QtWidgets/QApplication>
#include <stdio.h>
#include <windows.h>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QAxWidget* ocx = new QAxWidget("myclsid...")
    ocx->dynamicCall("somemethod()");

// Nothing happened.
// No error, no dialog appeared(dialog should be appeared by this function).
// And also the weird thing is the same thing happened(no error, just nothing)
// even I called some non-existing function such as dynamicCall("fuiwhfueohiwuohfewlfae()")
// (no "No Such Property" error occured)

    return a.exec();
}

As I commented, nothing happend when I call the dynamicCall(somemethod()) unlike above python & pyqt example. Since I'm a novice to qt, I can't really figure out what's going on with my C++&Qt code. Is there any possible reason of my C++ & Qt code not working? How can I solve this?
Any suggestions or helps are greatly appreciated. Thanks.
+++ ADDED
I just realized that my pyqt5.5.1 was 32bit pyqt and qt5.7.0 was 64bit pyqt, and my ocx file is 32bit. Is there a possibility that this caused a problem?


text:
Q: Does specifying the number of elements on defining a vector in Racket make the program use less time or memory? For example, can this
#!/usr/bin/env racket
#lang racket/base

(define vector-of-pleasures #6("eating" "cold showers" "swimming" "running" "pullups" "weighlifting"))
(for ((pleasure vector-of-pleasures)) (displayln pleasure))

be more performant because of the optional annotation than this
#!/usr/bin/env racket
#lang racket/base

(define vector-of-pleasures #("eating" "cold showers" "swimming" "running" "pullups" "weighlifting"))
(for ((pleasure vector-of-pleasures)) (displayln pleasure))

?
Methinks it should not matter since in both snippets vector-of-pleasures is immutable.
What are, other than performance, possible reasons for annotating the number of the elements of the vector on its definition?

A: No, it doesn't.  The real use of that syntax is that it lets you write a vector of a bunch of identical things easily: #6(1) is a vector of 6 1s.
But I think it could save space. I can't see why, for instance:
(let ((v #2((1 2))))
  (eq? (vector-ref v 0) (vector-ref v 1)))

should not be true.  But then this rapidly turns into the question of when similar literals can be folded: can (eq? '(1 2) '(1 2)) return true for instance?  I don't know what Racket's rules are on that.


text:
Q: Initialize content of a jQuery remote tab on initial page load I'm using the jQuery tabs library to create a set of remote (i.e., ajax loaded) tabs.
However, to avoid the initial page load being empty until the ajax request finishes, I'd like to include the content for the initial tab with the initial page download.
I've got this generally working by providing a div in the initial page load that matches the title of the tab, but even though this content appears immediately, as soon as I initialize the tabs it does the ajax request IN ADDITION which is both wasteful and causes a flicker.  My basic question is how can I get jQuery tabs to NOT do an ajax request for the initially selected tab, and get this content as part of the initial page load, while still loading the other tabs dynamically.
The complication is that I can't hard code the ids/hrefs for which tab is the "initial" one since the initial tab will change based on available content.
I'm sure there is some kind of hacky way to do this with javascript rewriting the URLs of tabs dynamically before I initialize the tabs but I'm looking for a cleaner solution.
Any ideas?

A: Are you using a specific tab control to do this? It's pretty dependent on how your tabs are implemented...
If you want the data to be included without a delayed load, you will have to include it server side.
Give me some more details and I'll see what I can do!

A: The best way to do it is using server side implementation to add the starting text. In the JQuery documentation the default text it is not loaded through AJAX.
I'm not sure exactly what you are doing but if that is not your case, then a simple boolean "hack" could be used like this:
var initial=true;

Then, in your tabs code:
$('.selector').tabs({
   select: function(event, ui) { if(initial) { initial=false; return false; }
});

This will prevent to execute the ajax call the very first time.

A: There's an option called "spinner" which holds the text, gif-animation or whatever to be displayed.
$( ".selector" ).tabs( { spinner: 'Retrieving data...' } );


text:
Q: Having trouble with jQuery dialog height I can't seem to get the dialog to open to the height I want, I can see the title bar, but don't get the content until I expand the dialog with my mouse
My Code
http://jsfiddle.net/Uu2G4/3/

        This is making me crazy!!!!

$(document).ready(function () {
    // init the image popup dialog
    $("#ImageDialog").dialog({ autoOpen: false, height: 500 });

    $(".open").click(function()
                 {
                     $("#ImageDialog").dialog("open");
                 });

    $(".close").click(function()
                 {
                     $("#ImageDialog").dialog("close");
                 });
});

A: I set the class of the div to ui-dialog in the HTML
removing this fixed the problem.

        This is making me crazy!!!!

$(document).ready(function () {
    // init the image popup dialog
    $("#ImageDialog").dialog({ autoOpen: false, height: 500 });

    $(".open").click(function()
                 {
                     $("#ImageDialog").dialog("open");
                 });

    $(".close").click(function()
                 {
                     $("#ImageDialog").dialog("close");
                 });
});


text:
Q: Words derived from 'veni' and 'vidi' of Latin Veni, vidi, vici (Classical Latin: [ˈweːniː ˈwiːdiː ˈwiːkiː];  "I came; I saw; I conquered") is a Latin phrase popularly attributed to Julius Caesar.
Veni, vidi, vici - Wikipedia
As for 'vici', there's words of 'victory', 'victor', ' originated from.
*weik- | Origin and meaning of root *weik- by Online Etymology Dictionary
Are there words derived from 'veni' and 'vidi'?

A: Lots and lots of words:
Veni (basic parts: venio, venire, veni, ventum): intervene, convene, convent, convention, convenient, venue, invent, prevent, convenant (https://www.etymonline.com/word/*gwa-)
Vidi (video, videre, vidi, visum): video, vision, visual, television, vista, view, preview, interview, provide, improvise, evidence, envy, visa (https://www.etymonline.com/word/*weid-)
Vici (vinco, vincere, vici, victum): invincible, victory, convince, evince, convict, conviction, eviction, Vincent, province, vanquish (https://www.etymonline.com/word/*weik-)
I built these lists myself, then realized you can refer to the sources I've appended from the Online Etymological Dictionary, after which I added a couple more examples.


text:
Q: iPhone Cells being drawn not showing full content till scroll I've had a problem like this before but it was to do with the reuse of the cell. Now I know the cuprit line which i'll point out in the code below, but it's been added to make sure the cell text fits properly in the table (changing text sizes from XML feed)
The code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    ViewRoutesCell * aCell = (ViewRoutesCell *)[tableView dequeueReusableCellWithIdentifier:@"ViewRoutesCell"];

    if (aCell == nil)
    {
        NSArray *arr = [[NSBundle mainBundle] loadNibNamed:@"ViewRoutesCell" owner:self options:nil];
        aCell = (ViewRoutesCell *)[arr objectAtIndex:0];
    }

    AssessObject *newObj1;
    newObj1=[totalArray objectAtIndex:indexPath.row];
    UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:newObj1.routeImage]]];

    aCell.imgRoute.image = image;
    aCell.lblRouteText.text = newObj1.routeText;
    aCell.lblRouteImage.text = newObj1.routeImage;
    aCell.txtRoute.text = newObj1.routeText;
    aCell.txtRoute.frame = CGRectMake(aCell.txtRoute.frame.origin.x, aCell.txtRoute.frame.origin.y, aCell.txtRoute.frame.size.width, aCell.txtRoute.contentSize.height);

    return aCell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    AssessObject *newObj1;
    newObj1=[totalArray objectAtIndex:indexPath.row];

    NSString *cellText = newObj1.routeText;

    UIFont *cellFont = [UIFont fontWithName:@"Helvetica" size:16.0];
    CGSize constraintSize = CGSizeMake(320.0, CGFLOAT_MAX);
    CGSize labelSize = [cellText sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];

    return labelSize.height + 250;

}

Now if i include the line:
aCell.txtRoute.frame = CGRectMake(aCell.txtRoute.frame.origin.x, aCell.txtRoute.frame.origin.y, aCell.txtRoute.frame.size.width, aCell.txtRoute.contentSize.height);

This happens (click for video)
However, when I comment that line out this happens:
Another short video
So it shows all the text at the start, but it's cutting the longer text sections out before all the text has been displayed (but making the cell the right height)
I'm very confused!
Tom

A: Are you setting up the txtRoute object's autoresizingMask property within your nib properly?


text:
Q: QWidget::setCursor on MacOS X does not work second time Qt 5.0.1, MacOS X 10.8.3
Setting cursor from resource QPixmap works only first time. All consequent calls to QWidget::setCursor for another cursors created from QPixmap apply first cursor.
Same if calling unsetCursor between different setCursor calls. Same if using QApplication's override cursor.
Additionally OS X ignores Qt hotspot - it is always (0,0)
Cursors created from predefined shapes set work OK. On Windows everything is OK
Has anyone guess what to do with this? Thanks


text:
Q: Changing int values of nested map using iterator depending on key string I currently have the following map
typedef map<int, int> inner;
map<string, inner> example;

example["hello"][1] = 100;
example["hi"][2] = 200; //need to increment 2 to 3, and increase by 200
example["bye"][3] = 300;
example["ace"][4] = 400;

What I want to do is modify values of the inner map, I am currently trying the following
int size; //second int in inner map
int count; //first int in inner map

for (map<string, inner>::iterator it = example.begin(); it != example.end(); it++)
    {
        cout << it->first << " " ;
        for (inner::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++)
        {
            if (it->first.compare("hi")) //if at key "hi"
            {
                count = it2->first + 1;//increment by one
                size = it2->second + 200;//add 200
                example.erase("hi"); //remove this map entry
                example["hi"][count] = size; //re-add the map entry with updated values
            }

        }

I have tried a few different ways of doing this, but I definitely feel like I'm not understanding how the pointers are working. My output says that the count value is 2, and size is 300 (values modified at key "hello")

A: In addition to the info given in the comments:
If you have a size and count mapped to a string, name the size and count something that makes sense and make it a struct:
struct Stats {
    int size;
    int count;
};

std::map<std::string, Stats> example;

example["hello"] = {1, 100};
example["hi"] = {2, 200};

If you want to find the value at key "hi":
auto it = example.find("hi");
if (it != example.end()) {
    ++it->second.count;
    it->second.size += 200;
}

If you want to print all the elements:
for (auto& i : example) {
    std::cout << i.first << " = {"
              << i.second.size << ", "
              << i.second.count << "}\n";
}


text:
Q: React Native Apollo + Django: Network Request Failed I'm very new to programming and couldn't understand how my react native expo app isn't fetching data from my Django server (which is running). How can I resolve this?
I've got graphene-django running at the back.
Here's my App.js
Network Error: Network Request Failed
PS. I definitely need more practice on this. Thanks for the help.
import React, { Component } from 'react'
import { StyleSheet, Text, View } from 'react-native'
import { ApolloClient, HttpLink, InMemoryCache } from 'apollo-boost'
import { ApolloProvider, gql, useQuery } from '@apollo/client'

const client = new ApolloClient({
  link: new HttpLink({
    uri: 'http://(local-ip-address):8000/graphql'
  }),
  cache: new InMemoryCache(),
})

const todoQuery = gql`
  query fetchTodo {
    todos {
      rank
      title
      content
    }
  }
`;

const TodoComponent = () => {
  const { loading, error, data } = useQuery(todoQuery);

  if (loading) return "Loading...";
  if (error) return `Error! ${error.message}`;

  return (

      {data.todos.title.map((title) => (

{title}

        ))}

  );
};

export default class App extends Component {
  render() {
    return (
      <ApolloProvider client={client}>
        <View style={styles.container}>
          <Text style={styles.welcome}>Welcome to React Native!</Text>
          <Text>
            <TodoComponent style={styles.welcome}/>
          </Text>
        </View>
      </ApolloProvider>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
})

A: Your django server is running when you run your react application. Sometime because of that this error is come.


text:
Q: JS Filter array to remove duplicate values based on condition I have an array containing duplicate elemnets
let myArray=[
     {role: "role-1", deviceId: ""},
     {role: "role-2", deviceId: "d-2"},
     {role: "role-3", deviceId: "d-3"},
     {role: "role-1", deviceId: "d-1"},
     {role: "role-2", deviceId: ""},
     {role: "role-4", deviceId: ""}
     {role: "role-5", deviceId: ""}
]

I want to remove the duplicate roles and have array which contains roles without empty("") deviceIds and if deviceId is empty keep only one role without duplicates in this way
myArray=[
         {role: "role-1", deviceId: "d-1"},
         {role: "role-2", deviceId: "d-2"},
         {role: "role-3", deviceId: "d-3"}
         {role: "role-4", deviceId: ""}
         {role: "role-5", deviceId: ""}

 ]

I have written the function in this way
function dedupeByKey(arr, key) {
  const temp = arr.map(el => el[key]);
  return arr.filter((el, i) =>
    temp.indexOf(el[key]) === i
  );
}

console.log(dedupeByKey(myArray, 'role'));

But in the result, its not checking to give priority for deviceId with values and role with empty deviceId is getting added. How to fix this?

A: You can map the unique role to an object and reduce the object to an array as following code snippet

let myArray = [
     {role: "role-1", deviceId: ""},
     {role: "role-2", deviceId: "d-2"},
     {role: "role-3", deviceId: "d-3"},
     {role: "role-1", deviceId: "d-1"},
     {role: "role-2", deviceId: ""},
     {role: "role-4", deviceId: ""},
     {role: "role-5", deviceId: ""}
];

var uniqueObj = myArray.reduce(function(acc, item) {
  var deviceId = acc[item.role] && acc[item.role].deviceId || item.deviceId;
  acc[item.role] = item;
  acc[item.role].deviceId = deviceId;
  return acc;
}, {});

var result = Object.keys(uniqueObj).reduce(function(acc2, item) {
  acc2.push(uniqueObj[item]);
  return acc2;
}, []);

console.log(result);

A: You could apply a filter an look ahead in the array for duplicates to decide to filter the index or keep it

const myArray= [
     {role: "role-1", deviceId: ""},
     {role: "role-2", deviceId: ""},
     {role: "role-3", deviceId: "d-3"},
     {role: "role-1", deviceId: "d-1"},
     {role: "role-2", deviceId: ""},
     {role: "role-4", deviceId: ""},
     {role: "role-5", deviceId: ""}
]

const cleanArray = myArray.filter( (item,index,array) => {
  if ( item.deviceId === "") {
    // filter it out when the same role is found in the array and the index isn't the same as current item you are looking at
    return !array.some((i,idx) => i.role === item.role && idx > index  )
  }
  return true
})

// for presentation: sort the array
const sortedArray = cleanArray.sort( (curr, next) => curr.role >  next.role? 1:-1);

console.log(sortedArray)

A: You can use reduce with default to object, and if you need, you can convert it to array at the end.

let myArray = [
     {role: "role-1", deviceId: ""},
     {role: "role-2", deviceId: "d-2"},
     {role: "role-3", deviceId: "d-3"},
     {role: "role-1", deviceId: "d-1"},
     {role: "role-2", deviceId: ""},
     {role: "role-4", deviceId: ""},
     {role: "role-5", deviceId: ""}
]

const res = myArray.reduce((agg, itr) => {
  if (agg[itr.role]) return agg // if deviceId already exist, skip this iteration
  agg[itr.role] = itr.deviceId  // if deviceId not exist, Add it
  return agg
}, {})

let make_array = Object.keys(res).map(key => { return { role: key, deviceId: res[key] }})

console.log(make_array)

A: I'd group by role, then take the first with an deviceId:
  function groupBy(array, key) {
    const result = { };
    for(const el of array) {
      if(!result[ el[key] ]) result[ el[key] ] = [];
       result[ el[key] ].push(el);
   }
  return result;
}

const result = [];
const grouped = groupBy(myArray, "role");
for(const group of Object.values(grouped)) {
  result.push(group.find(it => it.deviceId) || group[0]);
}


text:
Q: (Swift) when does the Cell init from StoryBoard? well, when i approach the cell in layoutDelegate Method, it makes error.
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ~~~, for: indexPath) as? MyCell {
        cell.configure(label: labels[indexPath.row])
        ...
    }

in my opinion, the collectionView's method order is
sizeForItemAt -> cellForItemAt
but i want to know cell's size in sizeForItemAt..
is the cell's init timing cellForItemAt???
I want to know cell's init timing..

A: You can't know size inside sizeForItemAt.
Looks like you already have configure method in your cell. You can add constraints inside your cell and modify constant value depending on your model:
class Cell: UICollectionViewCell {

    @IBOutlet var constraint: NSLayoutConstraint!

    func configure(label: String) {
        constraint.constant = // new value
    }
}

If you can't do that or prefer working with real frames, the only place you should interact with real view size is your cell layoutSubviews().
Call setNeedsLayout() to make sure cell will layoutSubviews: on first appearance it'll do it automatically, but when reusing it may not. Something like this:
class Cell: UICollectionViewCell {

    func configure(label: String) {
        setNeedsLayout()
        somePrameter = // new value
    }
    private var somePrameter: CGFloat?

    override func layoutSubviews() {
        super.layoutSubviews()
        if let somePrameter = somePrameter {
            // do your calculations
        }
    }
}


text:
Q: pass adoconnection from vba to delphi I'm looking to create a COM object in a VBA macro and then pass it to a Delphi DLL (D2009).  What should my procedure declaration in Delphi look like?
Background:
I'm expecting (hoping) the VBA macro to:
   create the COM object,
   invoke the Delphi DLL,
   pass the COM object to the Delphi DLL procedure,
   stay alive until the Delphi DLL closes itself (the DLL will have embedded forms for the user to interact with).
I think I'll need to create a callback function to let the VBA macro know that I'm done so it can tidy up but I'll work on that independently of this question.
UPDATE
More specifically: What should the exported function declaration be for the Delphi DLL.

A: you have to pass ADO Connection interface link _Connection to delphi procedure
then create TADOConnection instance and replace ConnectionObject with new interface link
library Project1;
uses ADODB;

{$R *.res}

    procedure SetConnection(aDBConnection : _Connection);  stdcall;
    var connect : TADOConnection;
    begin
        connect := TADOConnection.Create(nil);
        try
            connect.ConnectionObject := aDBConnection;
            //here you can use your connection
        finally
            connect.Free();
        end;
    end;

exports SetConnection name 'SetDBConnection';

begin
end.

it is better to use stdcall calling convention. using export keyword setConnection proc is available from uotside with SetDBConnection name , so you can LoadLibrary and getProcAddress to find its entry point (really I don't know VBA so I can't say how to load library using it)


text:
Q: copy object from a subview then place object I want my swift code to copy the object which is a brown view. So the user hits the copy button then the user hits the object they want to copy and then they point to the area where they want to place the object. Basically the gif below is exactly what I am look at I don't know if you would do something like a clone of something like this.

import UIKit;import CoreData

class ViewController: UIViewController {

    var addBoxes = [UIImageView]()
    let subview = UIImageView()
    var currentView: UIView?

    var box = UIButton()

    var copyButton = UIButton()

    override func viewDidLoad() {
        super.viewDidLoad()
        [box,copyButton].forEach {
            $0.translatesAutoresizingMaskIntoConstraints = false
            view.addSubview($0)
        }

        box.backgroundColor = .red

        box.setTitle("Add", for: .normal)

        copyButton.setTitle("Copy", for: .normal)

        NSLayoutConstraint.activate([

        box.leadingAnchor.constraint(equalTo: copyButton.trailingAnchor),
        box.bottomAnchor.constraint(equalTo: view.bottomAnchor),
        box.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.04),
        box.widthAnchor.constraint(equalTo:view.widthAnchor ,multiplier: 0.5),

        copyButton.leadingAnchor.constraint(equalTo: view.leadingAnchor),
        copyButton.bottomAnchor.constraint(equalTo: view.bottomAnchor),
        copyButton.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.04),
        copyButton.widthAnchor.constraint(equalTo:view.widthAnchor ,multiplier: 0.5),

        ])

        copy.addTarget(self, action: #selector(copyBox), for: .touchDown)
        box.addTarget(self, action: #selector(addQuarter), for: .touchDown)

        copyButton.backgroundColor = .blue

    }

    override var prefersStatusBarHidden: Bool {
        return true
    }

    @objc func copyBox() {

    }

    @objc func handlePanGestured(_ gesture: UIPanGestureRecognizer) {
        currentView = gesture.view

        let draggedView = gesture.view!
        view.bringSubviewToFront(draggedView)

        let translation = gesture.translation(in: view)
        draggedView.center = CGPoint(x: draggedView.center.x + translation.x, y: draggedView.center.y + translation.y)
        gesture.setTranslation(.zero, in: view)
    }

    @objc func addQuarter(){

        let subview = UIImageView()

        subview.isUserInteractionEnabled = true
        addBoxes.append(subview)
        view.addSubview(subview)

        let pan = UIPanGestureRecognizer(target: self, action: #selector(handlePanGestured(_:)))

        subview.addGestureRecognizer(pan)

        subview.frame = CGRect(x: view.bounds.midX , y: view.bounds.midY + CGFloat(100), width: CGFloat(100), height: 100)
        subview.backgroundColor = .brown

        addBoxes.append(subview)

    }
}

A: a way to achieve copy.
You can do it in the Model level.
In your case, to copy View, is to get the View property ( Frame Size, Color ),
then create a new one.

here is the code instruction
model part
// you can add info , in your needs
struct ViewModel{
     let color: UIColor
     let size: CGSize
}

Logic Part:
add an UITapGestureRecognizer  to the base view (add part view)
in copy mode, the view isUserInteractionEnabled false,
in add mode, the view isUserInteractionEnabled true,
var selectModel: ViewModel?

@objc func copyBox() {

    // now in the copy mode
}

func selectView(){
      // get current model
      selectModel = ViewModel(color: yourView.backgroundColor, size: yourView.frame.size)
}

@objc func AddBox() {

    // now in the add mode / paste mode
}

func touchToAdd(_ gesture: UITapGestureRecognizer){
     // get the tap location,
     // the location point is the new view's center

     //  use the model from `func selectView(){`

     //  now you got center . frame size 、color, enough to create a new one ( a copy)
}

A: Achieve your requirement with code
class ViewController: UIViewController {

var addBoxes = [UIImageView]()
let subview = UIImageView()
var currentView: UIView?
var location: CGPoint = CGPoint.zero

var box = UIButton()

var copyButton = UIButton()

override func viewDidLoad() {
    super.viewDidLoad()
    [box,copyButton].forEach {
        $0.translatesAutoresizingMaskIntoConstraints = false
        view.addSubview($0)
    }

    box.backgroundColor = .red

    box.setTitle("Add", for: .normal)

    copyButton.setTitle("Copy", for: .normal)

    NSLayoutConstraint.activate([

    box.leadingAnchor.constraint(equalTo: copyButton.trailingAnchor),
    box.bottomAnchor.constraint(equalTo: view.bottomAnchor),
    box.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.04),
    box.widthAnchor.constraint(equalTo:view.widthAnchor ,multiplier: 0.5),

    copyButton.leadingAnchor.constraint(equalTo: view.leadingAnchor),
    copyButton.bottomAnchor.constraint(equalTo: view.bottomAnchor),
    copyButton.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.04),
    copyButton.widthAnchor.constraint(equalTo:view.widthAnchor ,multiplier: 0.5),

    ])

    copyButton.addTarget(self, action: #selector(copyBox), for: .touchDown)
    box.addTarget(self, action: #selector(addQuarter), for: .touchDown)

    copyButton.backgroundColor = .blue

    self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTapGestured(_:))))

}

override var prefersStatusBarHidden: Bool {
    return true
}

@objc func copyBox() {
    if let copyObject = currentView?.copyView as? UIImageView{
        copyObject.center = location
        copyObject.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(handlePanGestured(_:))))
        view.addSubview(copyObject)
    }
}

@objc func handlePanGestured(_ gesture: UIPanGestureRecognizer) {
    currentView = gesture.view

    let draggedView = gesture.view!
    view.bringSubviewToFront(draggedView)

    let translation = gesture.translation(in: view)
    draggedView.center = CGPoint(x: draggedView.center.x + translation.x, y: draggedView.center.y + translation.y)
    gesture.setTranslation(.zero, in: view)
}

@objc func handleTapGestured(_ gesture: UITapGestureRecognizer) {
    if self.view == gesture.view{
        let loc = gesture.location(in: self.view)
        location = loc
    }
}

@objc func addQuarter(){

    let subview = UIImageView()

    subview.isUserInteractionEnabled = true
    addBoxes.append(subview)
    view.addSubview(subview)

    let pan = UIPanGestureRecognizer(target: self, action: #selector(handlePanGestured(_:)))
    subview.addGestureRecognizer(pan)

    subview.frame = CGRect(x: view.bounds.midX , y: view.bounds.midY + CGFloat(100), width: CGFloat(100), height: 100)
    subview.backgroundColor = .brown

    addBoxes.append(subview)

}
}

extension UIView{
var copyView : UIView?{
    if let archiv = try? NSKeyedArchiver.archivedData(withRootObject: self, requiringSecureCoding: false){
        if let view = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(archiv) as? UIView{
            return view
        }
    }
    return nil
}
}


text:
Q: How to store user search queries in SharePoint Online in a list I want to store the user search queries which are entered in the search box in a list and display them in a page without duplicates. I know I can get the excel report from popularity and search reports but not able to get them programatically in SharePoint Online.

A: You would have to roll this yourself. There is no API for user query history at this time. As for storing it in a list, that would be easy. Then you can make the queries clickable by linking them to your search center using the k= query string parameter.


text:
Q: Admin "manage categories" error after remove "size chart"extension i'm still having problem. please help!
I recently installed "size chart" extension and removed, and after that,
in my admin page, "Manage Categories" is not working.  But all other page seems to work fine.
I research other peoples question, but still couldn't figured it out.
i'm getting this error below.
Source model "maattabel/categorie" not found for attribute "maattabel_categorie"

A: You should find in table eav_attribute an entry with source_model = 'maattabel/categorie' and set source_model empty. For example, run this query:
UPDATE eav_attribute SET source_model = '' WHERE source_model = 'maattabel/categorie'

A: you get this error because you had an extension that was disabled (like) but a category attribute remained in the database.
If you disabled the extension it means you don't need the attribute anymore. So you can delete it.
Run this query on your database:
DELETE FROM `eav_attribute` WHERE `source_model` = 'maattabel/categorie';

Just to be on the safe side, you should look for other attributes that might have a source model that refers to the extension.
Run this query:
 SELECT * FROM `eav_attribute` where `source_model` like `%maattabel%`.

In case you find other records, back-up your db and delete them also.

A: SELECT * FROM eav_attribute WHERE source_model LIKE "maattabel_%
Then select this row and delete from database
clear cache it has done


text:
Q: SharePoint 2010 get all the files and folders recursively Post: http://******.com/_vti_bin/SiteData.asmx
SOAPAction:
http://schemas.microsoft.com/sharepoint/soap/GetListCollection
request:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
  </soap:Body>
</soap:Envelope>

Using above i get a list of all the top level folders/lists available
After getting all the top level folders using the same information i want to get all the lower level folders and their files using soap requests.
What i have tried is:
Post: http://******.com/_vti_bin/Lists.asmx
Soapaction:
http://schemas.microsoft.com/sharepoint/soap/GetListItems
Request:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <listName>test1</listName>
     <QueryOptions>
           <IncludeMandatoryColumns>TRUE</IncludeMandatoryColumns>
           <ViewAttributes Scope="RecursiveAll"/>
           <DateInUtc>TRUE</DateInUtc>
        </QueryOptions>
    </GetListItems>
  </soap:Body>
</soap:Envelope>

which should have returned all the folders and sub folders inside listname test1.
But again it returned only top level files and folders.
What expected is: to return all the files and folders recursively under list test1
Thanks in advance


text:
Q: For a simple $n$-step random walk, how to show that the mean number of visits to the point $b$ is $\sum_{n=1}^\infty P(S_1 \cdots S_n \neq 0, S_n=b)$? I'm reading Grimmett and Stirzaker's Probability and Random Processes and stuck on one the claims.
In the scenario where $S_n$ is a simple random walk starting at $S_0 = 0$, the authors make the claim that, letting "$\mu_b$ be the mean number of visits of the walk to point $b$ before it returns to its starting point,"
$$
\mu_b = \sum_{n=1}^\infty P(S_1 \cdots S_n \neq 0, S_n=b).
$$
This claim is on the bottom of page 79, which can be found here: https://books.google.com/books?id=G3ig-0M4wSIC&pg=PA79&lpg=PA79&dq=mean+number+of+visits+of+the+walk+to+the+point+b+grimmett+probability&source=bl&ots=BGliWRNRI2&sig=e6Mc2yLjAReDDMIeFLrJ12ivwkY&hl=en&sa=X&ved=0ahUKEwj159O_tM3SAhXE4iYKHemQCQEQ6AEIIjAB#v=onepage&q&f=false
I'd appreciate the help!

A: The number of visits $N: \Omega \rightarrow \mathbb{N}$ of the random walk to $B$ before returning to it's origin (taken to be $0$) is given by the random variable
$$
N = \sum_{k = 1}^{+\infty} \mathbb{I}\{S_{1}...S_{k-1} \neq 0\}.\mathbb{I}\{S_{k}=B\} = \lim_{n \rightarrow +\infty} \, \,  \sum_{k = 1}^{n} \mathbb{I}\{S_{1}...S_{k-1} \neq 0\}.\mathbb{I}\{S_{k}=B\}
$$
I use $\mathbb{I}$ as the indicator function here (can't seem to produce the correct symbol). Hence, by monotone convergence:
$$
E(N) = E(\lim_{n \rightarrow +\infty} \, \,  \sum_{k = 2}^{n} \mathbb{I}\{S_{1}...S_{k-1} \neq 0\}.\mathbb{I}\{S_{k}=B\}) =  \sum_{k = 1}^{+\infty}P(S_{1}...S_{k-1} \neq 0, S_{k} =B)
$$

A: This is linearity of expectation and monotone convergence.
\begin{align*}
E(\text{# visits to $b$ before returning to origin}) \\
= E(\sum_{i=1}^n\{\text{visit at time $n$ to $b$ before returning to origin}\})\\
= \sum_{n=1}^\infty P(S_1 \cdots S_n \neq 0, S_n=b)
\end{align*}


text:
Q: how to sort particular columns row in datatable using c# eg:-
var Rows = (from row in dt1.AsEnumerable()
                            orderby row["Amount"] descending
                            select row);

if table like this
              RegId     Name

              101       jone

              102       Raj

              103       guru

       i want output like this using c# DataTable

              RegId     Name

              103       jone

              102       Raj

              101       guru

i want sort only the regid column rows

A: So you want to order one column but keep the rest of the column in their old order? Strange requirement, are the columns not related to each other?
However, following code will select the desired column and order it descending. Then the DataTable will be updated with the new values of this column:
List<int> amountsOrdered = dt1.AsEnumerable()
    .Select(r => r.Field<int>("Amount"))
    .OrderByDescending(i => i)
    .ToList();
for (int i = 0; i < dt1.Rows.Count; i++)
    dt1.Rows[i].SetField("Amount", amountsOrdered[i]);

Note that the Field extension method is strongly typed what is a good thing. But it can cause an exception if your column's type is string. Then you first need to Parse it to int anyway.

A: var regIds = dt1.AsEnumerable()
                .Cast<DataRow>()
                .Select(r => (int)r["Amount"])
                .OrderByDescending(id => id)
                .ToArray();

for(int i=0; i < dt1.Rows.Count; i++)
{
    DataRow row = dt1.Rows[i];
    row["Amount"] = regIds[i];
}

Make sure you disable the constraints (if any) on the uniqueness of Amount column of your data table. More info in the documentation page.

A: if you can use dataview, then you can simple use dataview.sort = "expression"
otherwise i think there is no default option to sort data table, other than looping


text:
Q: RPC Server Is Unavailable error and Directory does not exist Background
I have written a utility that watches for files in a certain directory, and then copies them to defined target locations on remote machines. There is also a feature that allows stopping defined services in order to allow copying to the target.
In our work environment, these remote machines are typically VMs (we use VMWare Workstation) and the machines are part of a VM sub-domain, and are configured to use NAT networking (share the host machine's IP address). So when I say "remote" it's really referring to a VM running on the host.
Problem
For my utility, I'm trying to copy files using a UNC path to the target directory, and using the machine name get a list of services using the ServiceController.GetServices(string machineName) method.
So if you had a VM named server-1, you might be trying to copy a file to \\server-1\c$\destinationfolder. Most of the time this works, but sometimes I see an excetion because the target directory can't be found. When this happens, we also see an error when trying to get services on the remote machine - "The RPC server is unavailable."
When the VM is restarted, everything works fine... for a while.
I'm having a hard time trying to nail down the issue, because it's sporadic and doesn't affect most people. I'm wondering if it's an IP issue, where VMWare changes the IP and it's stale in the host's cache? (If I sound like I don't really know what I'm talking about here, it's only because I don't... my networking knowledge is fairly basic). When I look up issues with the 'RPC server is unavailable' error, I see a lot of answers regarding firewalls, which I don't believe is the case here. We don't run anything like McAfee internally and since it works most of the time, it doesn't seem like the cause.
Actual Questions
Anyone have any thoughts as to what might cause this problem? As a follow-up, if it is a stale IP issue, how could I recreate the issue for debugging purposes, so I can try to come up with a good way to resolve it going forward?


text:
Q: MySql.Data.MySqlClient.Replication.ReplicationManager throws an System.TypeInitializationException I'm having trouble with my code to access a MySQL Database. Everytime I try to open my connection, a System.TypeInitializationException is thrown by MySql.Data.MySqlClient.Replication.ReplicationManager. Here is my code:
DataTable results = new DataTable("Results");
using (MySqlConnection connection = new MySqlConnection("SERVER=127.0.0.1;DATABASE=foo;UID=bar;PASSWORD=foobar;"))
{
    using (MySqlCommand command = new MySqlCommand(queryString, connection))
    {
        command.Connection.Open(); //throws System.TypeInitializationException
        command.ExecuteNonQuery();

        using (MySqlDataReader reader = command.ExecuteReader())
        results.Load(reader);
    }
}

Edit: I guess MySQL Driver was corrupt. After an upgrade from Windows 7 to Windows 10 everything worked fine.

A: I had the same problem but when i installed the MySql.Data.dll using Nuget then the problem is solved
Install MySql.Dll file from Nuget,
not from MySQL Website.

A: Your connection string format is wrong. Try this :
static string cs = @"server=localhost;user id=bar;password=foobar;database=foo;";
DataTable results = new DataTable("Results");
using (MySqlConnection connection = new MySqlConnection(cs))
{
    using (MySqlCommand command = new MySqlCommand(queryString, connection))
    {
        command.Connection.Open(); //throws System.TypeInitializationException
        command.ExecuteNonQuery();

        using (MySqlDataReader reader = command.ExecuteReader())
        results.Load(reader);
    }
}

A: In my case, it raised error only in production. It was due to a wrong assumption in the MySql.Data package. It for some reason seems to demand to be in the same folder as the orchestrating dll (it was referencing another dll which was referencing MySql). I resolved my issue by removing MySql.Data and instead installing MySqlConnector package as suggested in here.


text:
Q: Libevent - causes an error at the very start Please tell me: I connected the libvent to the project for Windows VS2019 and called only one function Libevent:
#include <event2/bufferevent.h>
#include <event2/buffer.h>
#include <event2/event.h>

int main(void)
{
    struct event_base* Event_base = event_base_new();
}

And immediately got the error:
[warn] evsig_init_: socketpair: Either the application did not invoke WSAStartup, or an error occurred in WSAStartup.

That is, i understand that the point is that you need to initialize the Winsosk library Windows and call the WSAstartup() function, but shouldn't Libevent himself do this internally?


text:
Q: Handling events exposed on a .NET class via COM in VB6 Handling events exposed on a .NET class via COM in VB6
My test .NET (class libary registered for interop in compiler settings) code:
Imports System.Runtime.InteropServices

<InterfaceType(ComInterfaceType.InterfaceIsIDispatch), ComVisible(True)> _
Public Interface MyEventInterface
    <DispId(1)> Event Exploded(ByVal Text As String)
    <DispId(2)> Sub PushRedButton()
End Interface

<ClassInterface(ClassInterfaceType.None)> _
Public Class EventTest
    Implements MyEventInterface

    Public Event Exploded(ByVal Text As String) Implements MyEventInterface.Exploded

    Public Sub PushRedButton() Implements MyEventInterface.PushRedButton

        RaiseEvent Exploded("Bang")

    End Sub

End Class

My test VB6 application winforms code (which references the above class libary):
Public ct As New ComTest1.EventTest

Private Sub Command1_Click()

    ct.add_Exploded (ExplodedHandler)

    ct.PushRedButton

    ct.remove_Exploded (ExplodedHandler)

End Sub

Private Sub ExplodedHandler(ByVal Text As String)

    MsgBox Text

End Sub

Specifially I'm not sure how to set up the handler in VB6 the compile error I get is "Argument not optional" on this line in the VB6:
ct.add_Exploded (ExplodedHandler)

A: C#
[ComVisible(true)] //Exposed
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] //Our managed interface will be IDispatch
public interface IMathEvents
{

    void OnOperationCompleted(string message);

}
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(IMathEvents))]  //Our event source is IMathEvents interface
[ComDefaultInterface(typeof(IMath))]
public class Math:IMath  /*IMath interface just declares a method named Add */
{
    public int Add(int x, int y)
    {
        if (null != this.OnOperationCompleted)
            this.OnOperationCompleted("Operation completed, result: " + (x+y).ToString());
        return x + y;
    }

    [ComVisible(false)]
    public delegate void OperationCompletedDel(string message); //No need to expose this delegate
    public event OperationCompletedDel OnOperationCompleted;

}
[ComVisible(true)]
public interface IMath
{
    int Add(int x, int y);
}

vb

Private WithEvents m As Math
Private Sub Form_Load()
Set m = New PayClient.Math

End Sub
Private Sub m_OnOperationCompleted(ByVal Text As String)
MsgBox Text

End Sub
Private Sub Command2_Click()
     m.Add 1, 2
End Sub

A: Use <ComSourceInterfaces(GetType(the interface name))> for the events in .NET and WithEvents in VB6
.NET class libary:
Imports System.Runtime.InteropServices

' This interface is to expose the events
<Guid("28C7DCE1-90EF-4a30-AF7F-4187F9FFFDEB")> _
<InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
Public Interface MathsEvents
    <DispId(1)> _
    Sub Calculated(ByVal Result As Double)
End Interface

' This interface is to expose the properties and methods
<Guid("86CE5E8D-777D-4cd5-8A7D-7F58737F1DB4")> _
<InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
Public Interface _Maths
    <DispId(2)> _
    Property ValueA() As Double
    <DispId(3)> _
    Property ValueB() As Double
    <DispId(4)> _
    ReadOnly Property Result() As Double
    <DispId(5)> _
    Sub Add()
End Interface

' This is the actual class
' The events are exposed by using the ComSourceInterfaces attribute
' The properties and methods are exposed using the Implements keyword
<Guid("C58721B1-15B3-4eeb-9E1E-BCDA33D38EE6")> _
<ClassInterface(ClassInterfaceType.None)> _
<ComSourceInterfaces(GetType(MathsEvents))> _
Public Class Maths
    Implements _Maths
    Public Event Calculated(ByVal Result As Double)
    Private mValueA As Double
    Private mValueB As Double
    Private mResult As Double

    Public Property ValueA() As Double Implements _Maths.ValueA
        Get
            Return mValueA
        End Get
        Set(ByVal value As Double)
            mValueA = value
        End Set
    End Property

    Public Property ValueB() As Double Implements _Maths.ValueB
        Get
            Return mValueB
        End Get
        Set(ByVal value As Double)
            mValueB = value
        End Set
    End Property

    Public ReadOnly Property Result() As Double Implements _Maths.Result
        Get
            Return mResult
        End Get

    End Property

    Public Sub New()
        mValueA = 0
        mValueB = 0
        mResult = 0
    End Sub

    Public Sub Add() Implements _Maths.Add
        mResult = mValueA + mValueB
        RaiseEvent Calculated(mResult)
    End Sub

End Class

VB6 test application:
Private WithEvents calc As Maths

Private Sub btnAdd_Click()

   calc.ValueA = CDbl(txtValueA.Text)
   calc.ValueB = CDbl(txtValueB.Text)
   calc.Add

End Sub

Private Sub calc_Calculated(ByVal Result As Double)
   txtResult.Text = CStr(Result)
End Sub

Private Sub Form_Load()

   Set calc = New Maths

End Sub


text:
Q: Vary label color in R Leaflet I have a data frame with a binary variable and xy coordinates. I can map the data with Leaflet and vary the color of the markers for each variable, but I want to know if I can also vary the label color.
Below is an example of the data. Right now I can only make the labels one color (e.g., black). In this example, I'd like labels for electronics to be blue font and labels for non-electronics to be red font.
library(leaflet)
library(mapview)

data <- data.frame("ID"=1:5, "Name" = c("ipod", "book", "phone", "ipod", "book"), "Color" = c("blue","red","blue","blue","red"), "Lat"=c(38.56250,38.66163,38.66574,38.55060,38.55060), "Long"=c(-90.59690,-90.5000,-90.37138,-90.35756,-90.5285))

pal<-(colorFactor(c("blue","red"), domain=c("blue", "red")))

map <-leaflet()  %>% addTiles() %>%
  setView(lng = -90.576959, lat  = 38.440455, zoom = 10) %>%
  addProviderTiles("Esri") %>%
  addCircleMarkers(data=data, lng = ~Long, lat= ~Lat, radius = 5, fillColor = ~pal(`Color`), color="black", fillOpacity = .90, weight = 1) %>%
  addLabelOnlyMarkers(
    data = data,
    label = as.character(data$Name),
    labelOptions = labelOptions(noHide = T, #hides labels
                                direction = "auto",
                                textOnly = F,
                                offset = c(0,0),
                                style = list(
                                  "color" = "black",
                                  "font-family" = "serif",
                                  "font-style" = "normal",
                                  "box-shadow" = "1px 1px rgba(0,0,0,0.25)",
                                  "font-size" = "12px",
                                  "border-color" = "rgba(0,0,0,0.5)",
                                  "padding" = "2px"
                                )))
map

A: You need to do a little workaround by replace the label with HTML.
In addLabelOnlyMarkers() function, repalce label =  as.character(data$Name) with following codes:
label = purrr::map(glue("{as.character(data$Name)}"),htmltools::HTML)

So instead of using text as labels, you are using HTML as labels:
[[1]]
ipod

[[2]]
book

[[3]]
phone

[[4]]
ipod

[[5]]
book


text:
Q: How to return ICollection from method? Consider following method
public ICollection<int> method()
{
    ICollection<int> col = new List<int>();
    return col;
}

HashSet<int> result = (HashSet<int>) method();

Of course I'm getting error "Unable to cast object of type List to HashSet", because I've instantiaded col with List in method()
Is it possible to have generic method, which return ICollection and can be casted at HashSet or List, depending on my needs?

A: No, you can't straight cast it because the instance returned is not a HashSet or anything but a List, but you can easily use the ICollection instance returned to initialize a new instance of whatever you need.  For example:
ICollection<int> result = Method();
HashSet<int> newHashSet = new HashSet<int>(result);


text:
Q: How do I convert a text file into a list then sort it with Python? I have a text file with the following lyrics:

'First verse Im off till I'm off the island
  i'm riding like autoban on autopilot
  before I touch dirt I deal you all with kindness
  my natual persona much worse'

I want to convert it to a list, then sort it alphabetically, but what I keep getting is: [[First', 'verse', 'Im', 'off', 'till, "I'm", 'off' , 'the', 'island'] [then it prints the third line], [then the second line], [then the fourth line]]
and then it puts it into a list within a list [[ text, text..., ]]
How do I print it so it prints in order in one list and is sorted in
alphabetical order using python code?  Here is what I have so far:
fname = raw_input("Enter file name: ")  #prompts user for .txt file
fhand = open(fname)     #reads file
NewList =  []    #creating new list to append to
for line in fhand:    #for the lines in the text file, read them
    line.rstrip()   # strip the white space
    words = line.split()   #split the txt file into string words

    for word in words:      #for every word in txt file
        if words not in NewList:  #if not in the NewList
                NewList.append(words) #then appended words to Newlist

                NewList.sort()    #sort it alphabetically

print NewList   #then print the sorted list

A: It's possible in a single line!
sorted(open('file.txt').readlines())

or, if you want it to be printed like a single file
print "".join(sorted(open('file.txt').readlines()))

A: This creates a set to remove duplicate words and then sort it to a list
fname = raw_input("Enter file name: ")
with open(fname ,"r") as f:
    l = sorted(set([word for line in f for word in line.split()]))

A: Solution in Python 3
fname = input("Enter file name: ")
fh = open(fname)
lst = list()
newlist=[]
for line in fh:
    lst+=line.split()
for item in lst:
    if item not in newlist:
        newlist.append(item)
newlist.sort()
print(newlist)

you're welcome

A: #For the second for loop, using continue will skip the already present word
#in the list and go to the top of the loop for a new iteration.

fname = input("Enter file name: ")
handler = open(fname)
lst = list()
alst = list()

for line1 in handler :
    line1.rstrip()
    lst += line1.split()

for i in lst:
    if i not in alst:
        alst.append(i)
    else:
        continue
alst.sort()
print(alst)


text:
Q: Adding Padding to absolutely positioned div within parent expanding outside parent On the following site, I have a child div absolutely positioned at the bottom of its parent div - the hero image.
http://helpthemgrow.staging.wpengine.com/
Adding padding to the child div causes it to break out of parent div
Here is my code:

                    <img width="200" height="300" src="http://helpthemgrow.staging.wpengine.com/wp-content/uploads/2018/01/help-tehm-grow-book-cover-200x300.jpg" class="image wp-image-43  attachment-medium size-medium" alt="" style="max-width: 100%; height: auto;" srcset="http://helpthemgrow.staging.wpengine.com/wp-content/uploads/2018/01/help-tehm-grow-book-cover-200x300.jpg 200w, http://helpthemgrow.staging.wpengine.com/wp-content/uploads/2018/01/help-tehm-grow-book-cover.jpg 250w" sizes="(max-width: 200px) 100vw, 200px">

Careers are developed one conversation at a time – over time.

                Learn more

Here is my CSS:
.home-hero {
    background-image: url('/wp-content/uploads/2018/02/htg-hero-slide-one.jpg');
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    width: 100%;
    padding: 100px 0 150px 0;
    color: #fff;
    margin: 0;
    position:relative;
}
.home-hero-cta {
    height: 50px;
    width: 100%;
    background: rgba(0,0,0,0.5);
    position: absolute;
    bottom: 0;
}

.home-hero-cta .wrap {
    padding: 20px 0;
}

.home-hero-cta-text {
    font-size: 25px;
}

What am I doing wrong?

A: Remove the set height that you have for home-hero-cta and that should fix your issue.


text:
Q: How to keep lambda warm using zappa python I have an API function in python and deployed it on aws lambda using zappa. When I am hitting my API after 15 minutes time its taking atleast 5 to 10 seconds to respond (which is too long for my API) for first request. I have came to know about cold start issue in aws lambda. How to keep lambda warm using zappa python?

A: Zappa has a default warmer that keeps invoking the lambda to avoid cold starts - check https://github.com/Miserlou/Zappa#advanced-usage (make sure keep_warm is set to true).
You can verify that there is a CloudWatch event rule of a scheduled event.


text:
Q: JavaScript object's function not returning i have a question about JavaScript!
I've been studying JavaScript for a few days, but it wasn't that hard cuz i alread have a lot of knowledge from Java. I have programmed for long time until now. I work with objects and i wanted to add a function to the object. But that funcion doesn't work properly...
Code:
<!DOCTYPE html>

<html>

<head>
<script type="text/javascript">

    function person(name){
        this.name = name;
    }

    function printName(){
        return this.name;
    }

    var joza = new person("Josip");

</script>
</head>
<body>
<script type="text/javascript">
document.write(joza.printName());
</script>
</body>

</html>

So this code is supposed to use the object's function and print out it's name...
But... all I get is just a blank webpage!
Please help!!
Thank you!!

A: Ignoring the HTML for now here is your code:
function person(name){
  this.name = name;
}

function printName(){
  return this.name;
}

var joza = new person("Josip");
joza.printName() // Error

So what's going on above is that you are creating this person constructor function and then another function outside of it. Your joza object does not have the printName function on it.
The printName function is just a regular function that has its own context for this, which in this case is just the window.
When you call joza.printName you will find that printName doesn't exist on the joza object you just created.
Try this instead by adding your printName method to the actual returned person object:
function person(name){
  this.name = name;
  this.printName = function() {
    return this.name
  }
}

var joza = new person("Josip");
joza.printName() // "Josip"

A: You got some brutal answers, but the one with a lexical closure seems to be missing. So here you are:
function Person(name){
  this.printName=function(){
    console.log(name);
  };
}
test=new Person("John");
test.printName();

The thing is that JavaScript functions retain the environment where they were declared. So here the inner function can access local variables of the outer function, even when the outer function is not running any more. Actually it is similar to accessing final local variables from anonymous inner classes in Java, just these variables do not have to be final (so it would be perfectly possible to provide a setName method, which would alter the same name variable).
It is not very important/interesting for this particular use case, but this is a common way how you can get parameters into callback methods for example.
And the best part for confusion:
Your original code can be used too. JavaScript is not very picky about "this", you can invoke any method on any object:
function Person(name){
  this.name=name;
}
function printName(){
  console.log(this.name);
}
test=new Person("Jane");
printName.call(test);

Functions are objects, and they have a call method. Where the first argument sets this, and the rest are just passed as arguments for the method itself. For completeness: there is an apply method too, where the arguments for the function are passed as an array.
This is not very important here either, however a thing you should keep in mind is that this is not necessarily the object you expect. Yet again callback methods: if you use an object method as a callback, when the browser invokes it, this is usually the window object.

A: check this revision :
var person = function(name){

    var tmp = {};
    tmp.name = name;

    tmp.printName = function(){
        return tmp.name;
    }
return tmp;
}

var joza = new person("Josip");

Fiddle : https://jsfiddle.net/jwvvkgaf/
This is a factory pattern, one of the way to accomplish what you want.
If you want simple constructor pattern :
var person = function(name){
  this.name = name;

  this.printName = function() {
    return this.name;
  }

}

A: Just a minor change (you're trying to call the printName method of the person object).
function person(name){
  this.name = name;
  this.printName = function() {
    return this.name;
  }
}

var joza = new person("Josip");

document.write(joza.printName());

A:

(function(global){
    function person(name){
        this.name = name;
    }

    person.prototype ={
      printName: function(){
        return this.name;
      },
    };

    window.person = person;
}(window));

var joza = new person("Josip");

document.write(joza.printName());

Let me break it down for you. (function(){ /* code in here */ }()) this is a scope. Basically kind of like a namespace so you don't pollute the window global variable. Then you declare the function person which is more or less your "constructor" that constructor initializes the property name. Then, put your functions inside the prototype and call them.

A: Here's the way to add object like java in javascript
 function person(name){
            this.name = name;
        }

Add methods like this.  All Person objects will be able to invoke this
person.prototype.printName = function(){
    return this.name;
}

Instantiate new objects with 'new'
var joza = new person("Josip");

Invoke methods like this
 joza.printName();

A: <html>
<head>
    <script type="text/javascript">
        function person(name) {
            this.name = name;

            this.printName = function() {
                return this.name;
            }
        }
        var joza = new person("Josip");

    </script>
</head>
<body>
    <script type="text/javascript">
        document.write(joza.printName());

    </script>
</body>
</html>

The
function printName(){
        return this.name;
    }

is not a member of Person ,so you can get the name property from it, you should put the method inside the pesron object


text:
Q: Deleting a line shape in a excel file using vba I have a line shape in a excel file, named "Line 104". How do I delete this shape or other shape types, line using vba code ?

A: Courtesy of OP's comment:
ActiveSheet.Shapes("Line 104").Delete

A: try to use below piece of code
ActiveSheet.Shapes.Range(Array("Line 104")).Select
Selection.Delete

A: Sub DeleteShape()

Dim sht as Worksheet
Set sht = ThisWorkbook.Worksheets("SampleSheet")

Dim sObject as shape
For Each sObject in ActiveSheet.Shapes
    If sObject.Name = "Line 104" then
     sObject.Select
     Selection.Delete
    End If
Next

End Sub


text:
Q: Customized Hook with Observer not Rendering React published a nice custom hook example (useFriendStatus) where the hook subscribes to an API to update the online status.
I tried to simulate this example. My hook looks like the following:
export default function useStore(id) {
  const [data, setStatus] = useState(DataLayer.getData());

  useEffect(() => {

    function handleStatusChange() {
      console.log("udpate ...." + id);
      console.log(DataLayer.getData());
      setStatus(DataLayer.getData());
    }

    DataLayer.register({"id":id, "callback":handleStatusChange});
    setStatus(DataLayer.getData());
    return () => {
      DataLayer.unregister(id, handleStatusChange);
    };
  });

  return data;
}

The DataLayer implements a setInterval method which permanently notifies the hook and changes the data for testing purposes. Hence, I always get on my console the update.... message as well as the current object. This works fine!
My component looks like the following, but it does not re-render:
function MyComponent (props) {
  const config = useStore(Math.floor((Math.random() * 1000) + 1));

  return (

         {JSON.stringify(config, null, 3)}

  );
}

Why is my component,which uses the custom hook not updating?

A: The customHook works fine! The problem seems to be setState with an object. You have to create a copy of it every time when you want to update the state, e.g. with JSON.parse(JSON.stringify(obejct))
Simpliy passing a modified object to setState is NOT enough.


text:
Q: How to build a single form powershell gui application I would like to know how to do a gui powershell application that allows user to navigate through forms without using modal dialog boxes but only the parent dialog.
For example, I have a form A that has buttons and textboxes.
I want to display another form lets say B when the user clicks on a buttton but without opening a child dialog box.
Actually, I succeed to go to the form A to the form B.
What I really want to do is going to a third form lets say C from the form B by clicking on a button as well.
It's seems that I'm missing something and unfortunately I cant find someone who shows how to do it.
Here is a sample of the code.
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$form = New-Object System.Windows.Forms.Form
$form.Size = New-Object System.Drawing.Size( 300, 300 )
$button = New-Object System.Windows.Forms.Button
$button.Text = "gotoB"
$button.Location = New-Object System.Drawing.Point( 200, 200 )
$button.Size = New-Object System.Drawing.Size( 70, 25 )
$button.Add_Click( {
        $form.Controls.Remove( $button )
        $form.Update()
        LoadScreen2 -Form $form
    })
$form.Controls.Add( $button )
$form.ShowDialog()

function LoadScreen2 () {
    [cmdletbinding()] param
    (
        [Parameter(Mandatory = $True)]
        [System.Windows.Forms.Form]$Form
    )
    $bbutton = New-Object System.Windows.Forms.Button
    $bbutton.Text = "gotoC"
    $bbutton.Location = New-Object System.Drawing.Point( 200, 200 )
    $bbutton.Size = New-Object System.Drawing.Size( 70, 25 )
    $bbutton.Add_Click({
            $Form.Controls.Remove($bbutton)
            LoadScreen3 -Form $Form
    })
    $Form.Controls.Add($bbutton)
    $Form.Update()
}

function LoadScreen3 () {
    [cmdletbinding()] param
    (
        [Parameter(Mandatory = $True)]
        [System.Windows.Forms.Form]$Form
    )
    $cbutton = New-Object System.Windows.Forms.Button
    $cbutton.Text = "goNowhere"
    $cbutton.Location = New-Object System.Drawing.Point( 200, 200 )
    $cbutton.Size = New-Object System.Drawing.Size( 70, 25 )
    $cbutton.Add_Click({})
    $Form.Controls.Add($cbutton)
    $Form.Update()
}

A: I finally found how to do this.
I had to put the following line just before calling the LoadScreen3 function:
$Form.Controls.Clear()

A: Extending from my comment. So, just using group boxes (vs say your obversion to the tabbed interface option), yet ultimately the same thing.
All you'd need to do is add whatever from the elements you choose to each of the individual group boxes, they would all be contained in the individual group box.
Again, this is all UX/UI code and would work regardless of the programming language involved for other reasons. Your baseline UX/UI should just work. The code behind is for other data, string, interop needs.
$SingleFormUXUI = New-Object -TypeName System.Windows.Forms.Form

[System.Windows.Forms.GroupBox]$grpMainPage    = $null
[System.Windows.Forms.GroupBox]$grpDataPage    = $null
[System.Windows.Forms.GroupBox]$grpDetailsPage = $null

[System.Windows.Forms.Label]$lblMainPage       = $null
[System.Windows.Forms.Label]$lblFormPage       = $null

[System.Windows.Forms.ComboBox]$cbxSelectPage  = $null

function InitializeComponent
{
    $grpMainPage    = (New-Object -TypeName System.Windows.Forms.GroupBox)
    $grpDataPage    = (New-Object -TypeName System.Windows.Forms.GroupBox)
    $grpDetailsPage = (New-Object -TypeName System.Windows.Forms.GroupBox)
    $cbxSelectPage  = (New-Object -TypeName System.Windows.Forms.ComboBox)
    $lblMainPage    = (New-Object -TypeName System.Windows.Forms.Label)
    $lblFormPage    = (New-Object -TypeName System.Windows.Forms.Label)

    $grpMainPage.SuspendLayout()

    $SingleFormUXUI.SuspendLayout()
    #
    #grpMainPage
    #
    $grpMainPage.Controls.Add($lblMainPage)
    $grpMainPage.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]11,[System.Int32]12))
    $grpMainPage.Name     = [System.String]'grpMainPage'
    $grpMainPage.Size     = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]587,[System.Int32]325))
    $grpMainPage.TabIndex = [System.Int32]1
    $grpMainPage.TabStop  = $false
    $grpMainPage.Text     = [System.String]'MainPage'
    $grpMainPage.UseCompatibleTextRendering = $true
    $grpMainPage.Visible  = $false
    #
    #grpDataPage
    #
    $grpDataPage.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]12,[System.Int32]12))
    $grpDataPage.Name     = [System.String]'grpDataPage'
    $grpDataPage.Size     = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]586,[System.Int32]325))
    $grpDataPage.TabIndex = [System.Int32]2
    $grpDataPage.TabStop  = $false
    $grpDataPage.Text     = [System.String]'DataPage'
    $grpDataPage.UseCompatibleTextRendering = $true
    $grpDataPage.Visible  = $false
    #
    #grpDetailsPage
    #
    $grpDetailsPage.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]12,[System.Int32]12))
    $grpDetailsPage.Name     = [System.String]'grpDetailsPage'
    $grpDetailsPage.Size     = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]586,[System.Int32]325))
    $grpDetailsPage.TabIndex = [System.Int32]3
    $grpDetailsPage.TabStop  = $false
    $grpDetailsPage.Text     = [System.String]'DetailsPage'
    $grpDetailsPage.UseCompatibleTextRendering = $true
    $grpDetailsPage.Visible  = $false
    #
    #cbxSelectPage
    #
    $cbxSelectPage.FormattingEnabled = $true
    $cbxSelectPage.Items.AddRange(
        [System.Object[]]@([System.String]'Main Page',
        [System.String]'Data Page',
        [System.String]'DetailsPage Page')
    )

    $cbxSelectPage.Location          = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]444,[System.Int32]338))
    $cbxSelectPage.Name              = [System.String]'cbxSelectPage'
    $cbxSelectPage.Size              = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]153,[System.Int32]21))
    $cbxSelectPage.TabIndex          = [System.Int32]4
    #
    #lblMainPage
    #
    $lblMainPage.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]7,[System.Int32]17))
    $lblMainPage.Name     = [System.String]'lblMainPage'
    $lblMainPage.Size     = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]295,[System.Int32]19))
    $lblMainPage.TabIndex = [System.Int32]0
    $lblMainPage.Text     = [System.String]'Use the dropdown box to select a page to work with.'
    $lblMainPage.UseCompatibleTextRendering = $true

    $cbxSelectPage.Add_TextChanged(
    {
        switch($cbxSelectPage.Text)
        {
            'Main Page'
            {
                $grpMainPage.Visible    = $true
                $grpMainPage.BackColor  = [System.Drawing.ColorTranslator]::FromHtml("#4a90e2")
                $grpDataPage.Visible    = $false
                $grpDetailsPage.Visible = $false
            }
            'Data Page'
            {
                $grpDataPage.Visible    = $true
                $grpDataPage.BackColor  = [System.Drawing.ColorTranslator]::FromHtml("#50e3c2")
                $grpMainPage.Visible    = $false
                $grpDetailsPage.Visible = $false
            }
            'DetailsPage Page'
            {
                $grpDetailsPage.Visible   = $true
                $grpDetailsPage.BackColor = [System.Drawing.ColorTranslator]::FromHtml("#9b9b9b")
                $grpMainPage.Visible      = $false
                $grpDataPage.Visible      = $false
            }
        }
    })

    #
    #SingleFormUXUI
    #
    $SingleFormUXUI.ClientSize = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]599,[System.Int32]375))
    #
    #lblFormPage
    #
    $lblFormPage.Location                   = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]10,[System.Int32]338))
    $lblFormPage.Name                       = [System.String]'lblFormPage'
    $lblFormPage.Size                       = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]333,[System.Int32]19))
    $lblFormPage.TabIndex                   = [System.Int32]0
    $lblFormPage.Text                       = [System.String]'Welcome to my UX/UI. Use the dropdown box to select a page.'
    $lblFormPage.UseCompatibleTextRendering = $true
    #
    $SingleFormUXUI.Controls.AddRange(
        @(
            $lblFormPage,
            $grpMainPage,
            $grpDataPage,
            $grpDetailsPage,
            $cbxSelectPage
        )
    )
    $SingleFormUXUI.Text = [System.String]'Single from MDI UX/UI'

    $grpMainPage.ResumeLayout($false)
    $SingleFormUXUI.ResumeLayout($false)

    Add-Member -InputObject $SingleFormUXUI -Name grpMainPage -Value $grpMainPage -MemberType NoteProperty
    Add-Member -InputObject $SingleFormUXUI -Name lblMainPage -Value $lblMainPage -MemberType NoteProperty
    Add-Member -InputObject $SingleFormUXUI -Name grpDataPage -Value $grpDataPage -MemberType NoteProperty
    Add-Member -InputObject $SingleFormUXUI -Name grpDetailsPage -Value $grpDetailsPage -MemberType NoteProperty
    Add-Member -InputObject $SingleFormUXUI -Name cbxSelectPage -Value $cbxSelectPage -MemberType NoteProperty

    $SingleFormUXUI.ShowDialog()
}
. InitializeComponent


text:
Q: Minecraft 1.15.2 default resource pack to 1.12.2 I am aware that some of the subfolders in the assets folder in 1.15.2 are named differently from 1.12.2, I did change "block" to "blocks" and "item" to "items", but it doesn't seem to work.
I looked everywhere and for the life of me, I can't find a single person who attempted to do this.
I am also aware that some blocks and items names have changed, but even for example diamond_ore which has the same name for both versions, it didn't change to 1.15.2 texture.
Please, if you can tell me what I did wrong, or link me to some kind of converter, that would be amazing.

A: I haven't been able to figure it out, but I found someone on curseforge who backported it to 1.6 - 1.12 (name: Modernity) and so, I will be using their texture pack.


text:
Q: Convert String Values From Server Formatted as Double To Int Im working with a service that send back values of type String which contains floating point like Double as so for example "1240.86".
I want to cast it to Int and when i try to convert like so Int(stringObject) the cast fails when the values have floating points.
How can i cast it?
Thanks!

A: Try it in two steps:
if let aDouble = Double(someString) {
    let someInt = Int(aDouble)
}

or possibly:
let someInt = Int(Double(someString) ?? 0)

though the latter is a bit of a kludge since you probably don't want to force a value of 0 if the string isn't a valid number.

A: You could use the map(_:) method of Optional to optionally chain a conversion (initialization by, specifically) from String to Double followed by one from Double to Int and conditionally bind the resulting integer in case it is not nil (i.e. successfully converted):
let str = "1240.86"
if let number = Double(str).map(Int.init) {
    // number is of type Int and, in this example, of value 1240
}

A: You can separate string by dot .:
func printInt(from str: String) {
    let intValue = Int(str.components(separatedBy: ".")[0]) ?? 0
    print(intValue)
}

printInt(from: "1234.56")   // 1234
printInt(from: "1234")      // 1234
printInt(from: "0.54")      // 0
printInt(from: ".54")       // 0
printInt(from: "abc")       // 0


text:
Q: Where can I find *all* screensaver files on MacOS Sierra? When I go to "Desktop & Screen Saver", I see about 20 different screensavers. All online resources I've found have directed me to one of these locations, none of which contain ALL of the screensavers. In particular, I just want to edit/poke around in the .saver file for the Floating screensaver.
I can only find the abstract art screensavers like Flurry, Arabesque, Shell, Word of the Day, Random. There are other screen savers I can use, like Floating, Flip-up, Reflections, Origami, ...
Where are all of the other screensavers?
I've looked in these folders:
/Library/Screen Savers
    (only contains a folder with a bunch of pictures)
~/Library/Screen Savers
    (empty)
/System/Library/Screen Savers
    (only contains abstract screen savers mentioned above)
/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources
    (contains a bunch of irrelevant files)

A: In Mojave you have two kinds of screensavers:

*

*The abstract ones (these are the ones you already found: /System/Library/Screen Savers)

*The slideshows: /System/Library/PrivateFrameworks/Slideshows.framework/Versions/A/Resources/Content/Styles


text:
Q: How to understand a expression of " why don't you~" I've learned that this expression is more like to persuade someone than asking the reasons
I want to make sure of what i'm thinking
When i say

*

*Why don't you take that class?

Is more like persuading and listener wouldn't say the reason
So If i wan't to know the reason, should i say

*Why you don't take that class?

Can i use the first sentence(number one) just to know the reason?
But when it comes to past tense, would it definitely be an interrogative sentence?

*

*Why didn't you take that class?

Also

*Why you didn't take that class?

Both are expected that listener would say the reason

A: [No 2. are both bad grammar. Do not use either of these.]
Persuasion can only be done before someone has decided.
"Why don't you take that class?"
This is often used to encourage someone to do something. It is more polite than telling them to do something.
They will respond as if it was a suggestion: "That's a good idea".
Questioning can only be done after someone has decided.
So they can respond as if it was a question.
To make it clearer that it is a question you can ask
"Why don't you want to take that class?" or "Why can't you take that class?"
If it is possible to change their minds then it is both a question and persuasion. If they don't like their decisions being questioned they will respond "Because I don't want to".
If it is too late then it can not possibly be a persuasion. It has to be a question by elimination.
When a question is equivalent to an imperative it is just as rude. Do not ask "Why don't you go to hell?" https://www.youtube.com/watch?v=jOflpNvy_30&t=0m23s

A: You are correct that "Why don't you" usually implies that the person should do something.
If you want to know the reason they aren't, you would use the present progressive: "Why aren't you verb+ing...". Ex, "Why aren't you going to the concert?"
For the past tense, the verb "to do" is working differently. Here it is the auxiliary verb that is necessary for asking a question in the past tense.
Only option #1 (Why didn't you) is correct. #2's word order is not. When forming a sentence with question words (who, what, why), the question word must be followed by the auxiliary did


text:
Q: OpenForm freeze totally access I use an access database to register some datas. I have a click_button to open a form which doesn't work anymore and before yes. When I click, access is blocked but I can yet tape in vba window, but everything in access is freezed and I can't run a code... The form is not showed at window, I think the access is blocked because the form is open but not showed... There is no code event in load or opening form.
I have tried to force with Form.Visible=true but it's not working...
I have tried with the extension acNormal DoCmd.OpenForm "Insertion", acNormal but it's not working...
I saw no properties button that can block like this...
Private Sub Commande250_Click()
    On Error Resume Next
    DoCmd.OpenForm "Insertion"
End Sub

Normaly, a window open with the form, on the principal window. The software is a principal form with button which open some sub form in the form, or other form. Just this form not open...