1. Exercise more – 7 minutes might be enough
2. Sleep more – you’ll be less sensitive to negative emotions
3. Move closer to work – a short commute is worth more than a big house
4. Spend time with friends and family – don’t regret it on your deathbed
5. Go outside – happiness is maximized at 13.9°C
6. Help others – 100 hours a year is the magical number
7. Practice smiling – it can alleviate pain
8. Plan a trip – but don’t take one
9. Meditate – rewire your brain for happiness
10. Practice gratitude – increase both happiness and life satisfaction
via Buffer blog
Showing posts with label tip. Show all posts
Showing posts with label tip. Show all posts
2014-03-10
2013-08-02
How to disable Thunderbird mozmsgs
Mozilla Thunderbird has an option to integrate with Mac or Windows email search.
Using this option the emails are no longer stored in the SDB files (many emails in a single file) are stored in multiple and individual files.
This usually results in poor performance, especially if you have many emails.
To disable this option, go to 'Options', 'Advanced', 'General' and unselect the "Allow Windows Search to search message".
You can also unselect the "Enable Global Search and Indexer" option if you do not use the global search.
Using this option the emails are no longer stored in the SDB files (many emails in a single file) are stored in multiple and individual files.
This usually results in poor performance, especially if you have many emails.
To disable this option, go to 'Options', 'Advanced', 'General' and unselect the "Allow Windows Search to search message".
You can also unselect the "Enable Global Search and Indexer" option if you do not use the global search.
2013-07-31
How to use Gradle to generate Eclipse files with relative paths to libraries
First, apply the Gradle Eclipse plug-in to your build.gradle file:
You can now execute the following command to generate the Eclipse configuration files .project and .classpath:
You can now import and existing project into Eclipse, and enjoy all the correct configurations!
However, in the current Gradle version (1.6), the generated library paths are absolute, for example:
This leads to problems because if you commit these files in source code control, your specific user settings will be imposed on other developers.
One way to avoid this is to use an Eclipse Classpath Variable and customize the Eclipse plug-in output.
Note: an alternative solution could use Eclipse workspace Path variables (referred using the ${...} notation) but without DSL support like the pathVariables statement above.
apply plugin: 'java' apply plugin: 'eclipse'
You can now execute the following command to generate the Eclipse configuration files .project and .classpath:
$ gradle eclipse
You can now import and existing project into Eclipse, and enjoy all the correct configurations!
However, in the current Gradle version (1.6), the generated library paths are absolute, for example:
C:/Users/Miguel/.gradle/caches/artifacts-24/filestore/ junit/junit/4.11/source/ 28e0ad201304e4a4abf999ca0570b7cffc352c3c/junit-4.11-sources.jar
This leads to problems because if you commit these files in source code control, your specific user settings will be imposed on other developers.
One way to avoid this is to use an Eclipse Classpath Variable and customize the Eclipse plug-in output.
eclipse {
// find gradle cache location
def gradleCache = null
for (o in configurations.compile) {
if (o.toString().indexOf(".gradle") != -1) {
final def token = "filestore"
def s = o.toString()
def idx = s.indexOf(token)
if (idx != -1) {
gradleCache = new File(s.substring(0, idx + token.length()))
break
}
}
}
assert gradleCache && gradleCache.exists()
println "GRADLE_CACHE: " + gradleCache
// replace absolute paths with classpath variable GRADLE_CACHE
pathVariables 'GRADLE_CACHE': gradleCache
// make sure GRADLE_CACHE is defined in
// Eclipse, Preferences, Java, Build Path, Classpath Variables
}
Note: an alternative solution could use Eclipse workspace Path variables (referred using the ${...} notation) but without DSL support like the pathVariables statement above.
2013-06-19
How to produce a Graphviz PDF with smaller margins?
Graphviz is a great tool to generate graph images from a textual description.
The following tip shows how you can generate a PDF file with smaller margins.
The source file contains:
Alternatively, the margin can also be set in the command line:
The following tip shows how you can generate a PDF file with smaller margins.
The source file contains:
digraph G {
margin=0;
"subject" -> "object" [label="predicate"];
}
Alternatively, the margin can also be set in the command line:
> dot -Tpdf -Gmargin=0 triple.gv > triple.pdf
2013-03-06
Eclipse power shortcuts
Eclipse is a Java Integrated Development Environment (IDE) that has many problems, in my view, but also many good things.
Here are a few time-savers:
Type:
sysout CTRL+space
and Eclipse completes to:
System.out.println()
Type:
throw new NPE CTRL+space
and Eclipse presents a list of Exception classes whose capital letters start with N, P, and E.
In this case, we want to complete to:
throw new NullPointerException()
Again:
throw new IArE CTRL+space
and complete to:
throw new IllegalArgumentException()
Nice! :)
Here are a few time-savers:
Type:
sysout CTRL+space
and Eclipse completes to:
System.out.println()
Type:
throw new NPE CTRL+space
and Eclipse presents a list of Exception classes whose capital letters start with N, P, and E.
In this case, we want to complete to:
throw new NullPointerException()
Again:
throw new IArE CTRL+space
and complete to:
throw new IllegalArgumentException()
Nice! :)
2012-11-30
How to install Groovy on Windows?
Groovy is a great scripting language for the Java platform.
The first step to install it is to download the archive (ZIP).
http://groovy.codehaus.org/Download?nc
The second step is to unzip to a folder.
For example, C:\Java\groovy\2.0.5
Set GROOVY_HOME to the installation folder.
Then, edit the PATH variable, to add, in the beginning:
%GROOVY_HOME%\bin;
Finally, open a new console and execute the following command that should print the installed Groovy version:
The first step to install it is to download the archive (ZIP).
http://groovy.codehaus.org/Download?nc
The second step is to unzip to a folder.
For example, C:\Java\groovy\2.0.5
Set GROOVY_HOME to the installation folder.
Then, edit the PATH variable, to add, in the beginning:
%GROOVY_HOME%\bin;
Finally, open a new console and execute the following command that should print the installed Groovy version:
groovy -version
How to install the Java Developer Kit on Windows?
The first step is to download the installation package.
The file to get is the Java Developer Kit (JDK)
http://www.oracle.com/technetwork/java/javase/downloads/index.html
The second step is to execute the installer.
To compile and execute Java programs in the console, a few environment variables must be set.
Set JAVA_HOME to the installation folder.
For example, C:\Java\jdk\1.7.0_09
Then, edit the PATH variable, to add, in the beginning:
%JAVA_HOME%\bin;
Finally, to check if everything is OK, open a new console and execute the following commands that should print the installed Java version number:
That's it! Happy coding!
The file to get is the Java Developer Kit (JDK)
http://www.oracle.com/technetwork/java/javase/downloads/index.html
The second step is to execute the installer.
To compile and execute Java programs in the console, a few environment variables must be set.
Set JAVA_HOME to the installation folder.
For example, C:\Java\jdk\1.7.0_09
Then, edit the PATH variable, to add, in the beginning:
%JAVA_HOME%\bin;
Finally, to check if everything is OK, open a new console and execute the following commands that should print the installed Java version number:
javac -version java -version
That's it! Happy coding!
How to set environment variables in Windows?
Environment variables are values that, once set, become available to all programs running in the computer.
The value of an environment variable can be used like this: %name%. Typically, environment variables are used to specify program paths and settings.
Some environment variables are set by Windows.
%ProgramFiles% holds the value of the program folder (english Windows: C:\Program Files; portuguese Windows: C:\Programas).
%UserName% holds the user name of the user in session.
%UserProfile% holds the home folder of the user in session.
One of the most used environment variables is PATH, that specifies where the operating system looks for programs.
Folders are separated by the ; character.
To see the value of PATH, execute ECHO %PATH% in the console.
Also, the SET command can print and set environment variables.
To set environment variables permanently on Windows, go to Computer System Properties, Advanced, Environment Variables. The following screen-shots illustrate this procedure for Windows 7.
Environment variables can be defined for the current user (user) or for all users (system).
The new settings only take effect for new consoles.
The value of an environment variable can be used like this: %name%. Typically, environment variables are used to specify program paths and settings.
Some environment variables are set by Windows.
%ProgramFiles% holds the value of the program folder (english Windows: C:\Program Files; portuguese Windows: C:\Programas).
%UserName% holds the user name of the user in session.
%UserProfile% holds the home folder of the user in session.
One of the most used environment variables is PATH, that specifies where the operating system looks for programs.
Folders are separated by the ; character.
To see the value of PATH, execute ECHO %PATH% in the console.
Also, the SET command can print and set environment variables.
To set environment variables permanently on Windows, go to Computer System Properties, Advanced, Environment Variables. The following screen-shots illustrate this procedure for Windows 7.
Environment variables can be defined for the current user (user) or for all users (system).
The new settings only take effect for new consoles.
2012-10-18
How to add watermarks to your PDF files
You probably have seen documents with background watermarks stating something like:
Draft
Proof
Final
Urgent
Priority
Do Not Copy
Copy
For Your Eyes Only
Review Copy
Confidential
Top Secret
Duplicate
... you get the idea :)
There are free tools that can do it for you. I recommend PDFill Tools or Pdftk (command-line alternative).
Draft
Proof
Final
Urgent
Priority
Do Not Copy
Copy
For Your Eyes Only
Review Copy
Confidential
Top Secret
Duplicate
... you get the idea :)
There are free tools that can do it for you. I recommend PDFill Tools or Pdftk (command-line alternative).
2012-10-15
How to check SVN repository version
cat svn-repo/format/dbIf the file contents lists 3 on the first line, it stands for SVN 1.5, 4 for SVN 1.6
Credits: http://stackoverflow.com/a/282484/129497
The repository can be upgraded with:
svnadmin upgrade svn-repoThis can be important because SVN 1.5 and 1.6 introduced many improvements to branch operations including the svn mergeinfo command. If the repository is in an older version there is not enough metadata to ease the branch synchronizations.
How to set permissions for Linux personal web site
Let's suppose that we have a user account located at ~ and a web site at ~/www
We need to set the directory permissions to 755 allow every
We need to set the files to 644 (owner can r/w, everybody else can r)
These are the classic Unix file permissions.
However, if AFS is being used, we also need to provide permissions in the access control lists (ACL).
The following command gives access to the web folder to anyone:
The following lists the existing permissions:
More help on AFS
"
There are seven standard AFS permissions, each referred to by one of the letters r, l, i, d, w, k and a. The lida permissions apply to directories and the rwk permissions apply to files.
Directory permissions
l (lookup)
Allows one to list the contents of a directory. It does not allow the reading of files.
i (insert)
Allows one to create new files in a directory or copy new files to a directory.
d (delete)
Allows one to remove files and sub-directories from a directory.
a (administer)
Allows one to change a directory's ACL. The owner of a directory can always change the ACL of a directory that s/he owns, along with the ACLs of any subdirectories in that directory.
File permissions
r (read)
Allows one to read the contents of file in the directory.
w (write)
Allows one to modify the contents of files in a directory and use chmod on them.
k (lock)
Allows programs to lock files in a directory.
"
We need to set the directory permissions to 755 allow every
We need to set the files to 644 (owner can r/w, everybody else can r)
u g w 0 - 0 0 0 1 - 0 0 1 2 - 0 1 0 3 - 0 1 1 4 - 1 0 0 5 - 1 0 1 6 - 1 1 0 7 - 1 1 1u stands for 'user', g for 'group' and w for 'world'.
These are the classic Unix file permissions.
However, if AFS is being used, we also need to provide permissions in the access control lists (ACL).
The following command gives access to the web folder to anyone:
fs sa www system:anyuser rl
The following lists the existing permissions:
fs la www
More help on AFS
"
There are seven standard AFS permissions, each referred to by one of the letters r, l, i, d, w, k and a. The lida permissions apply to directories and the rwk permissions apply to files.
Directory permissions
l (lookup)
Allows one to list the contents of a directory. It does not allow the reading of files.
i (insert)
Allows one to create new files in a directory or copy new files to a directory.
d (delete)
Allows one to remove files and sub-directories from a directory.
a (administer)
Allows one to change a directory's ACL. The owner of a directory can always change the ACL of a directory that s/he owns, along with the ACLs of any subdirectories in that directory.
File permissions
r (read)
Allows one to read the contents of file in the directory.
w (write)
Allows one to modify the contents of files in a directory and use chmod on them.
k (lock)
Allows programs to lock files in a directory.
"
2012-10-05
How to backup and restore Subversion repository
Backing up and Restoring Your Subversion Repository - OCS Support Wiki: Using the Console
Establish an SSH connection to your designated SVN / Trac server and login with the same username and password you use to obtain access to the SVN / Trac control panel. Once in, run:
svnadmin dump ~/svn/repo_name > repo_name.svn.dump
Replace repo_name with your repository name. This will backup your repository into a file called repo_name.svn.dump. You can then restore a Subversion backup with:
svnadmin load ~/svn/repo_name < repo_name.svn.dump
Establish an SSH connection to your designated SVN / Trac server and login with the same username and password you use to obtain access to the SVN / Trac control panel. Once in, run:
svnadmin dump ~/svn/repo_name > repo_name.svn.dump
Replace repo_name with your repository name. This will backup your repository into a file called repo_name.svn.dump. You can then restore a Subversion backup with:
svnadmin load ~/svn/repo_name < repo_name.svn.dump
How to change paper size for IEEE LaTeX template
(La)TeX Support for manuscript preparation: Guide to use ieeeconf.cls (based on IEEEtrans.cls) IEEEtran_HOWTO.pdf
The document sample_new.tex may be configured for US Letter paper or A4. Please note the following four important lines:
\documentclass[letterpaper, 10 pt, conference]{ieeeconf} % use above line letter sized paper
\documentclass[a4paper, 10pt, conference]{ieeeconf} % Use this line for a4 paper
\IEEEoverridecommandlockouts % Needed if you want to use the \thanks command
\overrideIEEEmargins % Needed to meet printer requirements.
The document sample_new.tex may be configured for US Letter paper or A4. Please note the following four important lines:
\documentclass[letterpaper, 10 pt, conference]{ieeeconf} % use above line letter sized paper
\documentclass[a4paper, 10pt, conference]{ieeeconf} % Use this line for a4 paper
\IEEEoverridecommandlockouts % Needed if you want to use the \thanks command
\overrideIEEEmargins % Needed to meet printer requirements.
2012-10-04
Groovy one-liner to extract file name without extension
Does groovy have an easy way to get a filename without the extension? - Stack Overflow:
file.name.lastIndexOf('.').with {it != -1 ? file.name[0..<it] : file.name}
or with a simple regexp:
file.name.replaceFirst(~/\.[^\.] $/, ''
file.name.lastIndexOf('.').with {it != -1 ? file.name[0..<it] : file.name}
or with a simple regexp:
file.name.replaceFirst(~/\.[^\.] $/, ''
2012-10-03
How to paste text to multiple columns in Excel
Learn Microsoft Excel: Smart Paste: Pasting text into different Excel cells can be done by making use of the TAB key in the text editor. Pressing Tab represents a new cell in Excel when pasting the contents into Microsoft Excel. To create a four column layout in Excel one would simply write down the name of the first column, press tab, write down the name of the second column, press tab and so on.
How to pipe command output to Windows clipboard
Use clip.exe!
Copy Command Line Output to Windows Clipboard Directly:
dir /h | clip – Copy the help manual for DIR command to the clipboard
tracert www.labnol.org | clip – Trace the path from your computer to another website – the output is automatically copied to the clipboard and not displayed on the screen.
netstat | clip - Check if your computer is connecting to websites without your knowledge.
The clip.exe utility can also be used to copy contents of text files to clipboard directly from the command line.
clip < C:\AUTOEXEC.bat – this will copy all the text from autoexec.bat to your Windows Clipboard.
Copy Command Line Output to Windows Clipboard Directly:
dir /h | clip – Copy the help manual for DIR command to the clipboard
tracert www.labnol.org | clip – Trace the path from your computer to another website – the output is automatically copied to the clipboard and not displayed on the screen.
netstat | clip - Check if your computer is connecting to websites without your knowledge.
The clip.exe utility can also be used to copy contents of text files to clipboard directly from the command line.
clip < C:\AUTOEXEC.bat – this will copy all the text from autoexec.bat to your Windows Clipboard.
2012-07-13
How to change Epson Scan software language
solveXP: Epson V33 scanner change language
Even after choosing the English language during installation of the Epson software it ignored the choice and default to a different language.
To fix: check the folder: C:\Windows\twain_32\escndv\... and from there remove the folders containing the languages I would never use. English is 0809.
Just open the .chm file belonging to the above mentioned folders to find which number corresponds to which language.
Even after choosing the English language during installation of the Epson software it ignored the choice and default to a different language.
To fix: check the folder: C:\Windows\twain_32\escndv\... and from there remove the folders containing the languages I would never use. English is 0809.
Just open the .chm file belonging to the above mentioned folders to find which number corresponds to which language.
2012-06-30
LaTeX text color
LaTeX text colors... courtesy of Joana!
{\textcolor{red} bla bla bla}
Available colors: @ 000-config.tex
% ---------------------------
% PDF COLORS
% ---------------------------
% pdf package allow you to describe the colors you want to use for links
% -------------------
% COLORS by name (examples):
% RED:
\definecolor{red}{rgb}{1,0,0}
\definecolor{rltred}{rgb}{0.75,0,0}
\definecolor{webred}{rgb}{0.5,.25,0}
\definecolor{rltbrightred}{rgb}{1,0,0}
\definecolor{rltdarkred}{rgb}{0.5,0,0}
% GREEN:
\definecolor{green}{rgb}{0,1,0}
\definecolor{rltgreen}{rgb}{0,0.5,0}
\definecolor{webgreen}{rgb}{0,0.5,0}
\definecolor{rltbrightgreen}{rgb}{0,0.75,0}
\definecolor{rltdarkgreen}{rgb}{0,0,0.25}
% institutional
\definecolor{green-l2f}{rgb}{0.37,0.725,0.21}
% BLUE:
\definecolor{blue}{rgb}{0,0,1}
\definecolor{rltblue}{rgb}{0,0,0.75}
\definecolor{webblue}{rgb}{0,0,0.75}
\definecolor{rltbrightblue}{rgb}{0,0,1}
\definecolor{rltdarkblue}{rgb}{0,0,0.5}
% institutional
\definecolor{blue-phd}{rgb}{0.7,0.8,0.9}
\definecolor{blue-l2f}{rgb}{0,0.21,0.455}
\definecolor{blue-ist}{rgb}{0.055,0.30,0.486}
\definecolor{blue-ist-old}{rgb}{0.70,0.73,0.84}
\definecolor{blue-ist-new}{rgb}{0.25,0.333,0.39}
%% from WEB references:
\definecolor{white}{gray}{1}
\definecolor{black}{gray}{0}
\definecolor{gray}{gray}{0.5}
\definecolor{silver}{gray}{0.75}
\definecolor{lightgray}{gray}{0.97}
\definecolor{yellow}{rgb}{1,1,0}
\definecolor{orange}{rgb}{1,0.4,0}
\definecolor{pink}{rgb}{1,0,1}
\definecolor{purple}{rgb}{0.5,0,0.5}
\definecolor{teal}{rgb}{0,0.5,0.5}
\definecolor{navy}{rgb}{0,0,0.5}
\definecolor{aqua}{rgb}{0,1,1}
\definecolor{lime}{rgb}{0,1,0}
\definecolor{olive}{rgb}{0.5,0.5,0}
\definecolor{maroon}{rgb}{0.5,0,0}
\definecolor{brown}{rgb}{0.6,0.4,0.2}
2012-06-28
Saving Visio diagram as PDF
File-> Save As -> Change File Type to PDF (the actual description in Visio 2010 is "Save As Type...").
To get the size down to what you want, assuming you are using Visio 2010 - go to the Design ribbon at the top, and change "Size" to "Fit to Drawing"
Credits: DavidChenware @ superuser.com
To get the size down to what you want, assuming you are using Visio 2010 - go to the Design ribbon at the top, and change "Size" to "Fit to Drawing"
Credits: DavidChenware @ superuser.com
2012-06-20
Java memory options
On a 32-bit Windows 7 machine running Oracle JDK 7, the default Java heap size is around 256M.
The JVM memory settings are the following:
This means that we can change the initial and maximum heap size using:
M stands for MegaByte and G for GigaByte.
There is also a "standard" way of defining these parameters using the JAVA_OPTS environment variable:
For instance, execution scripts created using gradle install will apply the options specified in JAVA_OPTS and in an application-specific variable (e.g. MY_APP_OPTS).
This in practice, does:
The following Java program can query the memory using the Runtime object.
The JVM memory settings are the following:
-Xmsset initial Java heap size -Xmx set maximum Java heap size -Xss set java thread stack size
This means that we can change the initial and maximum heap size using:
java -Xms512M -Xmx1G MyMainClass
M stands for MegaByte and G for GigaByte.
There is also a "standard" way of defining these parameters using the JAVA_OPTS environment variable:
SET JAVA_OPTS=-Xms1G -Xmx1G
For instance, execution scripts created using gradle install will apply the options specified in JAVA_OPTS and in an application-specific variable (e.g. MY_APP_OPTS).
This in practice, does:
java %JAVA_OPTS% MyMainClass
The following Java program can query the memory using the Runtime object.
// credits: mike http://stackoverflow.com/a/7019624
public class MyMainClass {
public static void main(String[] args) {
Runtime rt = Runtime.getRuntime();
long totalMem = rt.totalMemory();
long maxMem = rt.maxMemory();
long freeMem = rt.freeMemory();
double megs = 1048576.0;
System.out.println ("Total Memory: " + totalMem +
" (" + (totalMem/megs) + " MiB)");
System.out.println ("Max Memory: " + maxMem +
" (" + (maxMem/megs) + " MiB)");
System.out.println ("Free Memory: " + freeMem +
" (" + (freeMem/megs) + " MiB)");
}
}
Subscribe to:
Posts (Atom)





