text:
Q: Error while inflating layout Android Studio The last days i'm facing issues with layout rendering in android studio layout preview.
I have already tried clear caches, deleting all strings from xml file, but this didn't help. I dont have any otehr ideas.
I will appreciate any help. Thank u.
I'm getting 2 errors
First stack trace
java.lang.reflect.InvocationTargetException
    at jdk.internal.reflect.GeneratedMethodAccessor588.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at android.view.BridgeInflater.lambda$createViewFromCustomInflater$0(BridgeInflater.java:259)
    at android.view.BridgeInflater.createViewFromCustomInflater(BridgeInflater.java:285)
    at android.view.BridgeInflater.onCreateView(BridgeInflater.java:122)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:928)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:948)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1002)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:309)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1121)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1095)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1124)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1095)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1124)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1095)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1124)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1095)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1124)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1095)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1124)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1095)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:680)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:499)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:325)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:369)
    at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:141)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:710)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$6(RenderTask.java:865)
    at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$2.run(RenderExecutor.kt:174)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:47)
    at java.base/java.lang.String.charAt(String.java:693)
    at android.content.res.BridgeTypedArray.getType(BridgeTypedArray.java:1024)
    at android.content.res.BridgeTypedArray.getType(BridgeTypedArray.java:809)
    at android.content.res.BridgeTypedArray.getValue(BridgeTypedArray.java:778)
    at android.content.res.BridgeTypedArray.peekValue(BridgeTypedArray.java:847)
    at android.view.View.<init>(View.java:5951)
    at android.widget.TextView.<init>(TextView.java:996)
    at android.widget.EditText.<init>(EditText.java:87)
    at android.widget.EditText.<init>(EditText.java:83)
    at androidx.appcompat.widget.AppCompatEditText.<init>(AppCompatEditText.java:74)
    at androidx.appcompat.widget.AppCompatEditText.<init>(AppCompatEditText.java:69)
    at androidx.appcompat.app.AppCompatViewInflater.createEditText(AppCompatViewInflater.java:209)
    at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:127)

Second error
String index out of range: -1

And there is layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:id="@+id/mapActivityLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    tools:context=".ui.mapactivity.MapsActivity">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/constraintLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/constraintLayoutMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <com.google.android.gms.maps.MapView
                android:id="@+id/map_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="1.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.0"
                tools:context=".ui.mapactivity.MapsActivity" />

        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="10dp">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/constraintLayoutServerSync"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:elevation="0dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <Button
                    android:id="@+id/buttonServerSync"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_marginStart="2dp"
                    android:layout_marginTop="2dp"
                    android:layout_marginEnd="2dp"
                    android:layout_marginBottom="2dp"
                    android:background="@drawable/button_sync"
                    android:elevation="10dp"
                    android:gravity="center"
                    android:singleLine="true"
                    android:textAllCaps="false"
                    android:textColor="@color/colorGray"
                    android:textSize="12sp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />
            </androidx.constraintlayout.widget.ConstraintLayout>

            <androidx.cardview.widget.CardView
                android:id="@+id/cv_select_farm"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/field_style_3"
                android:maxWidth="150dp"
                app:cardElevation="5dp"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <LinearLayout
                    android:id="@+id/ll_farms_container"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:focusable="true"
                    android:focusableInTouchMode="true"
                    android:maxWidth="174dp"
                    android:orientation="vertical">

                    <Button
                        android:id="@+id/bt_show_farms"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@drawable/button_farm"
                        android:elevation="10dp"
                        android:gravity="center"
                        android:maxWidth="150dp"
                        android:padding="5dp"
                        android:singleLine="true"
                        android:text="@string/farm"
                        android:textAllCaps="false"
                        android:textColor="@color/colorGray"
                        android:textSize="12sp" />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:orientation="horizontal">

                        <EditText
                            android:id="@+id/et_farm_filter"
                            android:layout_width="150dp"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:autofillHints=""
                            android:backgroundTint="@color/colorButtonsFirst"
                            android:ems="10"
                            android:gravity="center"
                            android:hint="@string/filter"
                            android:inputType="textPersonName"
                            android:paddingBottom="20dp"
                            android:textColor="@color/colorGray"
                            android:textColorHint="@color/colorGray"
                            android:textSize="12sp"
                            android:visibility="gone" />

                        <ImageButton
                            android:id="@+id/iv_hide_farms"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:padding="10dp"
                            android:background="?selectableItemBackground"
                            android:src="@drawable/ic_up_chevron"
                            android:visibility="gone"/>
                    </LinearLayout>

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/rv_farms_list"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:visibility="gone" />
                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <androidx.cardview.widget.CardView
                android:id="@+id/cv_select_field"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="10dp"
                android:background="@drawable/field_style_3"
                android:maxWidth="224dp"
                app:cardElevation="5dp"
                app:layout_constraintStart_toEndOf="@+id/cv_select_farm"
                app:layout_constraintTop_toTopOf="parent">

                <LinearLayout
                    android:id="@+id/ll_fields_container"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:focusable="true"
                    android:focusableInTouchMode="true"
                    android:orientation="vertical">

                    <Button
                        android:id="@+id/bt_show_fields"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="@drawable/button_field_with_icon"
                        android:elevation="10dp"
                        android:gravity="center"
                        android:padding="5dp"
                        android:singleLine="true"
                        android:textAllCaps="false"
                        android:textColor="@color/colorGray"
                        android:textSize="12sp" />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:orientation="horizontal">

                        <EditText
                            android:id="@+id/et_fields_fiter"
                            android:layout_width="150dp"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:autofillHints=""
                            android:backgroundTint="@color/colorButtonsFirst"
                            android:ems="10"
                            android:gravity="center"
                            android:hint="@string/filter"
                            android:inputType="textPersonName"
                            android:paddingBottom="20dp"
                            android:textColor="@color/colorGray"
                            android:textColorHint="@color/colorGray"
                            android:textSize="12sp"
                            android:visibility="gone" />

                        <ImageButton
                            android:id="@+id/iv_hide_fields"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:padding="10dp"
                            android:background="?selectableItemBackground"
                            android:src="@drawable/ic_up_chevron"
                            android:visibility="gone"/>
                    </LinearLayout>

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/rv_fields_list"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:visibility="gone" />
                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <androidx.cardview.widget.CardView
                android:id="@+id/cv_select_map_type"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="10dp"
                android:background="@drawable/field_style_3"
                android:maxWidth="200dp"
                app:cardCornerRadius="25dp"
                app:cardElevation="5dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toBottomOf="@id/constraintLayoutServerSync">

                <LinearLayout
                    android:id="@+id/ll_map_type_container"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <Button
                        android:id="@+id/bt_show_map_types"
                        android:layout_width="50dp"
                        android:layout_height="wrap_content"
                        android:background="@drawable/button_map_type"
                        android:elevation="10dp"
                        android:gravity="center"
                        android:padding="5dp"
                        android:singleLine="true"
                        android:textAllCaps="false"
                        android:textColor="@color/colorGray"
                        android:textSize="12sp" />

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/rv_map_types"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:visibility="gone" />
                </LinearLayout>
            </androidx.cardview.widget.CardView>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent">

                <Button
                    android:id="@+id/buttonZoomPlus"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_marginStart="2dp"
                    android:layout_marginEnd="2dp"
                    android:layout_marginBottom="2dp"
                    android:background="@drawable/button_map_zoom_in"
                    android:gravity="center"
                    android:singleLine="true"
                    android:textAllCaps="false"
                    android:textSize="18sp" />

                <Button
                    android:id="@+id/buttonZoomMinus"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_marginStart="2dp"
                    android:layout_marginEnd="2dp"
                    android:background="@drawable/button_map_zoom_out"
                    android:gravity="center"
                    android:singleLine="true"
                    android:textAllCaps="false"
                    android:textSize="18sp" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent">

                <com.github.clans.fab.FloatingActionMenu
                    android:id="@+id/floatingActionMenu"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="16dp"
                    app:menu_colorNormal="@color/app_accent"
                    app:menu_colorPressed="@color/dark_accent"
                    app:menu_icon="@drawable/ic_speedometer"
                    app:menu_labels_position="right"
                    app:menu_shadowRadius="5dp"
                    app:menu_showShadow="true">

                    <com.github.clans.fab.FloatingActionButton
                        android:id="@+id/fab_clear_selected_fields"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_delete"
                        app:fab_colorNormal="@color/app_accent"
                        app:fab_colorPressed="@color/dark_accent"
                        app:fab_label="@string/clear_selected_fields" />

                    <com.github.clans.fab.FloatingActionButton
                        android:id="@+id/fab_measure_selected_fields"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_add"
                        app:fab_colorNormal="@color/app_accent"
                        app:fab_colorPressed="@color/dark_accent"
                        app:fab_label="@string/measure_selected_fields" />

                </com.github.clans.fab.FloatingActionMenu>
            </LinearLayout>

        </androidx.constraintlayout.widget.ConstraintLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/topLayoutMapActivity"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

