Migrating back to Xiaomi smartphone

After some hours, days of review/research the winner is Xiaomi Mi Note 10 Lite
https://www.gsmarena.com/xiaomi_mi_note_10_lite-10183.php
My current Sony Xperia XZ 2 https://www.gsmarena.com/sony_xperia_xz2-9081.php was great during 2 years of usage, but instead having IP68 https://en.wikipedia.org/wiki/IP_Code the Rotate a Brightness adaptation doesn’t work anymore 😦
My research candidates were OnePlus 7T (great HW and UI), Nokia 7.2 (due Android One participation) and Pixel 4
OnePlus folded due still high price, Nokia, because of the UI of bottom navigation and Google Pixel 4 is too expensive for the included hardware.

So Xiaomi became the winner due hardware, but also due previous good experience. My son inherited the Xiaomi Redmi 4A https://www.gsmarena.com/xiaomi_redmi_4a-8420.php from me and after his “caring” usage (5 year old) the phone still works (also the adaptive brightness and rotate)

DSC_0112

Hope that Android Auto will work properly.

Notes from Calibrating Memo of Howard Marks

“What I would to is figure out how much you’ll want to have invested by the time the bottom is reached”
 
“All great investments begin in discomfort. One thing we know is that there’s great discomfort today”
 
“Oaktree explicitly rejects the notion of waiting for the bottom; we buy when we can access value cheap.”
 
“The investor’s goal should be to make a large number of good buys, not just a few perfect ones.”
 

Mosaic/grid view of RTSP streams with ffmpeg

Finally found a solution for grid/mosaic playback of RTSP streams.

ffmpeg -rtsp_transport tcp \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/101 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/201 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/301 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/401 \
-filter_complex "
nullsrc=size=1920×1080 [base];
[0:v] setpts=PTS-STARTPTS, scale=960×540 [upperleft];
[1:v] setpts=PTS-STARTPTS, scale=960×540 [upperright];
[2:v] setpts=PTS-STARTPTS, scale=960×540 [lowerleft];
[3:v] setpts=PTS-STARTPTS, scale=960×540 [lowerright];
[base][upperleft] overlay=shortest=1 [tmp1];
[tmp1][upperright] overlay=shortest=1:x=960 [tmp2];
[tmp2][lowerleft] overlay=shortest=1:y=540 [tmp3];
[tmp3][lowerright] overlay=shortest=1:x=960:y=540
" \
-c:v libx264 -preset superfast -crf 18 -f matroska – | ffplay –

Source: https://trac.ffmpeg.org/wiki/Create%20a%20mosaic%20out%20of%20several%20input%20videos

Yahoo finance stock data in Google Spreadsheet

Made my first script in Google Spreadsheet

function YahooFinance(ticker) {
var ticker = ticker || "GOOG";
ticker = encodeURI(ticker);
var response = UrlFetchApp.fetch("https://query2.finance.yahoo.com/v7/finance/options/" + ticker);
var chain = JSON.parse(response.getContentText());
return parseFloat(chain.optionChain.result[0].quote.regularMarketPrice);
}

view raw
YahooFinance.js
hosted with ❤ by GitHub

 

In Spreadshhet just click Tools > Script editor to add the script

After saving the script you can call it in the spreadsheet cell

=IF(A2 <> "", YahooFinance(A2), 0)

 

Remotely connecting to existing X server via VNC server

My goal was to connect to a remote desktop. Had to tweak systemd to autologin with specific user.

sudo vim /etc/systemd/system/getty@tty1.service.d/autologin.conf
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin mike --noclear %I $TERM

I’m a zsh user so had to add the following into ~/.zprofile

if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
    exec startx
fi

So after these changes after rebooting the PC the X server started and I could connect to it.

Just had to start

x0vncserver -display :0 -rfbauth .vnc/passwd

Sat Mar 28 16:18:32 2020
 Geometry:    Desktop geometry is set to 3840x1200+0+0
 XDesktop:    Using evdev codemap
 XDesktop:    
 XDesktop:    XTest extension present - version 2.2
 XDesktop:    RANDR extension not present
 XDesktop:    Will not be able to handle session resize
 Main:        Listening on port 5900

