CardView not showing shadow elevation

Question: I am working with cardviews but the problem is my CardView is not showing any elevation or shadow. I have already tried some of the methods suggested in stackoverflow answers like I have tried using elevation and shadow property. I have also tried using card_view:cardUseCompatPadding="true", but without any success. This is my xml file
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:card_view="http://schemas.android.com/tools"
    android:layout_marginLeft="12dp"
    android:layout_marginRight="12dp"
    android:layout_marginTop="6dp"
    android:layout_marginBottom="6dp"
    app:cardBackgroundColor="#FAFBFD"
    app:cardElevation="5dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

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

            <de.hdodenhof.circleimageview.CircleImageView
                android:id="@+id/post_profile_image"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:src="@mipmap/ic_launcher"
                android:layout_marginLeft="12dp"
                android:layout_marginTop="12dp"/>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/post_profile_image"
                android:layout_marginLeft="12dp"
                android:orientation="vertical"
                android:layout_marginTop="16dp">

                <TextView
                    android:id="@+id/post_username"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Name"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:textColor="#000000"/>

                <TextView
                    android:id="@+id/post_time"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="2dp"
                    android:text="Time"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:textColor="@color/grayColor"/>
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true">

                <ImageButton
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@android:drawable/ic_delete"
                    android:id="@+id/post_delete_btn"
                    android:visibility="invisible"/>

            </LinearLayout>

        </RelativeLayout>

        <ImageView
            android:id="@+id/post_image"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="12dp"
            android:adjustViewBounds="true"
            android:background="#00ffffff"
            android:src="@drawable/add_btn"
            android:visibility="gone"/>

        <TextView
            android:id="@+id/post_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:layout_marginLeft="12dp"
            android:text="Text about Posting...."
            android:textAppearance="?android:attr/textAppearanceMedium"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:layout_marginBottom="8dp">

            <ImageButton
                android:id="@+id/like_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="12dp"
                android:background="#00ffffff"
                android:src="@drawable/grey_like_bt"/>

            <TextView
                android:id="@+id/post_like_count"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="4dp"
                android:layout_marginTop="8dp"
                android:text="0 Likes"
                android:textColor="#2196F3"/>

            <ImageButton
                android:id="@+id/comment_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="32dp"
                android:background="#00ffffff"
                android:src="@drawable/comment_btn_gray"/>

            <TextView
                android:id="@+id/post_comment_count"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="4dp"
                android:layout_marginTop="8dp"
                android:text="0 Comments"
                android:textColor="#2196F3"/>

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <ImageButton
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@android:drawable/ic_menu_edit"
                    android:visibility="invisible"
                    android:id="@+id/post_edit_btn"
                    android:layout_alignParentRight="true"/>

            </RelativeLayout>

        </LinearLayout>

    </LinearLayout>

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

Dont know why it is not showing any elevation and shadow
Comment: where is `cardElevation`?
Comment: I have used elevation but it was not giving any results so I have removed it
Comment: margin and shadow elevation.
Comment: http://stackoverflow.com/questions/35369691/how-to-add-colored-border-on-cardview
Comment: I had the same issue as the OP. I've posted my solution here - https://stackoverflow.com/a/61398321/1617737 - to a similar question.
Answer: Do not forget that to draw shadow you must use hardwareAccelerated drawing
<application android:hardwareAccelerated="true" ...>

see for details
https://developer.android.com/guide/topics/graphics/hardware-accel.html?hl=ru
Answer: <android.support.v7.widget.CardView android:id="@+id/item_card"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:cardCornerRadius="2dp"
    app:cardUseCompatPadding="true"
    app:cardElevation="2dp"
    app:cardBackgroundColor="@color/md_white_1000"
    android:foreground="?android:attr/selectableItemBackground"
    android:clickable="true">

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

app:cardUseCompatPadding="true"  is the main catch here
Comment: I know that `` may cause some troubles, so `app:cardUseCompatPadding="true"` is the best solution, I think.
Comment: But when we use app:cardUseCompatPadding="true", we can not control the exact padding we want right ?  That will give default padding
Answer: If your manifest file has a android:hardwareAccelerated="false" line, delete it.
Answer: Lot of good answers, but sometimes just one doesn't work for all.
here's the one that worked for me after a lot of looking around,
Add this line to your CardView
app:cardUseCompatPadding="true"

So your cardview looks like this
  <androidx.cardview.widget.CardView
      android:id="@+id/cardView"
      android:layout_width="match_parent"
      app:cardUseCompatPadding="true"/>

Hope that works! Happy coding!
Comment: it's work for me.
Answer: use this inside cardView to show shadow:
app:cardElevation="4dp"
app:cardMaxElevation="4dp"

Comment: add app:cardUseCompatPadding="true"
Comment: I have used this Divyesh still not getting elevation in emulator and phone
Comment: This as well Divyesh I have already pointed out this in the question itself
Answer: You forget two things.

First of all, check your project's AndroidManifest.xml file, in the Application tag you have to write

<application android:hardwareAccelerated="true" ...>
instead of
<application android:hardwareAccelerated="false" ...>

Then check the parent tag of your layout file is there written like below line.

if you wanna use app: xmlns. then write :
xmlns:app="http://schemas.android.com/apk/res-auto"
OR
xmlns:card_view="http://schemas.android.com/apk/res-auto"

NOTE:  You don't need to write both simultaneous. Because it gives you duplicate attribute error.
The above line is most important when you use the attributes of res-auto.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardBackgroundColor="@android:color/white"
        app:cardCornerRadius="4dp"
        app:cardElevation="4dp" />

</RelativeLayout>

Answer: You should have to try this:
<android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        app:cardElevation="3dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
        </LinearLayout>

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

Comment: Tried this as well still not getting
Answer: There are two things that helped me solve this problem:

Setting this in the application tag of my manifest:
android:hardwareAccelerated="false"

File > Invalidate cache and restart
Answer: Try this
    <android.support.v7.widget.CardView
            android:id="@+id/driverCurrentJobsCardView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/dim_8"
            android:background="#ffffff"
            app:cardCornerRadius="4dp"
            card_view:cardElevation="4dp"/>

And make sure that you are using this dependency in gradle
compile 'com.android.support:cardview-v7:23.2.1'

Answer: remove below line from AndroidManifest.xml
android:hardwareAccelerated="false"

Answer: Add this line in CardView widget
app:cardElevation="5dp"

hope this will help!
Comment: First remove background of cardview then try this
Answer: <android.support.design.card.MaterialCardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:card_view="http://schemas.android.com/tools"
    app:cardCornerRadius="@dimen/_5sdp"
    card_view:cardCornerRadius="3dp"
    android:layout_margin="@dimen/_3sdp"
    card_view:cardElevation="10dp"
    card_view:cardUseCompatPadding="true">
</android.support.design.card.MaterialCardView>

Use above code and don't forget to use android:hardwareAccelerated="true".
It will work definitely.
Answer: If there is a parent for the Card View, try setting a background color for the parent layout like a color #EDEDED , anything other than white. This will also make a clear difference between card and the background.
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#EDEDED"
    >
 <com.google.android.material.card.MaterialCardView
        android:id="@+id/cardone"
        android:elevation="10dp"
        android:layout_margin="10dp"
       >

android:background="#EDEDED" on the parent layout makes the difference.
And don't use android:elevation="10dp" , use app:cardElevation="10dp"
Comment: instead of `android:elevation="10dp"`  `app:cardElevation="10dp"` gives a better effect
Answer: Try putting this in your rootview:
xmlns:card_view="http://schemas.android.com/apk/res-auto"

and use this code for elevation:
card_view:cardElevation="10dp"

Comment: Well i pasted your xml code and the cardview is showing shadows here. try using ``invalidate cache and restart`` option in android studio maybe that could help !
Answer:      <android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:cardElevation="10dp"
    app:cardCornerRadius="4dp"
    app:cardBackgroundColor="#ffff8800">
     ......
     </android.support.v7.widget.CardView>

Remove the background color first, add the elevation and later add the background again. Worked for me, though I had added the background through the layout designer.
Answer: Apparently, I was using Theme.AppCompat instead of Theme.MaterialComponents in as my AppTheme.

In your layout, use MaterialCardView instead of CardView
<com.google.android.material.card.MaterialCardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:cardCornerRadius="10dp"
    app:cardElevation="10dp">

Answer: Try adding android:outlineProvider="bounds" to the CardView layout.
Answer: <android.support.v7.widget.CardView
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:cardBackgroundColor="@android:color/white"
    android:foreground="?android:attr/selectableItemBackground"
    android:layout_marginLeft="@dimen/activity_horizontal_margin"
    android:layout_marginRight="@dimen/activity_horizontal_margin"
    android:layout_marginTop="@dimen/padding_small"
    android:layout_marginBottom="@dimen/padding_small"
    app:cardCornerRadius="4dp"
    app:cardElevation="4dp" >

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