A: Update  following Lines from your XML Layout file to proper autofillHints or remove the line
android:autofillHints=""

Blank autofillHints are not working in Android Studio 4.2 Layout Preview

A: You need to change your android version on your designed preview. Rendering problem caused
your designed preview to use higher API level than your current android API level.


text:
Q: Generating IDs for pie-like wedges (geometry) in PostgreSQL/PostGIS I have a query that generates 12 sections (pie-like wedges) in a circle (buffer) of 50 meters around point layer.
With buffer as(
SELECT gid as pt_id, (ST_DumpPoints(ST_Buffer(geom,50,3))).geom as geom
FROM my_point_table group by gid, geom
UNION ALL
SELECT gid as pt_id, geom FROM my_point_table
)
SELECT gid, (ST_Dump(ST_DelaunayTriangles(ST_Collect(geom),0, 0))).geom geom
FROM buffer
GROUP BY pt_id

I would like to assign IDs to these sections like this:

Suggestions on how to do this would be highly appreciated.

A: You can try something like this
With my_point_table as (
    select 1 as gid, 'POINT(0 0)'::geometry as geom
    union
    select 2 as gid, 'POINT(1 1)'::geometry as geom
), buffer as(
    SELECT gid as pt_id, (ST_DumpPoints(ST_Buffer(geom,50,3))).geom as geom
    FROM my_point_table group by gid, geom
    UNION ALL
    SELECT gid as pt_id, geom FROM my_point_table
) , tr as (
    SELECT pt_id, (ST_Dump(ST_DelaunayTriangles(ST_Collect(geom),0, 0))).geom geom
    FROM buffer
    GROUP BY pt_id
)
select row_number() OVER (partition by pt_id), pt_id, geom from tr

First part is to mock your "my_point_table" table.
row_number() OVER (partition by pt_id)
is what generates a sequential number for each feature.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Is it possible to combine a bootstrap collapsible list menu with jQuery UI menu? Currently, I have a jQuery UI menu as follows:
HTML

Transaction Management

Configure Processing

User Administration

About

JS
$("#leftmenu").menu();
JS Functions For Each Click of menu item:
$('#leftmenu>li').on('click', function(){

    var mvar = 0;
    $(".tabui").each(function() {

        $(this).hide();
    });

    $(".listitem").each(function() {

        $(this).css("background", "transparent");
    });

    $(this).css("background-color", "#C8C8C8");

    var targetId = $(this).data('target');
     var target = $(document.getElementById(targetId));
     target.show();

});
$(function showTab(target) {

    if (document.getElementById(target)) {
        document.getElementById(target).show();
    }
 });

$(function hideTab(target) {

    if (document.getElementById(target))
    {
        document.getElementById(target).hide();
    }

 });

So the basic  end result of all this is a UI which has a list of menus on the left side, and depending on which is clicked, the right side gets populated with the appropriate tabbed panels, and the selected menu item remains highlighted with the dark gray background, to indicate it was selected. Here is a screenshot:

Now my goal is to include collapsible submenus on the left menu, and in my research, I couldn't find that jQueryUI supports this, however, I found that bootstrap provides something like this, called collapsible list group:

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

       User Administration

One

Two

Three

       About

One

Two

Three

I don't know where to start or if it is even possible to combine this with my jQuery UI menu, so I am looking for any ideas on how this can be achieved if possible. The goal is to have the parent menu open a default tabbed panel on the right side, and the sub menus will have other tabs different from the default tabs of its parent.
Or is there another alternative to achieve this result?
Thank you.

A: As it turns out, all I needed to do was put the jQueryUI menu into the bootstrap menu, and things worked fine:

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://code.jquery.com/ui/jquery-ui-git.css">

       User Administration

Transaction Management

Configure Processing

User Administration

About

       About

One

Two

Three


text:
Q: How to change Authentication in sharepoint server 2010? how to change Authentication in sharepoint server 2010? By default it takes windows authentication.
After creating website it is possible to change authentication name in website if it possible how it so?

A: I think you need to read what Microsoft has discussed in glorious detail about all Authentication Mechanisms supported by SharePoint 2010:-
http://technet.microsoft.com/en-us/library/cc262350.aspx
Additionally, if you are planning for creating a topology with various authentication mechanism follow this deployment reference :-
http://www.microsoft.com/en-us/download/details.aspx?id=24079
The alternative to NT authentication is claims based authentication and read here how to implement the same :-
http://technet.microsoft.com/en-us/library/ee806886.aspx
http://technet.microsoft.com/en-us/library/ee806885.aspx

A: Prasanth,
Authentication is set on the web application level, not on the web site level. To change it, and you can use multiple types of providers, you need access to Central Administration. You also need to understand how to configure the authentication provider you want to use.
The following TechNet article is a great place to start:
http://technet.microsoft.com/en-us/library/cc262350.aspx
USPJA (I'm a partner) also has a course on planning and implementing security:
http://www.uspja.com/courses/user-management-and-security-in-sharepoint-2010/
.b


text:
Q: How to set Exoplayer as a service I am trying to make a music player with exoplayer but i am not able to set it as a service
class PlayerService : Service() {

    var exoPlayer : ExoPlayer? = null

    override fun onBind(p0: Intent?): IBinder? {

        setMedia()
        return MusicBinder()
    }

    override fun onCreate() {
        super.onCreate()
        exoPlayer = ExoPlayer.Builder(this).build()
        Log.d("tag","service Started")
    }

    inner class MusicBinder() : Binder(){
        fun getExoPLayer() = exoPlayer
    }

    private fun setMedia() {
        val mediaItem = MediaItem.fromUri(getString(R.string.media))
        player?.prepare()
        player?.setMediaItem(mediaItem)
        player?.prepare()
    }

}

A: You can and prepare exoplayer on onStartCommand override function like this
@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
          exoPlayer = ExoPlayer.Builder(this).build()
          setMedia()
          return START_STICKY;
}

This works for me


text:
Q: How to turn off auto-indenting in Java in Android Studio (2.1.1)? (Windows 7) If I have a line with 8 spaces (yes, spaces, not tabs) and some text...
        x=3;

... and my cursor is placed after the semicolon, when I hit Enter it positions the cursor under the x.  In other words it indents it 8 positions. If I then hit backspace it positions the cursor after the semicolon!   I expect the backspace to take me back 1 space on the new line.
In Editor>Code Style > Java, Tab size = 1, Indent = 0, Continuation indent = 0.     N.B. that if I try to set Tab size to 0 it's 1 next time I bring up that dialog, so 0 is apparently not acceptable to Android Studio, even though I see it suggested in several S.O. questions.
In Editor > Code Style I UNchecked Detect and use existing file indents for editing and now if I hit Enter with the cursor after the semicolon it positions the cursor 4 spaces in the from the right, in other words it still indents, just not as much.
N.B, that after making these settings I did a File > Invalidate Caches / Restart.
I don't want any automatic indenting.  When I hit Enter I want it to position the cursor at the first position of the new line, and when I hit backspace I want it to go back 1 position, just like an ordinary "dumb" editor.  How do I turn off all automatic indenting in Android Studio?

