Month: May 2018

How to implement $Date$ keyword in Git

This is fairly well documented in Git Attributes help but I didn’t like that given example requires a dedicated Ruby script.

Create two filters:

  • on smudge (to replace $Date$ into $Date: <timestamp>$ )
  • on clean (to revert  $Date: <timestamp>$  into  $Date$):
Now mark which files should be treated with the filters:
Finally, git add and commit.

My  $Date$ keyword has been replaced:

One annoying thing though is that the file is explicitly marked as changed. I have a feeling that SVN does it better 😃

Chef resources failing with wrong constant name

When trying to add a custom resource, no matter what, I always got a  wrong constant name  error, for example:

It turned out to be an issue with my cookbook name: it’s not allowed to have a cookbook name starting with a number (as later, it’s converted into a class name).

So my cookbooks as below are causing the problems:

They should be renamed into something else, for example:

Note, inside the files, there are references to the names, so you may need to update them accordingly, for example using:

After this, no more strange errors after adding resources.

PS: When you work on MacOS, you may face another problem with your resources: MacOS trash files (._* or .DS_Store) are causing another (similarly looking) error. Take a look at this web page.

 

Prevent Mac hidden files being written to a shared storage

MacOS tends to trash mounted disks with number of useless hidden files (e.g.  ._* or .DS_Store ). There were number of recipes in the Internet, some of them were working at some of time but are not anymore.

Below notes from my fights (at a moment of writing, on MacOS High Sierra 10.13.4 (17E199).

Removing the files when they are created

I used to apply a find . -name ... -print0 | xargs rm -0  combo but found that there is an built-in command to deal with these files:

From the man:

Preventing creating the files

On the MacOS side

NOTE: None of these solutions worked for me!

As I wrote, this didn’t work at all to me.

On the SMB server side

It actually turned the only working solution for me. Just add to the share configuration section a veto file parameter, e.g.:

And restart:

Note, after applying this change you will not be able anymore to use dot_clean  command from your Mac as any requests towards these files (including deletion) will be silently ignored by your SMB server hence files will remain untouched!