Comment: Tried this still not getting elevation

CardView not showing shadow elevation


Hoodie postinstall failed: process.env.PWD is undefined

Question: I'm trying to experiment with hoodie, but the npm install isn't working for me.
Windows 10
Node 7.0.0
NPM 3.10.8
npm ERR! email@example.com postinstall: `node ./bin/setup.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the email@example.com postinstall script 'node ./bin/setup.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the hoodie package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./bin/setup.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs hoodie
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls hoodie
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     F:\dev\mrkennedy-ca\countby\npm-debug.log
F:\dev\mrkennedy-ca\countby [gh-pages +0 ~3 -0]> node -v
v7.0.0
F:\dev\mrkennedy-ca\countby [gh-pages +0 ~3 -0]> npm -v
3.10.8

The problem is with the post-install script, specifically, process.env.PWD is undefined, but the script is trying to access it:
> email@example.com postinstall F:\dev\mrkennedy-ca\countby\node_modules\hoodie
> node ./bin/setup.js

F:\dev\mrkennedy-ca\countby\node_modules\hoodie\bin\setup.js:7
var installIntoApp = process.env.PWD.indexOf('node_modules') !== -1
                                ^

TypeError: Cannot read property 'indexOf' of undefined
at Object.<anonymous> (F:\dev\mrkennedy-ca\countby\node_modules\hoodie\bin\setup.js:7:37)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32)
at tryModuleLoad (module.js:449:12)
at Function.Module._load (module.js:441:3)
at Module.runMain (module.js:607:10)
at run (bootstrap_node.js:382:7)
at startup (bootstrap_node.js:137:9)
at bootstrap_node.js:497:3

Advice? THIS install is inside of an existing package, but I get the same result when attempting the install on a fresh package as in the quickstart directions.
Answer: This is caused by a change that was only released a day ago via https://github.com/hoodiehq/hoodie/pull/760. I've created an issue that you can follow to be notified when the problem is resolved: https://github.com/hoodiehq/hoodie/issues/763
for the time being, please try npm install --save firstname.lastname@example.com which installs the previous version.
Comment: The problem should be resolved now via https://github.com/hoodiehq/hoodie/releases/tag/v28.1.3
Comment: Timing is everything, hey? Haha. Thanks.


How do I open 443 port in Ubuntu?

Question: I am currently having some problems at work when having our web under ssl and using the 443 port. I found this website that checks the status of your server. It says that the 443 is closed.
Port 443 is closed on xx.xxx.xx.xxx.

After a while I tried everything and I don't know what I am doing wrong.
netstat shows this:
sudo netstat -anltp | grep LISTEN

tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:995             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN

And
netstat -nap | grep 443
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      27898/nginx
tcp        1      0 127.0.0.1:34371         127.0.0.1:443           CLOSE_WAIT  25998/openssl

It is supposed that nginx is listening on that port, right?
Looks that way, because if I use an openssl client I get:
openssl s_client -connect 127.0.0.1:443
  CONNECTED(00000003)

But when I try to reach my server from the outside using 443 port I get a connection time out.
openssl s_client -connect xx.xx.xx.xx:443
connect: Connection timed out
connect:errno=110

And here the iptable rules
sudo iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https

Chain ufw-after-forward (0 references)
target     prot opt source               destination

Chain ufw-after-input (0 references)
target     prot opt source               destination

Chain ufw-after-logging-forward (0 references)
target     prot opt source               destination

Chain ufw-after-logging-input (0 references)
target     prot opt source               destination

Chain ufw-after-logging-output (0 references)
target     prot opt source               destination

Chain ufw-after-output (0 references)
target     prot opt source               destination

Chain ufw-before-forward (0 references)
target     prot opt source               destination

Chain ufw-before-input (0 references)
target     prot opt source               destination

Chain ufw-before-logging-forward (0 references)
target     prot opt source               destination

Chain ufw-before-logging-input (0 references)
target     prot opt source               destination

Chain ufw-before-logging-output (0 references)
target     prot opt source               destination

Chain ufw-before-output (0 references)
target     prot opt source               destination

Chain ufw-reject-forward (0 references)
target     prot opt source               destination

Chain ufw-reject-input (0 references)
target     prot opt source               destination

Chain ufw-reject-output (0 references)
target     prot opt source               destination

Chain ufw-track-input (0 references)
target     prot opt source               destination

Chain ufw-track-output (0 references)
target     prot opt source               destination

Any suggestion would be appreciated.
Thank you.
UPDATE: I forgot to mention that no firewall is actually running:
ufw status
Status: inactive

Answer: Some checks first:

Is your server behind a firewall? The port may be closed due to firewall configuration
Only the root user can bind to port 433 (and other low ports). Is your server started with the right priviledges? (It is usual to configure it to run under its own user, nevertheless it needs to be started by the root user.)

P.S. Given your edit (nginx is listening to port 443), it looks like a firewall problem. Note that there are two types of firewalls: Internal (running on your server) and external (running on another machine that controls the network access of your server). Your Update only shows that there is no internal firewall.
Comment: I sent by mistake before I finish the previous msg, sorry -.-

I forgot to point out that no firewall is running on that server. And I'll check the priviledges of the server. It runs with www-data I think
Comment: @Jotaeme: No need to apologize. It is always good to improve questions by editing them.
Comment: @Jotaeme, I'm willing to bet there is some firewall between the web site you used to check and your server. Any business that doesn't have its network protected by a firewall is not going to be in business for very long. It is also a strong possibility that you have NAT in there, too. You probably need to open the port on the firewall, and forward it on any NAT.
Comment: @jknappen, we just get that cloudserver and the apps that are running over Nginx in 80 are Ok. I've been looking for firewall but there are not and ufw seems to be disabled.
Answer: If you are using some hosting service like Amazon Web Services that provides a front-end UI, search for the security groups that apply to your running node instance.
In my case I just needed to add 443 exception to the services allowed and that was all.

How do I open 443 port in Ubuntu?


Manage enable - disable nginx site by Hiera puppet?

Question: i got the task to implement hiera puppet script to manage sites_enabled for nginx.
Here is my puppet script:
common.yaml
---
classes:
    - nginx

nginx:
    enabled:
        abc.com
        xyz.com
    disabled:
        test.com
        test2.com

init.pp
class nginx{
    create_resources("site_enabled", hiera("nginx"), {})
}

define site_enabled($name){
    file { '/etc/nginx/sites_enabled/${name}':
       ensure => 'link',
       target => '/etc/nginx/site_available/${name}',
    }
}

But i got the error when puppet executed:

err: Could not retrieve catalog from remote server: Error 400 on
SERVER: can't convert String into Integer at
/etc/puppet/modules/nginx/manifests/init.pp:7 on node XX

When i tried to query hiera via commandline:

$ hiera nginx
{"enabled"=>["abc.com", "xyz.com"]}

I know i have wrong some where. Please kindly correct me.
i don't understand much, how hiera query and process with array data. please point me some useful document if it is possible.
Thanks so much.
Answer: Your questions is very similar to Problems creating Hiera hashes for create_resources, which has an answer. I'll provide a recap here.
According to the documentation for create_resources, the hash must be in the form {title => {parameters} }. You should edit your hiera data to set the parameters. Since there are none, I think it could just look like this:
common.yaml
---
classes:
    - nginx

nginx::enabled:
    abc.com: {}
    xyz.com: {}
nginx::disabled:
    test.com: {}
    test2.com: {}

Next, you need to actually load the right data from hiera. You want to load nginx::enabled, not all of nginx
init.pp
class nginx{
    create_resources("site_enabled", hiera("nginx::enabled"))
}

define site_enabled($name){
    file { '/etc/nginx/sites_enabled/${name}':
       ensure => 'link',
       target => '/etc/nginx/site_available/${name}',
    }
}

Comment: Thanks for quick respond, i tried as your suggestion but i did not make it worked. i got the error "err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find data item nginx::enabled in any Hiera data file and no default supplied at /etc/puppet/module". When i queried by command line: "hiera nginx
{"enabled"=>{"abc.com"=>{}, "xyz.com"=>{}}, "disabled"=>{"test.com"=>{}, "test2.com"=>{}}}.
hiera nginx::enabled
nil
" i use puppet 2.7.11
Comment: Sorry, I made an error in the yaml, it should be corrected now.
Answer: Thanks Sciunus for your quick respond.
May i ask for this question?
i would like to make my yaml data following this kind of format:

nginx:
enabled:
    abc.com
    xyz.com
disabled:
    test.com
    test2.com

i DO NOT want to make the format like that:

nginx::enabled:
abc.com: {}
xyz.com: {}

nginx::disabled:
test.com: {}
test2.com: {}

How can i make my puppet script worked as expected. i also read Hiera document, as i know, it is also supported three kinds of lookup data: hiera, hiera_hash and hiera_array.
but i could not make it work as my expected following my yaml file format above
Sorry as i am very new with hiera.
Thanks in advanced.


Como bloquear datas retroativas no input datetime?

Question: Tenho um formulário com um input do tipo datetime-local e preciso bloquear a inserção de datas retroativas, como faço isso?
<form name="F1" id="edit-profile" class="form-horizontal" action="" method="post" enctype="multipart/form-data">

    Titulo:
    <input type="text" class="form-space form-control form-margin disable" name="titulo" id="titulo" required="" value="">
    Subtitulo:
    <input type="text" class="form-space form-control form-margin" id="subtit" value="" name="subtit" required="">
    Caso deseja agendar, insira uma data e hora:
    <input type="datetime-local" class="form-space form-control form-margin" id="agend" value="" name="agend">
    <input type="submit" name="cadastro" value="Enviar" class="btn-post btn">

</form>

Comment: Você quer bloquear datas a partir de um mês, de um dia em específico, ou de datas anteriores a de hoje? Explique melhor o que você deseja fazer.
Answer: Segundo a documentação, um input type="datetime-local" possui o atributo min, que indica o valor mínimo a ser aceito. Ou seja, datas anteriores ao valor indicado no atributo min não serão aceitas.
Então a princípio bastaria setá-lo com o valor desejado. A documentação diz que a data e hora devem estar no formato "YYYY-MM-DDThh:mm" (que é o formato definido pela norma ISO 8601). Mas como você quer que o valor mínimo seja a data atual, o jeito seria alterá-la usando JavaScript. E é aí que começam os problemas...

A princípio, bastaria fazer new Date().toISOString().slice(0, 16) para obter a data e hora atual no formato que o atributo min espera. Mas há alguns poréns.
O método toISOString retorna os valores de data e hora em UTC. Mas campos input do tipo datetime-local (e também seus atributos, como o min) usam o timezone do browser (que não necessariamente será o mesmo que UTC), e isso pode causar alguns problemas meio chatos.
Por exemplo, meu browser está configurado com o Horário de Brasília. Ao rodar o código abaixo, se eu preencher a data e hora atual, não será aceito:

// ATENÇÃO: toISOString() não é a melhor opção, veja explicação abaixo
var hoje = new Date().toISOString().slice(0, 16);

// DOMContentLoaded: assim que carregar a página
document.addEventListener('DOMContentLoaded', function() {
    var campo = document.querySelector('#agend');

    // seta a data mínima para o campo
    campo.min = hoje;

    // mostra mensagem de erro customizada (caso não queira a mensagem padrão do browser)
    campo.addEventListener('invalid', function(e) {
        e.target.setCustomValidity(`A data não pode ser anterior a ${hoje}`);
    });
    campo.addEventListener('input', function(e) {
        e.target.setCustomValidity('');
        e.target.checkValidity();
    });
});
<form>
    <input type="datetime-local" id="agend" value="">
    <input type="submit" value="Enviar">
</form>

Isso porque new Date().toISOString() gera uma string levando-se em conta a data e hora em UTC. Por exemplo, testei o código hoje (29/08/2022), às 11h no Horário de Brasília. Porém, toISOString() retorna 2022-08-29T14:00:00.000Z (repare que a hora é 14h, pois 11h no Horário de Brasília corresponde a 14h em UTC). Ou seja, o resultado de new Date().toISOString().slice(0, 16) é 2022-08-29T14:00.
Mas como o campo datetime-local (e também o atributo min) trabalha no timezone do browser, ele acha que o menor valor aceito para o campo deve ser 29/08/2022, às 14h no Horário de Brasília. Então se eu selecionar a data de hoje, e um horário entre 11h e 13h59 (que em tese seriam válidos), ele não aceita.
Isso porque ao fazer o slice na saída de toISOString, eu deliberada e erroneamente eliminei a informação de que aquela data e hora estão em UTC (pois é isso que o "Z" no final indica). Como eu misturei valores em UTC (a saída de toISOString) com valores no timezone do browser (o valor do atributo min, além do próprio input), ocorrem essas discrepâncias.
O mais garantido seria setar o valor do atributo min nos valores que correspondam ao timezone do browser, em vez de UTC. Infelizmente não tem uma forma direta de, ao mesmo tempo, obter a data/hora no mesmo fuso do browser e no formato ISO 8601. O jeito é fazê-lo manualmente:

function pad(valor) {
    return valor.toString().padStart(2, '0');
}

function formata(data) {
    return data.getFullYear() + '-' + pad(data.getMonth() + 1) + '-' + pad(data.getDate())
           + 'T' + pad(data.getHours()) + ':' + pad(data.getMinutes());
}

var hoje = formata(new Date());

// DOMContentLoaded: assim que carregar a página
document.addEventListener('DOMContentLoaded', function() {
    var campo = document.querySelector('#agend');
    // seta a data mínima para o campo
    campo.min = hoje;

    // mostra mensagem de erro customizada (caso não queira a mensagem padrão do browser)
    campo.addEventListener('invalid', function(e) {
        e.target.setCustomValidity(`A data não pode ser anterior a ${hoje}`);
    });
    campo.addEventListener('input', function(e) {
        e.target.setCustomValidity('');
        e.target.checkValidity();
    });
});
<form>
    <input type="datetime-local" id="agend" value="">
    <input type="submit" value="Enviar">
</form>
Answer: Tente fazer desta forma.
Obs.: Não valida as horas, apenas o dia.

$("#edit-profile").submit(function(e) {

  var agendamento = $("#agend").val().split('T');
  agendamento = new Date(agendamento[0]).setHours(24);
  var hoje = new Date();
  if (agendamento <= hoje) {
    alert('Por favor, insira uma data válida!');
    e.preventDefault();
  }
});

<form name="F1" id="edit-profile" class="form-horizontal" action="" method="post" enctype="multipart/form-data">

    Titulo:
    <input type="text" class="form-space form-control form-margin disable" name="titulo" id="titulo" required="" value="">
    Subtitulo:
    <input type="text" class="form-space form-control form-margin" id="subtit" value="" name="subtit" required="">
    Caso deseja agendar, insira uma data e hora:
    <input type="datetime-local" class="form-space form-control form-margin" id="agend" value="" name="agend">
    <input type="submit" name="cadastro" value="Enviar" class="btn-post btn">

</form>
Answer: Você pode usar código em php, fica mais curto:
Codigo PHP:
date_default_timezone_set('America/Sao_Paulo');
$datahoje = date('Y-m-d', time());

Código HTML:
<form>
    <input  min="<?php echo $datahoje; ?>" type="date" id="agend" value="">
    <input type="submit" value="Enviar">
</form>

Answer:

var campo = document.querySelector('#agend');
// ATENÇÃO: toISOString() não é a melhor opção, veja explicação abaixo
var hoje = new Date().toISOString().slice(0, 16);

// DOMContentLoaded: assim que carregar a página
document.addEventListener('DOMContentLoaded', function() {
    // seta a data mínima para o campo
    campo.min = hoje;
});

// mostra mensagem de erro customizada (caso não queira a mensagem padrão do browser)
campo.addEventListener('invalid', function(e) {
    e.target.setCustomValidity(`A data não pode ser anterior a ${hoje}`);
});
campo.addEventListener('input', function(e) {
    e.target.setCustomValidity('');
    e.target.checkValidity();
});
<form>
    <input type="datetime-local" id="agend" value="">
    <input type="submit" value="Enviar">
</form>


unable to execute js from the java code of a android phonegap plugin

Question: i've written a plugin for android which when called from the js of my app, calls a particular js function of my app with a parameter.
So in the java code for my plugin, its like
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
super.loadUrl("alert('voila');");

but this js (alert) is not neing executed. i get an error saying
java.net.SocketException: Address family not supported by protocol.

after  it times out. The rest of the app works fine. What could be wrong so that its timing out and not working?
Answer: A JavaScript statement is not a url. It needs to be prefixed with javascript: like :
super.loadUrl("javascript:alert('voila');");

Comment: is there any other way to execute js in a android code, apart from this ?
Comment: There are several other ways. See the web apps section on the Android developer site at http://developer.android.com/guide/webapps/index.html. Or even easier, use PhoneGap. There are several getting started tutorials for PhoneGap, like http://phonegap.com/start#android or ours at http://www.mobiledevelopersolutions.com/home/start


How do I bring an MS Outlook 2007 dialog to the front from MS Access 2007?

Question: I am attempting to allow a user of a MS Access 2007 database to select another user from the MS Outlook GAL. I currently have working code that opens the Outlook Select Names Dialog, but it hides behind the database window until a user clicks on Outlook.
How do I make the dialog visible to the user in VBA?
Here's my code for the dialog (typos are a result of a manual copy--this code is on an airgapped network):
set OLApp = CreateObject("Outlook.Application")
set OLDialog = OLApp.Session.GetSelectNamesDialog
with OLDialog
    .SetDefaultDisplayMode olDefaultSingleName
    if .Display then
        if OLDialog.Recipients.Count then
            theUser = OLDialog.Recipients.Item(1)
        end if
    end if
end with

Answer: I made this work by adding the following line after .SetDefaultDisplayMode olDefaultSingleName:
OLApp.ActiveWindow.Activate

Answer: Thanks alot Randall! I've also found that if Outlook isn't actually opened that won't work because ActiveWindow will be null, so wrapping it up like this helps too:
If Not (oApp.ActiveWindow Is Nothing) Then  'only if there's a window
            oApp.ActiveWindow.Activate  'make sure outlook comes to foreground first
End If

Comment: Would that not mean the dialog will be hidden?


What are inner and outer voices in music of late 20th century and 21st century?

Question: In many textbooks voices are classified as inner and outer. Outer voices are the highest voice (soprano) and the lowest voice (bass), and the inner voices are all the other voices that are between the two outer voices. This classification is very important because the rules of counterpoint, voice-leading, harmony and other disciplines are very different for those two kinds of voices.
The rules for inner voices are more sparing, easier, simpler: the leading tone in inner voice does not have to be resolved, dissonant intervals are less disturbing in inner voices and so on. Therefore most of the composer's labor comes from the interaction between the outer voices.
In textbooks and other resources determining outer and inner voices is easy because the resources and books usually use piano examples with up to four simultaneous voices. But how do I determine the inner and outer voice in complex real-world music, like orchestral music with dozens of instruments, modern music of 20th and 21st centuries with many guitars, keyboards and ambiguous theory? Are the leading melody and the bass in the modern music the outer voices, or the vocal line and the bass?
Answer:
how do I determine the inner and outer voice in complex real-world music, like orchestral music with dozens of instruments?

For most traditional orchestral works, this will be clear.  The dozens of instruments typically participate in a four-voice texture, or perhaps five or six, through a technique known as "doubling": when everyone is playing at once, for example, the flutes and oboes and first violins are all playing the same notes, perhaps in octaves, but this tends to be the melody.  The cellos and basses and bassoons all play the bass line, almost always in octaves.  Sometimes, cellos or bassoons, especially the first bassoon when the bassoons divide, will move to the tenor part.  These moments are generally obvious.
In later music, innovative orchestration started to move away from four-voice textures.  When the music isn't written in a traditional homophonic or contrapuntal texture, it may be difficult to identify the "outer voices" but that's only to be expected, because the term ceases to have meaning in such a context.
If by "modern music" you mean to include music that can be presented on a lead sheet, that is, a melody with chord symbols, then the melody and the bass line (specified by the chord symbols) are, as you suggest, the outer voices, but the rules of voice leading are not applied strictly in this context, and there often aren't so much inner voices as just, well, chords.
Of course, there is also a lot of modern music that lacks harmony altogether, and even pitch.  You mention "ambiguous theory."  For much music, the question of identifying outer voices is meaningless.  I'm thinking of any unharmonized melody, or of rap, or of pieces using only unpitched percussion such as Steve Reich's Clapping Music.
Answer: When writing chorale-style for 4 equal voices, 'inner' and 'outer' are terms that mean something.   In other styles and textures, not so much!   And that's fine.  Know how to harmonise a hymn tune, Bach-style.  Know how to write a melody plus an accompaniment.  Maybe there will be a strong melodic bass line, maybe a simple 1-5 vamp.  Maybe there will be an internal counter-melody, maybe a rhythmic guitar strum.  No need to beat yourself up looking for 'inner voices' when there aren't any!
Answer: Inner and outer voices don't change because of instrumentation. Outer voices will always be the highest and lowest parts of homophonic music regardless of what instruments are playing those parts. Inner voices will be everything else in between.
The reason for the inner/outer voice distinction is because of the homophonic musical texture. The concept changed a bit over time, basically the "common practice" period, but homophonic texture essentially means melody with chords or melody with bass. A full description can't be given in a short answer, but homophonic music in very broad terms is a background structure of tertian chords decorated with melodic figuration. Stylistically the bass emphasizes chord roots in its lines compared with the more freely moving top part. That is how the bass realizes its important harmony defining role in homophonic music.
It does not matter what musical era you look at, if the music is homophonic, then the outer voices have primary importance. Modernism includes examples of homophonic music. You need to examine each piece of music to determine whether it is homophonic. Actually, you should examine each passage of music to determine the texture. In "classical" style and Modernism texture can change from phrase to phrase and either style may use various textures: monophonic, parallel, contrapuntal, homophonic, etc.
Satie's Gymnopedie and some of Bartok's dances are good examples of Modernism using homophonic texture with bass and melody plus harmonic filler. You can also find example where the texture changes within the piece. Satie's Ogive use monophonic, quasi-parallel, and homophonic texture in combination. Debussy's music is famous for parallel texture, but sometimes has moments of homophonic texture. Girl with the Flaxen Hair is an example. All of those examples I mention are piano music, but the same treatment of texture will apply to instrumental genres. Actually, some of those piano examples are popular enough that they have been orchestrated. The orchestrated versions should offer good models of modernism, fully orchestrated, but with homophonic texture.

...But how do I determine the inner and outer voice in complex real-world music, like orchestral music with dozens of instruments...

Many textbooks provide musical examples that are piano reductions of orchestral music. You should take a similar approach when analyzing orchestral music. Determine whether the music at hand homophonic in the first place, isolate the main melody and bass, be aware those could span over instrumental changes, filter out what is harmonic filler and orchestral coloring. Especially for the melody do not always assume the highest part is the melody. It's very common orchestral filler/coloring to be high registers above the actual melody, and to double parts in a higher octave.
I suggest doing this first with simpler Haydn and Mozart symphonies or divertimentos, even their orchestral dances. In those cases you can usually see easily the winds and horn adding filler/color/doubling while the main melody and bass and most often in the strings. In cases when the winds or brass get the main melody, you might see the strings drop out for a while.
Get comfortable with reading those classical orchestral scores then move on to appropriate modern homophonic orchestral (and perhaps larger chamber ensemble) music. The composer Poulenc may be a good one to check out. He was considered a sort of "Mozart" of modernism and his music will include homophonic type textures. You should see lots of examples of homophonic outer voices at play, and then you could compare it to a score like Stravinsky's The Rites of Spring to see a lot of not homophonic music, just to make clear the difference.


How do I hide the navigation bar in the editor for android studio?

Question: How do I make the bottom navigation bar disappear in the visual XML editor in Android Studio? I already have the AppTheme set to NoActionBar. The navigation bar is very annoying because my phone does not have one so when I place something on the very bottom of my app in the visual editor (https://i.stack.imgur.com/pxP84.png), This happens when I run the app on my phone: https://i.stack.imgur.com/rXxsw.jpg . Someone please help me. I cannot continue my development until this issue is fixed.
I have looked at both of these and they were no help to me.
How to hide navigation bar permanently in android activity?
How to emulate immersive mode in layout editor
Here is the screenshot of the Navigation bar which I want removed:
https://i.stack.imgur.com/0QRRx.jpg
Here is my XML Code for activity_main:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#474747"
    tools:context=".MainActivity">

    <EditText
        android:id="@+id/typeMessage"
        android:layout_width="354dp"
        android:layout_height="61dp"
        android:layout_marginTop="504dp"
        android:background="#595858"
        android:ems="10"
        android:hint="Type..."
        android:inputType="text"
        android:padding="10dp"
        android:textColorHint="#969494"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="60dp"
        android:layout_height="59dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="504dp"
        app:layout_constraintEnd_toEndOf="@+id/typeMessage"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@android:drawable/ic_menu_send" />

    <EditText
        android:id="@+id/messageOutput"
        android:layout_width="354dp"
        android:layout_height="480dp"
        android:background="#595858"
        android:ems="10"
        android:inputType="textMultiLine"
        app:layout_constraintBottom_toTopOf="@+id/typeMessage"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

Here is my code for MainActivity.kt:
import android.support.v7.app.AppCompatActivity
import android.os.Bundle

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }
}

Thank you for your help!
Comment: I think this may be what you're looking for: https://stackoverflow.com/questions/21724420/how-to-hide-navigation-bar-permanently-in-android-activity
Comment: See https://stackoverflow.com/questions/23291890/how-to-emulate-immersive-mode-in-layout-editor
Comment: these two links didnt help.
Answer: It may be too late, but in case you haven't figured it out yet, I think I may have found a solution for you:
Put this in your onCreate()
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

Then add this:
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}

Here's the documentation: https://developer.android.com/training/system-ui/navigation
Comment: Man you are a lifesaver!
Comment: Glad to hear it helped, @EthanAdams - I'd appreciate it if you'd mark the answer as accepted. Thanks!


Analyzing reaction time data by implementing GAMM analyses with non-normal distribution parameters

Question: I have two questions, a conceptual one and a practical one (that are closely related). And just as a note, I'm not super familiar with this level of stats (much more comfortable with simple linear regression and ANOVA), so apologies if there are oversimplifications/obvious conceptual issues at play here.
First: There are clearly issues with using means to analyze reaction time data because RT data are not normally distributed. An appropriate distribution that's frequently referenced is the ex-Gaussian distribution. Because I wanted to implement an analysis using an appropriate distribution without transforming the data I looked into using the GAMLSS package to run the analysis. But then I go back to the literature and what I see is that the ex-Gaussian parameters (mu, sigma, and tau) are being extracted from the gam model and then being used in a GLMM. So the question is: why not just report and interpret the gam model with an ex-Gaussian distribution? Is there anything incorrect about doing so in order to examine these data with a non-normal distribution?
Second: a brief rundown of the study then the questions (sample output is at the end).
Participants completed a simple RT task at two timepoints at two different locations. The RT task has a condition called valence with three levels. Participants are randomized to watch 1 of 2 videos at both timepoints. Participants complete a measure called STAI once.
Variables: location (w/in factor with two levels); valence (w/in factor with three levels); video (between factor with two levels); STAI (continuous variable). Random intercepts are included for individual participants.
There are a few things I don't understand about GAMLSS: 1) The output is  different when I include different estimation parameters (so if I include only mu in the formula e.g. gamlss(formula = RT~location, data=data) it's different from gamlss(RT~location, sigma.fo = ~location, nu.fo = ~location, data=data) Any thoughts on why this is the case? Are fit statistics reliable between these two models? I post an example output with the mu and nu formulas only at the end.
2) This is a continuation of the first part: my understanding of interpreting the parameters is that they each refer to a distinct component (mu refers to mean; sigma to sd; tau to the exponential component of the mean and sd). So if location (which strongly influences RT in every model I try and run except when I included the tau component in the analysis) is significant for tau, but not mu - does this mean that the real explanation for the difference of location on RTs is not global (i.e. average) but somehow explained by the exponential convolution of the mean and sd? How would I explain this?
Below I provide an example output of the model I ran first with all formulas, then only the mu and nu formula (gamlss refers to nu, but it's actually equivalent to tau in the context of the exGAUS distribution, I think?).
Family:  c("exGAUS", "ex-Gaussian")

Call:
gamlss(formula = RT ~ STAI_T_tot + location + video + valence +
    random(subID), sigma.formula = ~STAI_T_tot + location + video +
    valence + random(subID), nu.formula = ~STAI_T_tot + location +
    video + valence + random(subID), family = exGAUS(), data = na.omit(data))

Fitting method: RS()

-------------------------------------------------------------------
Mu link function:  identity
Mu Coefficients:
                Estimate Std. Error t value Pr(>|t|)
(Intercept)    606.19898    2.48220 244.219  < 2e-16 ***
STAI_T_tot      -0.78644    0.05277 -14.905  < 2e-16 ***
location1        1.03000    1.11498   0.924   0.3556
video1           8.08323    1.11894   7.224 5.09e-13 ***
valenceneutral   3.37995    1.35687   2.491   0.0127 *
valencepos       2.82100    1.35826   2.077   0.0378 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

-------------------------------------------------------------------
Sigma link function:  log
Sigma Coefficients:
                 Estimate Std. Error t value Pr(>|t|)
(Intercept)     4.6897578  0.0293722 159.667  < 2e-16 ***
STAI_T_tot     -0.0015505  0.0006102  -2.541  0.01106 *
location1       0.0236655  0.0131948   1.794  0.07289 .
video1          0.0384450  0.0131913   2.914  0.00356 **
valenceneutral  0.0185930  0.0161728   1.150  0.25029
valencepos      0.0255943  0.0161156   1.588  0.11225
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

-------------------------------------------------------------------
Nu link function:  log
Nu Coefficients:
                 Estimate Std. Error t value Pr(>|t|)
(Intercept)     5.6664104  0.0150130 377.432   <2e-16 ***
STAI_T_tot     -0.0030183  0.0003188  -9.467   <2e-16 ***
location1       0.1074412  0.0070122  15.322   <2e-16 ***
video1          0.0640823  0.0070783   9.053   <2e-16 ***
valenceneutral -0.0107050  0.0085951  -1.245    0.213
valencepos     -0.0102235  0.0085242  -1.199    0.230
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

-------------------------------------------------------------------
NOTE: Additive smoothing terms exist in the formulas:
 i) Std. Error for smoothers are for the linear effect only.
ii) Std. Error for the linear terms may not be reliable.
-------------------------------------------------------------------
No. of observations in the fit:  80795
Degrees of Freedom for the fit:  436.9502
      Residual Deg. of Freedom:  80358.05
                      at cycle:  20

Global Deviance:     1115911
            AIC:     1116784
            SBC:     1120848

`Family:  c("exGAUS", "ex-Gaussian")