A: Android studio tries its best, like most IDEs, to help you organize your work and make it successful. It is normal, but of course, there is a way to disable it.
Note: Your project can be really messy when disabling this, if you want to properly indent a block of code, highlight it then press CTRL+ALT+L, this will indent the highlighted for you.
So, to disable it, press CTRL+ALT+S, this will open settings. Now, go to the Editor tab at your left, where you then go to General, then Smart Keys. You should see a  "Backspace" part. Over there, there will be a dropdown menu, click that then select the "Disabled" option. (Settings>Editor>General>Smart Keys> )

A:
Is this just the normal, expected behavior of A.S.?

I'd say it's the normal expected behavior of any IDE to indent correctly while you are typing. Your next line is supposed to start at the same position than the previous and if you close a bracket A.S. will automatically unindent it once.
Now on your topic :
To make your backspace key just delete the space you can go to : Settings -> Editor -> General -> Smart Keys -> Backspace -> Unindent and put 'Disabled' instead of 'To proper indent position'


text:
Q: Jmeter - Use Loop controller based on array (created from from multiple variables) I have API call which returns JSON like:
 [
  "Kwara United - Sunshine Stars",
  "Nasarawa United - Rivers United",
  "Plateau United - Enyimba",
  "Abia Warriors - Dakkada",
  "Wikki Tourist - Lobi Stars",
  "Heartland Owerri - MFM FC"
]

from this JSON I create array of opponents:
List values = new ArrayList()

for (int i = 1; i <= 6 ; i++) {

    vars.put("opponentA" + i, (vars.get("ID1_" + i)).split(" - ")[0]);
    vars.put("opponentB" + i, (vars.get("ID1_" + i)).split(" - ")[1]);
    values.add((vars.get('opponentA' + i) as String))
    values.add((vars.get('opponentB' + i) as String))
    //log.warn(vars.get("opponentA" + i));
    //log.warn(vars.get("opponentB" + i));
}

vars.put('array', values as String);

Where the variable: array holds all the opponents.
[Kwara United, Sunshine Stars, Nasarawa United, Rivers United, Plateau United, Enyimba, Abia Warriors, Dakkada, Wikki Tourist, Lobi Stars, Heartland Owerri, MFM FC]

How can I tell Loop conroller to loop based on this variable array?

And then to pass that dynamic value to JDBC request?

A: *

*To get the size of the array use the following __groovy() function:
${__groovy(vars.get('array')[1..vars.get('array').length()-2].tokenize('\,').size(),)}

*To use current value in the loop iterations use the following __groovy() function:
${__groovy(vars.get('array')[1..vars.get('array').length()-2].tokenize('\,')[vars.get('__jm__Loop Controller__idx') as int],)}

Demo:

More information:

*

*Loop Controller

*The Groovy Templates Cheat Sheet for JMeter

A: I would use ForEach controller using opponentA variable (uncheck Add "_" before number)

ForEach controller loops through the values of a set of related variables. When you add samplers (or controllers) to a ForEach controller, every sample (or controller) is executed one or more times, where during every loop the variable has a new value. The input should consist of several variables, each extended with an underscore and a number. Each such variable must have a value.

Note: the "_" separator is now optional.


text:
Q: Qt QWidget/QDialog window is moved some time after creation on Linux This is a simple testcase of a window saving its position when it's closed:

*

*a dialog is created, and it is moved via QWidget::move to the last saved position

*in dialog's closeEvent, QWidget::pos is saved

Repeatedly creating/destroying should place the windows in the same position it was when it was closed.
Works fine on Windows and macOS.
On Linux, the window is shifted by (0, -37) some time after creation. Repeatedly creating/destroying the window causes the window to gradually shift upwards.
From the logged messages on macOS and Windows we see:
dialog pos after creation QPoint(200,200)
dialog pos (button clicked)  QPoint(200,200)
dialog pos before close QPoint(200,200)
dialog pos after creation QPoint(200,200)
dialog pos (button clicked)  QPoint(200,200)
dialog pos before close QPoint(200,200)

while on Linux (Ubuntu 20) we see:
dialog pos after creation QPoint(200,200)
dialog pos (button clicked)  QPoint(200,163)
dialog pos before close QPoint(200,163)
dialog pos after creation QPoint(200,163)
dialog pos (button clicked)  QPoint(200,126)
dialog pos before close QPoint(200,126)
dialog pos after creation QPoint(200,126)
dialog pos (button clicked)  QPoint(200,89)
dialog pos before close QPoint(200,89)
dialog pos after creation QPoint(200,89)
dialog pos (button clicked)  QPoint(200,52)
dialog pos before close QPoint(200,52)
dialog pos after creation QPoint(200,52)
dialog pos before close QPoint(200,27)

I thought as a workaround I would use geometry() / setGeometry() instead of pos() / move(), but then other problems arise.
Is this a bug? Is there a better solution to this?
Another solution I considered, is saving the dialog position some time later, but upon which event? I tried showEvent, but in that case reported position is (0, 0).
mainwindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPushButton>
#include <QPoint>

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    QPushButton *btn;

    friend class QDialog2;
};

#endif // MAINWINDOW_H

mainwindow.cpp:
#include "mainwindow.h"

#include <QCloseEvent>
#include <QPoint>
#include <QDialog>
#include <QDebug>

QPoint savedPos;
class QDialog2 *theDialog;

class QDialog2 : public QDialog
{
    MainWindow *mainWindow;

public:
    QDialog2(MainWindow *w, QWidget *parent = 0)
        : QDialog(parent), mainWindow(w)
    {
    }

    virtual void closeEvent(QCloseEvent * event)
    {
        qDebug() << "dialog pos before close" << this->pos();
        savedPos = this->pos();
        this->deleteLater();
        theDialog = nullptr;
    }
};

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    theDialog = nullptr;

    btn = new QPushButton(this);
    btn->setText("Create");

    connect(btn, &QPushButton::clicked, [=] {
        if(theDialog) {
            qDebug() << "dialog pos (button clicked) " << theDialog->pos();
            theDialog->close();
            btn->setText("Create");
            return;
        }

        theDialog = new QDialog2(this, this);
        Qt::WindowFlags flags = Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint;
#if __APPLE__
        flags |= Qt::Tool;
#else
        flags |= Qt::Dialog;
#endif
        flags |= Qt::MSWindowsFixedSizeDialogHint;
        flags |= Qt::WindowCloseButtonHint;
        theDialog->setWindowFlags(flags);
        theDialog->setModal(false);
        theDialog->setEnabled(true);
        theDialog->show();
        if(savedPos.isNull()) theDialog->move(QPoint(200, 200));
        else theDialog->move(savedPos);
        theDialog->resize(250, 250);
        btn->setText("Destroy");
        qDebug() << "dialog pos after creation" << theDialog->pos();
    });
    setCentralWidget(btn);
}

MainWindow::~MainWindow()
{
}

main.cpp:
#include "mainwindow.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}


text:
Q: Get usernames and IP addresses via tcpdump (or another capture tool) connecting to a MySQL server I've MySQL installed on my Ubuntu server.
Because I would like to clean up my users they're currently active in MySQL, I would like to check first which users - and from which host - are connecting to the MySQL server.
The only thing I need is: which host is connecting and which username is used.
I tried to perform this task with tcpdump, but with no luck so far. It looks easy to get the whole query, but I do not get the above mentioned information.
The server is heavily used, if there is no other option I can enable the general query log, but if it is possible I would like to prevent this option.
Does anyone have a tip for me on how I can perform this task?

