text:
Q: Cannot display AdMob banner I need to put at the bottom of my view the AdMob banner and above it the ScrollView for the content, in tis way the banner shoud always be visibile.
The problemis that my ScrollView fill the whole screen and the logcat sys that I have no space to display the banner.
This is the logcat:
03-14 10:22:56.342    1664-1664/com.elisafedeli.consiglipergenitori.app E/chromium﹕ [ERROR:gl_surface_egl.cc(153)] No suitable EGL configs found.
03-14 10:22:56.352    1664-1664/com.elisafedeli.consiglipergenitori.app E/chromium﹕ [ERROR:gl_surface_egl.cc(620)] GLSurfaceEGL::InitializeOneOff failed.
03-14 10:22:56.352    1664-1664/com.elisafedeli.consiglipergenitori.app E/chromium﹕ [ERROR:gl_surface_egl.cc(153)] No suitable EGL configs found.
03-14 10:22:56.352    1664-1664/com.elisafedeli.consiglipergenitori.app E/chromium﹕ [ERROR:gl_surface_egl.cc(620)] GLSurfaceEGL::InitializeOneOff failed.
03-14 10:22:56.352    1664-1664/com.elisafedeli.consiglipergenitori.app E/chromium﹕ [ERROR:gpu_info_collector.cc(86)] gfx::GLSurface::InitializeOneOff() failed
03-14 10:22:57.282    1664-1695/com.elisafedeli.consiglipergenitori.app E/ActivityThread﹕ Failed to find provider info for com.google.plus.platform
03-14 10:23:08.692    1664-1664/com.elisafedeli.consiglipergenitori.app E/Ads﹕ Not enough space to show ad! Wants: <720, 100>, Has: <720, 0>

