Tuesday, December 27, 2011

Example of Git config file, .gitconfig


[user]
name = Haris
email = haris@xxx.xxx
[core]
excludesfile = /Users/haris/.gitignore
[alias]
   st = status
   c = commit
   co = checkout
   br = branch

Ignore (modified) repository file with Git

So here is a problem, after you add something to git repository you have to remove it so you can ignore it. Problem with this is sometimes you want to ignore file but not remove it from repository. For example I am using RoR on windows and rest team is using MaxOS, so I should not commit Gemfile.lock but I cannot remove it either here is a way:

git update-index --assume-unchanged Gemfile.lock
or you can do same with directory
git update-index --assume-unchanged log

Re-install gem in Ruby

Good way to avoid using install and uninstall commands to re-install the game you can use.
gem pristine <gem name here>
You can also use --all flag to rollback all gems. 

Tuesday, December 13, 2011

Javac debug mode by default

So here is my problem, I am working on a big project and build is organized trough couple of dozens ant scripts. Of course nobody had insight to add debug mode to be configurable on javac tasks so you have to go manually change and add debug="true" attribute.

Not sure if anybody will need this but here it goes, way to default javac to be in debug mode. First go in JAVA_HOME/bin and change javac.exe to javac-old.exe, after that create javac.bat script.

Inside of javac.bat enter following command (this is tested with JDK 1.5_xx).


CALL javac-old -g %* 


What this will do is basically re-route all calls to javac to your "real" javac (in this example javac-old.exe) and pass parameter -g (meaning debug-all mode) and also %* (meaning pass or parameters that you received to next call). Hope it helps somebody.

Thursday, December 8, 2011

Iterate through HashMap template

I created this simple Eclipse template to loop through HashMap:
 ${:import(java.util.Map.Entry)}${String} key;  
 ${Object} value;  
 for (Entry<${String}, ${Object}> ${iterable_element} : ${test:localVar(Map)}.entrySet()) {  
   key = ${iterable_element}.getKey();  
   value = ${iterable_element}.getValue();  
   ${cursor}  
 }  
  • ${:import(java.util.Map.Entry)} - imports java.util.Map.Entry package
  • ${hashMap:localVar(Map)} - shows all variables to user that are of type Map
  • ${cursor} - After template is created, cursor will be positioned here
Here how it looks in eclipse:

To add template in Eclipse, choose Window->Preferences->Java->Editor->Templates->New. As an context select Java statement.

References:
http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Fconcepts%2Fconcept-template-variables.htm

Eclipse color console

Found excellent plugin for Eclipse via StackOverflow. Site link.

Example of reg-ex for selecting error messages:  (.*)(ERROR)(.*)
If you play closer attention in eclipse you can see you can customize each group individually, which is also very cool feature.

Note:
Install Site: http://eclipse.musgit.com
When installing it is important to un-check "Group items by category" check-box.

Ref. link:
http://stackoverflow.com/questions/233790/colorize-logs-in-eclipse-console

Restarting Membase

From time to time, I experienced problems with Membase. After changing networks, or in my case re-establishing VPN connection Membase starts being "confused" and I am not able to access it via localhost IP. Following is the way to remedy that.

 service_stop.bat
 service_unregister.bat
 service_register.bat ns_1@127.0.0.1
 service_start.bat 

Hope it works for you, I am still waiting to see if I will experience any more issues.

Introduction

This blog is created to be used as diary of my work. Comments are welcomed but main purpose of the blog is to be reminder for me of all my ups and downs in the ruthless world of software development.

UPDATE:
I have a pleasure of introducing Boris (screen name: dugokontov) as a co-author for this blog. Maybe this is start of something great, ... , maybe, ... probably not :)