A: *

*list currently active sessions

In your mysql prompt, you may typ the following for displaying currently active sessions:
mysql> show processlist;

Or this mysql query (which return the same info):
mysql> select * from information_schema.processlist;

And you may only get the {user,host} pair like that:
mysql> select User,Host from information_schema.processlist;

*log and display query history.

Turn on mysql query log
set global log_output = 'table';
set global general_log = 'on';

See all the executed queries
select * from mysql.general_log;

See the timestamp, the host_user and the related query:
select event_time,user_host,argument from mysql.general_log;

Hope it helps.


text:
Q: Extract attachments from EML files I currently use this code to Extract attachments from EML files. And I wanted to know if I can link the attachment to mail (EML file). That is, add the eml file name as the attachment name prefix.
So I can know the attachment belongs to what mail.
Thank You
import os, re
import email
import argparse
import olefile

def extractAttachment(msg, eml_files, output_path):
    #print len(msg.get_payload())
    #print msg.get_payload()
    if len(msg.get_payload()) > 2:
        if isinstance(msg.get_payload(), str):
            try:
                extractOLEFormat(eml_files, output_path)
            except IOError:
                #print 'Could not process %s. Try manual extraction.' % (eml_files)
                #print '\tHeader of file: %s\n' % (msg.get_payload()[:8])
                pass

        elif isinstance(msg.get_payload(), list):
            count = 0
            while count < len(msg.get_payload()):
                payload = msg.get_payload()[count]
                #récupérer les pièces jointes
                filename = payload.get_filename()
                #os.rename(filename,'rrrrr'+filename)
                #filename=os.path.join(str(filename), str(eml_files))
                if filename is not None:
                    try:
                        magic = payload.get_payload(decode=True)[:4]
                    except TypeError:
                        magic = "None"
                    # Print the magic deader and the filename for reference.
                    printIT(eml_files, magic, filename)
                    # Write the payload out.
                    writeFile(filename, payload, output_path)
                count += 1

    elif len(msg.get_payload()) == 2:
        payload = msg.get_payload()[1]
        filename = payload.get_filename()
        try:
            magic = payload.get_payload(decode=True)[:4]
        except TypeError:
            magic = "None"
        # Print the magic deader and the filename for reference.
        printIT(eml_files, magic, filename)
        # Write the payload out.
        writeFile(filename, payload, output_path)

    elif len(msg.get_payload()) == 1:
        attachment = msg.get_payload()[0]
        payload = attachment.get_payload()[1]
        filename = attachment.get_payload()[1].get_filename()
        try:
            magic = payload.get_payload(decode=True)[:4]
        except TypeError:
            magic = "None"
        # Print the magic deader and the filename for reference.
        printIT(eml_files, magic, filename)
        # Write the payload out.
        writeFile(filename, payload, output_path)
    #else:
    #    print 'Could not process %s\t%s' % (eml_files, len(msg.get_payload()))

def extractOLEFormat(eml_files, output_path):
    data = '__substg1.0_37010102'
    filename = olefile.OleFileIO(eml_files)
    msg = olefile.OleFileIO(eml_files)
    attachmentDirs = []
    for directories in msg.listdir():
        if directories[0].startswith('__attach') and directories[0] not in attachmentDirs:
            attachmentDirs.append(directories[0])

    for dir in attachmentDirs:
        filename = [dir, data]
        if isinstance(filename, list):
            filenames = "/".join(filename)
            filename = msg.openstream(dir + '/' + '__substg1.0_3707001F').read().replace('\000', '')

            payload = msg.openstream(filenames).read()
            magic = payload[:4]
            # Print the magic deader and the filename for reference.
            printIT(eml_files, magic, filename)
            # Write the payload out.
            writeOLE(filename, payload, output_path)
#filename = str(eml_files)+"--"+str(filename)
def printIT(eml_files, magic, filename):
    filename = str(eml_files)+"--"+str(filename)
    print ('Email Name: %s\n\tMagic: %s\n\tSaved File as: %s\n' % (eml_files, magic, filename))

def writeFile(filename, payload, output_path):

    filename = str(eml_files)+"--"+str(filename)
    try:
        file_location = output_path + filename
        open(os.path.join(file_location), 'wb').write(payload.get_payload(decode=True))
    except (TypeError, IOError):
        pass

def writeOLE(filename, payload, output_path):
    open(os.path.join(output_path + filename), 'wb')
def main():
    parser = argparse.ArgumentParser(description='Attempt to parse the attachment from EML messages.')
    parser.add_argument('-p', '--path',default='C:\\Users\\hamd\\Desktop\\TEX\\emails' ,help='eml')#Path to EML files
    parser.add_argument('-o', '--out', default='C:\\Users\\hamd\\Desktop\\TEX\\PJ\\eml_files\\',help='pj')#Path to write attachments to.
    args = parser.parse_args()

    if args.path:
        input_path = args.path
    else:
        print ("You need to specify a path to your EML files.")
        exit(0)

    if args.out:
        output_path = args.out
    else:
        print ("You need to specify a path to write your attachments to.")
        exit(0)

    for root, subdirs, files in os.walk(input_path):
        for file_names in files:
            eml_files = os.path.join(root, file_names)
            msg = email.message_from_file(open(eml_files))
            extractAttachment(msg, eml_files, output_path)

if __name__ == "__main__":
    main()

A: I tried to write this as a comment but is was too long. I won't give a full blown solution, but I'll explain the idea.
A possible solution would be to create an hard link to the extracted attachment, giving to the hard link the same name of EML file. You can append an incremental suffix if you have more attachments in the same EML file:
whatever.eml    (original email file)
whatever_001.attch    (hard link to first extracted attachment)
whatever_002.attch    (hard link to second extracted attachment)
...

This way:

*

*you are free to move the extracted attachment anywhere else (but in the same disk, because hard links by definition work only on the same disk)

*you can keep a copy of the attachment (the hard link) together with the EML file without consuming disk space

*in case the extracted file is deleted you have a backup copy of the attachment (the hard links) without consuming disk space

In Python you can create an hard link simply with:
import os
os.link(existing_target_file, new_link_name)


text:
Q: Parsing 2D array in JSON using Java I have a json file with the following format.
I'm having trouble with parsing the "Locations" segment which value is a double[][] array.
What is the best way to parse it?
Also, I can't figure out how to read the file, I used json.simple but it requires to cast every JSONObject or JSONArray, which is a bit uncomfortable to use.
[
  {
    "ID": 123456,
    "Locations": [
      [37.785220, -122.404378],
      [37.786661, -122.404571],
      [37.786356, -122.408992]
      ],
      "Time": 1426510324,
      "Tests Failed" : ["T1", "T2", "T5"]
  },
  {
    "ID": 123456,
    "Locations": [
      [37.793450, -122.422616],
      [37.782869, -122.462613],
      [37.772964, -122.458579],
      [37.762787, -122.458922]
      ],
      "Time": 1426510325,
      "Tests Failed" : ["T3", "T5", "T6"]
  },
  {
    "ID": 123456,
    "Locations": [
      [37.778689, -122.514214],
      [37.782759, -122.511639],
      [37.805187, -122.468924],
      [37.771611, -122.468666],
      [37.759059, -122.457336]
      ],
      "Time": 1426511324,
      "Tests Failed" : ["T1", "T5", "T7"]
  }
]

A: Using Gson you can simplify parsing the double[][] array as
String input = "[\r\n" +
        "  {\r\n" +
        "    \"ID\": 123456,\r\n" +
        "    \"Locations\": [\r\n" +
        "      [37.785220, -122.404378], \r\n" +
        "      [37.786661, -122.404571],\r\n" +
        "      [37.786356, -122.408992]\r\n" +
        "      ],\r\n" +
        "      \"Time\": 1426510324,\r\n" +
        "      \"Tests Failed\" : [\"T1\", \"T2\", \"T5\"]\r\n" +
        "  }]";