Call:
gamlss(formula = RT ~ STAI_T_tot + location + video + valence +
    random(subID), nu.formula = ~STAI_T_tot + location + video +
    valence + random(subID), family = exGAUS(), data = na.omit(data))

Fitting method: RS()

-------------------------------------------------------------------
Mu link function:  identity
Mu Coefficients:
                Estimate Std. Error t value Pr(>|t|)
(Intercept)    540.62127    2.58243 209.346  < 2e-16 ***
STAI_T_tot      -0.15510    0.05369  -2.889  0.00387 **
location1       -1.34292    1.17034  -1.147  0.25119
video1         -15.72136    1.17199 -13.414  < 2e-16 ***
valenceneutral   1.37373    1.43494   0.957  0.33840
valencepos       0.60667    1.43042   0.424  0.67148
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

-------------------------------------------------------------------
Sigma link function:  log
Sigma Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.418776   0.006184   714.6   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

-------------------------------------------------------------------
Nu link function:  log
Nu Coefficients:
                 Estimate Std. Error t value Pr(>|t|)
(Intercept)     5.8552886  0.0152149 384.838   <2e-16 ***
STAI_T_tot     -0.0045268  0.0003249 -13.934   <2e-16 ***
location1       0.1100487  0.0071404  15.412   <2e-16 ***
video1          0.0889630  0.0072172  12.327   <2e-16 ***
valenceneutral -0.0034509  0.0087375  -0.395    0.693
valencepos     -0.0029106  0.0086685  -0.336    0.737
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