This is my Layout:
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:fillViewport="true"
    android:orientation="vertical">

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"

        >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:layout_marginBottom="30dp"
            android:fillViewport="true" >

            <!-- Consiglio 1 -->
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginBottom="20dp">

                    <ImageView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:id="@+id/img1"
                            android:background="@drawable/uno"/>

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:id="@+id/testoUno"
                            android:text="Consiglio 1"/>

            </LinearLayout>
            <!-- /Consiglio 1 -->

            <!-- Consiglio 2 -->
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginBottom="20dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/testoDue"
                    android:text="Consiglio 2"/>

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/img2"
                    android:background="@drawable/due"/>

            </LinearLayout>
            <!-- /Consiglio 2 -->

            <!-- Consiglio 3 -->
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginBottom="20dp">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/img3"
                    android:background="@drawable/tre"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/testoTre"
                    android:text="Consiglio 3"/>

            </LinearLayout>
            <!-- /Consiglio 3 -->

            <!-- Consiglio 4 -->
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginBottom="20dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/testoQuattro"
                    android:text="Consiglio 4"/>

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/img4"
                    android:background="@drawable/quattro"/>

            </LinearLayout>
            <!-- /Consiglio 4 -->

            <!-- Consiglio 5 -->
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/img5"
                    android:background="@drawable/cinque"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/testoCinque"
                    android:text="Consiglio 5"/>

            </LinearLayout>
            <!-- /Consiglio 5 -->

        </LinearLayout>

    </ScrollView>
        <com.google.ads.AdView
            android:id="@+id/adView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            ads:adUnitId="ca-app-pub-*********/*******"
            ads:adSize="SMART_BANNER"
            ads:loadAdOnCreate="true"
            android:gravity="bottom">

        </com.google.ads.AdView>
</LinearLayout>

I can't understand what I'm missing. Any help is really appriciated!

A: The clue is here:
03-14 10:23:08.692    1664-1664/com.elisafedeli.consiglipergenitori.app E/Ads﹕ Not enough space to show ad! Wants: <720, 100>, Has: <720, 0>

Set the min-height of the container to 100dp. May as well set the main width, while you're at it.

A: This happens because your ScrollView's height is defined this way: android:layout_height="wrap_content". So basically, as you have too much things in your layout, it takes all the screen and leaves no space for the AdView.
Probably forcing the height of your AdView to be 100, should show that banner, as right now, as you see, it has no space.


text:
Q: Eclipse won't recognize Android devices Eclipse isn't recognizing neither of my two Android phones.
I've tried updating all of the Android SDKs in eclipse as well as eclipse itself.
Both of my phones are being recognized by my Macbook and Android File Transfer works like a charm.
They are both in Developer mode with Debug turned on.
I've also tried connecting them in both MTP and PTP but eclipse still won't recognize my phones.
I get the RSA fingerprint pop-up and I press OK but nothing happens.
What could be the problem? I don't know what else to do.
Edit: Eclipse used to work the last time I used it to run Android apps (which was about three-four months ago). Now, it won't recognize my phones. Also, you can't install drivers on the Mac. According to Google, it is just supposed to work.
Edit: This is what I get for the adb devices.
Marcos-MBP:platform-tools Poloe$ ./adb devices
List of devices attached

A: Found out the problem.
Turned out it was this.
adb devices list empty -- Snow Leopard
My phones weren't being recognized because I had EasyTether installed on my phones and on my Macbook.
According to the EasyTether website:

ADB on Mac OS X stops recognizing the attached device after installing EasyTether driver
Do not follow this advice if you are not a software developer who uses the Android SDK on Mac. Otherwise run "sudo kextunload /System/Library/Extensions/EasyTetherUSBEthernet.kext" to unload the EasyTether driver manually. Load it again with kextload when necessary.

redpajama_set_name: RedPajamaStackExchange


text:
Q: If Superman died on Earth, would his body decompose? If Superman died on Earth, would his body decompose?

A: He gets his powers and invulnerability by metabolizing the light from our yellow sun. If he is no longer alive, then his body won't be metabolizing that energy. In Tow of Babel for example this is exploited.
I don't think there has ever been evidence to suggest that the yellow sun affects his cells directly regardless of if he is alive or dead.
So, if Superman was dead and not metabolizing, he would then not have his powers, so I would expect he would decompose in the normal way Kryptonians decompose.

A: Alright, let's say he dies (Kryptonian cancer).
I'm not going to talk about his soul, so let's assume that the soul isn't an agenda here.
The absorbed sunlight in his body would still power a great deal of his cells, so it would take him some time if not years, to actually die (that is, if DC doesn't find a way of saving him again).
His Kryptonian cells would slowly vaporise, so his body wouldn't have the same odor as of a human body. So in short, he would pose as a giant energy container waiting to burst.
Having all this energy in one spot (presuming he is still in one piece), he would be like a dwarf star imploding into a black hole (there are also other possibilities here, turn into a neutron star, a magneter, burst/explode). What would happen to Earth and the human kind?
However, if I'm not correct and his organs really somehow decompose. His body would emit an amount of thermal radiation (an effect known as Hawking radiation), in the end leading to evaporation of his body.

A: I know I'm kinda late to the party on this one, but if you're willing to accept an answer from the DCEU:

 At the end of Batman v Superman: Dawn of Justice, Superman dies. When his corpse is later recovered during the events of Justice League, enough time has passed that it should have started to decompose, but instead it's in seemingly-perfect condition. Bruce Wayne even predicts that Superman's corpse won't have decayed (though I can't remember his reasoning).

From that evidence, he would decompose either much slower than a human corpse, or not at all.


text:
Q: Unable to Update RBAC role using Azure DevOps Pipeline I am using Azure Devops Pipeline.
I create a ServiceConnection in Azure Devops and added an Service Principal in it.
Agent i am using is 'ubuntu-latest'
I created a powershell task in pipeline
- task: AzureCLI@2
  displayName: 'Assign Role'
  name: task_inline
  inputs:
    scriptType: 'pscore'
    azureSubscription: 'AzureConnRM'
    scriptLocation: scriptPath
    addSpnToEnvironment: true
    scriptPath: './abc.ps1'

In Powershell to update an existing RBAC Role i am running below command:
az role assignment update --role-assignment $myjson  --debug --verbose

and json which i am passing is
$myjson = '{
  "conditionVersion": "",
  "roleDefinitionName": "Contributor",
  "principalType": "User",
  "condition": "",
  "id": "/subscriptions/097ca710-067e-4a70-8ce6-494268568148/resourceGroups/Trial-RG/providers/Microsoft.Authorization/roleAssignments/45d7dc3c-4a95-8a1c-bd87-f8a460c6d255",
  "resourceGroup": "Trial-RG",
  "roleDefinitionId": "/subscriptions/097ca710-067e-4a70-8ce6-494268568148/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c",
  "type": "Microsoft.Authorization/roleAssignments",
  "scope": "/subscriptions/097ca710-067e-4a70-8ce6-494268568148/resourceGroups/Trial-RG",
  "principalId": "8cd5df22-42f4-405e-b3ab-d562eaf1da92",
  "canDelegate": "",
  "description": "Updated",
  "name": "45d7dc3c-4a95-8a1c-bd87-f8a460c6d255"
  }'

But get the error:
Error detail: Expecting property name enclosed in double quotes: line 2 column 3 (char 4)

A: Thanks @Toni
--debug helped me see the detailed log.
3 fields conditionVersion,  canDelegate, condition  were not getting set correctly. I removed these properties from my json and it worked.


text:
Q: Mysql get sum of column_1 based on distinct value in column_2 I have this table:

+-----+--------+
|col1 |   col2 |
+-----+--------+
|   1 |     12 |
|   1 |     12 |
|   2 |     13 |
|   4 |     15 |
|   2 |     13 |
|   3 |     14 |
|   3 |     14 |
|   1 |     12 |
+-----+--------+

I'm looking for Total sum of col2 for distinct col1.

A: select col1, sum(col2) from mytable group by col1

A: With:
SELECT DISTINCT col1, col2 FROM tablename

get the distinct rows of the table and then get the sum:
SELECT SUM(col2) AS total
FROM (SELECT DISTINCT col1, col2 FROM tablename) t

A: then you just have to add another query
select sum(col2) from myTable


text:
Q: Can we enable alarm for a service inside the EC2 Instance? I have two EC2 instances, in which I have running Node engine in one EC2 and Mongo in another EC2 instance.
When I am trying to connect with Node instance to Mongo instance it is not connecting. But the Mongo Instance is running.
Later I found that the Mongo is not-working/stopped inside the instance.
Is there any way to know when a Mongo service is not-working/stopped. Like for enabling cloudwatch alarm to know the status of an instance.

A: You can use AWS Lambda to write a function to ping your mongodb, then trigger it by AWS Cloudwatch in minutes interval.
Steps:

*

*write an api in your node server which is used to ping mongodb

*write a function to send request to your node server in AWS Lambda Node

*attach a AWS Cloudwatch to your lambda function in minutes interval


text:
Q: Excel 2016 and Office 365 custom document property I have an Excel XLL which uses Excel Interop and I use customDocumentProperties to store some settings for the workbook. The C# code looks like:
var customDocumentProperties = Workbook.CustomDocumentProperties;
customDocumentProperties.Add("MyData", false, Microsoft.Office.Core.MsoDocProperties.msoPropertyTypeString, "mysettings");

Now I am trying to create an Office add-in (excel task-pane) with Office.js and the equivalent way to store custom data is using Office.context.document.settings. So javascript code looks something like:
Office.context.document.settings.set("MyData", "mysettings");

However, these two methods are incompatible. ie. if I set the property with the the XLL, I can not read it with the Office add-in and vice versa.
Is there anyway to create compatible custom document properties that can be used in both Excel 2016 (through xll c# or vba) and Office 365 Excel?
Thanks in advance,
Jon

A: No, it is not currently possible.  You may be able to inspect the OOXML format of the Word document to figure out where the Office add-in settings live, but there's no official path.
We do have adding custom document properties / custom XML parts on our backlog...
~ Michael Zlatkovsky, developer on Office Extensibility team, MSFT


text:
Q: RunTime Error when trying to add borders to spinner I tried adding borders to a spinner.
Here is the xml res/drawable/spinner_background.xml.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item><layer-list>
        <item><shape>
            <stroke android:width="2dp" android:color="#f58218" />
            <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
        </shape></item>
        <item >
            <bitmap android:gravity="right|center" android:src="@drawable/ic_arrow_downward_black_24dp" />
        </item>
    </layer-list></item>
</selector>

And here is the spinner
  <Spinner
                                android:id="@+id/marketSpinner"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="8dp"
                                android:background="@drawable/spinner_background"></Spinner>

@drawable/ic_arrow_downward_black_24dp is a vector resource.
I get this error at run time
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #9: <bitmap> requires a valid 'src' attribute
        at android.graphics.drawable.BitmapDrawable.updateStateFromTypedArray(BitmapDrawable.java:771)
        at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:731)
        at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130)
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1229)
        at android.graphics.drawable.LayerDrawable.inflateLayers(LayerDrawable.java:282)
        at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:196)
        at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130)
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1229)
        at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:188)
        at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:116)
        at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130)
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1229)
        at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1202)
        at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:715)
            ... 57 more


text:
Q: What are the cons of using a Maven-based project in Android Studio Short Version: As the title says, I'm looking for the bad sides of this type of project. By a maven-based project, I mean a project that have been imported from Eclipse ADT and it contains no gradle file at all.
Long version: I've been assigned to an android-only team that worked with Eclipse ADT using Maven (pom.xml with m2e plugin) for dependencies and Maven for the continuous integration (CI) on Bamboo. Since the release are made using Bamboo, maintaining the pom.xml file is crucial. I've read that support for Eclipse ADT will be dropped and that Android Studio is based primarely on Gradle so I thought that it was time to migrate. I've made some quick tryout of migration and one of them was to keep a "maven-based" project (no change to the structure). Everything compiled but I noticed some functionnalities like automatic signing on build weren't available since they are stored in the gradle file only. So, is this bad to use a maven-based project in Android Studio and if so, why (cons). I need to know to make the choice of staying with Eclipse ADT OR using a maven-based project on Android Studio OR switching completely to Android Studio with Gradle which will mean to change the setup on Bamboo completely and using Groovy plugins which cost 150$.
I know to know before I make my decision!
Thanks!

A: Android Studio is specifically built around the assumption that you are using Gradle. What you are experiencing is the built in support for Maven based projects which is inherited from IntelliJ IDEA, the Java IDE which Android Studio is based on.
If you'd like to continue to use Maven, you'll have a better time using the IntelliJ Android support rather than Android Studio. Note that it too is not directly supported by the Android Tools team so all new tool features will most likely be limited to Gradle (as has been the case for some time).


text:
Q: How to solve rejection problem of my app on google play console We have received these policy notice from the policy team.
They give the following reason:
"We were unable to verify the declared functionality {Proxy calls} during app review".
My app manifest requests the Call Log permission group (PROCESS_OUTGOING_CALLS).
I am not able to understand what core functionality I need to choose.
Can anyone help me?


text:
Q: Auto reconnection to TibcoEMS servers Do I need to implement anything to enable the "retry to connect" or "failover to another server"? From what I understand, these two should be taken care of as long as I configure them correctly (aka a fault-tolerant connection url and ReconnAttemptCount, etc.) However, it doesn't work for me.
My current scenario is that my app successfully connects to the EMS server, it can receive and send msg. Then I disable network connection, I can see exception "TIBCO.EMS.EMSException: Connection has been terminated" is thrown. Enable network connection but the connection to EMS server does not automatically restore.
Please help to advise. If my understand is wrong, please help to correct me as I am very new in this area.


text:
Q: Why isn't text displaying on UItableview object Here is the code and here is my resulting display. I'm using a table view object, not a table view controller (table view controller works fine), because I intend to do something with the background. Idk why the sample text isn't displaying? This is probably really stupid...
Here is the image of the output:
!https://drive.google.com/file/d/1tEWZUjWP-8FhZKDvuAQyVV2vkh2_dyRL/view?usp=sharing
And here is the image of how I configured the cells (I have another split view controller for another purpose, but never mind that since it's unrelated to problem): !https://drive.google.com/file/d/1u-T1J6xp1bZq12HRCSeD3Eq_VWlGH4lb/view?usp=sharing
Please help and thanks! I also tried to look at How to insert new cell into UITableView in Swift and used the +21 response
import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }

    //MARK: Properties
    @IBOutlet weak var drawingCanvas: UIView!
    @IBOutlet weak var tableView: UITableView!
    var tableData = ["one"]

    //MARK: Table View
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return tableData.count
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if tableView == self.tableView {
            let cell = tableView.dequeueReusableCell(withIdentifier: "TaskCell", for: indexPath)
            // Configure the cell...
            cell.textLabel?.text = tableData[indexPath.row]
            return cell
        }
        return UITableViewCell()
    }

}

A: Your tableview can't show data because you haven't been setting datasource and delegate for ViewController to display data.
You should register delegate and datasource of tableview in viewDidload()
Please follow the bellow code:
self.tableView.delegate = self
self.tableView.dataSource = self


text:
Q: Configuring Content for Editable Email Notification Jenkins I am using Editable E-mail notification to send email after a slave job is finished with the console output and test results as the email body.
I also need to add to the email direct link to the folder where build was actually built, is there an easy way to do this? maybe some kind of token? I didn't find any clues on how to get direct link to the build folder to display it location in the email.

A: Build output:
${BUILD_LOG, maxLines=1000}
For tests you can use the tokens as below:
There are ${TEST_COUNTS, var="total"} total tests of which ${TEST_COUNTS, var="fail"} test(s) failed.
${FAILED_TESTS} - Displays failing unit test information, if any tests failed.
For complete reference to Content token and arguments, click on help icon.

A: First, click the question mark ? next to Content Token Reference, this will tell you all you need.
What "folder where build was actually built" are you referring to? The Workspace, or the build Archive?
For Workspace: ${PROJECT_URL}/ws/
For Archive: ${BUILD_URL}/artifact/


text:
Q: In JSP,I entered a Float value into a Form.How could I access it from the Action page as Float? In JSP,I entered a Float value into a Form.how could i access it from the Action page as Float value?

A: Float.parseFloat(request.getParameter("value")) should work..


text:
Q: ResourceLink element in Tomcat is not working I am using apache-tomcat-7.0.35.I have defined an environment variable in server.xml as below
<GlobalNamingResources>

        <Environment name="sam"
                 value="D:\AppServers\apache-tomcat-7.0.35\conf\sample.xml"
                 type="java.lang.String" override="true"/>

  </GlobalNamingResources>

I am using ResourceLink element in side my context element in context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/Practice_1" docBase="/Practice_1"
    crossContext="true" reloadable="true" debug="1">
<ResourceLink name="sam" global="sam" type="java.lang.String"/>

</Context>

When I try to get this valuue in the code using
 Context initCtx = new InitialContext();
        String configPath = (String)initCtx.lookup("sam");

Its throwing javax.naming.NameNotFoundException.javax.naming.NameNotFoundException: Name [sam] is not bound in this Context. Unable to find [sam].
How can I rectify this?

A: tomcat jndi has default name space "java:comp/env".
Modify your code to either
Context initCtx = new InitialContext();
String configPath = (String)initCtx.lookup("java:comp/env/sam");

or
Context initCtx = new InitialContext();
Context rootCtx = (Context) initCtx.lookup("java:comp/env");
String configPath = (String)rootCtx.lookup("sam");

A: If i am not wrong you dont need to modify the server.xml .
Modified context.xml
<Resource auth="Container"            java.naming.factory.initial="org.jnp.interfaces.NamingContextFactory"
factory="de.example.CXIResourceLocator"
name="bean/CXIResourceLocator"
type="de.example.Bean"/>

web.xml
<resource-env-ref>
    <description>
        Connection pooling.
    </description>
    <resource-env-ref-name>bean/CXIResourceLocator</resource-env-ref-name>
    <resource-env-ref-type>
        de.example.Bean
    </resource-env-ref-type>
</resource-env-ref>

bean/CXIResourceLocator should match in both context and web xmls.

Since I dont know your purpose of doing this, I cant help you more. :-(
Follow this link for more details. Apache gave very good example.
hope this help.
http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html


text:
Q: Creating indexed nodes on neo4j cypher via rest api I'm trying to create an indexed node in cypher, with the following syntax:
neo4j-sh (?)$ start m=node:person(UID= "1")  return m;
==> +------------+
==> | m          |
==> +------------+
==> | Node[64]{} |
==> +------------+
==> 1 row
==> 0 ms
==>
neo4j-sh (?)$ start n = node(64) return n.UID;
==> EntityNotFoundException: The property 'UID' does not exist on Node[64]

Why is it that the node appears to be created, but the property I'm creating, and that seems to be successfully returned, does not exist?
Is there an easier way?  I used to use py2neo's function:
neo4j.GraphDatabaseService("http://localhost:7474/db/data/").get_or_create_indexed_node(index='person', key='UID', value=self.id, properties={'UID' : self.id})

But this appears to have been deprecated---it no longer works with the latest version of py2neo, which does not appear to support the properties argument any longer (and for future folks, index is replaced with index_name).

A: An index and a property are two different things.
It seems you have a node in your graph with an index named person and key/value pair UID:"1". Your first query gets your node by its index. But the index is not a property of the node. You can fire up the webadmin to visualize how the indices are managed in your graph.
As far as i know there is nothing in the documentation on how to create indices with cypher, but you can easily use the REST API to manipulate them (link).

A: The method has not been deprecated and the properties argument is still valid, as before. The only change, as you identify, is the change from index to index_name for the first argument.
The documentation is here:
http://book.py2neo.org/en/latest/graphs_nodes_relationships.html#py2neo.neo4j.GraphDatabaseService.get_or_create_indexed_node
Note that the properties will only actually be used when the node does not already exist, i.e. when doing a 'create' but not when doing a 'get'. Otherwise, the existing node will remain as-is.


text:
Q: Cannot restart mysql client on Windows 10 I am having issues restarting the MySQL client. I have tried to restart the client  under services.msc and the command line but it doesn't restart. The errors that I'm getting are:
# services.msc
The SQL Service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs.

# command line
The SQL Service is starting.
The SQL Service could not be started.
The Service did not report an error.
More help is available by typing NET HELPMSG 3534

I've tried changing the properties to use the Local System account as per some suggestions, but that does not solve the issue either.
Prior to restarting my client, I made some changes to the my.ini file. I am just wondering if making any changes to the config file would result in this issue. Also, how would I be able to restore a copy of the default my.ini file so I can replace it with the existing.
Thank you.

A: Here is the contents of the my.ini from a fresh install of MySQL 8.0 that I happened to have:
Default MySQL80 my.ini
Snippet:
# Other default tuning values
# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------------------------------------------
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options
# (@localstatedir@ for this installation) or to
# ~/.my.cnf to set user-specific options.


text:
Q: Save Changes made in Recyclerview THE APP : My e-commerce application has an activity to view and purchase products and add it to cart
image for reference :https://4.bp.blogspot.com/-Ug58s6O8yQA/XFFJWIxU4YI/AAAAAAAAFYo/LmIxVFSZDHkWPI95WGBhf_5uVkKDbqnQQCLcBGAs/s640/Nexus%2B5x-Screenshot1.png
PROBLEM : I can add items just fine ... but once I open the next activity and get back to this activity , all the quantity is set to its initial quantity in TextView as '0' again
WHAT I TRIED : I surfed the internet to come across several solutions SavedInstances ,Shared preferences etc.. all of them only suit for not more than a couple of TextViews...since mine has unpredictable data from firebase database and contains number of textviews its quite impossible to store them in shared pref or arraylist.
Thanks in advance!

A:
"but once I open the next activity and get back to this activity , all
the quantity is set to its initial quantity in TextView as '0' again"

Are you setting default values in onResume() of your FirstActivity?
Refer here for more info on Activity Lifecycle.

A: your problem occurred because  mishandling view lifecycle you have to handle it try to save your changes in the dataset not only view


text:
Q: Problems upgrading to EF 6.1 Tried to update my EF package from nuGet, but I don't think it's installing correctly.
The installer seemed to go without a hitch, but after deleting my old .Edmx model, it will not let me add a 6.x model, as that option is greyed out with the error message "Your project references an older version of EF. To use the latest version exit this wizard and upgrade before performing this action."
Research indicated that I needed to delete the System.Data.Entity reference, but that didn't fix it. The problem seems to be that my EntityFramework.dll reference is still on 5.0 (runtime version v4.0.30319), even after the upgrade. I tried uninstalling & reinstalling EF and it still puts in the old driver under references. When I remove that EntityFramework reference, I'm able to add an EF 6 model, however since the driver is old, several namespaces aren't available that I need, such as System.Data.Entity.Core. Am I doing something wrong or do I need to download a new EntityFramework.dll driver separately, and if so, where would I get that?

A: I've been facing similar problem few days ago. Some referenced project were using EF v4.4.0.0, but EF I added to current project (through NuGet) was v6.0.0.0. The problem is, that namespaces (and some constructors) changed between versions.
You can hack it by adding
 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="6.0.0.0" />
  </dependentAssembly>
 </assemblyBinding>

But this causes that program sometimes fails...
Method not found: 'Void System.Data.Entity.DbContext..ctor(System.Data.Objects.ObjectContext, Boolean)'.

I think that the best solution is using same version of EF across the project. Unfortunately (as in my case), sometimes you have to downgrade to old version because some projects are widely shared across the team/company.


text:
Q: Is it natural to use the phrasal verb "fasten up" in the sense of fastening one's belt in a car? Would a native English speaker use fasten up in the sense of fastening one's belt in a car? For example:

You had better fasten up as you never know what might happen on the road.

If it sounds off, what would a native English speaker say?

A: In the US, fasten up is understandable, though it's much more common to hear "fasten your seatbelt" without the preposition.
The most common phrasal verb for this is buckle up, which is defined as "to fasten one's seatbelt."
"Buckle Up" has a long history in public service announcements and ad campaigns about road safety. See these linked examples: Buckle Up for Life, Safe Kids Buckle Up and Risky Driving--The Benefits of Buckling Up.

A: It's very natural, if not the most one. So yes, a native English speaker would most likely use fasten up in that sense.
Also, as pointed out by @stevekeiretsu, buckle up is sometimes also used. One example that comes to my mind is from South Park, where Caitlyn Jenner says to President Trump

*Buckle up, Buckaroo!

Side note: Buckaroo is an American slang for cowboy, mostly used during the 1950s.


text:
Q: Auto-create propertys getter and setter for class elements I'm searching for a way to write less sameish looking code and I'm not sure if there is a solution for this. So far I tried using Visual Studio Snippets, but that was not as helpful as needed. I would love to have C-Style Macros for this, or even better using C# language features.
Here is what I'm currently working on and the problem I have with it:
I'm writing full feature tests for an embedded device with a Web-UI in C#. I'm using Selenium to interact with the UI and have written some small classes to interact with custom input elements. The UI has many pages on which different controls are visible and naturally I created a class for each page and added all the input element classes for each controllable element.
This looks something like this (input element would be the Switch and ValueInput class):
public class SomePage : Page
{
    protected const string id = "page_id";

    #region ContentControls
    protected Switch time_limit_enable;
    protected ValueInput time_limit;
    // and more ...
    #endregion

    internal SomePage() : base(id) { }

    protected override void Init()
    {
        time_limit_enable = new Switch("time_limit_enable_id");
        time_limit = new ValueInput("time_limit_id");
        // and more ...
    }

    #region GetterSetter
    public bool TimeLimitEnable
    {
        get => time_limit_enable.State;
        set
        {
            if (time_limit_enable.State != value)
                time_limit_enable.Toggle();
        }
    }

    public string TimeLimit
    {
        get => time_limit.Text;
        set => time_limit.Text = value;
    }

    // and more ...
    #endregion
}

While this example page is small, the real pages have a lot more elements often of the same type (Switch, ValueInput, and more). The only thing that I want to specify is the element class, the id of the element, and the name. Some element classes have a template parameter as well. So basically the construction of the element. Is there some way to automate everything else?
Meaning:

*

*creating a protected element

*Initializing it in the Init() function

*Adding a property getter and setter, named like the element in CamelCase. This property template would be different for different element classes.

Possible solutions:

*

*Make the element class directly public readonly. Sounds ok, but then I would expose the different interfaces to the test side. I like that every property can be read and read directly with =. I could implement this in each element class though.

*I could write a Code generator to do this, but that would be overkill. I'm probably looking at this from the wrong angle.

*I could hack C-Style macros in c#, but that's just wrong.

I feel a little bit lost in the weeds. The solution is probably straightforward and obvious.


text:
Q: Using Enum values as integers I have the following enumerated type:
        /// <summary>
        /// TTE Node types.
        /// </summary>
        public enum E_TTE_NODES
        {
            /// <summary>
            /// Represents FCM 0
            /// </summary>
            E_FCM0 = 0,

            /// <summary>
            /// Represents FCM 1
            /// </summary>
            E_FCM1,

            /// <summary>
            /// Represents FCM 2
            /// </summary>
            E_FCM2,

            /// <summary>
            /// Represents DCM 0
            /// </summary>
            E_DCM0,

            /// <summary>
            /// Represents DCM 1
            /// </summary>
            E_DCM1,

            /// <summary>
            /// Represents DCM 2
            /// </summary>
            E_DCM2,

            /// <summary>
            /// Represents CCM 0
            /// </summary>
            E_CCM0,

            /// <summary>
            /// Represents CCM 1
            /// </summary>
            E_CCM1,

            /// <summary>
            /// Represents CCM 2
            /// </summary>
            E_CCM2,

            /// <summary>
            /// Represents PDU C1
            /// </summary>
            E_PDU_C1,

            /// <summary>
            /// Represents the last node.
            /// Must remain last.
            /// </summary>
            E_LAST,
        }

I would like to initialize a generic list like this:
// Should initialize to a capacity of 10
private List<Int32> transmitIndex = new List<Int32>((Int32)E_TTE_NODES.E_LAST);

Yes, I know I can just pass the number 10 as a parameter.  The enum may add more nodes in the future, but E_LAST will always be the last node. My question is my does the compiler say I cannot cast my enum to an int on the above line of code.  Isn't the default value of a enum value an integer?

A: You can cast an enum type as you have to an int, the problem is probably somewhere else.
This would produce the compiling error you said:
 private List<Int32> transmitIndex = new List<Int32>(E_TTE_NODES.E_LAST);

This would not:
 private List<Int32> transmitIndex = new List<Int32>((Int32)E_TTE_NODES.E_LAST);

A: That should be fine. For example, this compiles with no issues:
using System;
using System.Collections.Generic;

enum Foo
{
    Bar = 0,
    Baz
}

public class Test
{
    static void Main()
    {
        List<Int32> transmitIndex = new List<Int32>((Int32)Foo.Baz);
    }
}

Could you post a similar short but complete program which fails to compile?
Are you perhaps missing a using System;?

A: Yes you can cast an enum value to and integer. If E_LAST is just for information purpose you could look at doing something like this.
string numberOfElements = Enum.GetNames( typeof( E_TTE_NODES ) ).Length;
List<Int32> transmitIndex = new List<Int32>( numberOfElements );

A: This does work.  The following compiles fine:
using System;
using System.Collections.Generic;

/// <summary>
/// TTE Node types.
/// </summary>
public enum E_TTE_NODES
{
    /// <summary>
    /// Represents FCM 0
    /// </summary>
    E_FCM0 = 0,

    /// <summary>
    /// Represents FCM 1
    /// </summary>
    E_FCM1,

    /// <summary>
    /// Represents FCM 2
    /// </summary>
    E_FCM2,

    /// <summary>
    /// Represents DCM 0
    /// </summary>
    E_DCM0,

    /// <summary>
    /// Represents DCM 1
    /// </summary>
    E_DCM1,

    /// <summary>
    /// Represents DCM 2
    /// </summary>
    E_DCM2,

    /// <summary>
    /// Represents CCM 0
    /// </summary>
    E_CCM0,

    /// <summary>
    /// Represents CCM 1
    /// </summary>
    E_CCM1,

    /// <summary>
    /// Represents CCM 2
    /// </summary>
    E_CCM2,

    /// <summary>
    /// Represents PDU C1
    /// </summary>
    E_PDU_C1,

    /// <summary>
    /// Represents the last node.
    /// Must remain last.
    /// </summary>
    E_LAST,
}

public class Example
{
    private List<Int32> transmitIndex = new List<Int32>((Int32) E_TTE_NODES.E_LAST);

    public static void Main()
    {
        Example example = new Example();
        Console.WriteLine(example.transmitIndex.Capacity);

        Console.ReadKey();
    }
}

This prints "10" as expected, at runtime.
That being said, I'd strongly recommend assigning values to all of your enum values, not just E_FCM0, if you're going to do this.

A: If you are trying to get the total number of items in this Enum, you might want to try using:
Enum.GetValues(typeof(E_TTE_NODES)).Length

Also, as some others have pointed out, it's probably a good idea to assign values to all your enum values so that the integer values associated with the enum values don't change if something is added in the middle.  This could make a difference if you write these values out to a database, or a file.


text:
Q: GIT-No supported authentication methods available I am using git version 2.6.2.windows.1 , I have suddenly started getting below error message while cloning the git repository on git bash :
$ git clone URL && scp -p -P 29418 URL:hooks/xxxxx/.git/hooks/
Cloning into 'xxxx'...
FATAL ERROR: Disconnected: No supported authentication methods available
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

A: export Git_SSH=/c/Users/user-name/AppData/Local/Programs/Git/bin/ssh.exe made it work.


text:
Q: Magento product attribute value returns "No" Im trying to get all attributes and values for all my products, im doing this for every product:
foreach($product->getAttributes() as $attribute)
{
    $attributeCode = $attribute->getAttributeCode();
    $fieldVal = $attribute->getFrontend()->getValue($product);
}

For most products it works, but for the products, that are simples and have no configs, the values for some attributs return "No" instead of their real value.


text:
Q: Read string from clipboard How can I read a string from the clipboard and write it on a button's title?  I can copy a string to the clipboard with:
UIPasteboard.generalPasteboard().string = "Hello world"

But how do I read that string from the clipboard and assign it to a String?

A: Just read it back into a variable like this:
let pasteboardString: String? = UIPasteboard.general.string
if let theString = pasteboardString {
    print("String is \(theString)")
}


text: Q: How to prevent interceptor call after action if any exception occure during respective action execution I want to prevent interceptor call after action if any exception occurs during action execution in struts2?


text:
Q: border-collapse using HTML attribute Is there an HTML attribute available equivalent to the CSS property border-collapse: collapse;?
I am trying to achieve the same 1px border with HTML only, and not using css.

table{
  border-collapse: collapse;
}

Row 1
Row 1
Row 1

Row 2
Row 2
Row 2

A: You could try cellspacing.

Row 1
Row 1
Row 1

Row 2
Row 2
Row 2

Note: cellspacing doesn't overlap borders of adjacent cells, which CSS property does.

A: You can use cellspacing or cellpadding but it's deprecated in HTML5

A: i don't understand why you want to stop using CSS because that is what css do
you can use boostrap the css is included inside.
for more info go to w3chools

Basic Table

The .table class adds basic styling (light padding and only horizontal dividers) to a table:

        Firstname
        Lastname
        Email

        John
        Doe
        john@example.com

        Mary
        Moe
        mary@example.com

        July
        Dooley
        july@example.com


text:
Q: need to check if multi directorys exists def check_and_remove(pathslist):
    for path in pathslist:
        if os.path.exists(path) and os.path.isdir(path):
        shutil.rmtree(path, ignore_errors=true)
        print("Deleted")
    else:
        print(path, " directory not found")

dirs_to_delete = [
'C:\Directory1',
'C:\Directory2',
'C:\Directory3'
]

check_and_remove()

Changed the suggested shutil.rmtree(dir, ignore_errors=true) to shutil.rmtree(path, ignore_errors=true)
now getting this error -
Traceback (most recent call last):
  File "C:\Users\Temp\PycharmProjects\crm\CRMReinstall.py", line 53, in
    check_and_remove()
TypeError: check_and_remove() missing 1 required positional argument: 'pathslist'

A: in shutil.rmtree(dir, ignore_errors=true) you are using dir which is python inbuilt function perhaps you want to do shutil.rmtree(path, ignore_errors=true)

A: Replace dir with path in that line:
shutil.rmtree(dir, ignore_errors=true)

dir is a built-in function of the language.


text:
Q: C++ - Initialize private array in c++ class I'm having a problem of storing data into the private array in a class.
I tried to Google and didn't find any solution.
Here's my code:
Foo.h
class Foo {
private:
    int arr[10];
    double d;
public:
    Foo::Foo(double d) {
        this->d = d;
    }
    // ...
};

Foo.cpp
int main() {
    double d = 123.456;
    int array[10];
    // Getting data from user input by for-loop 10 times.

    Foo f = Foo(d);

And here's my problem -- how to save the array into the f?
Seems like using pointer (*f.arr = array;) doesn't acturally change the arr.

I tried this solution by adding
class Foo {
// ...
Public:
    Foo::Foo(int arr_, double d_) : arr_(new int[10]), d_(d) { };

But the Visual Studio 2017 says the array is not initialized.

I also tried this solution, but VS says cannot modify the array in this scope.
Please help. Thank you in advance.

A: #include <algorithm>  // std::copy()
#include <iterator>   // std::size()

class Foo {
private:
    int arr[10];
    double d;
public:
    Foo(double d, int *data)
    : d{ d }
    {
        std::copy(data, data + std::size(arr), arr);
    }
    // ...
};


text:
Q: How does equals() method work in Java The equals method compares whether two object values are equal or not. My question is how it compares the two objects? How can it tell the two objects are equal or not? I want to know based on what it compares the two objects. I am not including the hashCode method.

A: The default implementation, the one of the class java.lang.Object, simply tests the references are to the same object :
150    public boolean equals(Object obj) {
151        return (this == obj);
152    }

The reference equality operator is described like this in the Java Specification :

At run time, the result of == is true if the operand values are both
  null or both refer to the same object or array; otherwise, the result
  is false.

This default behavior isn't usually semantically satisfying. For example you can't test equality of big Integer instances using == :
Integer a = new Integer(1000);
Integer b = new Integer(1000);
System.out.println(a==b); // prints false

That's why the method is overridden :
722     public boolean equals(Object obj) {
723         if (obj instanceof Integer) {
724             return value == ((Integer)obj).intValue();
725         }
726         return false;
727     }

which enables this :
System.out.println(a.equals(b)); // prints true

Classes overriding the default behavior should test for semantic equality, based on the equality of identifying fields (usually all of them).
As you seem to know, you should override the hashCode method accordingly.

A: Consider following example,
public class Employee {
    String name;
    String passportNumber;
    String socialSecurityNumber;
    public static void main(String[] args) {
        Employee e1 = new Employee();
        Employee e2 = new Employee();
        boolean isEqual = e1.equals(e2);  // 1
        System.out.println(isEqual);
    }
}

In the code at comment //1 it calls inherited equals method from Object class which is simply comparing references of e1 and e2. So it will always give false for each object created by using new keyword.
Following is the method excerpt from Object
public boolean equals(Object obj) {
    return (this == obj);
}

For comparing equality check JLS has given equals method to override in our class. It is not final method. JLS doesn't know on what basis programmar wants to make two objects equal. So they gave non-final method to override.
hashcode does not play role to check object's equality. hashcode checks/finds the Bucket where  object is available. we use hashcode in hashing technique which is used by some classes like HashMap..
If two object's hashcode are equals that doesn't means two objects are equal.
For two objects, if equals method returns true then hashcode must be same.
You will have to override equals method to decide on which basis you want object e1 and e2 in above code is equal. Is it on the basis of passportNumber or socialSecurityNumber  or the combination of passportNumber+socialSecurityNumber?
I want to know based on what it compares the two objects.

Answer is, by default with the help of inherited Object class's equals method it compares two object's reference equality by using == symbol. Code is given above.

A: logically, equals does not compare objects (however you can do anything with it), it compares values. for object comparison there is '==' operator


text:
Q: How to use Scanner and conditions in Java? I'm fairly new to java and now I'm testing the Scanner! Here is my code:
package Examples;

import java.util.Scanner;

public class UserLogin
{
    public static void main(String[] args)
    {
        Scanner in= new Scanner (System.in);
        System.out.println("Please enter your name!");
        String keyboard= in.nextLine();

        System.out.println("Welcome: " + keyboard);
        System.out.println("What is your password?");

        Scanner x= new Scanner (System.in);
        int password= x.nextInt();

        if(password ==14567)
        {
            System.out.println("Password accepted ! you are welcome!");
        }
        else
        {
            System.out.println("Sorry wrong password! Try again");
            Scanner input = new Scanner(System.in);
            int password2=input.nextInt();
            while (password2==password);
            {
                System.out.println("Welcome!!!!");
            }
        }
    }
}

I want the user's name, password and that is it! But I noticed that when I ask the name even if I press the enter key, it will ask me the password right away. So I want to make sure I get a name.  Also when I ask the password I want to be able to give him few chances before saying goodbye.
Please enter your name!
michel
Welcome: michel
What is your password?
12345
Sorry wrong password! Try again
12345

This is what I get on the console.
Thanks!

A: First things first, You have declared unnecessary scanner objects. You only need to make scanner object once. You can take input using that object as many times as you want.
Second thing is you need to remove semi-colon you have put at the end of while (password2==password);because putting a semi-colon there will execute the block of while loop regardless of whether condition of while loop is true of false.
Now to do what you want, try following code.
public static void main(String[] args) {
 Scanner in= new Scanner (System.in);
 int default_password = 14567;
 int counter = 3;

System.out.println("Please enter your name!");
String keyboard= in.nextLine();

System.out.println("Welcome: " + keyboard);
System.out.println("What is your password?");

int password= in.nextInt();

if(password == default_password)
{
    System.out.println("Password accepted ! you are welcome!");

}
else
{
    while(counter > 0)
    {
      System.out.println("Sorry wrong password! Try again");

       password = in.nextInt();

       if (password == default_password)
       {
         System.out.println("Welcome!!!!");
         break;
       }
       else
       {
        counter--;
       }

    }
    if(counter== 0)
           System.out.println("Good Bye !!");
}

}

A: You don't need two Scanner since it would work for userName and Pass word. Do-While works fine here. You keep asking for valid pass word. Updated with count 3.
package ab;
import java.util.Scanner;

public class UserLogin{
    public static void main(String[] args) {

        Scanner stdIn= new Scanner (System.in);

        String userName;
        int userPassWord;

        boolean invaildPassWord = false;

        System.out.println("Please enter your name!");
        userName = stdIn.nextLine();

        System.out.println("Welcome: " + userName);

        do {
              System.out.println("\nWhat is your password?");
              userPassWord = stdIn.nextInt();

              if (userPassWord ==14567){
                  System.out.println("Password accepted ! you are welcome!");
                  invaildPassWord = false;
              }

              else {
                  System.out.println("Sorry wrong password! Try again");
                  invaildPassWord = true;

        }

        } while(invaildPassWord);
    }
}

Also, you can do it like this. If you don't want "what's your password again and again.
package ab;
import java.util.Scanner;

public class UserLogin{
    public static void main(String[] args) {

        Scanner stdIn= new Scanner (System.in);

        String userName;
        int userPassWord;

        boolean invaildPassWord = false;

        System.out.println("Please enter your name!");
        userName = stdIn.nextLine();

        System.out.println("Welcome: " + userName);

        System.out.println("\nWhat is your password?");
        userPassWord = stdIn.nextInt();

        do {
              if (userPassWord ==14567){
                  System.out.println("Password accepted ! you are welcome!");
                  invaildPassWord = false;
              }

              else {
                  System.out.println("Sorry wrong password! Try again");
                  userPassWord = stdIn.nextInt();
                  invaildPassWord = true;

        }

        } while(invaildPassWord);
    }
}

With count 3 times:
package ab;

import java.util.Scanner;

public class UserLogin {
    public static void main(String[] args) {

        Scanner stdIn = new Scanner(System.in);

        String userName;
        int userPassWord;
        int count = 3;

        boolean invaildPassWord = false;

        System.out.println("Please enter your name!");
        userName = stdIn.nextLine();

        System.out.println("Welcome: " + userName);

        System.out.println("\nWhat is your password?");
        userPassWord = stdIn.nextInt();

        if (count > 0) {

            do {
                if (userPassWord == 14567) {
                    System.out.println("Password accepted ! you are welcome!");
                    invaildPassWord = false;
                }

                else {
                    --count;
                    System.out.println("Sorry wrong password! Try again");
                    userPassWord = stdIn.nextInt();
                    invaildPassWord = true;

                }

            } while (invaildPassWord && count > 0);

            System.out.println("GoodBye!");
        }
    }
}

Without goodbye after valid entry:
import java.util.Scanner;

public class UserLogin {
    public static void main(String[] args) {

        Scanner stdIn = new Scanner(System.in);

        String userName;
        int userPassWord;
        int count = 3;

        boolean invaildPassWord = false;

        System.out.println("Please enter your name!");
        userName = stdIn.nextLine();

        System.out.println("Welcome: " + userName);

        System.out.println("\nWhat is your password?");
        userPassWord = stdIn.nextInt();

        if (count > 0) {

            do {
                if (userPassWord == 14567) {
                    System.out.println("Password accepted ! you are welcome!");
                    invaildPassWord = false;
                }

                else {
                    --count;
                    System.out.println("Sorry wrong password! Try again");
                    userPassWord = stdIn.nextInt();
                    invaildPassWord = true;

                }

            } while (invaildPassWord && count > 0);

            if (count <= 0){
                System.out.println("GoodBye!");
            }
        }
    }
}

A: try this:
while true{
    Scanner x= new Scanner (System.in);
    int password= x.nextInt();
    if(password ==14567)
    {
        System.out.println("Password accepted ! you are welcome")
        break;

    }
    else
    {
        System.out.println("Sorry wrong password! Try again");
}


text:
Q: PHP Session not persisting I am trying to use PHP session to store a state that is passed through 1 time via the querystring from a referring website. The trouble is locally I can maintain this state in the session scope but it is not working the same on the production server.
Im trying to do this in Wordpress in wp-config.php at the foot of the file:
session_set_cookie_params(0);
session_start();

Starting a session that expires with the browser.
Then checking & setting for the querystring param:
if (!isset($_SESSION['isEUStore']) && isset($_GET['store']) && strtolower($_GET['store'])=='eu') $_SESSION['isEUStore']=true;
elseif (!isset($_SESSION['isUSStore']) && isset($_GET['store']) && strtolower($_GET['store'])=='us') $_SESSION['isUSStore']=true;

However, $_SESSION['isEUStore'] or $_SESSION['isUSStore'] returns NULL on any other Wordpress page in the site.
Any advice? Some configuration setting that is different perhaps?
Thanks,

A: I didn't solve the issue with session being forgotten, but I found using cookies worked instead. Such as:
if (!empty($_GET['store']) && strtolower($_GET['store'])=='eu') {
    setcookie('isEUStore', true, 0, '/', $faco_domain);
    setcookie('isUSStore', true, time()-3600, '/', $faco_domain);
} elseif (!empty($_GET['store']) && strtolower($_GET['store'])=='us') {
    setcookie('isUSStore', true, 0, '/', $faco_domain);
    setcookie('isEUStore', true, time()-3600, '/', $faco_domain);
}

The cookies are not forgotten between Wordpress pages, but expire at the end of the browsing session.


text:
Q: Object Required when trying to label y axis I am trying to use Excel Macros for the first time, but for some reason the corresponding VBA code doesn't like it when I try to label the y axis. I get a run time error 424, and then it says object required.
Sub Graphplotz()
'
' Graphplotz Macro
'

'

    Range("A2:B15").Select
    ActiveSheet.Shapes.AddChart2(240, xlXYScatterSmooth).Select
    ActiveChart.SetSourceData Source:=Range("Plot!$A$2:$B$15")
    ActiveChart.ChartTitle.Select
    Selection.Format.TextFrame2.TextRange.Characters.Text = _
        "Stress vs. Deformation"
    With Selection.Format.TextFrame2.TextRange.Characters(1, 22).ParagraphFormat
        .TextDirection = msoTextDirectionLeftToRight
        .Alignment = msoAlignCenter
    End With
    With Selection.Format.TextFrame2.TextRange.Characters(1, 6).Font
        .BaselineOffset = 0
        .Bold = msoFalse
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.RGB = RGB(89, 89, 89)
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 14
        .Italic = msoFalse
        .Kerning = 12
        .Name = "+mn-lt"
        .UnderlineStyle = msoNoUnderline
        .Spacing = 0
        .Strike = msoNoStrike
    End With
    With Selection.Format.TextFrame2.TextRange.Characters(7, 16).Font
        .BaselineOffset = 0
        .Bold = msoFalse
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.RGB = RGB(89, 89, 89)
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 14
        .Italic = msoFalse
        .Kerning = 12
        .Name = "+mn-lt"
        .UnderlineStyle = msoNoUnderline
        .Spacing = 0
        .Strike = msoNoStrike
    End With
    ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
    Selection.Format.TextFrame2.TextRange.Characters.Text = "Deformation"
    With Selection.Format.TextFrame2.TextRange.Characters(1, 11).ParagraphFormat
        .TextDirection = msoTextDirectionLeftToRight
        .Alignment = msoAlignCenter
    End With
    With Selection.Format.TextFrame2.TextRange.Characters(1, 11).Font
        .BaselineOffset = 0
        .Bold = msoFalse
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.RGB = RGB(89, 89, 89)
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 10
        .Italic = msoFalse
        .Kerning = 12
        .Name = "+mn-lt"
        .UnderlineStyle = msoNoUnderline
        .Strike = msoNoStrike
    End With
    ActiveChart.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis)
    ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "Stress(Mpa)"
    Selection.Format.TextFrame2.TextRange.Characters.Text = "Stress(Mpa)"
    With Selection.Format.TextFrame2.TextRange.Characters(1, 11).ParagraphFormat
        .TextDirection = msoTextDirectionLeftToRight
        .Alignment = msoAlignCenter
    End With
    With Selection.Format.TextFrame2.TextRange.Characters(1, 11).Font
        .BaselineOffset = 0
        .Bold = msoFalse
        .NameComplexScript = "+mn-cs"
        .NameFarEast = "+mn-ea"
        .Fill.Visible = msoTrue
        .Fill.ForeColor.RGB = RGB(89, 89, 89)
        .Fill.Transparency = 0
        .Fill.Solid
        .Size = 10
        .Italic = msoFalse
        .Kerning = 12
        .Name = "+mn-lt"
        .UnderlineStyle = msoNoUnderline
        .Strike = msoNoStrike
    End With
    Range("L7").Select
End Sub

A: Replace
    ActiveChart.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis)
with
ActiveChart.SetElement msoElementPrimaryValueAxisTitleBelowAxis
The msoElementPrimaryValueAxisTitleAdjacentToAxis const does not appear to work.


text:
Q: Django ajax form - redirect to main page after form validation I have a sidenav_form that is submitted using an ajax post to a view called form_validation. The validation errors for empty fields or invalid email are shown correctly, since when the form is submitted and passed to the view, the view renders the form displaying the errors. Here is the console output:

email

Required Field

[08/Feb/2020 13:26:37] "POST /patients/validate_form/ HTTP/1.1" 200 1253

However, the behavior when passing the validator for repeated email is different. The error is sent to the request as before, but the user an't see it since it seems that the request redirects to another view...

email

This email has already been taken.

[08/Feb/2020 13:26:40] "POST /patient/ HTTP/1.1" 200 7769
[08/Feb/2020 13:26:40] "POST /patients/validate_form/ HTTP/1.1" 200 1279

The sidenav_form.html is the following:
{% load i18n %}
{% load crispy_forms_tags %}

        <form class="form" id="form_patient">
            {% csrf_token %}
            {{ form.as_p}}

                <button type="submit" class="btn btn-primary" id="sidenav-btn-submit" formmethod="post">{% trans 'Guardar'%}
                </button>

        </form>

form_validation view checks if the form is correct or not. It looks as follows:
def validate_form(request, patient_id=None, user_id=None):
    form_initial_data = request.POST
    if request.method == 'POST':
        print(form_initial_data)
        form = UserForm(form_initial_data)
        if form.is_valid():
            print('Form2 is valid')
            # DO SOMETHING
    print(form.errors)
    return render(request, 'patients/sidenav_form.html', {'form1': form})

the form has the following validator:
def clean_email(self):
        email = self.cleaned_data["email"]

        if not self.instance.pk:
            try:
                User.objects.get(email=email)
            except User.DoesNotExist:
                return email
            print('Repeated email')
            raise ValidationError(_("This email has already been taken."))
        return email

Do you have any idea why errors related to empty fields or invalid email renders correctly the form errors but repeated email redirects to another page?

A: Actually the problem arises because the button that call the ajax had the property type defined as submit. Therefore, when the button was pressed it actually made another post request, so django started processing two requests at the same time.


text:
Q: PL SQL Dynamic SQL I want to create PL/SQL function recieves table name and column name and condition and then return one value from the table his name was passed in the parameter.
I have created the function like this:
create or replace function get_dynamic
  (tbl_name nvarchar2,col_name nvarchar2 ,cond nvarchar2 )
return nvarchar2 is
  res nvarchar2(30);
  code varchar2(500):='begin select :col_name into :res from :tbl_name where :cond; end;';
begin
  EXECUTE IMMEDIATE code using in col_name , out res , in tbl_name, in cond;
  return res;
end;

the function created without any problem BUT when I call the function using this code:
begin
    DBMS_OUTPUT.PUT_LINE(get_dynamic('EMPLOYEES', 'FIRST_NAME', 'EMPLOYEE_ID=100'));
end;

I get his Error:
ERROR at line 1:
ORA-06550: line 1, column 51:
PL/SQL: ORA-00903: invalid table name ORA-06550: line 1, column 7:
PL/SQL: SQL Statement ignored ORA-06512: at "HR.GET_DYNAMIC", line 7 ORA-06512: at line 2

although the table name, column name and condition all are correct.
Help Please!..

A: You cannot use bind variables to construct SQL statement. You can use it for passing data only. Rewrite your procedure in this way:
create or replace function get_dynamic
  (tbl_name nvarchar2,col_name nvarchar2 ,cond nvarchar2 )
return nvarchar2 is
  res nvarchar2(30);
  code varchar2(500):='begin select '||col_name||' into :res from '||tbl_name||' where '||cond||'; end;';
begin
  EXECUTE IMMEDIATE code using out res;
  return res;
end;


text:
Q: Destructor in C? C++ have nice feature allowing to call some code at end of the block - destructor. Yesterday i randomly discovered trick which in C works similarly like destructor in C++. For illustration, here is usage of this trick to automatically close file:
#include <stdio.h>

#define AUTO_FILE( id, name, access ) \
for ( FILE* id = fopen( name, access ); id != NULL; fclose( id ), id = NULL )

int main()
{
    AUTO_FILE( f, "hello.txt", "w" ) {
        fprintf( f, "Hello World!" );
    }
    return 0;
}

I think this is nice and can have interesting usages. For example if you combine it with stack data structure you can directly in source code declare very intuitive and readable tree structures:
frame("frm") {
    menu("mnu") {
        popupmenu("file", "File") {
            menuitem("exit", "Exit");
        }
        popupmenu("help", "Help") {
            menuitem("about", "About...");
        }
    }
    label("lbl", "Hello World!");
    button("btn", "Push me!", btn_onclick);
}

But of course this hack don't work like true destructor. If you use break or return statement inside the block, fclose will not be called. But instead you can use continue statement if you need break the block like with break statement in C++. :-) So maybe this trick can be improved with some macro magic to work almost like true destructor.
So question is:
Is it possible to have destructor in standard C programming language?


text:
Q: How do I configure ActiveDirectoryLdapAuthenticationProvider with a username, password or custom searchfilter? The only configurable parts of this Authenticator seem to be the URL and the Domain. I'm unable to figure out how I would pass on a username or a password or my own search filter.
I looked at the source code of this class but most of the methods seem to be operating on UsernamePasswordAuthenticationToken from which username and password are being extracted. I was unable to find the methods which are used to create this object.
Here's what I'm currently using for AD LDAP Authentication:
package com.test;

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider;

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        ActiveDirectoryLdapAuthenticationProvider adProvider = new ActiveDirectoryLdapAuthenticationProvider("domain.org",
                "ldap://activedirectory-url:389");
        adProvider.setConvertSubErrorCodesToExceptions(true);
        adProvider.setUseAuthenticationRequestCredentials(true);
        auth.authenticationProvider(adProvider);
    }

}


text:
Q: Extension badge icon not showing I'm trying to draw the badge's icon using <canvas> but the badge is not showing at all in the browser.
In the console, I see onload is logged.
manifest.json
{
  "name": "Extension",
  "description": "Description",
  "version": "0.0.1",
  "background": {"scripts": ["backgroundScript.js"], "persistent": false},
  "manifest_version": 2,
  "icons": {
    "64": "images/ico.png"
  },
  "options_ui": {
    "page": "options.html",
    "chrome_style": true
  },
  "browser_action": {
    "default_title": "Extension",
    "default_popup": "popup.html"
  }
}

backgroundScript.js
var canvas = document.createElement('canvas');
var img = document.createElement('img');
img.onload = function () {
  console.log('onload');
    var context = canvas.getContext('2d');
    context.drawImage(img, 0, 2);
    context.fillStyle = 'rgba(255,0,0,1)';
    context.fillRect(10, 0, 19, 19);
    context.fillStyle = 'white';
    context.font = '11px Arial';
    context.fillText('3', 0, 19);

    chrome.browserAction.setIcon({
     imageData: context.getImageData(0, 0, 19, 19)
   });
};
img.src = 'images/ico.png';

.
├── COPYING
├── README.md
└── addon
    ├── backgroundScript.js
    ├── images
    │   └── ico.png
    ├── manifest.json
    ├── options.html
    ├── options.js
    ├── popup.html
    └── style.css


text:
Q: Tricks for calculating absolute third moment? Are there any useful tricks for calculating third absoute moments, similar to MGFs for raw and central moments? In particular, I'd like the third absolute moment of the Lognormal, normal, weibull, and binomial (discrete version). I can't seem to find much on the web or in my textbooks about the $\textit{absolute}$ third moment $\gamma$.
Where $\gamma = \int |X|^3 dF $
Thanks for any help :)

A: I suspect the easiest method to obtain the answers is to use a computer algebra system to do the grunt work for you. Here is a quick session with the mathStatica add-on to Mathematica ... took less than a minute to derive all of them:

(I should add that I am one of the authors of mathStatica.)
As for tricks:
For the Lognormal, Binomial and the Weibull, the domain of support is positive, so the absolute third moment will be identical to the third moment (so you should be able to find these in a book). For the case of a Normal, the absolute third moment of a general Normal random variable will be the same as the third moment of a folded Normal random variable ... and one might be able to find that result in a book too.


text:
Q: Insert LINQ Query Results Into DataTable I am using a LINQ Query to get data from linked Entity Framework Tables.  How do I take the the variable I am storing the results in and create a DataTable?
In the code below, how could I create a DataTable of all the results that the variable empInfo holds?
var empInfo = (from import in db.HmspreadsheetImports
join hpp in db.Hppings on import.VText equals hpp.HAu
where import.importDT >= DateTIme.Parse(currDate)
select new Label {
    LastName = hpp.lastname,
    FirstName = hpp.firstname,
    Address1 = hpp.Address1,
    City = import.city,
    State = import.state
}).ToList();

A: You can use this Extension method to convert IList to DataTable:
public static DataTable ToDataTable<T>(this IList<T> data)
{
    PropertyDescriptorCollection props =
        TypeDescriptor.GetProperties(typeof(T));
    DataTable table = new DataTable("Results");
    for (int i = 0; i < props.Count; i++)
    {
        PropertyDescriptor prop = props[i];
        table.Columns.Add(prop.Name,  Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
    }
    object[] values = new object[props.Count];
    foreach (T item in data)
    {
        for (int i = 0; i < values.Length; i++)
        {
            values[i] = props[i].GetValue(item);
        }
        table.Rows.Add(values);
    }
    return table;
}

Then implementation just like this:
DataTable dtempInfo = empInfo.ToDataTable<Label>();

A: MoreLINQ is available via NuGet package and provide a ToDataTable extension method that:

Appends elements in the sequence as rows of a given (or new) object (DataTable) with a set of lambda expressions specifying which members (property or field) of each element in the sequence will supply the column values.


text:
Q: Add new route example.com/username while preserving existing routes Is there a way to have example.com/username while preserving example.com/users/1 route?
To put simply, I just need to link to users's profile via username.

A: You can add an arbitrary route like this using:
get "/:username" => "users#show", as: :username

This will pass the username as a parameter to the show action.
Then in your views:
<%= link_to user.name, username_path(username: user.username) %>

You'll also need a controller action that knows how to handle the username parameter. If you want to use your existing users controller and preserve your /users/:id URLs too, you could do something like:
def show
  @user = if params[:username].present?
    User.find_by_username(params[:username])
  else
    User.find(params[:id])
  end
end


text:
Q: Differentiability in the proof of Rademacher theorem I have a question about the proof of Rademacher theorem due to C. B. Morrey. (I'm reading it in Simon's Lectures on geometric measure theory.)
The proof can be summarized in the following steps:

*

*For every $ v \in R^n $, $ |v|=1 $, the directional derivative $ D_vf $ exists a.e. in $ R^n $.

*The directional derivative $ D_vf $ is a weak derivative and therefore it holds that:
$$D_vf(x)= v\cdot \nabla f(x) \text{ a.e. in } R^n.$$

*There exists $ A \subset R^n $ such that $L^n(R^n-A)=0 $ ($L^n $ is the Lebesgue measure) and such that for every $ x \in A $ and for every $ v $ the directional derivative $ D_vf(x) $ exists. Note the difference between this step and the first step.

As I've read, these three steps should be conclude the proof. But my doubt is obviously the following one:
Since a continuous function with all of its directional derivatives at a point $ x $ is not necessarily differentiable at $ x $, how can I conclude the proof using only these three steps?

A: When moving to step 3, you should not forget the result of step 2: the directional derivative is linear in $v$. Still, the existence and linearity of $D_vf(x)$ do not imply the differentiability of $f$ at $x$. The Lipschitz condition must be used yet again.
You may want to consult Lectures on Lipschitz Analysis by Heinonen, where the proof of Rademacher's theorem is carefully presented in Chapter 3. The following quote directly addresses your question.

The proof splits into three parts. First the one-dimensional result is used to conclude that the partial derivatives of $f$ exist almost everywhere. This gives us a candidate for the total derivative. Next, it is shown that all directional derivatives exist almost everywhere, and can be given in terms of the gradient. Finally, by using the fact that there are only "countably many directions" in $\mathbb R^n$, the total derivative is shown to exist; it is only in this last step that the Lipschitz condition is seriously used.

Anyway, here is self-contained proof of the "missing piece".
Claim. Suppose $f$ is Lipschitz and $x$ is a point such that $D_vf(x)$ exists for all $v$ and is linear in $v$; that is, $D_v(x)=Av$ for some matrix $A$. Then $f$ is differentiable at $x$, and $Df(x)=A$.
Proof. Let $L$ be the Lipschitz constant of $f$. Introduce $g(h)=f(x+h)-f(x)-Ah$. The function $g$ is $2L$-Lipschitz  because the norm of $A$ is at most $L$. To prove the differentiability of $f$ at $x_0$, we must show that $$\lim_{h\to 0}\frac{g(h)}{|h|}=0$$
Given $\epsilon>0$, let $v_1,\dots,v_N$ be an $\epsilon$-net in the unit sphere (since the  sphere is compact, it has a finite $\epsilon$-net for every $\epsilon>0$). By the directional differentiability assumption, there exists $\delta>0$
such that  $|g(tv_j)/t|<{\epsilon}$  whenever $|t|\le \delta$ and $1\le j\le  N$.
Given a vector $h$ with $0<|h|<\delta$, let $t=|h|$ and pick $j$ such that $|v_j-h/t|\le \epsilon$. Since $|tv_j-h|\le t\epsilon$, it follows that $$|g(h)|\le |g(tv_j)|+2Lt\epsilon \le t\epsilon + 2Lt\epsilon = (2L+1) t\epsilon$$
Hence $|g(h)|/|h|\le (2L+1)\epsilon$. Since $\epsilon$ was arbitrary, we are done. $\Box$


text:
Q: How do I unit test object serialization/deserialization in VB.NET 1.1? I am looking for example code that provides a unit test to serialize and deserialize an object from a memory stream.  I have found examples using C# 2.0, however my current project uses VB.NET 1.1 (don't ask me why...), so the solution can not use generics.  I am also using the NUnit framework for the unit tests.
Thanks!

A: This is the pattern I've settled upon:
<Test()> _
Public Sub SerializationTest()
    Dim obj As New MySerializableObject()
    'Perform additional construction as necessary

    Dim obj2 As MySerializableObject
    Dim formatter As New BinaryFormatter
    Dim memoryStream As New MemoryStream()

    'Run through serialization process
    formatter.Serialize(memoryStream, obj)
    memoryStream.Seek(0, SeekOrigin.Begin)
    obj2 = DirectCast(formatter.Deserialize(memoryStream), MySerializableObject)

    'Test for equality using Assert methods
    Assert.AreEqual(obj.Property1, obj.Property1)
    'etc...
End Sub

A: NUnit has built in support for this which makes it quite a bit easier:
Dim obj As New MySerializableObject()
Assert.That(obj, Is.BinarySerializable)

Or for xml:
Dim obj As New MySerializableObject()
Assert.That(obj, Is.XmlSerializable)

A: If all you want to do is to ensure that they are serializable then all you should have to do it to do a serialization of an object and make sure no XmlSerializationException was thrown
[Test]
public void ClassIsXmlSerializable()
{
   bool exceptionWasThrown = false;

   try
   {
      // .. serialize object
   }
   catch(XmlSerializationException ex)
   {
      exceptionWasThrown = true;
   }

   Asset.IsFalse(exceptionWasThrown, "An XmlSerializationException was thrown. The type xx is not xml serializable!");
}

A: Hmm...so you are trying to write a unit test for serialization? Or for streams? This is hopefully done by MS already...but if you don't trust or implement something on your own...you could just fill object with some data, save it, restore it, and check if the fields values are in place?


text:
Q: Unable to change an object property in MutableList I'm trying to change quantity in my MutableList of an Object if there is yet that object with same ID in the list, the issue is that i'm getting bunch of errors when trying to do it.qty += qty
Here is a screen of what android studio is saying:

If it would be useful here is my Articolo class code:
data class Articolo(var barcode: String, var qta: Number) {
    constructor() : this ("", 0)
}

And the code from the screenshot:
private var articoli = mutableListOf<Articolo>()
    articoli.find{
        it.barcode==barcode
    }?.let{
        it.qta += qta
    }?:{
        articoli.add(Articolo(barcode, qta))
    }

A: can't defined qta as Number,Number is an interface ,it has no  plus method
defined it as Int  Long  Double or other special type


text:
Q: Shebang won't work I have written a small python script but bash won't execute it:
#!/usr/bin/python

'''
Created on Dec 19, 2014

'''
import subprocess

if __name__ == '__main__':
    p = subprocess.Popen('df -h', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
    out,err = p.communicate()
    for o in out.splitlines():
        if('rootfs' in o):
            print o.split()[3]

When I run ./te.py, bash gives me an error:
-bash: ./te.py: /usr/bin/python^M: bad interpreter: No such file or directory

What's the problem?

A: try this one:
#!/usr/bin/env python