// Parse the input as an array
JSONArray jArr = new JSONArray(input);

// Get the required Location object
JSONObject jObj1 = jArr.getJSONObject(0);

// Get the Locations
String locations = jObj1.getJSONArray("Locations").toString();

// Parse using Gson
double[][] dArr = new Gson().fromJson(locations, double[][].class);

// Print the array
for (double[] d : dArr) {
    System.out.println(Arrays.toString(d));
}

Output :
[37.78522, -122.404378]
[37.786661, -122.404571]
[37.786356, -122.408992]

A: You can parse the object without using any JSON library by creating your own custom functions. For instance :
function getSpecificLocation(object, index, x, y){
    return object[index].Locations[x][y]
}

You can retrieve the Location (0,1) of the 3rd element with :
getSpecificLocation(t,0,0,1)

where t is your JSON object


text:
Q: Ruby on Rails for developing Real Time Application? or Node.js? Can Ruby on Rails be used for developing Real Time Application (similar to like Facebook, twitter, geekList ) ? What sort of database (NoSql), REST API is required ? Node.js seems to be popular for RTA. Any insight will be greatly appreciated?

A: You can try with Faye, but if you want development real time application, I think Node.js is the best. :)...Sorry, I'm only beginner developer :)

A: Ruby and Rails can definitely be used for that (twitter was originally a Rails app).  What kind of db you need will depend on the specifics of your application.  I am guessing from your question that you are a beginner. In that case, I would guess this is one of your first applications and you are trying to figure out which technology to you.  I suggest you pick whichever one you are most interested in.  You can do the kind of application you are talking about in most modern web frameworks.


text:
Q: NGINX. How get all request as GET request? I want return files for all  POST  and  GET request.
My current config is :
server {
    root         /server/files;
    server_name     files.example.net;
}

Currently I return  files only if request is GET.
How can I setup my nginx server? Please help me.

A: Not sure if this is the correct way to solve this, but it seems to work:
error_page 405 =200 $request_uri;


text:
Q: new orders are not showing in orders grid I upgraded to 2.3.1
I am using only PayPal as a payment method.
new orders are not showing in the orders grid in Admin > Sales > Orders
when I check PayPal summary I can find the invoice number so it is created in Magento but not showing in the grid
I already tried to change
Store > Configuration > Advance > Developer > Grid Settings
Enable / Disable, flush cache, reindex,  but not working
update: When I check sales_invoice there is no recent invoice! But in PayPal summary I have the invoice number and items!

