Mar 17, 2022

[memo] git error: cannot lock ref 'refs/remotes/origin...

I often face the follwoing error when I run git fetch or git pull.

error: cannot lock ref 'refs/remotes/origin/...

How to solve?

  • git fetch --prune
  • git remote prune origin
  • git gc --prune=now
  • git remote -v
    -> copy git info(red color)
         origin  git@...git (fetch)
         origin  git@...git (push)
    -> git remote rm origin
    -> git remote add origin git@...git

  • delete the directory and clone the repogitory. <== final solution...

Why?

When we run an operation of git, it creates index.lock file inside .git directory to make sure that other git process don't take place during the operation. "error: cannot lock ref " means corruption happened in ./refs directory and cannot create index.lock



Jan 31, 2022

未上場外資系のストックオプションの税金と確定申告

多くの未上場外資系は税制非適格ストック・オプションに該当すると思います。 

税制非適格ストック・オプションを権利行使(exercise)した場合、給与所得として所得税の対象になります。※1


例えば令和3年(2021年)下記のように行使した場合、115,000円の追加所得になります。

1000 Grant

800 Vest

500 Exercise

$5 Exercise price

$7 FMV(Fair Market Value) ※3

115円 行使日のTTM(Telegraphic Transfer Middle Rate) ※4

追加所得の計算

(7 - 5) * 500 * 115 = 115,000円


国税庁のページにも下記のように計算式があります。USDベースの株価なので為替計算が必要です。※1, ※2
(権利行使時株価 - 権利行使価格) × 株式数 = 所得金額


所得税額は所得税率によって変わりますが、年収1,000万だと多分23%になると思います。

115,000 * 0.23 = 26,450円が追加で支払う所得税になります。


令和3年の確定申告下記のリンクから作成できます。

https://www.keisan.nta.go.jp/kyoutu/ky/sm/top#bsctrl

ここでは作成の詳細は割愛しますが、ポイントになる部分をスクリーンショットとともに説明します。

前述した通り給与所得であるため「給与所得」の入力をクリックします。



ストックオプションは年末調整されてないため「書面で交付された年末調整済みでない源泉徴収票の入力」の「入力する」をクリックします。


前述した所得金額「115,000」円を①に入力します。
②には税金を支払ってないため「0」を入力します。
④には会社住所と社名を入力します。※2



※1. https://www.nta.go.jp/taxes/shiraberu/taxanswer/shotoku/1543.htm

※2. https://www.keisan.nta.go.jp/r3yokuaru/ocat2/ocat21/cid477.html

※3. FMVは会社に問い合わせするかCarta等のExercise recordに行使時の価格が表示されます。


※4. https://www.77bank.co.jp/kawase/cash.html



Jan 4, 2022

Resolutions of 2022

 It's new year resolutions for the first time in 10 years. Here is previous one.


Before to set resolutions, I would like to look back 2021. Every year I have 2 major goals, losing my weight and reading a book/month. Yes, I missed them every year. That's why I have them every time. But the miracle ocurred in 2021. I lost 12Kg, lost 18kg but the weight is recovering. And I read 17 books. Working From Home made it!


I would like to upgrade my resolutions like below.

1. Touch 69.9Kg and Keep the weight under 72Kg. Must loose 15.4Kg from Jan. 4th 2022

2. Write a book review post per month.

3. Make strong body that I can work for 24 hours without the break.

4. Be an expert of "Automation".

5. Make a fun a week.

Dec 8, 2021

[memo] Could not find method compile() for arguments gradle

 I got the following error when I build my project.

> Could not find method compile() for arguments [org.slf4j:slf4j-api:1.7.24] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.


Here is a part of build.gradle

compile 'org.slf4j:slf4j-api:1.7.24'
compile 'org.slf4j:slf4j-simple:1.7.24'

I found the anwer https://stackoverflow.com/questions/23796404/could-not-find-method-compile-for-arguments-gradle.

From gradle 7.0 compile, runtime, testCompile, testRuntime are changed to implementation, runtimeOnly, testImplementation, testRuntimeOnly.

After I changed to implementation, my project is built successfully.

implementation 'org.slf4j:slf4j-api:1.7.24'
implementation 'org.slf4j:slf4j-simple:1.7.24'




Nov 1, 2021

[memo] How to confirm port in usage in Windows

netstat -ano -p tcp | find "80"


netstat is a command to display TCP connections and port.