The desktop has no public IP so I had to port forward

ssh vnc-server -L 9900:localhost:5900

Now I was able to connect with vncviewer

vncviewer localhost:9900
TigerVNC Viewer 64-bit v1.10.1
Built on: 2019-12-27 09:17
Copyright (C) 1999-2019 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.

Sat Mar 28 16:20:09 2020
 DecodeManager: Detected 8 CPU core(s)
 DecodeManager: Creating 4 decoder thread(s)
 CConn:       Connected to host localhost port 9900
 CConnection: Server supports RFB protocol version 3.8
 CConnection: Using RFB protocol version 3.8
 CConnection: Choosing security type VeNCrypt(19)
 CVeNCrypt:   Choosing security type TLSVnc (258)

Simple SSH login email notify

Wanted to track remote SSH port forward login and the following is a great solution

$ cat /etc/profile.d/ssh-login-notify.sh
if [ -n "$SSH_CLIENT" ]; then
TEXT="$(date): ssh login to ${USER}@$(hostnamectl –static)"
TEXT="$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')"
echo $TEXT|mail -s "ssh login" info@example.com
fi

view raw
ssh-login-notify.sh
hosted with ❤ by GitHub

Source https://askubuntu.com/a/702743/168459

EZVIZ C3W IP cam RTSP URL

Finally got the stream URL

$ mpv rtsp://admin:VERIFICATION_CODE_FROM_CAMERA@CAMERA_IP/
Playing: rtsp://admin:JFORKE@192.168.2.70/
[ffmpeg/demuxer] rtsp: Missing PPS in sprop-parameter-sets, ignoring
(+) Video --vid=1 (h264 1920x1080 15.000fps)
(+) Audio --aid=1 (aac 1ch 16000Hz)
File tags:
Title: Media Presentation
AO: [pulse] 16000Hz mono 1ch float
VO: [gpu] 1920x1080 yuv420p

Just replace CAMERA_IP with IP and VERIFICATION_CODE_FROM_CAMERA with your code from camera

More info at https://www.ispyconnect.com/man.aspx?n=EZVIZ

ezviz stream

Custom sorting for WooCommerce products order by

I had to really customize the order by of the main WP query. Finally looks like I nailed it.

function pn_woocommerce_product_query( WP_Query $wp_query ) {
if ( $wp_query>get( 'orderby' ) == 'menu_order title' ) {
$wp_query>set( 'meta_query', [
'relation' => 'AND',
'internal_stock' => [
'key' => '_manage_stock',
'compare' => 'EXIST',
],
'stock_status' => [
'key' => '_stock_status',
'compare' => 'EXIST',
],
'price' => [
'key' => '_price',
'compare' => 'EXISTS',
],
] );
$wp_query>set( 'orderby', [
'internal_stock' => 'ASC',
'stock_status' => 'ASC',
'price' => 'ASC',
] );
}
}
add_action( 'woocommerce_product_query', 'pn_woocommerce_product_query' );
function pn_posts_orderby_request( $orderby ) {
// Output based on pn_woocommerce_product_query()
if ( $orderby == 'CAST(pn_postmeta.meta_value AS CHAR) ASC, CAST(mt1.meta_value AS CHAR) ASC, CAST(mt2.meta_value AS CHAR) ASC' ) {
$orderby = "pn_postmeta.meta_value ASC, FIELD (mt1.meta_value, 'instock', '3days', 'outofstock'), mt2.meta_value ASC";
}
return $orderby;
}

view raw
order-by-field.sql
hosted with ❤ by GitHub

Hungarian Mother’s day date in Google Calendar

I wanted to have a repeated calendar event for Mother’s day, but it’s custom logic required making an ICS file and importing it into Google Calendar.

The ICS:

BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
RRULE:FREQ=YEARLY;BYMONTH=5;BYDAY=1SU
SUMMARY:Mother day in Hungary
DTSTART;VALUE=DATE:20190101
SEQUENCE:0
DESCRIPTION:
END:VEVENT
END:VCALENDAR

view raw
mother-day.ics
hosted with ❤ by GitHub

Inspired by/how to import into Google Cal How to Set up Repeating Event in Google Calendar on Last Day of the Month