text:
Q: MVC4 WebSecurity.Login fails first time through, can't get User in Login method Ok, an afternoon down the drain, I concede to SO assistance. My login method is pretty standard.  As shown below, I'm using WebSecurity.Login.
Right after that, I want to run a check to see if the user's profile is completed and if it isn't, send them over to that view.
Controller
[AllowAnonymous]
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
    if (ModelState.IsValid && WebSecurity.Login(model.Email, model.Password, persistCookie: model.RememberMe))
    {

        if (!User.IsInRole("User"))
        {
            if (!IsProfileComplete(WebSecurity.GetUserId(User.Identity.Name)))
            {
                return RedirectToAction("ProfileCompletion");
            }

            if(!User.IsInRole("User")) Roles.AddUserToRole(User.Identity.Name, "Vendor");
        }
        else // user has role
        {
            return RedirectToAction("Index", "Dashboard");
        }
    }

    ModelState.AddModelError("", "Unknown username or password.");
    return View(model);
}

I've stepped through it a bunch....after WebSecurity.Login I was under the impression the WebSecurity user data would get set but WebSecurity.GetUserId(User.Identity.Name) comes back as -1
Even when a user has completed profile, it will redirect them to the profile completion because it is trying to look up profile for userid -1
Is there something about the http post and login context set that I'm missing?  The end result I am looking for is to just make sure a user has completed the profile page before let into the system.  maybe there is a better way to do this?
Edit-----
found this link but I'd still appreciate a quick comment if someone could suggest a better pattern for my desired functionality
MVC 4 SimpleMembership - Why WebSecurity.CurrentUserId -1 after login

A: As the post you found pointed out the user identity is not set immediately after login, so User.Identity.Name does not contain the user name. Use model.UserName instead. Try changing this line:
if (!IsProfileComplete(WebSecurity.GetUserId(User.Identity.Name)))

To this:
if (!IsProfileComplete(WebSecurity.GetUserId(model.UserName)))


text:
Q: StackOverFlowError quadtree insert I want to implement insert method for a quadtree. In this quadtree i will insert certain shapes like rectangle, triangle, circle and diamond. All shaoes come with an rectangle border(all shaoes are considered rectangles in this method). My method works for few inputs, but for most of all i get the error mentioned.
void insert(Node parent, GeometricObj shape) {
    switch(parent.getType()) {
        case EMPTY:
            this.setShapeForNode(parent, shape);

            break;
        case LEAF:
            if(needSplit(parent, shape)) {
                this.setShapeForNode(parent, shape);
            }

            else {
                this.split(parent);
                this.insert(parent, shape);
                for (int i = 0; i < parent.Shapes.size(); i++) {
                    this.insert(parent, parent.Shapes.get(i));

                }
            }

            break;
        case PARENT:
            for (int i = 0; i < getQuadrantForShape(parent, shape.getX(), shape.getY(),
                    shape.getWidth(), shape.getHeight()).size(); i++) {
                if(getQuadrantForShape(parent, shape.getX(), shape.getY(),
                    shape.getWidth(), shape.getHeight()).get(i).equals(parent.Quads.get(0))) {
                    this.insert(parent.Quads.get(0), shape);
                }

                if(getQuadrantForShape(parent, shape.getX(), shape.getY(),
                    shape.getWidth(), shape.getHeight()).get(i).equals(parent.Quads.get(1))) {
                    this.insert(parent.Quads.get(1), shape);
                }

                if(getQuadrantForShape(parent, shape.getX(), shape.getY(),
                    shape.getWidth(), shape.getHeight()).get(i).equals(parent.Quads.get(2))) {
                    this.insert(parent.Quads.get(2), shape);
                }

                if(getQuadrantForShape(parent, shape.getX(), shape.getY(),
                    shape.getWidth(), shape.getHeight()).get(i).equals(parent.Quads.get(3))) {
                    this.insert(parent.Quads.get(3), shape);
                }

            }
            break;
    }
}

Split method is this:
void split(Node node) {

    node.setType(NodeType.PARENT);

    double x = node.getX();
    double y = node.getY();
    double halfwidth = node.getWidth()/ 2;
    double halfheight = node.getHeight()/ 2;

    node.setQuad1(new Node(x + halfwidth, y + halfheight, halfwidth, halfheight, node));
    node.setQuad2(new Node(x, y + halfheight, halfwidth, halfheight, node));
    node.setQuad3(new Node(x, y, halfwidth, halfheight, node));
    node.setQuad4(new Node(x + halfwidth, y, halfwidth, halfheight, node));

    node.Quads.add(node.quad1);
    node.Quads.add(node.quad2);
    node.Quads.add(node.quad3);
    node.Quads.add(node.quad4);

}

GetQuadrantForShape method returns a list of quadrants for the new shape.
void setShapeForNode(Node node, GeometricObj shape) {
   if (node.getType() != NodeType.PARENT) {
        node.setType(NodeType.LEAF);
        node.Shapes.add(shape);
    }

}

If someone has a clue of what the problem could be, or what am I doing wrong, or any hint of what can I improve, please tell me. If you need any other class or method I'm gonna attach it here.
UPDATE:
boolean needSplit(Node node, GeometricObj shape) {
    boolean result = false;
    for (int i = 0; i < node.Shapes.size(); i++) {
        GeometricObj o = node.Shapes.get(i);
        result = this.overlaps(shape.getX(), shape.getY(), shape.getWidth(), shape.getHeight(), o);
        if(result == false) {
            break;
        }
    }
    return result;
}

boolean overlaps (double x, double y, double width, double height, GeometricObj r) {
        return x < r.getX() + r.getWidth() && x + width > r.getX() && y < r.getY() + r.getHeight() && y + height > r.getY();
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Auto-submit an upload form when a file is selected, and trigger an action I'm trying to submit an uploaded file automatically when the user uploads the file. The shortest way I found was to insert onChange="form.submit()"in the upload files input. Source I did that, and now when I insert an action to the submit input (through JavaScript), it doesn't get triggered.
How can I trigger an event when I do onChange="form.submit()"?
JSFiddle
Code snippet:

$("form").on('submit',function(){
    alert("It works");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="http://example.com">
    <input type="file" id="file" onChange="form.submit()" />
    <input id="submit" type="submit" name="submit" value="Upload"/>
</form>

Update
I know it's possible to perform that with $('#file').change(function()... But I want to know if it's possible to do it with onChange="form.submit()".

A: Solution 1: jsFiddle 1

$(document).ready(function(){
    $("form").on('submit',function(){
        alert("It works");
    });
});
<form action="http://example.com">
    <input type="file" id="file" onchange="$('form').submit();" />
    <input id="submit" type="submit" name="submit" value="Upload"/>
</form>

Solution 2: jsFiddle 2

$(document).ready(function(){
    $("form").on('submit',function(){
        alert("It works");
    });
});

function submitForm()
{
    $('form').submit();
}
<form action="http://example.com">
    <input type="file" id="file" onchange="submitForm()" />
    <input id="submit" type="submit" name="submit" value="Upload"/>
</form>

A: The <input> tag type file responds for change event when a file is selected by user, so you can do something like this:
input.onchange = function (event) {
  // do something
}

Checkout the documentation here

A: Like this:

$('#file').on('change', function() {
    alert('test');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="http://example.com">
    <input type="file" id="file" />
    <input id="submit" type="submit" name="submit" value="Upload"/>
</form>

A: $('#file').change(function() {
    alert("Form is being submitted");
    $('#myBeautifulForm').submit();
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="myBeautifulForm" action="http://example.com">
    <input type="file" id="file" />
    <input id="submit" type="submit" name="submit" value="Upload"/>
</form>


text:
Q: mem_fn to function of member object I was tinkering around with the std::mem_fn and couldn't manage to bind it to data/functions of an member of a struct (one layer deeper).
I hope that the code shows the problem better than I can describe it, because I'm not familiar with the terminology.
#include <functional>

struct Int
{
    Int(int _x = 0) : x(_x) {}
    int GetInt() const { return x; }
    int x;
};

struct IntWrapper
{
    IntWrapper(int _x = 0) : test(_x) {}
    int GetWrappedInt() const { return test.GetInt(); }
    Int test;
};

int main()
{
    IntWrapper wrapper{ 123 };

    auto x = std::mem_fn(&IntWrapper::GetWrappedInt);
    //auto y = std::mem_fn(&IntWrapper::test.GetInt); // ERROR
    //auto z = std::mem_fn(&IntWrapper::test.x); // ERROR

    int a = x(wrapper);
    //int b = y(wrapper);
    //int c = z(wrapper);

    //std::cin.ignore();

    return 0;
}

The error message is the following:
error C2228: left of '.GetInt' must have class/struct/union
error C2672: 'std::mem_fn': no matching overloaded function found
error C3536: 'y': cannot be used before it is initialized
error C2064: term does not evaluate to a function taking 1 arguments

Question:
Is it possible to make these binds? Do I need std::bind for this?

A: According to the specification, std::mem_fn() takes as argument a member function pointer, i.e.
auto y = std::mem_fn(&Int::GetInt);
auto b = y(wrapper.test);

As far as I'm aware, std::mem_fn() is more or less obsolete, since lambda expressions. For example
auto y = [](IntWrapper const&wrapper) { return wrapper.test.GetInt(); };
auto b = y(wrapper);    // note: no need to get hold of member 'test'

A: Your syntax is wrong, &IntWrapper::test is a pointer to member.
I've never seen &IntWrapper::test.GetInt, I don't even know how it is getting parsed.
Perhaps this is what you want
auto y = std::mem_fn(&decltype(IntWrapper::test)::GetInt);
auto b = y(wrapper.test);

A: Since anyway the return type of std::mem_fn is unspecified, I simply see no reason why using it instead of some lambda function:
auto x = [&wrapper]{  return wrapper.GetWrappedInt(); };
int a = x();

Or:
auto x = [](const IntWrapper& wrapper){ return wrapper.GetWrappedInt(); };
int a = x(wrapper);

I even think these are better since the compiler can have better optimization opportunities.


text:
Q: Setting Spark driver memory in Zeppelin on Docker (local mode) I checked many resources such as:

*

*https://github.com/dylanmei/docker-zeppelin

*http://bigdatums.net/2017/02/26/running-apache-zeppelin-on-docker/
But non has a clear way to set the driver memory, I tried to set variables like:

*

*-e SPARK_SUBMIT_OPTIONS="--driver-memory 6G" and

*-e ZEPPELIN_JAVA_OPTS="-Dspark.driver.memory=6g"
without any success.
Here is my full command:
docker run -p 8080:8080 \
-p 4040:4040 \
-v $PWD/logs:/logs \
-v $PWD/notebook:/notebook \
-v $PWD/jars:/jars \
-v $PWD/conf/interpreter.json:/zeppelin/conf/interpreter.js \
-v $PWD/data:/data \
-e ZEPPELIN_LOG_DIR='/logs' \
-e ZEPPELIN_NOTEBOOK_DIR='/notebook' \
-e SPARK_SUBMIT_OPTIONS="--driver-memory 6G" \
apache/zeppelin:0.8.1

A: OK, after some investigations I had to add -e ZEPPELIN_INTP_MEM="-Xmx6g" to the options.


text:
Q: java.lang.ClassNotFoundException: sun.misc.GC I used tomcat server 8.0.
Error: When I run the Tomcat server, I found below error.
SEVERE: Failed to trigger creation of the GC Daemon thread during Tomcat start to prevent possible memory leaks. This is expected on non-Sun JVMs.
java.lang.ClassNotFoundException: sun.misc.GC
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:315)
    at org.apache.catalina.core.JreMemoryLeakPreventionListener.lifecycleEvent(JreMemoryLeakPreventionListener.java:310)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:394)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:99)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:580)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:603)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:310)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:484)