A: Clear the var and generated folders and run cron
rm -rf var/*
php bin/magento setup:upgrade
rm -rf var/*
rm -rf generated/*
php bin/magento cache:clean
php bin/magento cron:run
php bin/magento cron:run


text:
Q: How can I write that the lone prime number that is followed by a perfect cube is seven in predicate logic? I have a general idea of how to prove this statement, but I'm having trouble translating the statement to predicate logic. My attempt is as follows:
$P(x): x$ is prime
$\forall m \in \mathbb{N}, \exists x \in \mathbb{N}, x = m^3 -1 \land P(x) \Rightarrow x = 7 $

A: Adrian is right that the $\exists$ should be a $\forall$. Why? Because otherwise, we can make the conditional vacuously true simply by pointing to any $x$ for which the antecedent is false, and thus the statement would be true without saying anything interesting about any numbers that do have the property of being one less than a perfect cube. Indeed, note what I used there: 'any'!  That is, it is true that for any number whose successor is a perfect cube, that number will have to be $7$, and so we really need to use a universal quantifier, i.e.:
$\forall m \in \mathbb{N}, \forall x \in \mathbb{N}, ((x = m^3 -1 \land P(x)) \Rightarrow x = 7)$
or, what is the equivalent:
$\forall x \in \mathbb{N}, (\exists m \in \mathbb{N}, (x = m^3 -1 \land P(x)) \Rightarrow x = 7)$
I am wondering if maybe you used $\exists \ x$ because when translating 'there is only ...' or 'there is a unique ...' you are typically not told what this special something is, and hence you do need to introduce an existential. That is, if the sentence was: 'There is only one number whose successor is a perfect cube', you'd do:
$\exists y \in \mathbb{N}, \forall x \in \mathbb{N}, (\exists m \in \mathbb{N}, (x = m^3 -1 \land P(x)) \Rightarrow x = y)$
But in this case we know what this 'special something' is: it is $7$, and so we don't need the $\exists$.  But, we do need the $\forall$ in order to rule out any numbers other than $7$ to have the property in question.
However, notice that we actually want to do something more than ruling out anything other than $7$ to have this property. You also want to say that $7$ actually has this property. That is, the way the statement is now, we don;t know whether $7$ has the property or not, but the statement clearly suggests that it does.  So, I would do:
$\forall x \in \mathbb{N}, (\exists m \in \mathbb{N}, (x = m^3 -1 \land P(x)) \Leftrightarrow x = 7)$


text:
Q: Adding Default Opportunity Team via Javascript Button using SFORCE To Replicate 'Default Opportunity Member' I created a Javascript Button and below is the Code:
{!REQUIRESCRIPT('/soap/ajax/33.0/connection.js')}
{!REQUIRESCRIPT('/soap/ajax/33.0/apex.js')}

var opObj = new sforce.SObject("Opportunity");
var userTeamObj = new sforce.SObject("UserTeamMember");
opporObj = '{!Opportunity.Id}';
var getOwner = sforce.connection.query("select id, Ownerid from Opportunity where id = '{!Opportunity.Id}'");
var ownID = getOwner.records.OwnerId;

var usersWithTeam = [];
usersWithTeam = sforce.connection.query("SELECT Id, TeamMemberRole, OpportunityAccessLevel, userId  FROM UserTeamMember where OwnerId = '"+ownID+"'");

var ot = [];
for(var i = 0; i < usersWithTeam.size; i++){
    if(usersWithTeam.records[i].OpportunityAccessLevel != '' && usersWithTeam.records[i].TeamMemberRole != ''){
        console.log('user ---'+usersWithTeam.records[i]);
        var opTeamObj = new sforce.SObject("OpportunityTeamMember");
        opTeamObj.UserId = usersWithTeam.records[i].UserId;
        opTeamObj.OpportunityId = opporObj;
        opTeamObj.OpportunityAccessLevel = usersWithTeam.records[i].OpportunityAccessLevel;
        opTeamObj.TeamMemberRole = usersWithTeam.records[i].TeamMemberRole;
        ot.push(opTeamObj);
    }
}

var result = sforce.connection.create(ot);
console.log('result--'+result);

But, it's giving me the below error:

message:'Unable to create/update fields: OpportunityAccessLevel. Please check the security settings of this field and verify that it is read/write for your profile or permission set.', statusCode:'INVALID_FIELD_FOR_INSERT_UPDATE'

I checked all the permission and they are fine. I did the same functionality using Apex Class in Anonymous Window and was able to do this easily. But I am unable to understand why this is giving me error in this case.


text:
Q: Linux Kernel - traverse to buffer heads In the Linux kernel, is there a way to traverse down to the buffer_heads from within a module?
I can see how to get to struct bio (task_struct macro: current->bio). But how can I get to the buffer heads? The buffer_head struct holds some information I'd like to obtain at any point regarding physical block numbers.

A: Nevermind. I was looking at this wrong.


text: Q: i am new to writing angularjs directives how to add style to directive template I was using the


text:
Q: Ionic 2 : Take picture like a scan I develop an app with Ionic 2 and cordova and I want to have the same effect I already found in apps like "Tiny Scanner", "Clear Scanner" or "Fast Scanner" in the google play store.
I want to know if exist a cordova plugin to do something like that when I take a picture in my application ?
Thanks for your help ! :)


text:
Q: How to get the Signal-to-Noise-Ratio from an image in Python? I am filtering an image and I would like to know the SNR. I tried with the scipy function  scipy.stats.signaltonoise() but I get an array of numbers and I don't really know what I am getting.
Is there any other way to get te SNR of my image?

A: UPDATE: (for those who don't read linked material in the comments)
The scipy.stats.signaltonoise function has been deprecated and removed. In the linked github thread, you can find the original recipe to implement it yourself:
def signaltonoise(a, axis=0, ddof=0):
    a = np.asanyarray(a)
    m = a.mean(axis)
    sd = a.std(axis=axis, ddof=ddof)
    return np.where(sd == 0, 0, m/sd)

Original answer:
The reason you are getting an array back rather than a single number, is because you haven't specified axis=None in your call to scipy.stats.signaltonoise.
Thus, you probably needed this:
snr = scipy.stats.signaltonoise(img, axis=None)

Without that option, you will get the SNR for every column in the image. This makes a lot of sense when the data is not actually an image, but a sequence of time signals for example.


text:
Q: What do I do after I have installed a RTL8814AU driver? I've downloaded this file:
https://github.com/xxNull-lsk/rtl8812AU/blob/a88cb341d021b58397307a144b1af1d9941da5c0/os_dep/linux/usb_intf.c
I then followed the steps they had in README.md:
$ make
$ sudo make install
$ sudo modprobe -a 8812au

$ sudo make -f Makefile.dkms install

$ sudo apt-get install build-essential
$ sudo apt-get install linux-headers-4.4.0-67-generic

I bumped into no errors along the way, however when I plug in my adapter, nothing happens.
Is there another procedure I have to go through?
Thanks

A: You device is RTL8814AU. You can install a driver from git.
Connect to internet by another way and run:
sudo apt update
sudo apt install git dkms
git clone https://github.com/ScrambledAuroras/rtl8814AU.git
cd rtl8814AU
sudo ./dkms-install.sh


text:
Q: how to align flex items to represent a bar chart I have been trying to style the react component so that it looks like a horizontal bar chart. However, I am unable to align the centre div to the left as expected.
here is my react component for each row.
import React from 'react'

const level3UnitItem = ({ item, ratio }) => {
    return (

{item.country}

            <div style={{ width: `${ratio * 400}px`, backgroundColor: 'red' }} className='bar-div'>

{item.population.toLocaleString('en-US')}

    )
}

export default level3UnitItem

here is the css
.country-div{
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    margin: .2px;
}
.country-div h1, h2{
    font-size: small;
}

and the current design is

I am expecting it to be

A: You will have to put 'name-div' and 'bar-div' inside another div(a parent div), like this:
import React from 'react'

const level3UnitItem = ({ item, ratio }) => {
return (

{item.country}

         <div style={{ width: `${ratio * 400}px`, backgroundColor: 'red' }} className='bar-div'>

{item.population.toLocaleString('en-US')}

)
}

export default level3UnitItem

CSS for 'name-bar-container' div:
.name-bar-container {
  width: 100%;
  display: flex;
}

you can also add margin-left to 'bar-div' to format it.

A: Can you try this? i add div inside the center div. then style it..
import React from 'react'

const level3UnitItem = ({ item, ratio }) => {
return (

{item.country}

              <div style={{ width: `${ratio * 400}px`, backgroundColor: 'red' }} className='bar-div'>

{item.population.toLocaleString('en-US')}

)
}

export default level3UnitItem

and as for the css
   .country-div{
      width: 100%;
      display: flex;
      justify-content: space-between;
      padding: 1rem;
      margin: .2px;
   }

  .country-div h1, h2{
     font-size: small;
  }

  .__toLeft {
      display: flex;
      justify-content: flex-start;
      align-items: center;
  }

A: 1. Create a container element and set its display property to "flex" to make it a flex container.

2. Create the individual flex items that will represent the bars of the chart. These can be div elements or any other HTML elements you prefer.

3. Set the width of each flex item to the appropriate percentage based on the data you want to represent in the chart. For example, if you want to represent a 50% value, set the width of the flex item to 50%.

4. Set the height of each flex item to a fixed value, such as 20px, to create a consistent height for all the bars in the chart.

5. Use the align-items property on the flex container to align the bars vertically. For example, use "align-items: center" to center the bars vertically in the container.

6. Use the justify-content property on the flex container to align the bars horizontally. For example, use "justify-content: space-between" to distribute the bars evenly across the container.

7. Use CSS to add colors and other styling to the flex items to make them look like bars in a chart.

8. Finally, add labels and other text elements to the chart to provide context and information about the data.

Note: To make the chart responsive, you can use media queries to adjust the width and height of the flex items and container based on the screen size.

A: I figured a a way to align those elements by wrapping the last two div(inside parent-div) into a new div and that solve my porblem.

import React from 'react'

const level3UnitItem = ({ item, ratio }) => {
    return (

{item.country}

                <div style={{ width: `${ratio * 400}px`, backgroundColor: '#ffa500 ' }} className='bar-div' >

{item.population.toLocaleString('en-US')}

    )
}

export default level3UnitItem
.country-div{
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: .3rem;
    margin: .2px;
    /* border: 1px solid black;
    border-radius: .25rem; */
    line-height: 2;
 }

.country-div h1, h2{
   font-size: small;
}
.name-div{
    width: 300px;
}
.barbar-div{
    width: 100%;
    display: flex;
    justify-content: space-between;
}


text:
Q: Populating many controls from the database (architecture and performance concerns) So I have this page that collections a lot of information to create a little complicated object. so I collect all the related details together in a div and I have like 7 Divs, and I populate like 20 controls (DropDownListss, CheckBoxLists, Repeaters, etc).
Now I'm just creating methods to be called on Click and Page_Load events.
each population process is done separately.
The code is a hassle and I don't except the performance to be good either, because I know that a lot of connections/trips to the database is not good for performance and the load on the database.
so how can I put this functionality in a better design and a better performance, any help here =) ?

A: Why not load all this data in Page_Load?  Then once in memory (whether in objects, data readers, or data sets), populate your controls?

A: That's a slightly philosophical question. As far as page perf. goes you shouldn't see a problem with only 20 controls. However, you have two key bottlenecks:
1) Get from database
You need to try and get all of the data from the database at once. Of course that's not always possible but it will save you a couple roundtrips. You can also cache that object for the current request.
2) Save
if you write to db on each change event on postback, it will take unnecessarily long. I'd suggest you crete a Model property that gets the model from the db and each change handler changes that model. Once the postbacks have all fired (I can't remember the best event now, but I think Page_Load is ok) write that model to the database in one single commit.
As far as performance goes, this is probably the least effort for maximum gain. You can also load controls with Ajax to make seem faster but it doesn't solve anything.

A: NHibernate has very nice feature called NHibernate Futures (but not all databases are supported). You could also get another benefits from it such as caching out of the box, batching write queries and so on. So I recommend to consider this option.
BTW, do you really need all this information at the same time on the screen? You could split your UI layer and create, for example, wizard.

A: If you write the SQL queries yourself, you can combine most queries so that you only need one query per table.
E.g. you might have table dropdown_choices, which has dropdown_id and choice columns.
You could SELECT all the data that concerns you and then split it up in your code.
SELECT * FROM dropdown_choices WHERE dropdown_id IN (1, 2, 3, 10, ...);