-------------------------------------------------------------------
NOTE: Additive smoothing terms exist in the formulas:
 i) Std. Error for smoothers are for the linear effect only.
ii) Std. Error for the linear terms may not be reliable.
-------------------------------------------------------------------
No. of observations in the fit:  80795
Degrees of Freedom for the fit:  294.7012
      Residual Deg. of Freedom:  80500.3
                      at cycle:  20

Global Deviance:     1119469
            AIC:     1120059
            SBC:     1122799 `

Answer: There is a paper covering the package, but I'm not sure how much help to you it might be.
Based on my understanding the purpose of GAMLSS is to be able to run different models of distribution parameters in the same global model. This is similar to mixed-effects regression where the model is hierarchical, i.e., that equations for parameters at different levels are fit in one model in order to better model sources of error (e.g., dependency between repeated measures responses). But but GAMLSS you are modeling specific explanatory effects on specific parameters from whatever distribution you have chosen (in your case, the ex-Gaussian).
That works well because in the RT literature using the ex-Gaussian as the model of cognition, there are theoretical reasons to believe that experimental manipulations will affect one or more parameters by not the others (but see Matzke & Wagenmakers, 2009). In your case, one might theorize that, say, valence only affects $\mu$, but not the other parameters (I am just picking at random here). So then you'd specify an equation only for $\mu$ but not the other variables. Everything else would go in the first formula call, as you have done.
If you do not enter an explicit equation for a parameter, the function just fits an "intercept", i.e., an estimate of that parameter without any knowledge of factors or covariates.
[1]: Matzke, D., & Wagenmakers, E.-J. (2009). Psychological interpretation of the ex-Gaussian and shifted Wald parameters: A diffusion model analysis. Psychonomic Bulletin & Review, 16(5), 798–817. http://doi.org/10.3758/PBR.16.5.798
Comment: Also, to put sigma and nu back on the scale of seconds, you must exponentiate the estimate for the intercept, as the link function is log.


AWS - lambda versions to different gateway stages?

Question: Coming from a "classic/standard" development I'm used to have different deployment stages, e.g. staging and production, each one with its application version.
AWS Lambda functions and API Gateway are freaking me out on how to handle versions and releases, and maybe it is because I'm trying to do it in the non correct way it's meant to be on AWS.
Lambda functions can have both versions and aliases while gateways can have stages, so I'm expecting to be able to have an alias pointing to the production version of the function and an alias pointing to the staging version, and have each one being called on the same gateway resource from the two stages, e.g.:

But it seems to be that api gateway stages cannot call different lambda function alias nor versions, the only things I can override in a stage resource are just CloudWatch and throttling settings.
Probably I'm missing something about this aspect of development on AWS, can anyone point me in the right direction?
Just to be clear, I'm approaching AWS development with vscode and aws/sam cli, anything that needs to be done by web interface looks wrong to me, even if I'm aware that there may be technical/logical/business constraints to have it done that way, so I'd prefer answers that involve code generation or cli commands if possible.
Update #1
As @Purefan suggested in his comment, Working with stages for HTTP APIs section of the docs explain how to use stages variables to reference different lambda versions/aliases on each gateway stage, the problem is that I couldn't create my staging function alias pointing it to the latest version from sam cli:
aws lambda create-alias --function-name test-hello-world --name staging --function-version $LATEST

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

aws: error: argument --function-version: expected one argument

I did fallback to creating it from web console, but now seems that any sam deploy from cli overwrite the alias reference (function name + stage variable) in the gateway resource, probably due the missing of this configuration in my local 'template.yaml'.
Comment: have you read https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-stages.html ? "You can use a stage variable in place of a Lambda function name or alias, as shown in the following examples."
Comment: That'd be great, but I've just started with aws sam and my actual level of knowledge about cloudformation templates is below zero, so just give me some time to gain confidence with sam (for work) and probably I'll call you back, but thanks man ;)
Comment: @Purefan thanks, it helped me a bit, but when syncing or deploying from cli the gateway resource integration request is being overwritten, probably due the missing of these configuration in my `template.yaml`, I'll update my question right now.
Comment: @Purefan your comment actually solved my question on "how call two aliases in a gateway stages" since my problem is now shifted to the persistence of this configuration in my local `template.yaml`, so you can write it down as an answer.
Comment: I think maybe SAM templates dont have all the functionality that you need, for comparison cloudformation templates do allow you to define aliases but the closest sam offers is the autopublishalias. Im passionate about cloudformation so if you want to give that a try I'd be willing to help :)
Comment: anytime :) glhf
Answer: Glad it helped :)
To API Gateway a reference to a lambda is a string and we can use variables in that string to point to different. Conveniently, API Gateway supports Stage variables, so you can define a variable in the stage "production" that would point to a lambda version called "production", another stage could have the same variable pointing to another lambda or another lambda version.
More information can be found here


Lasso (or Ridge) vs Bayesian MAP

Question: This is the first time I have posted here. I am looking for some feedback or perspective on this question.
To make it simple, let's just talk about linear models. We know the MLE solution for the $l_1$ loss objective is the same as the Bayesian MAP estimate with a Laplace prior for each parameter. I'll show it here for convenience.
For vector $Y$ with $n$ observations, matrix $X$, parameters $\beta$, and noise $\epsilon$
$$Y = X\beta + \epsilon,$$
the standard lasso parameter estimate is
$$\hat{\beta}_{l_1} = \arg \min_\beta \sum_{i=1}^n (y_i - \beta^Tx_i)^2 + \lambda\sum_{j=1}^p|\beta_j|.$$
We can instead consider the MAP estimate solution
$$\hat{\beta}_{MAP} = \arg \max_\beta \prod_{i=1}^n P(\epsilon_i|\beta)P(\beta),$$
where under mean 0 Normal noise $\epsilon$ and mean 0 Laplace priors for $\beta$ we have
$$\hat{\beta}_{MAP} = \arg \max_\beta \log \left(\prod_{i=1}^n \dfrac{1}{\sigma\sqrt{2\pi}}e^{-\dfrac{(y_i-\beta^Tx_i)^2}{2\sigma^2}}\right) + \log\left(\prod_{j=1}^p\dfrac{1}{2b}e^{-\dfrac{|\beta_j|}{b}}\right)$$
and after simplifying and substituting $\lambda = \dfrac{1}{b}$ we obtain the MAP estimate
$$\hat{\beta}_{MAP} = \arg \min_\beta \sum_{i=1}^n \left(y_i - \beta^Tx_i\right)^2 + \lambda \sum_{j=1}^p |\beta_j| = \hat{\beta}_{l_1}.$$
However, I think there is a subtle nuance that is not captured and was curious if anyone else has insight on this. What I find in practice is that I can typically outperform a Lasso by making insightful variable selections. Essentially, I remove the variables for which I believe a regression will most likely only find high variance parameter estimates. By doing so, I am placing a very informative prior on variables that I eliminate and a very uninformative prior on variables I decide to keep. And this was peculiar to me because I was casually aware of this proof.
I think the main nuance is that $b$, the Laplace variance, is shared by all parameters in this frame work, but when I am selecting things, it is not. I briefly also considered the implications of unquestionably rescaling all $X$ variables to 0 mean and unit variance, but I don't think that impacts the priors on $\beta$ so that they all come from a Laplace with 0 mean and $b$ scale.
However, I did not show it was the case. I am not sure what happens to $\beta_j = \dfrac{\text{Cov}(X_j,Y)}{\text{Cov}(X_j,X_j)}$ when you transform $\tilde{X_j} = \dfrac{X_j - \bar{X_j}}{\sigma_{X_j}}$. Essentially, $\tilde{\beta}_j = \dfrac{\text{Cov}(\tilde{X_j},Y)}{\text{Cov}(\tilde{X_j},\tilde{X_j})} = \dfrac{\sigma_{X_j}\text{Cov}(X_j,Y)}{\text{Cov}(X_j,X_j)} $. Does this rescaling give reasonable grounds to say all $\beta$ come from the same Laplace distribution? If so, why do I still beat out the Lasso? Did I implement the Lasso wrong or cheat?
This is the best explanation I can come up with for why my informative but crude variable selection/Bayesian method outperforms the Lasso even though the Lasso is Bayes-esque. Very curious if anyone else has insights on other things to consider or can show the effects of rescaling $X$ variables. Thanks.
Answer: When you select variables using your "crude" method, this amounts to placing a prior on your coefficients that says that one specific subset of coefficients is (a priori) certainly equal to 0, and the others are (a priori) entirely unknown (i.e. a uniform prior).
So the question is: is this a better prior than the Laplace prior that is implied by a lasso regression? If you have good reason to believe that these coefficients are 0, then the answer is probably yes. The Laplace prior is less informative than the prior you impose in the selection method. It only says "generally, most coefficients are small". It doesn't say which coefficients in particular are small, and it doesn't require them to be exactly 0 either (even if it will push them in that direction).
Imposing a more informative prior will always improve performance (in expectation), if that informative prior is accurate. Basically, any prior knowledge you have, you should use. Using the less specific Laplace prior discards information. Of course, this only works if your prior is accurate. It is not the case that any manual variable selection will beat Laplace. If you discard the wrong variables, Laplace will beat your selection.
As for scaling, this can definitely make a big difference. If one of your independent variables happens to be in very large units, while the others are not, then you can generally expect the coefficient on that variable to be much smaller than the others. Not because it explains less variance, but because of the difference in scale. What you want your Laplace prior to do is shrink to zero those coefficients of variables that explain little variance in the data. To do this, it helps to ensure that all explanatory variables are scaled to have similar variances, so that their coefficients are proportional to how much variance they explain in the data. This allows the Laplace prior to capture the inductive bias that only some variables are necessary to explain the data. Without proper scaling, the Laplace prior becomes basically meaningless, as the relative magnitudes of the coefficients are then essentially arbitrary, and so their distribution has nothing to do with how much variance they explain.
Comment: Scaling variables correctly is necessary but not sufficient to make sure that the Laplace assumption is valid. If the true underlying distribution of the coefficients isn't Laplace in the first place, then the Laplace assumption will still be wrong after scaling. Also (in case you didn't know), note that the variance of the Laplace is (typically) a priori unknown and does need to be tuned (e.g. through cross-validation). I.e. scaling doesn't allow you to enforce a certain variance.
Comment: Thank you for your thoughtful response! Regarding scaling, do you think scaling all variables to similar variances results in making the prior for each $\beta$ coefficient reasonably come from the same LaPlace(0,b) distribution (ie is it necessary to make this Lasso assumption true)? I do believe it is important for reasons you say, but I didn't think it would be sufficient to enforce that LaPlace(0,b) prior assumption for all coefficients

Lasso (or Ridge) vs Bayesian MAP


how does one solve $\lim_{n\to \infty} (\frac{n^{2}-2n+1}{n^{2}-4n+2})^{n}$

Question: I cant use lhopital's rule here is my attempt:
Limit of $(\frac{n^{2}-2n+1}{n^{2}-4n+2})^{n}$ =$e^{\lim_{n\to \infty} n\times \ln(\frac{1 -2-n +\frac{1}{n^{2}}}{1 -\frac{4}{n} +\frac{2}{n^{2}}})}$
I got stuck here
Comment: The limit on the inside of the log can be handled by dividing the numerator and denominator by the highest power of n in the denominator and taking the limit, or you can use L'Hospitals rule on it now as it is of the form of infinity over infinity
Comment: You don't need to divide the numerator and denominator by $n^2$ inside the logarithm.  Instead, change the $n$ out in front to $1/(1/n)$ and use l'Hopital's rule.  If you are not allowed to use l'Hopital's rule, you must transform it to look like a limit for $e$.
Comment: Rather similar limit was calculated in the solution of this problem: [How to determine if $\sum_{n=1}^{\infty}\left (\frac{n^2-5n+1}{n^2-4n+2}\right)^{n^2}$ converges or diverges](http://math.stackexchange.com/q/1263557). Found [using Approach0](https://approach0.xyz/search/?q=%24%5Clim_%7Bn%5Cto%20%5Cinfty%7D%20(%5Cfrac%7Bn%5E%7B2%7D-2n%2B1%7D%7Bn%5E%7B2%7D-4n%2B2%7D)%5E%7Bn%7D%24&p=1).
Answer: Lemma: If $g(n)>0$, $h(n)>0$ when $n \to \infty$ and
$$\lim_{n \to \infty}g(n)=a, \lim_{n \to \infty}h(n)=b,$$ then
$$\lim_{n \to \infty}g(n)^{h(n)}=a^b.$$
So
$$\lim_{n \to \infty}(\frac{n^2-2n+1}{n^2-4n+2})^n=\lim_{n \to \infty}(1+\frac{2n-1}{n^2-4n+2})^n=\lim_{n \to \infty}(1+\frac{2n-1}{n^2-4n+2})^{ {\frac{n^2-4n+2}{2n-1}  (\frac{2n-1}{n^2-4n+2} n)}}=e^2$$.
Comment: Trying to understand how you reached e^2 in the end
Comment: @user3133165 is it clear now.
Comment: Yes it is ,still trying to grasp when i should use these kind tricks when solving limits
Comment: @user3133165 If $\lim_{n \to \infty} \varphi(n)=\infty$, then follows from the well known limit $\lim_{n \to \infty}(1+\frac{1}{n})^n=e$ that $\lim_{n \to \infty}(1+\frac{1}{\varphi(n)})^{\varphi(n)}=e$. Now let $\varphi(n)=\frac{n^2-4n+2}{2n-1}$, and you will see that.
Answer: Hint
After taking logarithm, observe that
$$n\ln(\frac{n^2-2n+1}{n^2-4n+2})=$$
$$n\ln(\color{red}{1}+\frac{2n-1}{n^2-4n+2})=$$
$$n\frac{2n-1  }{  n^2-4n+2}\frac{ \ln(  \color{red}{1}+\frac{2n-1  }{n^2-4n+2  } )  }{  \frac{2n-1  }{  n^2-4n+2 } }.$$
Now, use the well-known limit
$$\lim_{X\to 0}\frac{\ln(\color{red}{1}+X)}{X}=1$$.
the limit is $e^2$.
Comment: Is there a power of $n$ missing?
Comment: $2n-1$, and $n^2-4n+2$ are different so the well known limit does not apply here.
Comment: @DeepSea please look now it is clear


dnf update - dependencies

Question: During update I've encountered following errors
yum update
Last metadata expiration check: 0:44:43 ago on Mon 11 Apr 2022 06:33:55 AM CEST.
Error:
 Problem 1: package containers-common-2:1-23.module_el8.7.0+1106+45480ee0.x86_64 requires runc, but none of the providers can be installed
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1:1.0.3-3.module_el8.7.0+1106+45480ee0.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1:1.0.3-3.module_el8.7.0+1106+45480ee0.x86_64
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.5.0+733+9bb5dffa.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.5.0+733+9bb5dffa.x86_64
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.1-5.module_el8.5.0+878+851f435b.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.1-5.module_el8.5.0+878+851f435b.x86_64
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.1-5.module_el8.5.0+890+6b136101.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.1-5.module_el8.5.0+890+6b136101.x86_64
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.6.0+926+8bef8ae7.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.6.0+926+8bef8ae7.x86_64
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.1-3.module_el8.5.0+870+f792de72.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.1-3.module_el8.5.0+870+f792de72.x86_64
  - cannot install the best update candidate for package containers-common-1:1.2.2-4.module_el8.5.0+733+9bb5dffa.x86_64
  - problem with installed package containerd.io-1.4.11-3.1.el8.x86_64
  - package runc-1.0.0-64.rc10.module_el8.4.0+522+66908d0c.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-73.rc95.module_el8.6.0+1107+d59a301b.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-56.rc5.dev.git2abd837.module_el8.4.0+521+9df8e6d3.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-70.rc92.module_el8.5.0+736+58cc1a5a.x86_64 is filtered out by modular filtering
  - package runc-1:1.0.3-1.module_el8.6.0+1108+b13568aa.x86_64 is filtered out by modular filtering
 Problem 2: package skopeo-2:1.6.1-1.module_el8.7.0+1106+45480ee0.x86_64 requires containers-common >= 2:1-2, but none of the providers can be installed
  - package containers-common-2:1-2.module_el8.6.0+926+8bef8ae7.noarch requires runc, but none of the providers can be installed
  - package containers-common-2:1-2.module_el8.5.0+890+6b136101.noarch requires runc, but none of the providers can be installed
  - package containers-common-2:1-23.module_el8.7.0+1106+45480ee0.x86_64 requires runc, but none of the providers can be installed
  - package containers-common-2:1-4.module_el8.6.0+944+d413f95e.noarch requires runc, but none of the providers can be installed
  - package containers-common-2:1-6.module_el8.6.0+954+963caf36.noarch requires runc, but none of the providers can be installed
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1:1.0.3-3.module_el8.7.0+1106+45480ee0.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1:1.0.3-3.module_el8.7.0+1106+45480ee0.x86_64
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.5.0+733+9bb5dffa.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.5.0+733+9bb5dffa.x86_64
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.5.0+911+f19012f9.x86_64
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.1-5.module_el8.5.0+878+851f435b.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.1-5.module_el8.5.0+878+851f435b.x86_64
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.1-5.module_el8.5.0+890+6b136101.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.1-5.module_el8.5.0+890+6b136101.x86_64
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.2-1.module_el8.6.0+926+8bef8ae7.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.2-1.module_el8.6.0+926+8bef8ae7.x86_64
  - package containerd.io-1.4.11-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.1-3.module_el8.5.0+870+f792de72.x86_64
  - installed package containerd.io-1.4.11-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.1-3.module_el8.5.0+870+f792de72.x86_64
  - package docker-ce-3:20.10.9-3.el8.x86_64 requires containerd.io >= 1.4.1, but none of the providers can be installed
  - cannot install the best update candidate for package skopeo-1:1.4.0-6.module_el8.5.0+890+6b136101.x86_64
  - problem with installed package docker-ce-3:20.10.9-3.el8.x86_64
  - package containers-common-2:1-19.module_el8.6.0+1108+b13568aa.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-64.rc10.module_el8.4.0+522+66908d0c.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-73.rc95.module_el8.6.0+1107+d59a301b.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-56.rc5.dev.git2abd837.module_el8.4.0+521+9df8e6d3.x86_64 is filtered out by modular filtering
  - package runc-1.0.0-70.rc92.module_el8.5.0+736+58cc1a5a.x86_64 is filtered out by modular filtering
  - package runc-1:1.0.3-1.module_el8.6.0+1108+b13568aa.x86_64 is filtered out by modular filtering
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

How to solve such errors?
Answer: You can simply remove the problematic package:
dnf remove -y containers-common-2:1-23.module_el8.7.0+1106+45480ee0.x86_64

And then:
dnf clean all && dnf check && dnf check-update

Followed by:
dnf update -y && dnf upgrade -y

Comment: That's defying the purpose if you actually need the containers-common pckage

dnf update - dependencies


JSON to tree diagram

Question: I have a JSON object which is heavily nested. Is there a way in which I could view a hierarchical tree diagram? I went through several resources like Pydot, Plotly etc but nothing could render the JSON in my format.
JSON file:
{
  "found_intents": {
    "_DATE": {}
  },
  "sentence": "What is your name",
  "tree": [
    [
      {
        "canonical": null,
        "concept": "_START_TAG",
        "correct_string": "<start>",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "<start>",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "<start>",
            "language": "english",
            "span": [
              0,
              1
            ],
            "span_string": "<start>",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "<start>",
        "language": "english",
        "span": [
          0,
          1
        ],
        "span_string": "<start>",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_WHAT_IS",
        "correct_string": "what is",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "what",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "what",
            "language": "english",
            "span": [
              1,
              2
            ],
            "span_string": "what",
            "weight": 1.0
          },
          {
            "canonical": null,
            "concept": "",
            "correct_string": "is",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "is",
            "language": "english",
            "span": [
              2,
              3
            ],
            "span_string": "is",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "what is",
        "language": "english",
        "span": [
          1,
          3
        ],
        "span_string": "what is",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_DICTIONARY",
        "correct_string": "your",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "your",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "your",
            "language": "english",
            "span": [
              3,
              4
            ],
            "span_string": "your",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "your",
        "language": "english",
        "span": [
          3,
          4
        ],
        "span_string": "your",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_DICTIONARY",
        "correct_string": "name",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "name",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "name",
            "language": "english",
            "span": [
              4,
              5
            ],
            "span_string": "name",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "name",
        "language": "english",
        "span": [
          4,
          5
        ],
        "span_string": "name",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_END_TAG",
        "correct_string": "<end>",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "<end>",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "<end>",
            "language": "english",
            "span": [
              5,
              6
            ],
            "span_string": "<end>",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "<end>",
        "language": "english",
        "span": [
          5,
          6
        ],
        "span_string": "<end>",
        "weight": 1.0
      }
    ],
    [
      {
        "canonical": null,
        "concept": "_START_TAG",
        "correct_string": "<start>",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "<start>",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "<start>",
            "language": "english",
            "span": [
              0,
              1
            ],
            "span_string": "<start>",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "<start>",
        "language": "english",
        "span": [
          0,
          1
        ],
        "span_string": "<start>",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_WHAT_IS",
        "correct_string": "what is",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "what",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "what",
            "language": "english",
            "span": [
              1,
              2
            ],
            "span_string": "what",
            "weight": 1.0
          },
          {
            "canonical": null,
            "concept": "",
            "correct_string": "is",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "is",
            "language": "english",
            "span": [
              2,
              3
            ],
            "span_string": "is",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "what is",
        "language": "english",
        "span": [
          1,
          3
        ],
        "span_string": "what is",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_DICTIONARY",
        "correct_string": "your",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "your",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "your",
            "language": "english",
            "span": [
              3,
              4
            ],
            "span_string": "your",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "your",
        "language": "english",
        "span": [
          3,
          4
        ],
        "span_string": "your",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_THEATRE_ID",
        "correct_string": "name",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "name",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "name",
            "language": "english",
            "span": [
              4,
              5
            ],
            "span_string": "name",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "name",
        "language": "english",
        "span": [
          4,
          5
        ],
        "span_string": "name",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_END_TAG",
        "correct_string": "<end>",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "<end>",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "<end>",
            "language": "english",
            "span": [
              5,
              6
            ],
            "span_string": "<end>",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "<end>",
        "language": "english",
        "span": [
          5,
          6
        ],
        "span_string": "<end>",
        "weight": 1.0
      }
    ],
    [
      {
        "canonical": null,
        "concept": "_START_TAG",
        "correct_string": "<start>",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "<start>",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "<start>",
            "language": "english",
            "span": [
              0,
              1
            ],
            "span_string": "<start>",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "<start>",
        "language": "english",
        "span": [
          0,
          1
        ],
        "span_string": "<start>",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_WHAT_IS",
        "correct_string": "what is",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "what",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "what",
            "language": "english",
            "span": [
              1,
              2
            ],
            "span_string": "what",
            "weight": 1.0
          },
          {
            "canonical": null,
            "concept": "",
            "correct_string": "is",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "is",
            "language": "english",
            "span": [
              2,
              3
            ],
            "span_string": "is",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "what is",
        "language": "english",
        "span": [
          1,
          3
        ],
        "span_string": "what is",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_THEATRE_ID",
        "correct_string": "your",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "your",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "your",
            "language": "english",
            "span": [
              3,
              4
            ],
            "span_string": "your",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "your",
        "language": "english",
        "span": [
          3,
          4
        ],
        "span_string": "your",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_DICTIONARY",
        "correct_string": "name",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "name",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "name",
            "language": "english",
            "span": [
              4,
              5
            ],
            "span_string": "name",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "name",
        "language": "english",
        "span": [
          4,
          5
        ],
        "span_string": "name",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_END_TAG",
        "correct_string": "<end>",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "<end>",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "<end>",
            "language": "english",
            "span": [
              5,
              6
            ],
            "span_string": "<end>",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "<end>",
        "language": "english",
        "span": [
          5,
          6
        ],
        "span_string": "<end>",
        "weight": 1.0
      }
    ],
    [
      {
        "canonical": null,
        "concept": "_START_TAG",
        "correct_string": "<start>",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "<start>",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "<start>",
            "language": "english",
            "span": [
              0,
              1
            ],
            "span_string": "<start>",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "<start>",
        "language": "english",
        "span": [
          0,
          1
        ],
        "span_string": "<start>",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_WHAT_IS",
        "correct_string": "what is",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "what",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "what",
            "language": "english",
            "span": [
              1,
              2
            ],
            "span_string": "what",
            "weight": 1.0
          },
          {
            "canonical": null,
            "concept": "",
            "correct_string": "is",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "is",
            "language": "english",
            "span": [
              2,
              3
            ],
            "span_string": "is",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "what is",
        "language": "english",
        "span": [
          1,
          3
        ],
        "span_string": "what is",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_THEATRE_ID",
        "correct_string": "your",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "your",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "your",
            "language": "english",
            "span": [
              3,
              4
            ],
            "span_string": "your",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "your",
        "language": "english",
        "span": [
          3,
          4
        ],
        "span_string": "your",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_THEATRE_ID",
        "correct_string": "name",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "name",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "name",
            "language": "english",
            "span": [
              4,
              5
            ],
            "span_string": "name",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "name",
        "language": "english",
        "span": [
          4,
          5
        ],
        "span_string": "name",
        "weight": 1.0
      },
      {
        "canonical": null,
        "concept": "_END_TAG",
        "correct_string": "<end>",
        "definition": "",
        "details": [
          {
            "canonical": null,
            "concept": "",
            "correct_string": "<end>",
            "definition": "",
            "details": [],
            "e.g.": [],
            "grammar": "<end>",
            "language": "english",
            "span": [
              5,
              6
            ],
            "span_string": "<end>",
            "weight": 1.0
          }
        ],
        "e.g.": [],
        "grammar": "<end>",
        "language": "english",
        "span": [
          5,
          6
        ],
        "span_string": "<end>",
        "weight": 1.0
      }
    ]
  ]
}

More precisely, I'd like to extract the average number of branches per level.
Expected results would be:
Level 0: 4
Level 1: (1 + 2 + 1 + 1)/4
Level 2: 0

Answer: It's not completely clear what you're trying to do, but the following code counts the number of dicts and lists at each nesting depth. We use collections.deque as a stack to perform a breadth-first search, counting the number of nested containers at each level, storing the counts in a defaultdict of lists, and pushing those containers onto the stack for future processing. When we've finished counting all the objects we compute the mean number of branches at each level.
I won't paste your data into this code, since it's about 740 lines long. I refer to that data as data_string, on my machine I simply wrapped your data in triple-quotes, but of course you could save it as a file, and use json.load to load it.
import json
from collections import defaultdict, deque

data = json.loads(data_string)

def get_branches(obj):
    branches = defaultdict(list)
    stack = deque()
    stack.append((obj, 0))
    while stack:
        obj, depth = stack.pop()
        newdepth = depth + 1
        branch_count = 0
        if isinstance(obj, dict):
            obj = obj.values()
        for child in obj:
            if isinstance(child, (list, dict)):
                branch_count += 1
                stack.append((child, newdepth))
        if branch_count:
            branches[depth].append(branch_count)
    return branches

branches = get_branches(data)
for depth in sorted(branches.keys()):
    row = branches[depth]
    mean = sum(row) / len(row) if row else None
    print('Level', depth, row, mean)

output
Level 0 [2] 2.0
Level 1 [4, 1] 2.5
Level 2 [5, 5, 5, 5] 5.0
Level 3 [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3] 3.0
Level 4 [1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1] 1.2
Level 5 [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3] 3.0

Comment: Thanks for the answer. Is there a way I can get what portion of the entire json falls under the respective levels? One such instance would be self explanatory.
Comment: @nikinlpds That sounds like a good topic for a fresh question. ;) You can put a link in the new question back to this one, if you want. You'll need to explain exactly how you want to measure that. I assume you want it in terms of the number of nodes (items), but maybe you want to measure it in characters.
Comment: Thanks for the quick response. Basically, whatever part of the JSON that falls in each level while traversing has to be fetched. I've made a separate question over here - https://stackoverflow.com/questions/51189250/nested-json-get-elements-corresponding-to-each-depth. What I'm trying to do finally is see how many elements are present corresponding to say "concept" across each level.
Comment: @nikinlpds As bruno said, you need to explain your question more clearly, otherwise it will get put on hold.
Comment: Alright. I'll make it simpler. Currently we have the counts for number of dicts and lists at each nesting depth. I just want those dict/list as a whole to be extracted per level. Is it clear now?
Comment: @nikinlpds No, it's not clear now. But why are you putting that info here? You need to put further info into the body of your new question. Currently, it's being ignored because people can't tell what you want. But you probably saved yourself from getting downvotes because the question includes some code. If you show us a small sample of input data along with the exact expected output that matches that input then people will be able to help you. When you edit your question it will get bumped back to the front page, so many people will notice it.
Comment: I've added a diagram which could be helpful in understanding.

JSON to tree diagram