-a Displays all active TCP connections and the TCP and UDP ports on which the computer is listening.

-n Displays active TCP connections, however, addresses and port numbers are expressed numerically and no attempt is made to determine names.

-o Displays active TCP connections and includes the process ID (PID) for each connection. You can find the application based on the PID on the Processes tab in Windows Task Manager. This parameter can be combined with -a-n, and -p.

-p Shows connections for the protocol specified by Protocol. In this case, the Protocol can be tcp, udp, tcpv6, or udpv6. If this parameter is used with -s to display statistics by protocol, Protocol can be tcp, udp, icmp, ip, tcpv6, udpv6, icmpv6, or ipv6.

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/netstat

find is a command to search a string of text

Oct 6, 2021

[memo] Stop IIS via command line

1. windows key and type "cmd"

2. Choose "command prompt" with "run as administrator"


3. Type "iisreset /stop"



Now you can use port 80

Dec 23, 2020

[memo] tail -f, grep in windows

Run PowerShell

tail -f

Get-Content -Path C:\MyLogs\mylog.log -Wait -Tail 100


tail -f | grep

Get-Content -Path C:\MyLogs\mylog.log -Wait -Tail 100 | Select-String "Search Word"


[memo] Traefik ver 2.2 log configuration

If you search "traefik log file path setting" in Google. The following 2 URLs are top. 

https://doc.traefik.io/traefik/observability/logs/

https://doc.traefik.io/traefik/v1.7/configuration/logs/


I was confused. Because first URL shows the following example.

[log]

  filePath="/MyLogs/traefik.log"

  format = "json"

  level = "DEBUG"


And second URL shows the following example. But it doesn't work with Traefik version 2.2

 logLevel = "DEBUG"  

[traefikLog]

  filePath="/MyLogs//traefikLog.log"


Here is my traefik.toml for Traefik version 2.2. I found the reason of 404.

[log]

  filePath="/MyLogs/traefik.log"

  format = "json"

  level = "DEBUG"


[accessLog]

  filePath="/MyLogs//traefikAccess.log"

Jan 20, 2017

[memo] How to use jacoco

Here is my configuration of pom.xml







"jacoco-initialize" prepare jacoco-agent before "test" maven lifecycle. And "jacoco-site" export report in "package" maven lifecyccle phase.

mvn clean package
You can see the report in ${your_project_root_directory}/target/site/jacoco/index.html

I learned how to use jacoco from here.
http://www.javaworld.com/article/2074515/core-java/unit-test-code-coverage-with-maven-and-jacoco.html

If you use maven-surefire-plugin and argLine, you would see "Skipping JaCoCo execution due to missing execution data file......" message and failed to create report. Please refer the official document of jacoco.
http://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html

If your project already defines VM arguments for test execution, be sure that they will include property defined by JaCoCo.
One of the ways to do this in case of maven-surefire-plugin - is to use syntax for late property evaluation:

org.apache.maven.plugins
maven-surefire-plugin

@{argLine} -your -extra -arguments


Here is my real configuration pom.xml

Oct 5, 2016

[memo] How to check max open files(file descriptors) in Linux

Entire OS

cat /proc/sys/fs/file-max


Max open file number of each process
ps aux | grep glassfish
#find process id(pid)
grep "open files" /proc/10244/limits
Max open files            65535                65535                files

Mar 15, 2016

[memo] How to delete all jobs of jenkins

Delete all jobs

Go to the following URL.
http://your.jenkins.url/script

And input the following script

for(j in jenkins.model.Jenkins.getInstance().getProjects()) {
    j.delete();
}

http://stackoverflow.com/questions/5076246/hudson-ci-how-to-delete-all-jobs

Sep 13, 2015

[memo] How to keep SSH session from disconnection in Mac

Set 5 minutes for interval.

vi ~/.ssh/config
ServerAliveInterval 300
TCPKeepAlive yes

Jun 15, 2015

[memo] How to show only total for each directories

du -csh *

The -c option can be added to provide a grand total for all of the files and directories that are listed.
The -s (for suppress or summarize) option tells du to report only the total disk space occupied by a directory tree and to suppress individual reports for its subdirectories.
The -h (i.e., human readable) can make the output easier to read by displaying it in kilobytes (K), megabytes (M) and gigabytes (G) rather than just in the default kilobytes.

Reference
http://stackoverflow.com/questions/10103604/linux-command-line-du-how-to-make-it-show-only-total-for-each-directories