text:
Q: strtok() behavior that I don't understand
I'm hoping to use strtok() in a C program I'm writing. I was trying to fiddle with it a little to jog my memory with it, and get back in practice with it, and ran into some behavior that I can't understand.
It seems like... my program is just exiting when I get to the strtok() call? I don't even get a seg fault, core dump, anything like that... the program just apparently stops running. I've no idea what's going on, or whether I'm doing something wrong.
Thoughts? Suggestions?
C file.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    printf("hello\n\n");

    char * str1 = "14:26";

    char * tokens1 = ":";
    char * curtok = strtok(str1, tokens1);
    printf("just got past first strtok() call.\n\n");

    printf("str1 is %s\n", str1);
    printf("tokens1 is %s\n", tokens1);
    printf("Is (curtok == (str1 + 2)) ? \n");
    if (curtok == (str1 + 2))
        printf("yes\n");
    else
        printf("no\n");
    printf("\n");

    curtok = strtok(NULL, "\0");
    printf("tokenizing for the null terminator.\n");
    printf("Is (curtok == (str1 + 5))? (Ie., did it give us the index of the null terminator?)\n");
    if (curtok == (str1 + 5))
        printf("yes\n");
    else
        printf("no\n");

    return 0;
}

Output.
C:\Users\Ryan\Documents\WSU\Classes\20 - 21\WSU Spring 2021\cs360_sys_programming\pa4
> .\fiddling-with-strtok.exe
hello

C:\Users\Ryan\Documents\WSU\Classes\20 - 21\WSU Spring 2021\cs360_sys_programming\pa4
>

Using mingw on Windows, output of gcc --version is gcc (tdm64-1) 5.1.0. I got the same result when using an online C shell, see http://cpp.sh/52gwv .
I've previously used strtok() in other things I've done (for school), but maybe I'll just make my own string tokenizer for this program.


text:
Q: data bind if does show div knockout js So I was trying to show some divs which basically shows different color of boxes depending on the numbers they have, basically AA and B both returns 5 so they should be showing and the other divs should be blank or empty and basically not even showing the divs, but for some reason now all the data-binds dont show anything and I get empty divs.

 0">
                                AAA

 0.00">
                                AA

 0.00">
                                A

 0.00">
                                 B

 0.00">
                                 C

                            Not invested

Not sure if this is important but the AAA and AA and so on are all ko computed.
Here is the image if I use if AA or if AAA

A: I have came across this same issue few times as well. After that I always try to use either if in comments or visible binding:
For example:

                                AAA

Or with visibility:

                                AAA

If above fails, then i suggest you re-check your variables since there is no valid reason why it wouldn't work.

A: When you're evaluating the observable against a condition, you need to do:
data-bind="if: AAA() > 0"

instead of
data-bind="if : AAA  > 0"

Likewise for the other if's

A: When you're creating expressions that contain an observable inside a knockout binding, you need to evaluate the observable yourself.
I.e.: You'll need to write your data-binds in the form of: data-bind="if: AAA() > 0"
Explanation:
Knockout wraps the values you input in your binding in a function. The AAA in if: AAA becomes function() { return AAA; }. If this function returns an observable instance, it evaluates the observable's value and subscribes to changes.
When you create an expression inside your binding, the observable that might be in there gets lost in the wrapper function: function() { return AAA > 0; } will compare your observable instance to the value 0. This will simply return false, no matter what the observable's value is.

A: try this
data-bind="visible: AAA() > 0"


text:
Q: Can using cloud storage for backup backfire and ruin local data? I was thinking of using a simple backup strategy like copying my Documents directory into the Dropbox directory.
This strategy should work in case my laptop gets stolen or my house burns down. But if the data gets corrupted on the part of the cloud storage provider, the corrupted data will be synchronized with my local directory and I will lose the data from both locations.
More likely I can accidentally corrupt the local data and it will be synchronized with the remote version and destroy the data on both locations.
Is my reasoning correct? If so, does the following strategy make sense?
In addition to backing up to Dropbox, I would back up to a local directory using for example Deja Dup. This way the data is protected against both destruction and corruption of the data.

A: Corruption of files sent to Dropbox (or any cloud-based service) is pretty much non-existent. I would argue that since Dropbox uses TCP as its file transfer protocol, it is assured that files on either end are the same.
Corruption of files in Dropbox is also a non-existent problem, as generally these sorts of services maintain backups in case of a severe or catastrophic failure on one of their servers (these companies wouldn't stay up if they couldn't keep your files safe, which is one of the main selling points of this kind of product). Dropbox also has a form of differential storage, so that you can, in some cases, revert back to an older version of a file.
Local (unintended) corruption is also difficult, having in mind the usually high-reliability of consumer storage media. Of course nothing stops you from messing around in your own files.
I have used Dropbox for several years and quite probably the biggest problem I have had with it was due to shared folder ownership. As it turns out, space is handled in a relatively easy way: the one who creates the folder owns every file in it, even if uploaded by other users. This can corrupt files only if the folder creator has no free space. Dropbox tries to upload a preexisting file, whose newer version is heavier. In this particular case, nothing is changed in Dropbox and the older version remains.

A: But if the data gets corrupted on the part of the cloud storage provider, the corrupted data will be synchronized with my local directory and I will lose the data from both locations.
Is my reasoning correct? - No
Only the local Dropbox folder could potentially be corrupted. The data in your My Documents folder won't be corrupted because Dropbox isn't synching with that folder.


text:
Q: How do you debug a record triggered flow triggered by owner change? How does one debug an before save flow triggered by owner change?
I have a before save trigger that checks if the account owner has been changed and if so proceeds to do a second check then updates the record.
I think my logic is correct but the record is not getting updated and I don't know any other way to debug since running the flow in debug mode, the ownerid is greyed out.
The tier change path is working correctly but the owner change is not.
I am testing by changing the owner in a record where the target tier is top 5(as seen in decision element) but the update is not happening so I am guessing the path is not being taken at all.
Thanks!
See the attached screenshots.


text:
Q: Mix AdMob and other Ad solution in one Android app I'm wondering if it's not against the AdMob's policy to use it alongside with other ad solution in one Android app?
Thanks,
ToM

A: Yes, it's against. Don't do this, they will ban you.


text:
Q: Create new folder with user-defined name and location in java I am using JavaFX to write a script, part of which involves the user selecting an existing project, or creating a new one.  In the latter case I have a popup window that prompts the user for a name and a place to save the project.  What I hope to do is create a folder in the place that the user specifies with the same name as the project, from here I will save different items to it and load them later.  However when I use filechooser to have the user pick the location for the folder it requires them to select an item before the chooser actually picks anything.  Then the folder that it makes has the name of this item in the beginning.  (For example if I picked the Chrome shortcut on my desktop the folder name would be chrome.exeProject1 or something like that)
I know part of the problem is because I reused part of my filechooser code for a different function where I required the user to have an item selected before they could submit it, anyway...
Is there any way for the user to select a folder, or just submit the filechooser without selecting any items and create the new folder here? (Inside the selected folder or in the current folder in the latter case).
relevant code below, any help is appreciated. Thanks!
@FXML
private void submitName(ActionEvent event) {
    name = nameOfProject.getText();
    if (name != null && location != null)
    {
        new File(location + name).mkdir();
    }
}

@FXML
private void createProjectDirectory(ActionEvent event) {
    FileChooser projectDirectory = new FileChooser();
    projectDirectory.setTitle("Create Project Directory:");
    File refLocation = projectDirectory.showOpenDialog(null);
    if (refLocation != null) {
        locationOfProject.clear();
        location = refLocation.getPath();
        locationOfProject.appendText(location);
    }
}

