Wednesday, November 30, 2022

Plot your locations from photos on a map

 First, get location data and save to CSV file as follows:

% exiftool -filename -DateTimeOriginal -gpslatitude -gpslongitude -gpsaltitude -csv -T -r -n <photosdirectory>    > output-all.csv

Where <photosdirectory> is the full path to the photos directory. This will produce a CSV file with location data of each photo, when available. Please note that for some photos exiftool fails to extract the GPS data (see https://exiftool.org/forum/index.php?topic=14228.0)

Then use GPS Visualizer site to plot the data into a map: https://www.gpsvisualizer.com/map_input?form=data
File upload limit is 10MB, so if your file is too heavy, delete path info etc. and leave only GPS long/lat data with file name for example. Remove also lines without long/lat data because the photo does not have it. Using GPS Visualizer you can output as image, Google Maps etc.


Another way is to import the CSV file to Google Maps' My Maps, but there is a limit of 2000 lines per import (per layer), and there is also a limit of layers. With over 50 thousands data for example from my photos, My Maps cannot be used. When using Google Maps' My Maps, you can split the CSV file into 2000 lines using split command on Mac:

% split -l 2000 --numeric-suffixes  output-all.csv file output-all-



Wednesday, July 6, 2022

Control Android from Mac

 Use scrcpy (https://github.com/Genymobile/scrcpy) to control Android from a Mac:

Installation on Mac:

    brew install scrcpy

Then,

    scrcpy

If there is error related to android.permission.MANAGE_APP_OPS_MODES, enable "disable permission monitoring" in developer options.

Saturday, November 21, 2020

Create subtitle for your YouTube video on MacOS

If your language is supported by automatic captioning by YouTube, you are OK. But if not, then you can create your own. 1) Basically, follow this "Creating translated subtitles with AI" article Follow the steps in this article: https://cloud.google.com/community/tutorials/speech2srt However, some parts of the code needs to be updated to be compatible with current Speech API: 1-1) enums is deprecated #encoding = enums.RecognitionConfig.AudioEncoding.LINEAR16 encoding = speech_v1.RecognitionConfig.AudioEncoding.LINEAR16 #https://github.com/googleapis/python-speech/blob/master/UPGRADING.md#enums-and-types 1-2) long_running_recognize #operation = client.long_running_recognize(config, audio) operation = client.long_running_recognize(request={"config":config, "audio":audio}) #https://stackoverflow.com/questions/64287266/google-speech-to-text-jupyterlab-notebook-script-run-locally-using-google-cloud 1-3) nanos is deprecated #start_ms = int(w.start_time.nanos / 1000000) start_ms = int(w.start_time.microseconds / 1000000) #https://github.com/googleapis/python-speech/issues/71 #end_ms = int(w.end_time.nanos / 1000000) end_ms = int(w.end_time.microseconds / 1000000) #https://github.com/googleapis/python-speech/issues/71 2) Install ffmpeg for converting movie to audio file 3) Then you can execute the creation of SRT file to be uploaded to YouTube: 3-1) Download your video from YouTube Studio 3-2) Convert video to audio Uncompressed WAV is best for speech to text ffmpeg -i video.mp4 -ac 1 -ar 44100 audio.wav 3-3) Upload to Google bucket ../../../google-cloud-sdk/bin/gsutil cp audio.wav gs://$BUCKET_IN/ 3-4) Do speech to text python3 speech2srt.py --storage_uri gs://$BUCKET_IN/audio.wav --language_code id-ID --sample_rate_hertz 44100 --out_file audio 3-5) Upload audio.srt file to your YouTube video

Saturday, June 2, 2018

Turn PDF to text on Mac

To turn PDF to text on Mac, first install imagemagick using homebrew. Then install tesseract using homebrew. Download and put "eng.traineddata" into tessdata directory for English text.

Then run the following command:

convert -density 300 [input.pdf] -depth 8 -strip -background white -alpha off [output.tiff]
tesseract [input.tiff] [output] -c load_system_dawg=false -c language_model_penalty_non_freq_dict_word=0.1 -c language_model_penalty_non_dict_word=0.15 -c matcher_bad_match_pad=0.20


Tuesday, September 6, 2016


Gitinspector helps you analyze git activities from your repository.
Here is one of suggested options to use (using Terminal on Mac):

python gitinspector.py -Tlrw --format=htmlembedded --file-types="cs,js,asax,ascx,asmx,aspx,cshtml,fs" -x "/lib" >netisware2.html

Saturday, January 9, 2016

Rsync revisited (for Mac OS 10.10.5 Yosemite)

Get latest rsync from https://rsync.samba.org. Download also its patches, which now are in separate file. Patch.
patch -p1
patch -p1
patch -p1
Do configure and sudo make; make install
By default it will be installed to /usr/local/bin

Then execute rsync as follows:
sudo /usr/local/bin/rsync -aHxvuPESWANXN /src /dst --progress --dry-run

a equals -rlptgoD
N preserve createtimes
H preserve hardlinks
A preserve ACLs
X preserve xattr
x don't cross file system
v verbose
u skip files that are newer on the receiver

E preserve the file's executability
S handle sparse files efficiently
W copy files whole (without delta-xfer algorithm)

P equals --partial --progress, i.e., shows progress, and don't delete partially synced files when command is interrupted (to be resumed later)

Reference
http://www.lbackup.org/developer/rsync_hfs
https://discussions.apple.com/thread/6436787?start=0&tstart=0

Friday, July 10, 2015

As follow up to the entry about initial setting of Yamaha RTX on Mac, here is how to run tftp on Mac and do a firmware update:

First, start tftp server:
sudo launchctl load -w /System/Library/LaunchDaemons/tftp.plist

Then run these commands
tftp xxx.xxx.xxx.xxx (the IP address the router)
tftp> mode binary

tftp> put rtx1100.bin exec

Then stop tftp
sudo launchctl unload -w /System/Library/LaunchDaemons/tftp.plist