[ git ] error: addinfo_cache failed for path

Problem

error: addinfo_cache failed for path

Solution

#################### Reset header on both side & commit
git reset -- assets/loc-lang-constants.json
git add assets/loc-lang-constants.json
git commit -m "Resolve loc-lang-constants.json 1"
git push
#################### Copy the real file and replace it after pulling in assets/loc-lang-constants.json
git pull -X theirs
git add assets/loc-lang-constants.json
git commit -m "Resolve loc-lang-constants.json 2"
git push
#################### But there're some conflicts cannot be resolved. So we commit it again with conflicts.
git pull -X theirs
git add assets/loc-lang-constants.json
git commit -m "Resolve loc-lang-constants.json 3"
git push
#################### Copy the real file and replace it. There're some modification must be committed. So we commit it again.
git pull -X theirs
git add assets/loc-lang-constants.json
git commit -m "Resolve loc-lang-constants.json 4"
git push
#################### Finally done
git pull -X theirs

[ java on windows ] Access is denied reading file using FileInputStream

Problem : 

Exception in thread "main" java.io.FileNotFoundException: d:/Knowledge/test.txt (Access is denied)Exception in thread "main" java.io.FileNotFoundException: d:/Knowledge/test.txt (Access is denied) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(Unknown Source) at java.io.FileInputStream.<init>(Unknown Source) at java.io.FileInputStream.<init>(Unknown Source) at ExcelSheet.setExcelFile(ExcelSheet.java:41) at ExcelSheet.<init>(ExcelSheet.java:28) at Chrome_Browser.main(Chrome_Browser.java:14)

File reading code using FileInputStream

File file = new File("d:/Knowledge/test.txt");
FileInputStream fis = null;
try
{
fis = new FileInputStream(file);
System.out.println("Total file size to read (in bytes) : " + fis.available());
int content;
while ((content = fis.read()) != -1)
{
// convert to char and display it
System.out.print((char) content);
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
if (fis != null)
fis.close();
}
catch (IOException ex)
{
ex.printStackTrace();
}
}

Solution : 

  1. Put the following file into user home directory

feel free to change the file path

.java.policy

// Standard extensions get all permissions by default

grant codeBase "file:${{java.ext.dirs}}/*" {
permission java.security.AllPermission;
};

&nbsp;

// default permissions granted to all domains

grant {
permission java.io.FilePermission "d:/Knowledge/test.txt", "read";
};

2. Put the following arguments into VM arguments ( Run > Run configuration )

-Djava.security.manager -Djava.security.policy=security.policy

 

ref : https://stackoverflow.com/questions/23476145/strange-behaviour-of-accesscontroller-checkpermission

~/.rvm/bin/rvm-auto-ruby

pong@pong-VirtualBox:~/.rvm/bin$ rvm use 2.4.0
Using /home/pong/.rvm/gems/ruby-2.4.0
pong@pong-VirtualBox:~/.rvm/bin$ rvm-auto-ruby --version
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
pong@pong-VirtualBox:~/.rvm/bin$ rvm use 2.1.2
Using /home/pong/.rvm/gems/ruby-2.1.2
pong@pong-VirtualBox:~/.rvm/bin$ rvm-auto-ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

[ rails ] reek in sublime

Install package

*** important ! even we have reek in the rvm

gem install reek

NOTE : you have to run this install in the right directory !!!

 

Sublime package

Install SublimeLinter-contrib-reek package

 

​​​​SublimeLinter-contrib-reek package read reek configuration from config.reek

Example : if our project uses `site.reek`

Tools > SublimeLinter > Open User Settings

SublimeLinter.sublime-settings

"linters": {
"reek": {
"@disable": false,
"args": ["-c", "/home/pong/Desktop/whatever_project/site.reek"],
"excludes": []
}

}

 

SublimeLinter Debug Tips

Tools > SublimeLinter > Debug mode

Then

View > Show Console

 

ref : https://packagecontrol.io/packages/SublimeLinter-contrib-reek ,

http://www.sublimelinter.com/en/latest/troubleshooting.html#debug-mode

facebook fetch image

We can specify width and height in the meta to let facebook fetch the image first time we share.

NOTE : `img` tag in body is crucial, without that facebook will not prefetch image.

<html>
<head>
    <meta property="og:title" content="Whatever" />
    <meta property="og:image:url" content="https://dsin.appspot.com/static/image/medium/black_and_white/2.jpg" />
    <meta property="og:image:width" content="960" />
    <meta property="og:image:height" content="540" />
</head>
<body>
<img src="https://dsin.appspot.com/static/image/medium/black_and_white/2.jpg"/>
</body>
</html>

ref : https://developers.facebook.com/docs/sharing/best-practices/#precaching