A: Your version of Tomcat is not compatible with the used java version. Check documentation to see which version o java you can use with that particular version of tomcat or upgrade tomcat to the matching java version


text:
Q: How to override standart padding in CardView while using cardUseCompatPadding? When I use cardUseCompatPadding to show shadow in my card view, top padding is bigger than left one. How to make both padding equal, because my ribbon looking not beautiful, it's bigger on top? Thanks.

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <!-- Green triangles for badge -->
    <FrameLayout
        android:id="@+id/ribbon_parts"
        android:layout_width="58dp"
        android:layout_height="58dp"
        android:background="@drawable/ic_ribbon_parts"
        android:visibility="gone"/>

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.CardView
            android:id="@+id/item_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:animateLayoutChanges="true"
            android:background="@color/red"
            android:clickable="true"
            android:foreground="?attr/selectableItemBackground"
            android:theme="@style/LightGrayHighlightTheme"
            card_view:cardBackgroundColor="@color/white"
            card_view:cardCornerRadius="4dp"
            card_view:cardElevation="2dp"
            card_view:cardPreventCornerOverlap="true"
            card_view:cardUseCompatPadding="true">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="130dp"
                android:animateLayoutChanges="true"
                android:orientation="horizontal"
                android:background="@color/blue"
                android:weightSum="3"> </LinearLayout>
</FrameLayout>

<!-- badge -->
<FrameLayout
        android:id="@+id/ribbon_main"
        android:layout_width="58dp"
        android:layout_height="58dp"
        android:background="@drawable/ic_ribbon_main"
        android:visibility="gone"/>

https://www.shutterstock.com/search/new+blue+corner+ribbon

A: Taken from the documentation:

This may cause Cards to have different sizes between Lollipop and
  before Lollipop. If you need to align CardView with other Views, you
  may need api version specific dimension resources to account for the
  changes. As an alternative, you can set this flag to true and CardView
  will add the same padding values on platforms Lollipop and after.

Next, you can add the indentation you need by using the margin attribute
example.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#2861">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.CardView
            android:id="@+id/item_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginEnd="2dp"
            android:layout_marginStart="2dp"
            android:layout_marginTop="1dp"
            android:clickable="true"
            android:focusable="true"
            android:foreground="?attr/selectableItemBackground"
            card_view:cardBackgroundColor="@android:color/white"
            card_view:cardCornerRadius="4dp"
            card_view:cardElevation="2dp"
            card_view:cardPreventCornerOverlap="false"
            card_view:cardUseCompatPadding="true">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="130dp"
                android:animateLayoutChanges="true"
                android:orientation="horizontal"
                android:weightSum="3">

                <!-- Your code here -->

            </LinearLayout>

        </android.support.v7.widget.CardView>

    </FrameLayout>

    <!-- badge -->
    <FrameLayout
        android:id="@+id/ribbon_main"
        android:layout_width="58dp"
        android:layout_height="58dp"
        android:layout_gravity="end"
        android:background="@drawable/corner_ribbon"
        android:visibility="visible" />

</FrameLayout>

Now it looks great on different versions of the API.
API 19 example
API 26 example
comparison side by side
In your project, you can use these settings for both CardView and FrameLayout (ribbon) to achieve the desired result.
example_2.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#2861">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.CardView
            android:id="@+id/item_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="18dp"
            android:layout_marginTop="17dp"
            android:clickable="true"
            android:focusable="true"
            android:foreground="?attr/selectableItemBackground"
            card_view:cardBackgroundColor="@android:color/white"
            card_view:cardCornerRadius="4dp"
            card_view:cardElevation="2dp"
            card_view:cardPreventCornerOverlap="false"
            card_view:cardUseCompatPadding="true">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="130dp"
                android:animateLayoutChanges="true"
                android:orientation="horizontal"
                android:weightSum="3">

                <!-- Your code here -->

            </LinearLayout>

        </android.support.v7.widget.CardView>

    </FrameLayout>

    <!-- badge -->
    <FrameLayout
        android:id="@+id/ribbon_main"
        android:layout_width="58dp"
        android:layout_height="58dp"
        android:layout_gravity="end"
        android:layout_marginEnd="16dp"
        android:layout_marginTop="16dp"
        android:background="@drawable/corner_ribbon"
        android:visibility="visible" />

</FrameLayout>

increased indentation

A: You can't fix this. When cardUseCompatPadding flag is set, these methods are used to calculate padding on all API levels:
final static float SHADOW_MULTIPLIER = 1.5f;

static float calculateVerticalPadding(float maxShadowSize, float cornerRadius, addPaddingForCorners) {
   if (addPaddingForCorners) {
      return (float) (maxShadowSize * SHADOW_MULTIPLIER + (1 - COS_45) * cornerRadius);
   } else {
      return maxShadowSize * SHADOW_MULTIPLIER;
   }
}

static float calculateHorizontalPadding(float maxShadowSize, float cornerRadius, boolean addPaddingForCorners) {
   if (addPaddingForCorners) {
      return (float) (maxShadowSize + (1 - COS_45) * cornerRadius);
   } else {
      return maxShadowSize;
   }
}

addPaddingForCorners is true when you use card_view:cardPreventCornerOverlap="true".
Perhaps setting some layout_marginTop on ribbon_main and ribbon_parts will give you the desired effect?

A: This is working for me, may be it would work for you too:
    float cardelevation = cardView.getMaxCardElevation();
    float cardradius = cardView.getRadius();
    double cardcos = Math.cos(Math.toRadians(45));

    int horizontalPadding = (int) (cardelevation + (1 - cardcos ) * cardradius);
    int verticalPadding = (int) (cardelevation * 1.5 + (1 - cardcos ) * cardradius);

Thank You.


text:
Q: Can we get some information about search term statistics Can we get some information about search term statistics in Stack Overflow.
Users may input terms (tags or phrase) that are supposed to be included in the intended content.
In other words, I want to know what kind of terms do users usually use for search?
e.g. c#, c++, java, error, memory exception  and so on
What I want to extract out of the information is the feature of query terms.
When users try to search for articles in Stack Overflow,
- they are likely to use terms describing the development environment such as language name, framework name...
- or to use terms describing problematic situation like error-handling and memoryleaks...
More concretely I want to get the portion of terms given each perspective.


text:
Q: Pattern.DOTALL with String.replaceAll I have a multiline HTML document that I am trying to get some stuff from. I'm using java's regex (I know - XML parsers bla bla bla, just bear with me here please :) ).
    dfahfadhadaaaa<object classid="java:com.sun.java.help.impl.JHSecondaryViewer" width="14" height="14">
<param name="content" value="../Glossary/glInterlinkedTask.html">

<param name="text" value="interlinked task">
<param name="viewerActivator" value="javax.help.LinkLabel">
<param name="viewerStyle" value="javax.help.Popup">
<param name="viewerSize" value="390,340">
<param name="textFontFamily" value="SansSerif">
<param name="textFontWeight" value="plain">
<param name="textFontStyle" value="italic">
<param name="textFontSize" value="12pt">
<param name="textColor" value="blue">

<param name=iconByID" value="">
</object>
sjtsjsrjrsjsrjsrj

I've got this HTML in a string: input.
    input = input.replaceAll("<object classid=\"java:com.sun.java.help.impl.JHSecondaryViewer.*?object>", "buh bye!");

Obviously, it's not working. HOWEVER, I can get a pattern match if I use pattern.compile with Pattern.DOTALL.
So, my question is - how can I do something like Pattern.DOTALL with string.replaceall?

A: Attach (?s) to the front of your pattern :
input = input.replaceAll("(?s)<object classid=\"java:com\\.sun\\.java\\.help\\.impl\\.JHSecondaryViewer.*?object>", "buh bye!");

From the Javadoc:

Dotall mode can also be enabled via the embedded flag expression (?s). (The s is a mnemonic for "single-line" mode, which is what this is called in Perl.)

Other flags work this way as well

Special constructs (non-capturing)
...
(?idmsux-idmsux)    Nothing, but turns match flags i d m s u x on - off

On a side note, if your goal is to remove unsafe objects from HTML from an untrusted source, please don't use regular expressions, and please don't blacklist tags.


text:
Q: Speech recognization sppech to text does't work in python I have programmed this code to convert audio to text. It is not converting entire text. The total duration of the audio is 1.21 minutes. But the program outputs just 4 words from the audio, rest of the conversation from the audio is missing. Can some one please help me to fix this issue. Below is the code.
import speech_recognition as sr
from gtts import gTTS
import os
import playsound

r = sr.Recognizer()

with sr.AudioFile('Track1.wav') as source:
    r.adjust_for_ambient_noise(source, duration=0.5)
    audio = r.listen(source)
    try:
        text = (r.recognize_google(audio, language="en-US"))
        print('working on...')
        print(text)
    except:
        print('Sorry.. run again..')

A: Try a different audio file. If you are getting only a few words for other audio files also, it could be limit of the "free" default Google API key that is used by the recognize_google function in the speech_recognition library. In that case, you will need your own API key to transcribe longer audio files.


text:
Q: Unicorn w/ Sinatra error Rack::Lint::LintError: Status must be >=100 seen as integer I'm creating a simple application with sinatra, and I'm deploying it with unicorn.
On local using ruby webserver.rb it works perfectly, but on production server, when executing with unicorn (without -D) it raise an error when calling an specific post route:
post '/save-preset' do
  preset = Preset.create_new params['preset_name'], params['data']
  session[:flash] = 'Preset Saved'
  {id: preset.id}.to_json
end