A: You have to use DirectoryChooser instead of FileChooser to let the user select a directory.
You can read the documentation on how to use these classes here (it's from JavaFX 2, but I guess the interface is mostly the same).


text:
Q: Display the side menu in ionic using different pages I am trying to display the side menu in ionic, I wrote the code for side menu.
If I write all the code in a single page, it is displaying the side menu and drag is also working.
Same way, I am trying to display the side menu proving route $stateProvider, here the root is working and also it is going to home page without any problem. But in home page, it is displaying empty, I mean white page and I tried just wrote text using h1 tag at that time also it is displaying white page.
My requirement is, if I click or drag the menu in home page it should open the side menu and also must be code in different files.
INDEX.HTML
<!DOCTYPE html>

    <title>IonicSideMenu Example</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <link href="http://code.ionicframework.com/1.0.0-rc.4/css/ionic.min.css" rel="stylesheet">

    <ion-nav-view animation="slide-left-right"></ion-nav-view>

MODULE.JS
var ionicInfoApp = angular.module('ionicApp', ['ionic']);

CONFIG.JS
ionicInfoApp.config(function($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('/Home', {
            templateUrl: 'Home.html',
            controller: "MenuController"
        })
        .state('/Item1', {
            templateUrl: 'item1.html'
                // controller : "MenuController"
        })
        .state('/Item2', {
            templateUrl: 'item2.html'
                //controller : "MenuController"
        })
    $urlRouterProvider.otherwise('/Home');
});

AppCtrl
ionicInfoApp.controller('AppCtrl', function($scope, $ionicSideMenuDelegate) {

    ionic.Platform.ready(function() {

    });

});

MenuController
ionicInfoApp.controller('MenuController', function($scope, $ionicSideMenuDelegate) {
    $scope.toggleLeft = function() {
        $ionicSideMenuDelegate.toggleLeft();
    }
});

HOME.html

    <ion-side-menus>
        <ion-side-menu-content>
            <ion-header-bar class="bar-dark">
                <button class="button button-icon icon ion-navicon" ng-click="toggleLeft()"></button>

App

            </ion-header-bar>
            <ion-content>
            </ion-content>
        </ion-side-menu-content>
        <ion-side-menu side="left">
            <ion-header-bar class="bar-dark">

Projects

            </ion-header-bar>
            <ion-content>

Item1

Item2

            </ion-content>
        </ion-side-menu>
    </ion-side-menus>

A: Keep the ion-side-menus directive in index.html and use ng-include to load in it the right template depending on a string variable with template url.
https://docs.angularjs.org/api/ng/directive/ngInclude
That variable could be selected in state provider, look for how to attach custom data to state objects

A: Side Menus should not be in your ionNavBar container. In your code , its just some things don't really work well when they are not placed in the correct place.
home.html
<ion-side-menus enable-menu-with-back-views="false">
    <ion-side-menu-content>
        <ion-nav-bar class="bar-stable">
            <ion-nav-back-button>
            </ion-nav-back-button>
            <ion-nav-buttons side="left">
                <button class="button button-icon icon ion-navicon" menu-toggle="left"></button>
            </ion-nav-buttons>
        </ion-nav-bar>
        <ion-nav-view name="menuContent"></ion-nav-view>
    </ion-side-menu-content>
    <ion-side-menu side="left">
        <ion-header-bar class="bar-dark">

Projects

        </ion-header-bar>
        <ion-content>
            <ion-item menu-close href="#/app/item1">
                Item1
            </ion-item>
            <ion-item menu-close href="#/app/item2">
                Item2
            </ion-item>
        </ion-content>
    </ion-side-menu>
</ion-side-menus>

config.js
ionicInfoApp.config(function($stateProvider, $urlRouterProvider) {

    $stateProvider
        .state('app', {
            url: '/app',
            // abstract: true,
            templateUrl: 'templates/menu.html',
            controller: 'menuController'
        })

    .state('app.item1', {
        url: '/item1',
        views: {
            'menuContent': {
                templateUrl: 'templates/item1.html'
            }
        }
    })

    .state('app.item2', {
        url: '/item2',
        views: {
            'menuContent': {
                templateUrl: 'templates/item2.html'
            }
        }
    });
    // if none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/app/item1');
});

If you need any help.Please let me know.Thanks


text:
Q: Mongodb $graphLookup build hierarchy I have an output from mongodb $graphLookup aggregation:
db.getCollection('projects').aggregate([
    {
    $lookup: {
      from: "projects",
      localField: "_id",
      foreignField: "parent",
       as: "childrens"
     }
 }
])

{
    "_id" : "1",
    "name" : "Project1",
    "parent" : null,
    "childrens" : [
        {
            "_id" : "3",
            "name" : "ProjectForId1",
            "parent" : "1"
        }
    ]
},
{
    "_id" : "3",
    "name" : "ProjectForId1",
    "parent" : "1",
    "childrens" : [
        {
            "_id" : "6",
            "name" : "ProjectForId3",
            "parent" : "3"
        },
        {
            "_id" : "7",
            "name" : "ProjectForId3",
            "parent" : "3"
        }
    ]
}

I need to build hierarchy from this output in javascript or if is possible directly from query so the final output should look like:
{
    "_id" : "1",
    "name" : "Project1",
    "parent" : null,
    "childrens" : [
        {
            "_id" : "3",
            "name" : "ProjectForId1",
            "parent" : "1",
            "childrens" : [
                {
                    "_id" : "6",
                    "name" : "ProjectForId3",
                    "parent" : "3"
                },
                {
                    "_id" : "7",
                    "name" : "ProjectForId3",
                    "parent" : "3"
                }
            ]
        }
    ]
}

Also if someone have a brave heart to help in one more case where the hierarchy will be created by filtering _id:
ex: For _id = "1" the output will be same as above but if _id is 3 the final output should look like:
{
    "_id" : "3",
    "name" : "ProjectForId1",
    "parent" : "1",
    "childrens" : [
        {
            "_id" : "6",
            "name" : "ProjectForId3",
            "parent" : "3"
        },
        {
            "_id" : "7",
            "name" : "ProjectForId3",
            "parent" : "3"
        }
    ]
}

A: Below solution is more or less the same as one of my past answers so you can get thorough explanation here
db.projects.aggregate([
    {
        $graphLookup: {
            from: "projects",
            startWith: "$_id",
            connectFromField: "_id",
            connectToField: "parent",
            as: "children",
            maxDepth: 4,
            depthField: "level"
        }
    },
    {
        $unwind: "$children"
    },
    {
        $sort: { "children.level": -1 }
    },
    {
        $group: {
            _id: "$_id",
            children: { $push: "$children" }
        }
    },
    {
        $addFields: {
            children: {
                $reduce: {
                    input: "$children",
                    initialValue: {
                        currentLevel: -1,
                        currentLevelProjects: [],
                        previousLevelProjects: []
                    },
                    in: {
                        $let: {
                            vars: {
                                prev: {
                                    $cond: [
                                        { $eq: [ "$$value.currentLevel", "$$this.level" ] },
                                        "$$value.previousLevelProjects",
                                        "$$value.currentLevelProjects"
                                    ]
                                },
                                current: {
                                    $cond: [
                                        { $eq: [ "$$value.currentLevel", "$$this.level" ] },
                                        "$$value.currentLevelProjects",
                                        []
                                    ]
                                }
                            },
                            in: {
                                currentLevel: "$$this.level",
                                previousLevelProjects: "$$prev",
                                currentLevelProjects: {
                                    $concatArrays: [
                                        "$$current",
                                        [
                                            { $mergeObjects: [
                                                "$$this",
                                                { children: { $filter: { input: "$$prev", as: "e", cond: { $eq: [ "$$e.parent", "$$this._id"  ] } } } }
                                            ] }
                                        ]
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    {
        $addFields: { children: "$children.currentLevelProjects" }
    },
    {
        $match: {
            _id: "1"
        }
    }
])

Last stage is supposed to be the filtering so you can get the data for any level of depth here.


text:
Q: silverlight 3.0 control in master page in asp.net 3.5 Can any body tell me how to add silverlight 3.0 control in master page in asp.net 3.5 (ide VS2008)?

A: Have a contentplaceholder in the master. Then create a webform for the masterpage. Place the silverlight control in the content part with the contentplaceholder set to masterpage contentplaceholder.

A: i done by simply copy script and object tag from your test page for xmal and put in master page that's it in content place holder of master page it wont get displayed for me