2013-02-28

How to write the end-of-file character in a Java String?

Use the \u001a unicode character.

There is a character called EOF. It's also called control-Z.
If you want to include it in a string, you have to type it as "\u001a" as in:

String iHaveAnEof = "file ends here\u001a";

Credits:

Ed Staub

http://stackoverflow.com/a/7591594/129497

How to avoid Mac temporary files in archives

> tar --exclude "._*" -zcvf template.tgz template
template/
template/.classpath
template/.project
template/build.xml
template/src/
template/src/log4j.properties
template/src/main/
template/src/main/dml/
template/src/main/dml/domain.dml
template/src/main/java/

(VS)

> tar -zcvf template.old.tgz template
template/
template/._.classpath
template/.classpath
template/._.project
template/.project
template/._build.xml
template/build.xml
template/._src
template/src/
template/src/._log4j.properties
template/src/log4j.properties
template/src/._main
template/src/main/
template/src/main/._dml
template/src/main/dml/
template/src/main/dml/._domain.dml
template/src/main/dml/domain.dml
template/src/main/._java
template/src/main/java/

You can also add the following to /etc/profile :
# disable special creation/extraction of ._* files by tar, etc. on Mac OS X
echo "[/etc/profile] disable special creation of ._* files"
COPYFILE_DISABLE=1; 
export COPYFILE_DISABLE

Mac-specific option:
# from man bsdtar
--disable-copyfile
Mac OS X specific.  Disable the use of copyfile(3).

Credits:

Joana

Sources:

http://stackoverflow.com/questions/8766730/tar-command-in-mac-os-x-adding-hidden-files-why

http://superuser.com/questions/61185/why-do-i-get-files-like-foo-in-my-tarball-on-os-x

http://superuser.com/questions/198569/compressing-folders-on-a-mac-without-the-ds-store

2013-02-27

How to change shell in Linux

To find out which shell you are using:
echo $SHELL

To change shell:
chsh


Credits:

Joana

How to define environment variable in Linux?

Define the environment variable in
.bashrc, .zshrc or /etc/bashrc or /etc/zshrc
or in a similar file.

Using a Mac OS X, edit /etc/profile
You might also want to know about MacPorts.

Credits:

Joana