Monday, February 15, 2021

How to fix time in name of files from Google camera application from UTC to localtime

 copy all files in test folder


# to rename all jpeg

jhead -nPXL_%Y%m%d_%H%M%S *.jpg


# do only mp4 as jpeg is better to be done by jhead

find . -type f -name "*.mp4" -exec exiftool -d 'PXL_%Y%m%d_%H%M%S.%%e' '-FileName<filemodifydate' {} \;


# sources are at https://gist.github.com/romani/e2358e3c1dece784fae9fe19be0fd143

./split-img.sh


------


# sometimes required to https://gist.github.com/romani/862f33b98eb05060245ef864115ee66f 

./move-portrait.sh


in case re-split, source of wisdom:

find . -type f -mindepth 2 -exec mv -i -- {} . \; 


Friday, May 15, 2020

How to pass "diff wall" caused by reformatting or bulk change

Digging git history in terminal 
https://medium.com/@drdmason/git-blame-all-the-way-back-62957f8407

Digging git history in Github
https://help.github.com/en/github/managing-files-in-a-repository/tracking-changes-in-a-file

Digging git history in IDEA
https://www.jetbrains.com/help/idea/investigate-changes.html#annotate_previous_revision

Friday, February 7, 2020

My actions of mac setup from scratch

1)
remap "End" key if key board is long
https://apple.stackexchange.com/a/16137

2) Show path and statis bar
Open finder, in menu "View" click on "Show ...."

3) show hidden files
https://ianlunn.co.uk/articles/quickly-showhide-hidden-files-mac-os-x-mavericks/
"Show/Hide Hidden Files the Long Way"

4) Show path in title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true

Install Homebrew (https://brew.sh/)
or https://iterm2.com/
update profiles for "Default" , choose presets ".. Natural ..."
and make Terminal to keep whole history of output
Once in the Profiles section, go to the Terminal tab in the right panel of the settings, then go down to the Notificationssection and click the Silence bell option.

5)  install Sublime
sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

6) Disable swipe between pages to avoid conflict with horizontal scrolling
https://apple.stackexchange.com/a/33009/371076

7) full clock

utc clock in menu bar(if required): https://github.com/netik/UTCMenuClock/downloads



8) use bash 
chsh -s /bin/bash
disable warning on zsh usage - https://support.apple.com/en-us/HT208050  to ~/.bash_profile or ~/.profile:
export BASH_SILENCE_DEPRECATION_WARNING=1
install https://github.com/magicmonty/bash-git-prompt , update ~/.bash_profile to use GIT_PROMPT_ONLY_IN_REPO=0 as I like time in prompt.


Friday, November 8, 2019

How to list all changed files between two branches that does not have common ancestor

If tree is like this:

Same tree you can see by(if you do not have gitk): git log --all --graph

to get a all files:
$ (git diff --name-status master...staging && \
    git diff --name-status $(git merge-base  master staging) fb-4) \
  | cut -f 2 | sort | uniq
2-2.txt
2.txt
3.txt
4.txt


Good picture that explain difference between "..." and ".." - https://stackoverflow.com/a/46345364

Tuesday, November 5, 2019

How to keep release branch commits in history but do not keep branch

Command: git merge --no-ff -s "ours" release-branch 
Removal of branch label from git tree: git branch -D release-branch

It will make "diamond" in git history BUT it will not merge any changes from release branch to master. Blue dots are former "release-branch"

Tuesday, October 22, 2019

move log file with timestamp prefix

mv server.log server.log.before.$(date '+%Y%m%d%H%M%S')

How to connect from docker container to host local service

Elasticsearch is running on localhost MacOS.
run image with curl and test connection to host local webservice.
Some interesting steps are at https://dev.to/bufferings/access-host-from-a-docker-container-4099 , it explains why networks are not wokrigin MacOS (it is not supported).

custom docker net creation - https://nickjanetakis.com/blog/docker-tip-35-connect-to-a-database-running-on-your-docker-host

$ docker container run --rm -it curlimages/curl sh
Unable to find image 'curlimages/curl:latest' locally
latest: Pulling from curlimages/curl
9d48c3bd43c5: Pull complete
9fbab065c978: Pull complete
Digest: sha256:4c7b687d607d7f5f397db1ca877a626fedc79c7a537a3f145482083bd68dc115
Status: Downloaded newer image for curlimages/curl:latest

/ $ curl 'localhost:9200/_cat/indices?v'
curl: (7) Failed to connect to localhost port 9200: Connection refused
#### This is expected as elastic search in NOT in docker container

# base on https://docs.docker.com/docker-for-mac/networking/
/ $ ping host.docker.internal
PING host.docker.internal (192.168.65.2): 56 data bytes
ping: permission denied (are you root?)

/ $ curl 'host.docker.internal:9200/_cat/indices?v'
health status index      uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   conv_v12 tIP0ha4USEG3Wr5cKJNzGw   5   1     837120            0      1.2gb          1.2gb
yellow open   conv_v11 0e-Y9pnlQHGyFTicGfQHbg   5   1    3917501           27      5.6gb          5.6gb
yellow open   geota    lSixJug2QDqtR8sjtXWdKg   5   1      69070            0      1.6gb          1.6gb
yellow open   conv_v10 9WX0fuMgRTCem0OgHn9fPw   5   1      67706            0    127.6mb        127.6mb

/ $ curl '192.168.65.2:9200/_cat/indices?v'
health status index      uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   conv_v12 tIP0ha4USEG3Wr5cKJNzGw   5   1     832120            0      1.2gb          1.2gb
yellow open   conv_v11 0e-Y9pnlQHGyFTicGfQHbg   5   1    3917501           27      5.6gb          5.6gb
yellow open   geota    lSixJug2QDqtR8sjtXWdKg   5   1      69070            0      1.6gb          1.6gb
yellow open   conv_v10 9WX0fuMgRTCem0OgHn9fPw   5   1      67706            0    127.6mb        127.6mb