Blog Posts


SQL Date

Posted 2022-04-22 8:19 by azri.

select date_format(time,'%Y-%m-%d %H:%i'), count(*)  from adsb_nopositions where time > '2022-04-21 15:00' group by date_format(time,'%Y-%m-%d %H:%i');

Changes to Flights Page

Posted 2022-04-17 16:30 by azri.

Flights Page: Added plot2.tpl so that when clicking the flight link, no markers can be seen

Notes:

  1. acID and flID in div class sidebar left
  2. Add below in flight.php (not flights.php):

            $dbh = $common->pdoOpen();
            $sql = "SELECT id, icao, firstSeen FROM ".$settings::db_prefix."aircraft WHERE id = :id";
            $sth = $dbh->prepare($sql);
            $sth->bindParam(':id', $position['aircraft'], PDO::PARAM_INT);
            $sth->execute();
            $aircraft = $sth->fetch();
            $sth = NULL;
            $dbh = NULL;


            $flightData['flId'] = $flight['id'];
            $flightData['acId'] = $aircraft['id'];
            $flightData['icao'] = $aircraft['icao'];
            $flightData['flight'] = $flight['flight'];

 

Lock wait timeout exceeded; try restarting transaction

Posted 2022-04-16 19:28 by azri.

show open tables where in_use>0;

show processlist;

kill id of offending process

Python Notes etc.

Posted 2022-04-16 4:08 by azri.

Python String manipulation
JSON & SQL
Forming SQL Queries from JSON
JSON Structure
Pretty printing
Boolean and limitations
Textmate & Regular Expressions
Exiting if clause
nano, less & textmate
has_key or in 
You could use :%s/. \{1}$// to delete 1 character off the end of each line.


python_map = { "foo": "bar", [ "baz", "biz" ] } sql = "INSERT INTO your_table (json_column_name) VALUES (%s)" cursor.execute( sql, (json.dumps(python_map),) )

https://stackoverflow.com/questions/4251124/inserting-json-into-mysql-using-python
https://stackoverflow.com/questions/36593638/python-list-comprehensions-join-with-for-loop
https://stackoverflow.com/questions/1388818/how-can-i-compare-two-lists-in-python-and-return-matches
https://stackoverflow.com/questions/8249539/python-how-to-concatenate-to-a-string-in-a-for-loop
https://stackoverflow.com/questions/4251124/inserting-json-into-mysql-using-python
https://towardsdatascience.com/how-to-best-work-with-json-in-python-2c8989ff0390
https://stackoverflow.com/questions/2069662/how-to-exit-an-if-clause
https://stackoverflow.com/questions/1323410/should-i-use-has-key-or-in-on-python-dicts
https://flexiple.com/check-if-key-exists-in-dictionary-python
https://stackoverflow.com/questions/11303032/how-to-add-text-at-the-end-of-each-line-in-vim
https://stackoverflow.com/questions/6118948/bash-loop-ping-successful
https://itsfoss.com/recover-deleted-files-linux/
https://stackoverflow.com/questions/28421864/how-do-i-remove-first-5-characters-in-each-line-in-a-text-file-using-vi

((count = 60))                           # Maximum number to try.
while [[ $count -ne 0 ]] ; do
    ping -c 1 8.8.8.8                    # Try once.
    rc=$?
    if [[ $rc -eq 0 ]] ; then
        ((count = 1))                    # If okay, flag loop exit.
    else
        sleep 1                          # Minimise network storm.
    fi
    ((count = count - 1))                # So we don't go forever.
done

if [[ $rc -eq 0 ]] ; then                # Make final determination.
    echo `say The internet is back up.`
else
    echo `say Timeout.`
fi



 

This will do it to every line in the file:

:%s/$/,/

If you want to do a subset of lines instead of the whole file, you can specify them in place of the %.

One way is to do a visual select and then type the :. It will fill in :'<,'> for you, then you type the rest of it (Notice you only need to add s/$/,/)

:'<,'>s/$/,/



Use str. replace() to replace a string in a list
  1. strings = ["a", "ab", "aa", "c"]
  2. new_strings = []
  3. for string in strings:
  4. new_string = string. replace("a", "1") Modify old string.
  5. new_strings. append(new_string) Add new string to list.
  6. print(new_strings)

 

FFmpeg

Posted 2021-11-05 16:56 by azri.

trim ffmpeg -ss 00:00:00 -i ErynaCat5.mp4 -to 00:00:30 -c copy ErynaCat6.mp4 scale x2 ffmpeg -i input.mp4 -vf scale=iw*2:ih output.mp4 downscale /2 ffmpeg -i input.mp4 -vf "scale=iw/2:ih/2" output.mp4 Encode the audio to AAC ffmpeg -i input.mov -c:v copy -c:a aac output.mp4 analyse volume ffmpeg -i input.wav -filter:a volumedetect -f null /dev/null change volume ffmpeg -i input.wav -filter:a "volume=10dB" output.wav

https://ottverse.com/change-resolution-resize-scale-video-using-ffmpeg/

https://trac.ffmpeg.org/wiki/AudioVolume