Sunday, 28 November 2021

Upon restarting a Jupyter notebook, automatically run 1st/nth cell only (to load modules and other variables), ideally using a keyboard shortcut

In addition to loading required modules, in the first cell of the jupyter notebook, I usually load variables (e.g. metadata, tables etc.). So every time when I restart a jupyter notebook, I need to run the 1st cell of the notebook. I know this is not a big issue, but sometimes can be an annoyance. For example, if I would be working at the end of the notebook and need to restart it, I would have to scroll all the way up, run the first cell, and then scroll all the way back to resume the work.

I hope there is a way to automatically run 1st (or any n'th) cell of a jupyter notebook when it is restarted. I wonder if anybody knows if such a functionality exists.



from Upon restarting a Jupyter notebook, automatically run 1st/nth cell only (to load modules and other variables), ideally using a keyboard shortcut

Firebase server-timestamp differs from the correct time

I am trying to use firebase-server-timestamp to show the user when he/she send their order to us.

The problem I encounter is, that the server-timestamp is showing a wrong time (e.g: Current time is 12:30, but timestamp shows 12:15). How is that possible?

Android code

data class MyTimestampPOJO(
    val date: Timestamp = Timestamp.now(), // wrong, 15 minutes too early
)

Database screenshot (sending was at 12:50 and not 12:35)

enter image description here

I am testing this inside the firebase-emulator. The time on my phone is correct (even tho it does not matter, because the server-timestamp is independent to the phone-time, as it should be.)



from Firebase server-timestamp differs from the correct time

Android some EditText fields don't respond to long-press (API 30+ with layout_width 0dp)

I'm wondering if anyone else has experienced this strange bug. My layout is complicated but essentially it's rows of view holders with EditText fields.

It worked flawlessly until I updated my target SDK to API 30.

After targetting API 30, some of my EditText fields don't respond to "focus touch events" (the cursor handle doesn't show up, you can't long press, and you can't select any text). You can still type in the field and move the cursor by tapping. Again, some text fields work perfectly fine while others are affected by this bug.

enter image description here

^ The image is not of my app, just to show the cursor handler for understanding.

<!-- in constraint layout -->
<androidx.appcompat.widget.AppCompatEditText
    android:id="@+id/myTextField"
    android:layout_height="wrap_content"
    android:layout_width="0dp"
    app:layout_constraintHorizontal_weight="1"
    app:layout_constraintLeft_toRightOf="parent"
    app:layout_constraintRight_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"/>

<!-- in linear layout -->
<androidx.appcompat.widget.AppCompatEditText
    android:id="@+id/myTextField"
    android:layout_height="wrap_content"
    android:layout_width="0dp"
    android:layout_weight="1"/>

If I change the text fields width to wrap_content it works perfectly for all text fields, but that doesn't fit with my design. I need the text field to fill the available space.

I even tried manually setting the width to a random dp value and it still didn't work.

I've tested on < API 30 devices and it's totally fine.

Did I miss something? Why isn't this working on API 30+?

Is there another way to get the EditText field to fill the space?



from Android some EditText fields don't respond to long-press (API 30+ with layout_width 0dp)