sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Sunday, March 04, 2012
Wednesday, February 29, 2012
Creating a local maven repository in your company
Try
Artifactory.
It is also useful (if there are more than 1-2 developers working together) to set up an internal repository (likeArtifactory) and use that internally. It makes it much easier to deal with libraries that are not in the public repos (just add it to your internal repo!) and you can also use build tools to push builds of your own code there so other can use the modules without checking out the code (useful in larger projects)
It is also useful (if there are more than 1-2 developers working together) to set up an internal repository (likeArtifactory) and use that internally. It makes it much easier to deal with libraries that are not in the public repos (just add it to your internal repo!) and you can also use build tools to push builds of your own code there so other can use the modules without checking out the code (useful in larger projects)
Tuesday, February 28, 2012
Checkout subdirectory in git for previous revision
From: http://stackoverflow.com/questions/5859943/subdirectories-in-checked-out-directory-of-a-previous-revision-not-disappearing
To checkout a sub-folder from a previous revision, what you do is three commands:
To revert back to the HEAD state:
I didn't try the three HEAD commands above. But should work.
To checkout a sub-folder from a previous revision, what you do is three commands:
git reset <hash> thing/
git checkout <hash> thing/
git clean -fd thing/
To revert back to the HEAD state:
git reset HEAD thing/
git checkout HEAD thing/
git clean -fd thing/
I didn't try the three HEAD commands above. But should work.
Handling null values in freemarker using if condition
From: http://stackoverflow.com/questions/306732/how-to-check-if-a-variable-exists-in-a-freemarker-template
Two solutions:
First Solution:
Two solutions:
First Solution:
Example 1:
<#if userName??>
Hi ${userName}, How are you?
</#if>
Example 2:
<#if router.cableFacility.direction??> Hi ${
router.cableFacility.direction
}, How are you?</#if>
Second Solution:
Hi ${userName!}, How are you?
the default operator also supports a default value, such as:Hi ${userName!"John Doe"}, How are you?
Thursday, February 23, 2012
Tuesday, February 21, 2012
Executing a command using another user on linux
If the user has no shell associated with it (ie. passwd indicates a nologin at the end of
su -s /bin/bash -c "command to run" apache
If user has a login shell then there is no need for -s /bin/bash
su -s /bin/bash -c "command to run" apache
If user has a login shell then there is no need for -s /bin/bash
Wednesday, February 15, 2012
Sunday, February 12, 2012
Excellent tip for importing static methods in eclipse
One of the great features of Java 1.5 is Static Imports. In order to configure Eclipse to search for static imports in a particular class, you have to perform the following steps:
1. Navigate to Preferences by clicking on the Window -> Preferences Menu Item
2. Navigate to Java -> Editor -> Content Assist -> Favorites using the menu tree (or search for Favorites using the search bar at the top)
3. Click the New Type button
4. Type in the name of the Class that has static methods that you would like to be used when using Eclipse's Content Assist / Code Completion (eg Assert)
5. Click on the Browse button which will bring up the Open Type Dialog using what you entered previously as the search criteria
6. Find the class that you would like to add, and then click Okay on the Open Type Dialog
7. Then Click Okay on the New Type Favorite Dialog.
1. Navigate to Preferences by clicking on the Window -> Preferences Menu Item
2. Navigate to Java -> Editor -> Content Assist -> Favorites using the menu tree (or search for Favorites using the search bar at the top)
3. Click the New Type button
4. Type in the name of the Class that has static methods that you would like to be used when using Eclipse's Content Assist / Code Completion (eg Assert)
5. Click on the Browse button which will bring up the Open Type Dialog using what you entered previously as the search criteria
6. Find the class that you would like to add, and then click Okay on the Open Type Dialog
7. Then Click Okay on the New Type Favorite Dialog.
Now when you are editing Java code, instead of typing Assert.assertEquals, you only need to type assertEquals, with Ctrl-Space, and the Assert Type will be searched for in order to resolve the static import.
Sunday, February 05, 2012
Inject Util Class with Google Guice vs static Methods?
http://stackoverflow.com/questions/4370683/inject-util-class-with-google-guice-vs-static-methods
It depends on the nature of your convert()
method.
If it's something
- simple
- deterministic (i.e. doesn't depend on additional parameters)
- have no side effects
- is unlikely to change
- etc
you can keep it as a static utility method.
Otherwise it's a good candidate for dependecy injection (you can rename it to ConversionService
to make it more clear).
convert()
method.ConversionService
to make it more clear).Tuesday, January 31, 2012
Monday, January 30, 2012
Adding Recent File List Plugin to VIM
From: http://stackoverflow.com/questions/3171284/recent-file-history-in-vim
MRU (Most Recently Used) Plugin
http://www.vim.org/scripts/script.php?script_id=521
How to add on unix:
On vim enter:
:help add-plugin
Steps:
mkdir ~/.vim
mkdir ~/.vim/plugin
cd
To Use:
While working on vim, enter the command:
1. :MRU
2. Select a file, press enter, thats it.
MRU (Most Recently Used) Plugin
http://www.vim.org/scripts/script.php?script_id=521
How to add on unix:
On vim enter:
:help add-plugin
Steps:
mkdir ~/.vim
mkdir ~/.vim/plugin
cd
~/.vim/plugin
wget -O mru.vim http://www.vim.org/scripts/download_script.php?src_id=11919To Use:
While working on vim, enter the command:
1. :MRU
2. Select a file, press enter, thats it.
ProcessBuilder Runtime Redirecting Output and Exec uting
The following discuss details of the problem:
http://stackoverflow.com/questions/5986324/processbuilder-redirecting-output
Shell redirection operators are unknown to
http://stackoverflow.com/questions/5740390/printing-my-macs-serial-number-in-java-using-unix-commands/5740673#5740673
http://stackoverflow.com/questions/3777654/problem-with-runtime
http://stackoverflow.com/questions/3259143/split-a-string-containing-command-line-parameters-into-a-string-in-java
Wonderful answer here:
ProcessBuilder redirecting output
http://stackoverflow.com/questions/5986324/processbuilder-redirecting-output
Shell redirection operators are unknown to
ProcessBuilder
. Put your command in a shell script and execute it, as shown here. Alternatively, use bash -c
, as shown here.
Or prepending "bash -c" to the exec
http://stackoverflow.com/questions/5740390/printing-my-macs-serial-number-in-java-using-unix-commands/5740673#5740673
How to use OutputStream for output redirection
http://stackoverflow.com/questions/3777654/problem-with-runtime
Split a string containing command-line parameters into a String[] in Java
http://stackoverflow.com/questions/3259143/split-a-string-containing-command-line-parameters-into-a-string-in-java
Wonderful answer here:
Here is a pretty easy alternative for splitting a text line from a file into an argument vector so that you can feed it into your options parser:
This is the solution:
public static void main(String[] args) {
String myArgs = Commandline.translateCommandline("-a hello -b world -c \"Hello world\"");
for (String arg:myArgs)
System.out.println(arg);
}
Git, How to revert to a previous commit?
Best on this is:http://stackoverflow.com/questions/4114095/git-revert-to-previous-commit-how
I like this way:
I like this way:
git checkout 0d1d7fc32 .
git commit
Also you can do the following if you have some local modifications:
git stash git checkout 0d1d7fc32 git stash pop git commit
Subscribe to:
Posts (Atom)