Dec 9, 2014

[memo] How to change a git URL in all Jenkins jobs

Each job's configuration is saved at config.xml. So you just find old URL and change them to new URL like the below.


Sep 9, 2014

[memo] How to get hostname with logback

Just use ${HOSTNAME} logback can get hostname. Don't set hostname manually. It may make other engineers try to fix problem on other server. It's my experience. :)

Aug 13, 2014

[git] How to split repository by sub directories and retain all branches and tags

Because of Legacy and Enterprise code, I have a very big git repository moved from svn. If I build and deploy a external API's client, other clients are also updated and I should spent time to find why my war file has so many differences between current and new. If I fixed parent pom.xml, I could solve this problem. But I decided to split a big repository into 20 small repositories.

As usual, I Googled I found how to use git subtree to divide a sub directory to new git repository. It is very simple way!
Detach subdirectory into separate Git repository
 But it looses our commit logs and branches.

I asked Google again and found what I want.
git splitting repository by subfolder and retain all old branches
But I missed tags with this answer. Yes I know I should study myself. So I just added one more process to above.

Here is an example with github.

Make new repository on you github.
You can see how to push your project to new repository.
https://github.com/baepiff/test

git clone https://github.com/baepiff/voldemort voldemort
cd voldemort
git checkout --detach 
# delete all branches
git branch | grep --invert-match "*" | xargs git branch -D 
# get all branches
for remote in `git branch --remotes | grep --invert-match "\->"`; do
    git checkout --track $remote
done 
# confirm you have all branches and tags
git branch
git tag

# make another local repository
git clone voldemort voldemort2
cd voldemort2
git checkout --detach
git branch | grep --invert-match "*" | xargs git branch -D
for remote in `git branch --remotes | grep --invert-match "\->"`; do
    git checkout --track $remote
done
git branch
git tag 
# Isolate docs and recreate branches
# --prune-empty removes all commits that do not modify docs
# -- --all updates all existing references, which is all existing branches
git filter-branch --prune-empty --subdirectory-filter docs -- --all

# clean up git log
rm -rf .git/refs/original/*
git reflog expire --all --expire-unreachable=0
git repack -A -d
git prune

# push all branches and tags to new repository
git remote set-url origin https://github.com/baepiff/test
git push --all
git push --tags


I made separated repository shell script. I hope it helps you.
 

Jun 18, 2014

[git] how to change remote repository url

We have some development servers. We build source on the development on these servers. When I executed 'git fetch', git required another guy's password.

git fetch
#Password for 'https://another.guy@git.com':


Of course, I don't know his password. So I decided to change remote repository url. I got found the answer here.


git remote -v
#origin https://another.guy@git.com/scm/xxx.git (fetch)
#origin https://another.guy@git.com/scm/xxx.git (push)

git remote set-url origin https://git.com/scm/xxx.git

git remote -v
#origin https://git.com/scm/xxx.git (fetch)
#origin https://git.com/scm/xxx.git (push)

git fetch
#Username for 'https://git.com/': my.user
#Password for 'https://my.user@git.com':


---
git remote set-url origin https://git.com/scm/xxx.git
git remote -v
#origin https://git.com/scm/xxx.git (fetch)
#origin https://another.guy@git.com/scm/xxx.git (push)

git remote set-url --push origin https://git.com/scm/xxx.git
git remote -v
#origin https://git.com/scm/xxx.git (fetch)
#origin https://git.com/scm/xxx.git (push)

Jun 15, 2014

[git] how to remove remote tag

If you just started to use maven release plug in, you would get some problems with release plug in like failed on prepare due to not exist snapshot version, or failed on prepare because of existing tag. I would like to share how to remove git tag from remote.
It's easy. Just run the following commands. That's it!

git tag -d myapp-0.0.1
git push origin :refs/tags/myapp-0.0.1


Apr 29, 2014

[memo] How to add/delete jvm options for glassfish

I need to modify jvm options of glassfish(2.1). I asked Google and found the following URLs.
http://docs.oracle.com/cd/E19879-01/820-4332/create-jvm-options-1/index.html
http://docs.oracle.com/cd/E19879-01/820-4332/delete-jvm-options-1/index.html

Here is my example.


Current glassfish has NewRatio and SurvivorRatio. So I deleted them and add new options like below.
-XX:NewRatio=1
-XX:SurvivorRatio=4
-Xms1024m
-XX:CMSInitiatingOccupancyFraction=70