the error is:
Rack::Lint::LintError: Status must be >=100 seen as integer
    /usr/local/rvm/gems/ruby-2.2-head/gems/rack-1.5.5/lib/rack/lint.rb:20:in `assert'

I know the logic of the action is being executed because I end with a new entry on my db.
This is also working fine on local.
I've searched over the internet about this error, but only found it to be related to other ruby webserver, it seem to me like the http status for the response is not valid, but i'm not specifying it and for others routes (even other POST) it works just fine.

A: Try this hack for Lint:
module Rack
  class Lint
    def assert message, &block
    end
  end
end

It helped me with async requests in thin


text:
Q: COUNTIF equivalent in dplyr summarise I have a data frame listing total students (Stu) and number of students per group (ID) who are taking part in an activity (Sub):
     ID   Stu   Sub
  (int) (int) (int)
1   101    80    NA
2   102   130    NA
3   103    10    NA
4   104   210    20
5   105   180    NA
6   106   150    NA

I would like to know the number of groups in size bands (>400, >200, >100, >0) who are either involved in an activity (Sub > 0), or not (Sub is.na)
output <- structure(list(ID = c(101L, 102L, 103L, 104L, 105L, 106L),
                       Stu = c(80L, 130L, 10L, 210L, 180L, 150L),
                       Sub = c(NA,NA, NA, 20L, NA, NA)),
                  .Names = c("ID", "Stu", "Sub"),
                  class = c("tbl_df", "data.frame"),
                  row.names = c(NA, -6L))

temp <- output %>%
mutate(Stu = ifelse(Stu >= 400, 400,
         ifelse(Stu >= 200, 200,
             ifelse(Stu >= 100, 100, 0
                 )))) %>%
group_by(Stu) %>%
summarise(entries = length(!is.na(Sub)),
          noentries = length(is.na(Sub)))

The results should be:
    Stu entries noentries
  (dbl)   (int)     (int)
1     0       0         2
2   100       0         3
3   200       1         0

But I get:
    Stu entries noentries
  (dbl)   (int)     (int)
1     0       2         2
2   100       3         3
3   200       1         1

How can I make the length function in the summarise act like a countif?

A: Following the same idea provided by @eipi10, but cutting to the chase with count() instead of group_by() %>% tally() and showing that tidyr::spread can mimic reshape2::dcast:
output %>%
  count(Sub = ifelse(is.na(Sub), 'No Entries', 'Entires'),
        Stu = cut(Stu, c(0, 100, 200, 400, +Inf), labels = c(0, 100, 200, 400))) %>%
  tidyr::spread(Sub, n, fill = 0)

A: summarise expects a single value, so sum instead of length does the job:
output %>%
  mutate(Stu = ifelse(Stu >= 400, 400,
                      ifelse(Stu >= 200, 200,
                             ifelse(Stu >= 100, 100, 0
                             )))) %>%
  group_by(Stu) %>%
  summarise(entries = sum(!is.na(Sub)),
            noentries = sum(is.na(Sub)))

Source: local data frame [3 x 3]

Stu entries noentries
(dbl)   (int)     (int)
1     0       0         2
2   100       0         3
3   200       1         0

A: Another option is to group by both Stu and Sub, but to do that we need to first recode the values of Sub and Stu to match the output groupings we want. We also use cut, instead of nested ifelse, to set the value breaks in Stu:
library(reshape2)

output %>%
  group_by(Sub=ifelse(is.na(Sub), "No Entries", "Entries"),
           Stu=cut(Stu, c(0,100,200,400,Inf), labels=c(0,100,200,400))) %>%
  tally %>%
  dcast(Stu ~ Sub, fill=0)

     Stu Entries No Entries
1      0       0          2
2    100       0          3
3    200       1          0


text:
Q: Как узнать количество индексов в ArrayList У меня есть массив:
List<String> list = new ArrayList<>();

list.add("word1");

Если я использую функцию list.size, то мне выдаст 1, но я хочу узнать количество индексов;
List<String> list = new ArrayList<>();
list.add("1");
list.add("2");
list.add("3");
System.out.println(list.size());

Я хочу узнать сколько лишних ячеек создалось в ArrayList.

A: Данный код покажет размер Листа и его Capacity при заполнении ArrayList:
 public static void main(String[] args) throws Exception {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 17; i++) {
            list.add(i);
            System.out.format("Size: %2d, Capacity: %2d%n",
                    list.size(), getCapacity(list));
        }
    }

    static int getCapacity(List<?> l) throws Exception {
        Field dataField = ArrayList.class.getDeclaredField("elementData");
        dataField.setAccessible(true);
        return ((Object[]) dataField.get(l)).length;
    }


text:
Q: How to use AVERAGEIF in Google Sheets, only addressing columns with a specific text In Google Sheets, I'm trying to use AVERAGEIF to calculate an average of only some of the columns in another table.
The columns to be included in the average are marked by some text in a specific cell (e.g. the first or last row of that column).
Some columns are to be included in several averages, so the text in the top\bottom row would include several words (effectively meaning I'll need some sort of substring check such as FIND).
I've tried using AVERAGEIF() in conjuction with FIND() but couldn't get this to work.
Any ideas?
Here is an example of how the data sheet looks like, and how I would expect it to work

A: You can use following formula:
=ARRAYFORMULA(AVERAGE(IF(ISNUMBER(SEARCH(D2,A2:A9)),B2:B9,"")))

Edit:
For table mentioned in comment you must change ranges:
=ARRAYFORMULA(AVERAGE(IF(ISNUMBER(SEARCH(E2,$A$1:$C$1)),$A$2:$C$4,"")))

A: You can use a query
=AVERAGE(QUERY(TRANSPOSE($A$1:$D),"where Col1 contains '"&D1&"'"))

Functions used:

*

*AVERAGE

*QUERY

*TRANSPOSE


text:
Q: my code is working on codepen but not in my browser. i wanted to getelementbyid and then then that element on console <!DOCTYPE html>

    <meta charset="UTF-8" />
    <title>Assignment 4</title>

Biryani

Rohan

Biryani is Pakistan's special dish. Main Ingredients are rice and chicken.

script.js
<-- this script is used to getelementbyid "hello" and then displaying on console.-->
var myname = document.getElementById("hello");
console.log(myname.innerHTML);
const el = document.querySelector('h2');
el.textContent = 'Assignment 4';

A: You should include js below of your element definitions.
Browser is compiling html scripts from top to below. If you included js code before all elements defined then that catch nothing and it returns error.
...
// your elements are defined here.

A: The code is correct. You just need to move your script tag just before you close the body tag.
<!DOCTYPE html>

    <meta charset="UTF-8" />
    <title>Assignment 4</title>

Biryani

Rohan

      Biryani is Pakistan's special dish. Main Ingredients are rice and chicken.


text:
Q: Is there a way to check if web console (e.g. FireBug) is open in java language? I am creating automated test cases with Selenium WebDriver 2. My code is set up, so that FireBug automatically is opened when Selenium WebDriver opens FireFox. A few seconds later I ask Selenium to close it again. For some reason, if I don't do this, sometimes FireBug won't be available to me at a later stage.
My problem:
When I use the TestNG suite to run my test suite, some of the test cases end up opening FireBug but not closing it again. My guess is, that this is due to existing browser windows already being open. The "close FireBug code" is then misused to open FireBug instead of closing it.
For this reason, I would like to make a check to see if FireBug is open, and if so, I would like to close it.
Opening code:
String firebugPath = TO_Constant.fireBug();
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(new File(firebugPath));
profile.setPreference("extensions.firebug.showFirstRunPage", false);
profile.setPreference("extensions.firebug.allPagesActivation", "on");
driver = new FirefoxDriver(profile);

Code to close FireBug:
Actions action = new Actions(driver);
action.sendKeys(Keys.F12).build().perform();

I can find ways to do this in javascript, using window.console. Is there any way to do something similar in java?

A: console.log('is DevTools open?', window.devtools.open);

You can also listen to an event:
window.addEventListener('devtoolschange', function (e) {
    console.log('is DevTools open?', e.detail.open);
});

It doesn't work when DevTools is undocked. However, works with the Chrome/Safari/Firefox DevTools and Firebug.
The answer is by Sindre Sorhus and has been taken from here!
Find out whether Chrome console is open


text:
Q: How to delete columns by colours from HTML table by python I have below html table and I'd like to delete all columns that don't have background:white cells
soup = BeautifulSoup(htmlbody, 'html.parser')
table1 = soup.find_all('table')[3]
print(table1)

KPI ↓<o:p></o:p>

ch<o:p></o:p>

eg<o:p></o:p>

fr<o:p></o:p>

om<o:p></o:p>

sa<o:p></o:p>

sa m<o:p></o:p>

tr<o:p></o:p>

uk<o:p></o:p>

ukv<o:p></o:p>

ust<o:p></o:p>

avg<o:p></o:p>

Update1<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

--<o:p></o:p>

100<o:p></o:p>

Web1<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

--<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

Update2<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

--<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

100<o:p></o:p>

A: Try this to remove tds having that style:
for t in table1.findAll("td"):
    if "background:white" in t["style"]:
        t.decompose()

To remove columns wherein tds have that style, you can use a combination of BeautifulSoup and pandas:
from bs4 import BeautifulSoup
import pandas as pd

soup = BeautifulSoup(htmlbody, 'html.parser')
table1 = soup.find_all('table')[3]

cols = set([])
for tr in table1.findAll("tr"):
    for i, td in enumerate(tr.findAll("td")):
        if "background:white" in td["style"]:
            cols.add(i)

df = pd.read_html(table1)
df = df[0]
df.drop(df.columns[list(cols)], axis=1, inplace=True)

Hope I have understood your request.


text:
Q: This site can't be reached during cypress configuration I am a newbie to cypress and trying to install cypress on my local machine but while doing configuration through UI I am getting the below issue. I already use the below command to install cypress:
npm install cypress --save-dev

Step 1: Select chrome browser and click start E2E testing in Chrome

Sep 2: Getting the below issue after launching the chrome browser

Log:
cypress:launcher:browsers launching browser { browser: { name: 'chrome', family: 'chromium', channel: 'stable', displayName: 'Chrome', version: '108.0.5359.98', path: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', minSupportedVersion: 64, majorVersion: '108', isHeaded: true, isHeadless: false }, url: 'about:blank' } +0ms
  cypress:launcher:browsers spawning browser with args { args: [ 'about:blank', '--test-type', '--ignore-certificate-errors', '--start-maximized', '--silent-debugger-extension-api', '--no-default-browser-check', '--no-first-run', '--noerrdialogs', '--enable-fixed-layout', '--disable-popup-blocking', '--disable-password-generation', '--disable-single-click-autofill', '--disable-prompt-on-repos', '--disable-background-timer-throttling', '--disable-renderer-backgrounding', '--disable-renderer-throttling', '--disable-backgrounding-occluded-windows', '--disable-restore-session-state', '--disable-new-profile-management', '--disable-new-avatar-menu', '--allow-insecure-localhost', '--reduce-security-for-testing', '--enable-automation', '--disable-print-preview', '--disable-device-discovery-notifications', '--autoplay-policy=no-user-gesture-required', '--disable-site-isolation-trials', '--metrics-recording-only', '--disable-prompt-on-repost', '--disable-hang-monitor', '--disable-sync', '--disable-web-resources', '--safebrowsing-disable-download-protection', '--disable-client-side-phishing-detection', '--disable-component-update', "--simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT'", '--disable-default-apps', '--use-fake-ui-for-media-stream', '--use-fake-device-for-media-stream', '--disable-ipc-flooding-protection', '--disable-backgrounding-occluded-window', '--disable-breakpad', '--password-store=basic', '--use-mock-keychain', '--disable-dev-shm-usage', '--proxy-server=http://localhost:58163', '--proxy-bypass-list=<-loopback>', '--remote-debugging-port=58175', '--remote-debugging-address=127.0.0.1', '--load-extension=C:\\Users\\dipak.bachhav\\AppData\\Roaming\\Cypress\\cy\\production\\browsers\\chrome-stable\\interactive\\CypressExtension,C:\\Users\\dipak.bachhav\\AppData\\Local\\Cypress\\Cache\\12.0.1\\Cypress\\resources\\app\\packages\\extension\\theme', '--user-data-dir=C:\\Users\\dipak.bachhav\\AppData\\Roaming\\Cypress\\cy\\production\\browsers\\chrome-stable\\interactive', '--disk-cache-dir=C:\\Users\\dipak.bachhav\\AppData\\Roaming\\Cypress\\cy\\production\\browsers\\chrome-stable\\interactive\\CypressCache' ] } +0ms
  cypress:launcher:browsers spawning browser with environment { env: { ALLUSERSPROFILE: 'C:\\ProgramData', APPDATA: 'C:\\Users\\dipak.bachhav\\AppData\\Roaming', BPPDOMAIN_MANAGER_ASM: 'EdrDotNet, Version=56.0.0.0, Culture=neutral, PublicKeyToken=da1b3922653ea916', BPPDOMAIN_MANAGER_TYPE: 'EdrDotNet.EdrAppDomainManager', COLOR: '1', CommonProgramFiles: 'C:\\Program Files\\Common Files', 'CommonProgramFiles(x86)': 'C:\\Program Files (x86)\\Common Files', CommonProgramW6432: 'C:\\Program Files\\Common Files', COMPUTERNAME: 'UKC-DSEV023991', ComSpec: 'C:\\WINDOWS\\system32\\cmd.exe', CYPRESS: 'true', CYPRESS_INTERNAL_ENV: 'production', DEBUG: 'cypress:*', DEBUG_COLORS: '1', DriverData: 'C:\\Windows\\System32\\Drivers\\DriverData', EDITOR: 'notepad.exe', FORCE_COLOR: '1', FORCE_STDERR_TTY: '1', FORCE_STDIN_TTY: '1', FORCE_STDOUT_TTY: '1', FPS_BROWSER_APP_PROFILE_STRING: 'Internet Explorer', FPS_BROWSER_USER_PROFILE_STRING: 'Default', GRADLE: 'C:\\Users\\dipak.bachhav\\Downloads\\gradle-6.9.1-bin\\gradle-6.9.1\\bin', HOME: 'C:\\Users\\dipak.bachhav', HOMEDRIVE: 'C:', HOMEPATH: '\\Users\\dipak.bachhav', INIT_CWD: 'C:\\Users\\dipak.bachhav\\CypressFramework', 'IntelliJ IDEA Community Edition': 'C:\\Users\\dipak.bachhav\\AppData\\Local\\JetBrains\\IntelliJ IDEA Community Edition 2022.1.2\\bin;', JAVA_HOME: 'C:\\Program Files\\Java\\jdk1.8.0_281', LOCALAPPDATA: 'C:\\Users\\dipak.bachhav\\AppData\\Local', LOGONSERVER: '\\\\UKC-DSEV023991', MAVEN_HOME: 'C:\\Users\\dipak.bachhav\\Downloads\\apache-maven-3.8.4\\bin', MOCHA_COLORS: '1', NODE: 'C:\\Tools\\nodejs\\node.exe', NODE_EXE: 'C:\\Tools\\nodejs\\\\node.exe', NODE_TLS_REJECT_UNAUTHORIZED: '0', NO_PROXY: '127.0.0.1,::1,localhost', NPM_CLI_JS: 'C:\\Tools\\nodejs\\\\node_modules\\npm\\bin\\npm-cli.js', npm_command: 'exec', npm_config_cache: 'C:\\Users\\dipak.bachhav\\AppData\\Local\\npm-cache', npm_config_globalconfig: 'C:\\Tools\\nodejs\\etc\\npmrc', npm_config_global_prefix: 'C:\\Tools\\nodejs', npm_config_init_module: 'C:\\Users\\dipak.bachhav\\.npm-init.js', npm_config_legacy_peer_deps: 'true', npm_config_local_prefix: 'C:\\Users\\dipak.bachhav\\CypressFramework', npm_config_metrics_registry: 'https://registry.npmjs.org/', npm_config_node_gyp: 'C:\\Tools\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js', npm_config_noproxy: '', npm_config_prefix: 'C:\\Tools\\nodejs', npm_config_userconfig: 'C:\\Users\\dipak.bachhav\\.npmrc', npm_config_user_agent: 'npm/8.19.2 node/v18.12.1 win32 x64 workspaces/false', npm_execpath: 'C:\\Tools\\nodejs\\node_modules\\npm\\bin\\npx-cli.js', npm_lifecycle_event: 'npx', npm_lifecycle_script: 'cypress', npm_node_execpath: 'C:\\Tools\\nodejs\\node.exe', npm_package_json: 'C:\\Users\\dipak.bachhav\\CypressFramework\\package.json', npm_package_name: 'cypressframework', npm_package_version: '1.0.0', NPM_PREFIX_NPX_CLI_JS: 'C:\\Tools\\nodejs\\node_modules\\npm\\bin\\npx-cli.js', NPX_CLI_JS: 'C:\\Tools\\nodejs\\node_modules\\npm\\bin\\npx-cli.js', NUMBER_OF_PROCESSORS: '4', OneDrive: 'C:\\Users\\dipak.bachhav\\OneDrive - Specsavers', OneDriveCommercial: 'C:\\Users\\dipak.bachhav\\OneDrive - Specsavers', ORIGINAL_NODE_OPTIONS: ' --openssl-legacy-provider', ORIGINAL_XDG_CURRENT_DESKTOP: 'undefined', OS: 'Windows_NT', Path: 'C:\\Users\\dipak.bachhav\\CypressFramework\\node_modules\\.bin;C:\\Users\\dipak.bachhav\\CypressFramework\\node_modules\\.bin;C:\\Users\\dipak.bachhav\\node_modules\\.bin;C:\\Users\\node_modules\\.bin;C:\\node_modules\\.bin;C:\\Tools\\nodejs\\node_modules\\npm\\node_modules\\@npmcli\\run-script\\lib\\node-gyp-bin;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\windows\\System32\\OpenSSH\\;C:\\Program Files\\WindowsPowerShell\\Scripts;C:\\Program Files\\Amazon\\AWSCLIV2\\;%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;%SYSTEMROOT%\\System32\\OpenSSH\\;C:\\Users\\dipak.bachhav\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\dipak.bachhav\\AppData\\Local\\JetBrains\\IntelliJ IDEA Community Edition 2022.1.2\\bin;;C:\\Program Files\\Java\\jdk1.8.0_281;C:\\Users\\dipak.bachhav\\Downloads\\mongodb-windows-x86_64-5.0.2\\mongodb-win32-x86_64-windows-5.0.2\\bin;C:\\Users\\dipak.bachhav\\Downloads\\gradle-6.9.1-bin\\gradle-6.9.1\\bin;C:\\Users\\dipak.bachhav\\Downloads\\apache-maven-3.8.4\\bin;C:\\Users\\dipak.bachhav\\AppData\\Local\\Programs\\Git\\cmd;C:\\Users\\dipak.bachhav\\AppData\\Local\\Programs\\Python\\Python310;C:\\Users\\dipak.bachhav\\AppData\\Local\\Programs\\Python\\Python310\\Scripts;C:\\Tools\\nodejs;;C:\\Users\\dipak.bachhav\\AppData\\Local\\Programs\\Microsoft VS Code\\bin', PATHEXT: '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC', PROCESSOR_ARCHITECTURE: 'AMD64', PROCESSOR_IDENTIFIER: 'Intel64 Family 6 Model 78 Stepping 3, GenuineIntel', PROCESSOR_LEVEL: '6', PROCESSOR_REVISION: '4e03', ProgramData: 'C:\\ProgramData', ProgramFiles: 'C:\\Program Files', 'ProgramFiles(x86)': 'C:\\Program Files (x86)', ProgramW6432: 'C:\\Program Files', PROJECT_BASE_DIR: 'C:\\Users\\dipak.bachhav\\AppData\\Local\\Cypress\\Cache\\12.0.1\\Cypress\\resources\\app', PROMPT: '$P$G', PSModulePath: 'C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules', PUBLIC: 'C:\\Users\\Public', SESSIONNAME: 'Console', snow_agent: 'C:\\Program Files\\Snow Software\\Inventory\\Agent', SystemDrive: 'C:', SystemRoot: 'C:\\WINDOWS', TEMP: 'C:\\Users\\DIPAK~1.BAC\\AppData\\Local\\Temp', TMP: 'C:\\Users\\DIPAK~1.BAC\\AppData\\Local\\Temp', USERDNSDOMAIN: 'ad.Specsavers.com', USERDOMAIN: 'ROOT', USERDOMAIN_ROAMINGPROFILE: 'ROOT', USERNAME: 'dipak.bachhav', USERPROFILE: 'C:\\Users\\dipak.bachhav', UV_THREADPOOL_SIZE: '128', windir: 'C:\\WINDOWS' } } +2ms
  cypress:network:connect received error on connect, retrying { iteration: 0, delay: 100, err: Error: connect ECONNREFUSED 127.0.0.1:58175     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 58175 } } +20s
  cypress:network:connect received error on connect, retrying { iteration: 1, delay: 100, err: Error: connect ECONNREFUSED 127.0.0.1:58175     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 58175 } } +103ms
  cypress:network:connect received error on connect, retrying { iteration: 2, delay: 100, err: Error: connect ECONNREFUSED 127.0.0.1:58175     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 58175 } } +108ms
  cypress:network:connect received error on connect, retrying { iteration: 3, delay: 100, err: Error: connect ECONNREFUSED 127.0.0.1:58175     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 58175 } } +116ms
  cypress:network:connect received error on connect, retrying { iteration: 4, delay: 100, err: Error: connect ECONNREFUSED 127.0.0.1:58175     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 58175 } } +112ms
  cypress:network:connect received error on connect, retrying { iteration: 5, delay: 100, err: Error: connect ECONNREFUSED 127.0.0.1:58175     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 58175 } } +132ms
  cypress:network:connect received error on connect, retrying { iteration: 6, delay: 100, err: Error: connect ECONNREFUSED 127.0.0.1:58175     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 58175 } } +135ms
  cypress:network:connect received error on connect, retrying { iteration: 7, delay: 100, err: Error: connect ECONNREFUSED 127.0.0.1:58175     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 58175 } } +125ms
  cypress:network:connect received error on connect, retrying { iteration: 8, delay: 100, err: Error: connect ECONNREFUSED 127.0.0.1:58175     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 58175 } } +113ms
  cypress:network:connect received error on connect, retrying { iteration: 9, delay: 100, err: Error: connect ECONNREFUSED 127.0.0.1:58175     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 58175 } } +113ms
  cypress:network:connect received error on connect, retrying { iteration: 10, delay: 500, err: Error: connect ECONNREFUSED 127.0.0.1:58175     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 58175 } } +112ms
  cypress:network:connect received error on connect, retrying { iteration: 11, delay: 500, err: Error: connect ECONNREFUSED 127.0.0.1:58175     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -4078, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 58175 } } +551ms
  cypress:launcher:browsers chrome stderr: DevTools listening on ws://127.0.0.1:58175/devtools/browser/7e36c6be-5f03-448f-b778-3bb16a60f1c9 +2s
  cypress:network:connect successfully connected { opts: { host: '127.0.0.1', port: 58175, getDelayMsForRetry: [Function: getDelayMsForRetry] }, iteration: 12 } +516ms
  cypress:server:browsers:cri-client connecting { target: 'ws://127.0.0.1:58175/devtools/browser/7e36c6be-5f03-448f-b778-3bb16a60f1c9' } +0ms
  cypress:server:browsers:browser-cri-client Attaching to target url about:blank +0ms
  cypress:server:browsers:cri-client connecting { target: '8FF8DFB3A6DAD300EF9853759F387E8B' } +150ms
  cypress:server:browsers:cri-client registering CDP on event { eventName: 'Inspector.targetCrashed' } +13ms
  cypress:server:browsers:chrome attaching listeners to chrome { url: 'http://localhost:58163/__/', options: { browser: { name: 'chrome', family: 'chromium', channel: 'stable', displayName: 'Chrome', version: '108.0.5359.98', path: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', minSupportedVersion: 64, majorVersion: '108', isHeaded: true, isHeadless: false }, url: 'http://localhost:58163/__/', browsers: [ [Object], [Object], [Object] ], userAgent: null, proxyUrl: 'http://localhost:58163', proxyServer: 'http://localhost:58163', socketIoRoute: '/__socket', chromeWebSecurity: true, isTextTerminal: false, downloadsFolder: 'C:\\Users\\dipak.bachhav\\CypressFramework\\cypress\\downloads', experimentalModifyObstructiveThirdPartyCode: false, experimentalWebKitSupport: false, onBrowserClose: [Function (anonymous)], onError: [Function: onError], relaunchBrowser: [AsyncFunction (anonymous)], onBrowserOpen: [Function: onBrowserOpen] } } +3s
  cypress:server:browsers:cri-client registering CDP on event { eventName: 'Network.requestWillBeSent' } +1ms
  cypress:server:browsers:cri-client registering CDP on event { eventName: 'Network.responseReceived' } +1ms
  cypress:launcher:browsers chrome stderr: [9984:11536:1208/135124.795:ERROR:scoped_file_writer.cc(16)] Could not open pak file for writing: The process cannot access the file because it is being used by another process. (0x20) +828ms
  cypress:server:browsers:cri-client registering CDP on event { eventName: 'Page.downloadWillBegin' } +441ms
  cypress:server:browsers:cri-client registering CDP on event { eventName: 'Page.downloadProgress' } +0ms
  cypress:server:browsers:chrome received CRI client +450ms
  cypress:server:browsers:chrome navigating to page http://localhost:58163/__/ +0ms
  cypress:server:browsers:cri-client registering CDP on event { eventName: 'Fetch.requestPaused' } +572ms
  cypress:server:browsers:chrome listen for frame tree changes +565ms
  cypress:server:browsers:cri-client registering CDP on event { eventName: 'Page.frameAttached' } +1ms
  cypress:server:browsers:cri-client registering CDP on event { eventName: 'Page.frameDetached' } +0ms
  cypress:server:browsers browser opened +4s
  cypress:launcher:browsers chrome stderr: [9984:9040:1208/135128.366:ERROR:device_event_log_impl.cc(215)] [13:51:28.372] USB: usb_device_handle_win.cc:1045 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F) +4s
  cypress:launcher:browsers chrome stderr: [9984:9040:1208/135128.377:ERROR:device_event_log_impl.cc(215)] [13:51:28.377] USB: usb_device_handle_win.cc:1045 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[9984:9040:1208/135128.377:ERROR:device_event_log_impl.cc(215)] [13:51:28.377] USB: usb_device_handle_win.cc:1045 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F) +5ms
  cypress:server:util:process_profiler current & mean memory and CPU usage by process group:
  cypress:server:util:process_profiler ┌─────────┬───────────┬──────────────┬─────────────────────────────────────────────────────────┬────────────┬────────────────┬──────────┬──────────────┬─────────────┐
  cypress:server:util:process_profiler │ (index) │   group   │ processCount │                          pids                           │ cpuPercent │ meanCpuPercent │ memRssMb │ meanMemRssMb │ maxMemRssMb │
  cypress:server:util:process_profiler ├─────────┼───────────┼──────────────┼─────────────────────────────────────────────────────────┼────────────┼────────────────┼──────────┼──────────────┼─────────────┤
  cypress:server:util:process_profiler │    0    │ 'Chrome'  │      8       │ '9984, 8772, 6004, 13368, 9076, 15556 ... 2 more items' │    0.07    │      0.07      │  372.75  │    372.75    │   372.75    │
  cypress:server:util:process_profiler │    1    │ 'cypress' │      1       │                         '8648'                          │    3.31    │      6.86      │  330.57  │    296.42    │   330.57    │
  cypress:server:util:process_profiler │    2    │  'other'  │      6       │        '6688, 17712, 10992, 13048, 3460, 17504'         │    3.48    │      2.96      │  241.91  │    206.43    │   262.01    │
  cypress:server:util:process_profiler │    3    │ 'plugin'  │      2       │                      '9872, 10916'                      │     0      │      0.16      │  80.52   │     79.6     │    80.52    │
  cypress:server:util:process_profiler │    4    │  'TOTAL'  │      17      │                           '-'                           │    6.86    │      9.96      │ 1025.75  │    655.74    │   1025.75   │
  cypress:server:util:process_profiler └─────────┴───────────┴──────────────┴─────────────────────────────────────────────────────────┴────────────┴────────────────┴──────────┴──────────────┴─────────────┘ +11s
  cypress:server:util:process_profiler current & mean memory and CPU usage by process group:
  cypress:server:util:process_profiler ┌─────────┬───────────┬──────────────┬─────────────────────────────────────────────────────────┬────────────┬────────────────┬──────────┬──────────────┬─────────────┐
  cypress:server:util:process_profiler │ (index) │   group   │ processCount │                          pids                           │ cpuPercent │ meanCpuPercent │ memRssMb │ meanMemRssMb │ maxMemRssMb │
  cypress:server:util:process_profiler ├─────────┼───────────┼──────────────┼─────────────────────────────────────────────────────────┼────────────┼────────────────┼──────────┼──────────────┼─────────────┤
  cypress:server:util:process_profiler │    0    │ 'Chrome'  │      8       │ '9984, 8772, 6004, 13368, 9076, 15556 ... 2 more items' │    4.68    │      2.37      │  384.62  │    378.68    │   384.62    │
  cypress:server:util:process_profiler │    1    │ 'cypress' │      1       │                         '8648'                          │    1.56    │      5.8       │  325.21  │    302.18    │   330.57    │
  cypress:server:util:process_profiler │    2    │  'other'  │      6       │         '6688, 17712, 10992, 1488, 16900, 2224'         │    0.82    │      2.53      │  209.05  │    206.95    │   262.01    │
  cypress:server:util:process_profiler │    3    │ 'plugin'  │      2       │                      '9872, 10916'                      │     0      │      0.12      │  80.52   │    79.83     │    80.52    │
  cypress:server:util:process_profiler │    4    │  'TOTAL'  │      17      │                           '-'                           │    7.06    │      9.38      │  999.39  │    724.47    │   1025.75   │
  cypress:server:util:process_profiler └─────────┴───────────┴──────────────┴─────────────────────────────────────────────────────────┴────────────┴────────────────┴──────────┴──────────────┴─────────────┘ +11s
  cypress:server:util:process_profiler current & mean memory and CPU usage by process group:
  cypress:server:util:process_profiler ┌─────────┬───────────┬──────────────┬─────────────────────────────────────────────────────────┬────────────┬────────────────┬──────────┬──────────────┬─────────────┐
  cypress:server:util:process_profiler │ (index) │   group   │ processCount │                          pids                           │ cpuPercent │ meanCpuPercent │ memRssMb │ meanMemRssMb │ maxMemRssMb │
  cypress:server:util:process_profiler ├─────────┼───────────┼──────────────┼─────────────────────────────────────────────────────────┼────────────┼────────────────┼──────────┼──────────────┼─────────────┤
  cypress:server:util:process_profiler │    0    │ 'Chrome'  │      7       │ '9984, 8772, 6004, 13368, 9076, 15556 ... 1 more items' │   -0.28    │      1.49      │  364.69  │    374.02    │   384.62    │
  cypress:server:util:process_profiler │    1    │ 'cypress' │      1       │                         '8648'                          │   -0.16    │      4.81      │  313.13  │     304      │   330.57    │
  cypress:server:util:process_profiler │    2    │  'other'  │      6       │         '6688, 17712, 10992, 4500, 9404, 10956'         │     0      │      2.11      │  207.4   │    207.03    │   262.01    │
  cypress:server:util:process_profiler │    3    │ 'plugin'  │      2       │                      '9872, 10916'                      │   -0.07    │      0.08      │  64.07   │    76.68     │    80.52    │
  cypress:server:util:process_profiler │    4    │  'TOTAL'  │      16      │                           '-'                           │    -0.5    │      7.73      │  949.29  │    761.94    │   1025.75   │
  cypress:server:util:process_profiler └─────────┴───────────┴──────────────┴─────────────────────────────────────────────────────────┴────────────┴────────────────┴──────────┴──────────────┴─────────────┘ +11s
  cypress:data-context:sources:GitDataSource Refreshing git data +48s
  cypress:data-context:sources:GitDataSource getting git info for [ 'C:/Users/dipak.bachhav/CypressFramework/cypress/e2e/search.feature' ]: +203ms
  cypress:data-context:sources:GitDataSource executing command: `FOR %x in ("C:\Users\dipak.bachhav\CypressFramework\cypress\e2e\search.feature") DO (git log --max-count=1 --pretty="format:%ci %ar %an|%h|%s" %x)` +0ms
  cypress:data-context:sources:GitDataSource cwd: `C:\Users\dipak.bachhav\CypressFramework` +0ms
  cypress:data-context:sources:GitDataSource On current branch  +337ms
  cypress:server:util:process_profiler current & mean memory and CPU usage by process group:


text:
Q: How to correctly set Fabric-CA with a PostgreSQL-11 database in Ubuntu 18.04.02 Server Edition? Following the indications here: https://hyperledger-fabric-ca.readthedocs.io/en/release-1.4/users-guide.html#configuring-the-database I'm trying to understand how to correctly set Fabric-CA with a PostgreSQL-11 database in Ubuntu 18.04.02 Server Edition.
I created a postgresql-11 db to which I can connect with SSL:
(base) marco@pc:~$ psql --cluster 11/fabmnet -h 127.0.0.1 -d fabmnetdb -U fabmnet_admin
Password for user fabmnet_admin:
psql (11.5 (Ubuntu 11.5-1.pgdg18.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

fabmnetdb=> \l
                                List of databases
   Name    |     Owner     | Encoding | Collate |  Ctype  |   Access privileges
-----------+---------------+----------+---------+---------+-----------------------
 fabmnetdb | fabmnet_admin | UTF8     | C.UTF-8 | C.UTF-8 |
 postgres  | postgres      | UTF8     | C.UTF-8 | C.UTF-8 |
 template0 | postgres      | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
           |               |          |         |         | postgres=CTc/postgres
 template1 | postgres      | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
           |               |          |         |         | postgres=CTc/postgres
(4 rows)

fabmnetdb=>

but when trying to start a fabric-ca-server :
(base) marco@pc:~/fabric/fabric-ca$ fabric-ca-server start -b admin:adminpw
2019/09/23 11:54:20 [INFO] Configuration file location: /home/marco/fabric/fabric-ca/fabric-ca-
server-config.yaml
2019/09/23 11:54:20 [INFO] Starting server in home directory: /home/marco/fabric/fabric-ca
2019/09/23 11:54:20 [INFO] Server Version: 1.4.4
2019/09/23 11:54:20 [INFO] Server Levels: &{Identity:2 Affiliation:1 Certificate:1 Credential:1
 RAInfo:1 Nonce:1}
2019/09/23 11:54:20 [INFO] The CA key and certificate already exist
2019/09/23 11:54:20 [INFO] The key is stored by BCCSP provider 'SW'
2019/09/23 11:54:20 [INFO] The certificate is at: /home/marco/fabric/fabric-ca/ca-cert.pem
2019/09/23 11:54:20 [WARNING] Failed to connect to database 'fabmnetdb'
2019/09/23 11:54:20 [WARNING] Failed to connect to database 'postgres'
2019/09/23 11:54:20 [WARNING] Failed to connect to database 'template1'
2019/09/23 11:54:20 [ERROR] Error occurred initializing database: Failed to connect to Postgres
database. Postgres requires connecting to a specific database, the following databases were
tried: [fabmnetdb postgres template1]. Please create one of these database before continuing
2019/09/23 11:54:20 [INFO] Home directory for default CA: /home/marco/fabric/fabric-ca
2019/09/23 11:54:20 [INFO] Operation Server Listening on 127.0.0.1:9443
2019/09/23 11:54:20 [INFO] Listening on http://0.0.0.0:7054

This is how I set the pg_hba.conf file in the fabmnet postgresql cluster :
(base) marco@pc:~$ sudo -su postgres
(base) postgres@pc:~$ nano /etc/postgresql/11/fabmnet/pg_hba.conf
Unable to create directory /home/marco/.local/share/nano/: Permission denied
It is required for saving/loading search history or cursor positions.

Press Enter to continue

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# Database administrative login by Unix domain socket
local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5

# Allow connections from 10.1.2.0/24 subnet only to fabric_ca_db for fabric_ca_user
hostssl fabmnetdb    fabmnet_admin      10.1.2.0/24             cert

# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5

And this is the db's configuration in (base) marco@pc:~$ nano ./fabric/fabric-ca/fabric-ca-
server-config.yaml :

db:
  type: postgres
  datasource: host=localhost port=5433 user=fabmnet_admin password=pwd dbname=fabmnetdb
sslmode=verify-full

---Update 01---:
Trying again to start fabric-ca-server:
(base) marco@pc:~/fabric/fabric-ca$ fabric-ca-server start -b
admin:adminpw
2019/09/25 20:56:57 [INFO] Configuration file location: /home/marco/fabric
/fabric-ca/fabric-ca-server-config.yaml
2019/09/25 20:56:57 [INFO] Starting server in home directory: /home/marco
/fabric/fabric-ca
2019/09/25 20:56:57 [INFO] Server Version: 1.4.4
2019/09/25 20:56:57 [INFO] Server Levels: &{Identity:2 Affiliation:1
Certificate:1 Credential:1 RAInfo:1 Nonce:1}
2019/09/25 20:56:57 [INFO] The CA key and certificate already exist
2019/09/25 20:56:57 [INFO] The key is stored by BCCSP provider 'SW'
2019/09/25 20:56:57 [INFO] The certificate is at: /home/marco/fabric
/fabric-ca/ca-cert.pem
2019/09/25 20:56:57 [WARNING] Failed to connect to database 'fabmnetdb'
2019/09/25 20:56:57 [WARNING] Failed to connect to database 'postgres'
2019/09/25 20:56:57 [WARNING] Failed to connect to database 'template1'
2019/09/25 20:56:57 [ERROR] Error occurred initializing database: Failed
to connect to Postgres database. Postgres requires connecting to a
specific database, the following databases were tried: [fabmnetdb postgres
 template1]. Please create one of these database before continuing
2019/09/25 20:56:57 [INFO] Home directory for default CA: /home/marco
/fabric/fabric-ca
2019/09/25 20:56:57 [INFO] Operation Server Listening on 127.0.0.1:9443
2019/09/25 20:56:57 [INFO] Listening on http://0.0.0.0:7054

This is the corresponding part in /var/log/postgresql/postgresql-11-fabmnet.log :
2019-09-25 20:51:52.655 CEST [1096] LOG:  listening on IPv6 address "::1",
port 5433
2019-09-25 20:51:52.673 CEST [1096] LOG:  listening on IPv4 address
"127.0.0.1", port 5433
2019-09-25 20:51:52.701 CEST [1096] LOG:  listening on Unix socket
"/var/run/postgresql/.s.PGSQL.5433"
2019-09-25 20:51:52.912 CEST [1171] LOG:  database system was interrupted;
 last known up at 2019-09-25 09:50:30 CEST
2019-09-25 20:51:53.001 CEST [1171] LOG:  database system was not properly
 shut down; automatic recovery in progress
2019-09-25 20:51:53.011 CEST [1171] LOG:  redo starts at 0/1668238
2019-09-25 20:51:53.011 CEST [1171] LOG:  invalid record length at
0/1668318: wanted 24, got 0
2019-09-25 20:51:53.011 CEST [1171] LOG:  redo done at 0/16682E0
2019-09-25 20:51:53.043 CEST [1096] LOG:  database system is ready to
accept connections
2019-09-25 20:51:53.569 CEST [1206] [unknown]@[unknown] LOG:  incomplete
startup packet
2019-09-25 20:56:57.540 CEST [4620] [unknown]@[unknown] LOG:  could not
accept SSL connection: sslv3 alert bad certificate
2019-09-25 20:56:57.543 CEST [4622] [unknown]@[unknown] LOG:  could not
accept SSL connection: sslv3 alert bad certificate
2019-09-25 20:56:57.544 CEST [4623] [unknown]@[unknown] LOG:  could not
accept SSL connection: sslv3 alert bad certificate

--- Update 02 ---
Affer removing the previous cert and key files,  I started again the fabric-ca server discovering that new cert and key files were created:
(base) marco@pc:~/fabric/fabric-ca$ fabric-ca-server start -b
admin:adminpw
2019/09/26 11:56:18 [INFO] Configuration file location: /home/marco
/fabric/fabric-ca/fabric-ca-server-config.yaml
2019/09/26 11:56:18 [INFO] Starting server in home directory:
/home/marco/fabric/fabric-ca
2019/09/26 11:56:18 [INFO] Server Version: 1.4.4
2019/09/26 11:56:18 [INFO] Server Levels: &{Identity:2 Affiliation:1
Certificate:1 Credential:1 RAInfo:1 Nonce:1}
2019/09/26 11:56:18 [WARNING] &{69 The specified CA certificate file
/home/marco/fabric/fabric-ca/ca-cert.pem does not exist}
2019/09/26 11:56:18 [INFO] generating key: &{A:ecdsa S:256}
2019/09/26 11:56:18 [INFO] encoded CSR
2019/09/26 11:56:18 [INFO] signed certificate with serial number
542755587310273579559145444277178107021548224556
2019/09/26 11:56:18 [INFO] The CA key and certificate were generated for
CA
2019/09/26 11:56:18 [INFO] The key was stored by BCCSP provider 'SW'
2019/09/26 11:56:18 [INFO] The certificate is at: /home/marco/fabric
/fabric-ca/ca-cert.pem
2019/09/26 11:56:18 [WARNING] Failed to connect to database 'fabmnetdb'
2019/09/26 11:56:18 [WARNING] Failed to connect to database 'postgres'
2019/09/26 11:56:18 [WARNING] Failed to connect to database 'template1'
2019/09/26 11:56:18 [ERROR] Error occurred initializing database: Failed
to connect to Postgres database. Postgres requires connecting to a
specific database, the following databases were tried: [fabmnetdb
postgres template1]. Please create one of these database before
continuing
2019/09/26 11:56:18 [INFO] Home directory for default CA: /home/marco
/fabric/fabric-ca
2019/09/26 11:56:18 [INFO] Operation Server Listening on 127.0.0.1:9443
2019/09/26 11:56:18 [INFO] Listening on http://0.0.0.0:7054
but, again, the corresponding log says "bad certificate" :
2019-09-26 11:55:04.514 CEST [4837] [unknown]@[unknown] LOG:  could not
accept SSL connection: sslv3 alert bad certificate
2019-09-26 11:55:04.517 CEST [4839] [unknown]@[unknown] LOG:  could not
accept SSL connection: sslv3 alert bad certificate
2019-09-26 11:55:04.518 CEST [4840] [unknown]@[unknown] LOG:  could not
accept SSL connection: sslv3 alert bad certificate
2019-09-26 11:56:18.967 CEST [4862] [unknown]@[unknown] LOG:  could not
accept SSL connection: sslv3 alert bad certificate
2019-09-26 11:56:18.969 CEST [4865] [unknown]@[unknown] LOG:  could not
accept SSL connection: sslv3 alert bad certificate
2019-09-26 11:56:18.971 CEST [4866] [unknown]@[unknown] LOG:  could not
accept SSL connection: sslv3 alert bad certificate

So..how could it be "bad certificate" if it's just been created brand new by the execution of fabric-ca-server start?
--- Update 03 ---
I initialized again fabric-ca-server in order to check if it creates the .key file as well:
(base) marco@pc:~/fabric/fabric-ca$ fabric-ca-server init -b
admin:adminpw
2019/09/26 14:52:52 [INFO] Configuration file location: /home/marco
/fabric/fabric-ca/fabric-ca-server-config.yaml
2019/09/26 14:52:52 [INFO] Server Version: 1.4.4
2019/09/26 14:52:52 [INFO] Server Levels: &{Identity:2 Affiliation:1
Certificate:1 Credential:1 RAInfo:1 Nonce:1}
2019/09/26 14:52:52 [WARNING] &{69 The specified CA certificate file
/home/marco/fabric/fabric-ca/ca-cert.pem does not exist}
2019/09/26 14:52:52 [INFO] generating key: &{A:ecdsa S:256}
2019/09/26 14:52:52 [INFO] encoded CSR
2019/09/26 14:52:52 [INFO] signed certificate with serial number
632719069251912632400042774311489818382937855511
2019/09/26 14:52:52 [INFO] The CA key and certificate were generated for
CA
2019/09/26 14:52:52 [INFO] The key was stored by BCCSP provider 'SW'
2019/09/26 14:52:52 [INFO] The certificate is at: /home/marco
/fabricfabric-ca/ca-cert.pem
2019/09/26 14:52:52 [WARNING] Failed to connect to database 'fabmnetdb'
2019/09/26 14:52:52 [WARNING] Failed to connect to database 'postgres'
2019/09/26 14:52:52 [WARNING] Failed to connect to database 'template1'
2019/09/26 14:52:52 [ERROR] Error occurred initializing database: Failed
 to connect to Postgres database. Postgres requires connecting to a
specific database, the following databases were tried: [fabmnetdb
postgres template1]. Please create one of these database before
continuing
2019/09/26 14:52:52 [INFO] Home directory for default CA: /home/marco
/fabric/fabric-ca
2019/09/26 14:52:52 [INFO] Initialization was successful

I then modified /etc/postgresql/11/fabmnet/postgresql.conf accordingly:
ssl = on
ssl_cert_file = '/home/marco/fabric/fabric-ca/ca-cert.pem'
ssl_key_file = '/home/marco/fabric/fabric-ca/msp/keystore
/a486a5dbb2f9b44bfac55203dd3268be760b22eff1c6f451fdf93d6394e3da30_sk'

But again, after restarting postgresql, executing the start of fabric-ca-server gives error again:
(base) marco@pc:~/fabric/fabric-ca$ fabric-ca-server start -b
admin:adminpw
2019/09/26 15:05:06 [INFO] Configuration file location: /home/marco
/fabric/fabric-ca/fabric-ca-server-config.yaml
2019/09/26 15:05:06 [INFO] Starting server in home directory:
/home/marco/fabric/fabric-ca
2019/09/26 15:05:06 [INFO] Server Version: 1.4.4
2019/09/26 15:05:06 [INFO] Server Levels: &{Identity:2 Affiliation:1
Certificate:1 Credential:1 RAInfo:1 Nonce:1}
2019/09/26 15:05:06 [INFO] The CA key and certificate already exist
2019/09/26 15:05:06 [INFO] The key is stored by BCCSP provider 'SW'
2019/09/26 15:05:06 [INFO] The certificate is at: /home/marco/fabric
/fabric-ca/ca-cert.pem
2019/09/26 15:05:06 [WARNING] Failed to connect to database 'fabmnetdb'
2019/09/26 15:05:06 [WARNING] Failed to connect to database 'postgres'
2019/09/26 15:05:06 [WARNING] Failed to connect to database 'template1'
2019/09/26 15:05:06 [ERROR] Error occurred initializing database: Failed
to connect to Postgres database. Postgres requires connecting to a
specific database, the following databases were tried: [fabmnetdb
postgres template1]. Please create one of these database before
continuing
2019/09/26 15:05:06 [INFO] Home directory for default CA: /home/marco
/fabric/fabric-ca
2019/09/26 15:05:06 [INFO] Operation Server Listening on 127.0.0.1:9443
2019/09/26 15:05:06 [INFO] Listening on http://0.0.0.0:7054

--- Update 04 ---
In order to restart from a clean situation and configuration, I removed the previous fabric-ca folder, created a new one, and then initiated the fabric-ca-server. With the default SQLite everything seem working fine. But one I try to use the PostgreSQL-11 db I created before, errors appear:
(base) marco@pc:~/fabric$ rm -rf fabric-ca
(base) marco@pc:~/fabric$ mkdir fabric-ca
(base) marco@pc:~/fabric$ cd fabric-ca/
(base) marco@pc:~/fabric/fabric-ca$ fabric-ca-server init -b
admin:adminpw
(base) marco@pc:~/fabric/fabric-ca$ fabric-ca-server start -b
admin:adminpw
2019/09/26 15:48:54 [INFO] Created default configuration file at
/home/marco/fabric/fabric-ca/fabric-ca-server-config.yaml
2019/09/26 15:48:54 [INFO] Starting server in home directory:
/home/marco/fabric/fabric-ca
2019/09/26 15:48:54 [INFO] Server Version: 1.4.4
2019/09/26 15:48:54 [INFO] Server Levels: &{Identity:2 Affiliation:1
Certificate:1 Credential:1 RAInfo:1 Nonce:1}
2019/09/26 15:48:54 [WARNING] &{69 The specified CA certificate file
/home/marco/fabric/fabric-ca/ca-cert.pem does not exist}
2019/09/26 15:48:54 [INFO] generating key: &{A:ecdsa S:256}
2019/09/26 15:48:54 [INFO] encoded CSR
2019/09/26 15:48:54 [INFO] signed certificate with serial number
162595303982096068338873480987512684820342253664
2019/09/26 15:48:54 [INFO] The CA key and certificate were generated for
CA
2019/09/26 15:48:54 [INFO] The key was stored by BCCSP provider 'SW'
2019/09/26 15:48:54 [INFO] The certificate is at: /home/marco/fabric
/fabric-ca/ca-cert.pem
2019/09/26 15:48:54 [INFO] Initialized sqlite3 database at /home/marco
/fabric/fabric-ca/fabric-ca-server.db
2019/09/26 15:48:54 [INFO] The issuer key was successfully stored. The
public key is at: /home/marco/fabric/fabric-ca/IssuerPublicKey, secret
key is at: /home/marco/fabric/fabric-ca/msp/keystore/IssuerSecretKey
2019/09/26 15:48:54 [INFO] Idemix issuer revocation public and secret
keys were generated for CA ''
2019/09/26 15:48:54 [INFO] The revocation key was successfully stored.
The public key is at: /home/marco/fabric/fabric-
ca/IssuerRevocationPublicKey, private key is at: /home/marco/fabric
/fabric-ca/msp/keystore/IssuerRevocationPrivateKey
2019/09/26 15:48:54 [INFO] Home directory for default CA: /home/marco
/fabric/fabric-ca
2019/09/26 15:48:54 [INFO] Operation Server Listening on 127.0.0.1:9443
2019/09/26 15:48:54 [INFO] Listening on http://0.0.0.0:7054

I set the brand-new fabric-ca-server-config.yaml in this way:
#db:
#  type: sqlite3
#  datasource: fabric-ca-server.db
#  tls:
#      enabled: false
#      certfiles:
#      client:
#        certfile:
#        keyfile:

db:
  type: postgres
  datasource: host=localhost port=5433 user=fabmnet_admin
  password=password dbname=fabmnetdb sslmode=verify-full

and in /etc/postgresql/11/fabmnet/postgresql.conf :
ssl = on
ssl_cert_file = '/home/marco/fabric/fabric-ca/ca-cert.pem'
ssl_key_file = '/home/marco/fabric/fabric-ca/msp/keystore
/IssuerSecretKey'

After systemctl restart postgresql, I tried to start the fabric-ca-server:
(base) marco@pc:~/fabric/fabric-ca$ fabric-ca-server start -b
admin:adminpw
2019/09/26 15:56:50 [INFO] Configuration file location: /home/marco
/fabric/fabric-ca/fabric-ca-server-config.yaml
2019/09/26 15:56:50 [INFO] Starting server in home directory:
/home/marco/fabric/fabric-ca
2019/09/26 15:56:50 [INFO] Server Version: 1.4.4
2019/09/26 15:56:50 [INFO] Server Levels: &{Identity:2 Affiliation:1
Certificate:1 Credential:1 RAInfo:1 Nonce:1}
2019/09/26 15:56:50 [INFO] The CA key and certificate already exist
2019/09/26 15:56:50 [INFO] The key is stored by BCCSP provider 'SW'
2019/09/26 15:56:50 [INFO] The certificate is at: /home/marco/fabric
/fabric-ca/ca-cert.pem
2019/09/26 15:56:50 [WARNING] Failed to connect to database 'fabmnetdb'
2019/09/26 15:56:50 [WARNING] Failed to connect to database 'postgres'
2019/09/26 15:56:50 [WARNING] Failed to connect to database 'template1'
2019/09/26 15:56:50 [ERROR] Error occurred initializing database: Failed
to connect to Postgres database. Postgres requires connecting to a
specific database, the following databases were tried: [fabmnetdb
postgres template1]. Please create one of these database before
continuing
2019/09/26 15:56:50 [INFO] Home directory for default CA: /home/marco
/fabric/fabric-ca
2019/09/26 15:56:50 [INFO] Operation Server Listening on 127.0.0.1:9443
2019/09/26 15:56:50 [INFO] Listening on http://0.0.0.0:7054

Before I also removed all the previous content of /var/log/postgresql/postgresql-11-fabmnet.log to have a clean situation. But strangely now I do not get any new logging information in postgresql-11-fabmnet.log
So. I think there must be something to fix in the interface between fabric-ca-server and PostgreSQL-11 db. In fabric-ca-server-config.yaml, in postgresql.conf, in both or somewhere else.
-- Update 05 ---
Now after fixing configuration in postgresql-11 I can connect with ssh to the database (changed db's name) :
(base) postgres@pc:~$ psql --cluster 11/fabmnet -h localhost -d fabmnet_ca
Password for user postgres:
psql (11.5 (Ubuntu 11.5-1.pgdg18.04+1))
Type "help" for help.

fabmnet_ca=# \conninfo
You are connected to database "fabmnet_ca" as user "postgres" on host
"localhost" at port "5433".
fabmnet_ca=#

But I still cannot connect fabric-ca-server to postgreSQL's db with ssh:
/var/log/postgresql/postgresql-11-fabmnet.log  :
2019-09-27 15:32:59.651 CEST [5080] [unknown]@[unknown] LOG:  could not
accept SSL connection: sslv3 alert bad certificate

This is what I set in fabric-ca-server-config.yaml  :
#db:
#  type: sqlite3
#  datasource: fabric-ca-server.db
#  tls:
#      enabled: false
#      certfiles:
#      client:
#        certfile:
#        keyfile:

db:
  type: postgres
  datasource: host=localhost port=5433 user=postgres password=pwd
  dbname=fabmnet_ca sslmode=verify-full
  tls:
      enabled: false
      certfiles:
      client:
        certfile:
        keyfile:

How to correctly set Fabric-CA in order to make it see and use PostgreSQL-11 database?
Looking forward to your kind help
Marco


text:
Q: AppDelegate is not being called I can't seem to get my appdelegate to be called at all. Using breakpoints it doesn't even seem like the first like is being called.
This is what I have in my main.m
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegatename");
[pool release];
return retVal;
}

A: Let say your AppDelegate is MyAppDelegate, defined in MyAppDelegate.h and MyAppDelegate.m.
Try with this:
#import <UIKit/UIKit.h>
#import "MyAppDelegate.h"

int main(int argc, char *argv[])
{
    @autoreleasepool
    {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([MyAppDelegate class]));
    }
}

EDIT: This is ofcourse ment for ARC-enabled app. In case you are not using ARC you should consider unsing it. If you insist with non-ARC approach then just replace your line:
int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegatename");

with
int retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([MyAppDelegate class]));

In both cases you have to replace MyAppDelegate with the real name of your application delegate class.
EDIT2:
According to your additional commands your main.m should look something like this:
#import <UIKit/UIKit.h>
#import "Radio99AppDelegate.h"

int main(int argc, char *argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([Radio99AppDelegate class]));
    [pool release];
    return retVal;
}

I'm not sure if you are using radio99AppDelegate or Radio99AppDelegate - the last one would be 'standard'. And if this is a new project it would be wise to consider 'translating' it to ARC. Much less hussle with memory management.

A: int retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

A: I was migrating a legacy app to iOS 9.2 and ran into this problem.  In my main method I had to pass the AppDelegate's class name as the principalClassName parameter as well as the delegateClassName parameter of UIApplicationMain.
int main(int argc, char * argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, NSStringFromClass([AppDelegate class]), NSStringFromClass([AppDelegate class]));
    }
}


text:
Q: Kubernetes clusters merge to minimize the clusters This should be the topic of my bachelor thesis. At the moment I am looking for literature or general information, but I can't really find it. Do you have more information on this topic? I want to find out if it makes sense to run dev and test stages on a cluster instead of running each stage on its own.
I also want to find out, if it's a good idea, how I can consolidate the clusters.

A: That's a nice question. It's a huge topic to cover actually, in short Yes and No you can setup a single cluster for all of your environments.
But in general, everyone need to consider various things before merging all the environments into a single cluster. Some of them include, number of services that you are running on k8s, number of engineers you have in hand as Ops to manage and maintain the existing cluster without any issues, location of different teams who use the cluster(If you take latency into consideration).
There are many advantages and disadvantages in merging everything into one.

*

*Advantages include easy to manage and maintain a small cluster, you can spread out your nodes with labels and deploy your applications with dev label on dev node and so on. But this also hits a waste of resources thing, if you are not letting k8s take the decision by restricting the deployment of the pod. People can argue on this topic for hours and hours if we setup a debate.

*Costing of resources, imagine you have a cluster of 3 nodes and 3 masters on prod, similarly a cluster of 2 nodes and 3 masters on dev, a cluster of 2 nodes and 3 masters on test. The costing is huge as you are allocating 9 masters, if your merge dev and test into 1 you will be saving 3 VMs cost.

*K8s is very new to many DevOps engineers in many organisations, and many of us need a region to experiment and figure out things with the latest versions of the softwares before that could be implemented on Prod. This is the biggest thing of all, because downtime is very costly and many cannot afford a downtime no matter what. If everything is in single cluster, it's difficult to debug the problems. One example is upgrading Helm 2.0 to 3.0 as this involves losing of helm data. One need to research and workout.

*As I said, team locations is another thing. Imagine you have a offshore testing team, if you merge dev and test into single cluster. There might be network latency for the testing team to work with the product and as all of us have deadlines. This could be arguable but still one need to consider network latencies.
In short Yes and No, this is very debatable question and we can keep adding pros and cons to the list forever, but it is advisable to have different cluster for each environment until you become some kind of kubernetes guru understanding each and every packet of data inside your cluster.

A: This is already achievable using namespace

https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/

With name space we will be able to isolate.
Merging with different namespace would achieve what your thinking.


text:
Q: How to update rows by Id I'm trying to update a row by its Id using Java mysql and angular js
the problem is that I'm getting false and nothing is changing in the database
Here is my java function :
public boolean modifierClient(int idclient, String nomcomplet, String mail,int numerocompte, String mdp) {
            try
            {
                System.out.println("Edition du client avec le nom complet: " + idclient);
                Connection con = Connexion.getConnection();

             // L'insert avec mysql
                String query = " UPDATE client SET nomcomplet = ?, mail = ?, numerocompte = ?, mdp = ? WHERE idclient = ?";

                PreparedStatement ps = con.prepareStatement(query);
                ps.setInt(1, idclient);
                ps.setString (2, nomcomplet);
                ps.setString (3, mail);
                ps.setInt (4, numerocompte);
                ps.setString (5, mdp);

                ps.executeUpdate();
                if(ps.executeUpdate() > 0) {
                    return true;

                }
                else
                {
                    return false;
                }
            }

            catch (Exception e)
            {
                    System.out.println("Erreur avec modifierClient() -->" + e.getMessage());
                    return false;
            }
        }

Here is my controller function :
    @POST
        @Path("modifierClient/{idclient}/{nomcomplet}/{mail}/{numerocompte}/{mdp}")
        @Produces(MediaType.APPLICATION_JSON)
        @Consumes(MediaType.APPLICATION_JSON)
        public boolean modifierClient(@PathParam("idclient") int idclient, @PathParam("nomcomplet") String nomcomplet, @PathParam("mail") String mail,@PathParam("numerocompte") int numerocompte, @PathParam("mdp") String mdp) {
                 ClientDao dao = new ClientDao();
             return dao.modifierClient(idclient,nomcomplet,mail,numerocompte,mdp);
        }

and my angular js function :
$http.post('rest/client/modifierClient/'+idclient+'/'+$scope.fullname+'/'+$scope.mail+'/'+$scope.numcompte+'/'+$scope.mdp).then(function(data){
                    alert('modified  '+data.data);

                })

I need your help, thank you.

A: You are not using the correct index in your PreparedStatement. See the index used in the below code
String query = " UPDATE client SET nomcomplet = ?, mail = ?, numerocompte = ?, mdp = ? WHERE idclient = ?";

PreparedStatement ps = con.prepareStatement(query);

ps.setString (1, nomcomplet);
ps.setString (2, mail);
ps.setInt (3, numerocompte);
ps.setString (4, mdp);

ps.setInt(5, idclient);

The index value depends of the order you defined in the query.
Note : You should get an exception since you are trying to do idClient = "apassword" but idClient seems to be a numeric. The DB should tell you that you can't compare a varchar with a numeric

A: Change your code as below
 ps.setString (1, nomcomplet);
 ps.setString (2, mail);
 ps.setInt (3, numerocompte);
 ps.setString (4, mdp);
 ps.setInt(5, idclient);

 int rowsAffected = ps.executeUpdate();

 if( rowsAffected  > 0) {
     return true;
 }
 else {
     return false;
 }


text:
Q: how to get a d3.js graph's value at a particular point? I've got a group of graphs (using angular 7 and d3.js v5).
with axis x=> date , y values, it's a curve (basis).
I'd like to be able to enter a date and display at this particular date the value. My problem is , i do not see how to retreive the calculated values for a given date.
Is it possible?
I did not find anything.
I add an image to clarify.

thanks for any help :)

A: There isn't a simple answer that'd work in general case.
In your case however, since you are using basis curve, and your data is in equal intervals, you can use d3 basis interpolator https://github.com/d3/d3-interpolate#interpolateBasis

<!DOCTYPE html>

<head>
  <meta charset="utf-8">
  <script src="https://d3js.org/d3.v4.min.js"></script>
  <style>
    body {
      margin: 0;
      position: fixed;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
    }

    path {
      fill: none;
      stroke: black;
    }

    rect {
      fill: white;
    }
  </style>
</head>

<body>
  <script>
    var points = [{
        x: 0,
        y: 0
      },
      {
        x: 5,
        y: 10
      },
      {
        x: 10,
        y: 20
      },
      {
        x: 15,
        y: 15
      },
      {
        x: 20,
        y: 5
      },
      {
        x: 25,
        y: 10
      },
      {
        x: 30,
        y: 12
      },
      {
        x: 35,
        y: 5
      },
      {
        x: 40,
        y: 20
      },
    ];

    var interp = d3.interpolateBasis(points.map(function(p) {
      return p.y;
    }));
    var scaleX = d3.scaleLinear()
      .domain([0, 40])
      .range([0, 200]);
    var scaleY = d3.scaleLinear()
      .domain([-10, 30])
      .range([200, 0]);
    var lineGen = d3.line()
      .x(function(d) {
        return scaleX(d.x);
      })
      .y(function(d) {
        return scaleY(d.y);
      })
      .curve(d3.curveBasis);

    var svg = d3.select("body").append("svg")
      .attr("width", 200)
      .attr("height", 200);

    svg.append('rect')
      .attr('width', 200)
      .attr('height', 200)
      .on('mousemove', function() {
        var x = d3.event.x;
        var y = interp(x / scaleX(40));
        svg.select('circle')
          .attr('cx', x)
          .attr('cy', scaleY(y));
        svg.select('text')
          .text('x: ' + scaleX.invert(x) + ', y: ' + y);
      })

    svg.append('path')
      .attr('d', lineGen(points));

    svg.append('text')
      .attr('y', 20);

    svg.append('circle')
      .attr('r', 3);
  </script>
</body>

A: What you're looking for is called a bisector, and d3 has built-in functionality for it. You can create a bisect function like this:
const bisectDate = d3.bisector(d=>d.date).right;
Then use it with an inverse of a given x position. Here's the d3 documentation on its bisect methods:
https://github.com/d3/d3-array#bisectLeft
And d3 documentation on inverting scales:
https://github.com/d3/d3-scale#continuous_invert
And a working example of a line chart that bisects the mouse x position to get the value at a given date:
https://bl.ocks.org/alandunning/cfb7dcd7951826b9eacd54f0647f48d3