Loading...
i just started using GIT, i say i love it.
since i have been using IntellIJ idea for a long while, in GIT world i felt like alone though i was using idea but not getting any idea how to live without some IDE’s version control support.
i want to compare my changes before i commit, i want to see more user friendly diff merging tool which idea is providing with other version control support.
so i found GITIDEA over here http://github.com/Fudge/gitidea/tree/master, after cloning and building this project.
i found it wasn’t working. so looking into code i found, it is executing “git” command. since my “git” executable is not under /usr/s|bin, i had to create a new symblink to make it work.
now it is working great, i can see where i have changed just by looking at the code (which bhaves like the usual svn support).
thanks fudge
today i was almost stucked with lucene RangeFilter. here is description -
i have used this query - “price:[0 TO 2000]” to find all items which are bellow 2000.
but my search result was also including 12000 any clue ?
good news is i got my solution though it took bit longer to find my actual reason.
the quick answer is i have to use NumberTools.longToString(…) to index my number fields and to perform range search i have to convert my range value using NumberTools.
you can see my code here -
source view
just digging through lucene source code here is what i found -
to perform range query (which is later rewrite to range filter), it tooks lower token for example price: [0 TO 1000] here ‘0′ is the lower token. it asks TermInfosReader to return a list of available terms for a specific field (such as price here).
RangeFilter iterate through each suggested term and seek for the token position in a random access segment file.
the problem is, the suggested terms are not sorted. also i didn’t find any way to sort them before filtering out.
though i index my content after sorting them properly. but it didn’t affect any result.
since lucene treats everything as string, and it uses String::compare to determine the range position, i think NumberTools, DateTools are the only way out there.
anyway, i am satisfy with what i got.
best wishes,
“…i do what i love to do…”
i had a problem with spring framework, as you know while we are defining dependency over the xml documents, it becomes less changeable unless you know about my recent post about ext-util namespace handler and if you know any other alternatives.
before digging inside the problem better i clarify my context -
i have been working with one of my projects, where i have a several configurations which suppose to be different in different deployment environment, for example - to make my service avail, user has to define his database, his content index directory, server port, ip address and few more.
all these configurations were kept within the spring bean declaration scope. though few of them were moved to the properties file through ext-util namespace handler.
previously to make those configuration changeable i kept those files under WEB-INF/classes so it overrides the default bundled resource.
but still it wasn’t user friendly, since my user has to change one xml document to add more index services also he has to edit different configurations from java properties file.
again when i started bundling jetty with my whole application i found it is tricker to keep those xml outside of application, since i don’t wanna make my user confused with lot of xml files. and i have to keep few xml out of my classpath context, so spring has to load my configuration from my “config/index-configuration/” directory.
though by default spring can do it over “file:///absolute/path/to/file.xml” since spring is using java URL class to locate this resource. but in my case i can’t put any aboslute path.
so i found a simple way out there to support relative path reference.
previously i had the following xml document -
today while i was working with one of my projects, i was wondering how this came up with a bit more fluent with my credential object.
just i can’t resists myself to share this code with every one.
assertNotNull(mProfileManager.authenticate(
Credential.Builder
.aNew().userName(userName).password(password).build()));
within spring container i was getting problem with managing multi level configuration.
for example while i am developing i got a specific filesystem path, database configuration and so on.
this configuration are mostly get changed while i an deploying them on the test or production environment.
this type of scenario is common on most of the projects. managing different scoped configuration is one of the bothering stuff. so i was always thinking some simpler way with in spring container.
so i wrote “ext-util” namespace handler, which is locating property from multi scoped resource.
lets give you a more details use case -
in my test environment i have a property “index.directory=/Users/…/index”
in my test server i use “index.directory=/var/index”
in my production server i use “index.directory=/nfs/index”
here i have a bean which need this property.
< bean id="fsDirectory" class="org.springmodules.lucene.index.support.FSDirectoryFactoryBean" >
< property name="location" value="file:////Users/nhmtanveerhossainkhanhasan/java-tmp/index" / >
< /bean>
you can see the hardcoded configuration. which is not easy to manage.
thats why here my “ext-util” goes with the simplest solution -
< ext-util:resource id="directoryResource" from-property="index.directory" scope="test" / >
< bean id="fsDirectory" class="org.springmodules.lucene.index.support.FSDirectoryFactoryBean" >
< property name="location" ref="directoryResource" / >
< /bean>
now my property resource is locating from “test” scope.
you might think, this “scope=’test’” is again hardcoded stuff, so i also support the following value -
scope=”sys:env”, now you have to define “-Denv=test” while you running your application, and spring bean will find the right property.
so what ever you put over your spring are no longer hardcoded as long as you locate them through “ext-util” which is stands for “extended utility”.
how to use -
include the source file with in your project
keep “META-INF” while you building your jar or keep them inside your classpath.
change your spring configuration -
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:lang=”http://www.springframework.org/schema/lang”
xmlns:aop=”http://www.springframework.org/schema/aop”
xmlns:ext-util=”http://dev.somewherein.net/schema/ext-util”
xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://dev.somewherein.net/schema/ext-util http://dev.somewherein.net/resources/schemas/ext-util-0.1.xsd“/>
basic properties of ext-util -
1. from-property - which property you are looking for.
2. or-default - define default value if no property is found from default scope (system properties) this value is returned.
3. scope - define scope name, by default whatever you set except “sys:” prefixed string, will search for “classpath:”. also you can use “sys:abc” where abc is located from system properties.
4. path-prefix - you can define scope properties path prefix, this prefix can be “file:///, classpath:”. this value also can be prefixed by “sys:abc” where abc is located from system properties.
[download source code]
[download missing xsd file]
best wishes,
i had no experience of using emacs as development environment, so never had any knowledge about emacs color scheme. once when i had been to norway for an official task, i met with one of our escenic colleague “harald khur”.
i was surprised while i had a look on his intelliJ idea color scheme, it all was dark, at the beginning i had a belief that dark color is stressful for eyes. recently when i got introduce with TextMate and their dark color scheme, i was really impressed.
so i didn’t make any delay to let harald know about my interest on his color scheme. he sent me his generated scheme for intelliJ idea. it was simply awesome.
here i have added screen snap of one of my ruby code in dark scheme. i have also attached my modified color scheme as well as the original one, which i received from harad.
modified intelliJ idea emacs color scheme
original intelliJ idea emacs color scheme by harald
i just gathered a few of my known conventions and best practices. i belief this will help many of us.
few of my previously written posts -
usages of “final” keyword in java -
http://www.somewhereinblog.net/blog/hasan/28708715
usages of comment and coding
http://www.somewhereinblog.net/blog/hasan/28704020
let’s check out my recipes -
1. code from your peer developer perspective view.
while you writing your code, always think your code will be reviewed by some other developers, who is not like you,
who is very serious in simple fault and ignorance in writing code. your code will reflect who you are, so better be careful while you exposing yourselves (through writing code).
2. variable convention -
never write short variable name, always write variable which reflects it usages.
for example -
$user = new User() instead of $u = new User(). follow same convention when you have nested “loop”
3. source file naming convention (except java)
set your file name in such a way that will reflect the usages of the file.
for example -
verify_user_authentication.php (or in a packaging manner - user_util_verify_authentication.php). in java you better know how to write package.
4. keep your url domain centric
all urls should be inherited by some specific problem domain for example -
http://abc.com/user/login
http://abc.com/user/register
http://abc.com/user/update
here “user” is problem domain and “login|register|update” are actions or you could say problem.
5. method naming convention -
write method name in such a format that will reflect it usages. or simply make it self describing.
for example -
function verify_user_credentials() {}
def verify_whether_user_profile_is_complete() {}
private void checkUserFlyLimit() {}
6. don’t write query from controller:
build or execute query from DAO or helper or utility or domain itself. don’t put it over controller which limits the reuability and later extendability and interception
7. single concern
while coding, keep your method slim and less concerned about other implementation. for example -
private void isAuthorizedUser(pUser, pAction) {
if (userAlreadyLoggedOn(pUser) && userIsNotBlocked(pUser) && userHasPermission(pUser, pAction)) {
// boooooooooooooooomm…
}
}
8. think from testability
while writing your code always think from testable perspective view. this means, how you could testify your work or module
or bunch of code which your company is paying for.
9. follow coding norms -
i. think before coding
whatever you want to put on your code try to think or imagine before start coding.
ii. dump your think in comment
whatever you thought just write it down over comment or paper or in a common place where you or future developers could have look on. (better place in comment)
iii. write your algorithm in comment.
whatever you planned write in comment before kick start your coding.
iv. set up your unit test case.
find all probable assertion points from use case, put them over your unit test case.
v. write your code
vi. coding routine -
(1) test -> (2) code - go to > (1) [recursively]
10. always put your tag over the source file,
whatever you wrote, that reflects your confident and work efficiency, so better you tag your name over every source code you have written or modified. good for tech lead or project manager, because tagging each file with author name, it creates a hidden responsibility for the author
good for both parties.
for example -
/**
* @author someone
*/
those who doesn’t know about JETTY RUNNER:
JETTY RUNNER is a standalone swing based application which is used to bundle java ee based application along with jetty container. it comes with simple web app configuration xml file and global properties manager through a simple properties file.
actually i have been using this project for my own development solution, so i belief this project will become a great strengthen feature gradually.
JETTY RUNNER is now running on max OSX, i have removed system try support in new tag v-0.2, soon i will release *.dmg package for mac osx. here are few screen snaps -

figure - 1: server console main window

figure - 2: global properties editor
change logs -
1. removed system tray support
2. removed default jmx configuration
3. added “start.sh” to launch JETTY RUNNER on *nix based platform where ruby script is installed.
here are few screen snaps, which i have taken from the newly added ruby script! -

figure - 3: newly added jetty runner on ruby

figure - 4: newly added jetty runner implementation in ruby
this script really great
, at least i like it
i have been practicing test first development (from TDD) approach for last 1.5 years. i wrote a lot of junit test cases and wrote a lot of jmock based mock objects. it was amazing work with it these tools. specially jmock was fantastics and my most favorite mocking tool.
anyway, while i seriously started ruby on rails it is about 2/3 months ago, when i formed my own rails team and started working on first commercial rails project.
at the beginning i was working on IntelliJ IDEA 6M2 on windows environment, where i found running runit test cases are taking longer than we suppose to expect. it was really annoying.
good luck i got my mac book pro where i set up all rails stuff with IntelliJ IDEA 6M2. now i could see a lot more significant difference. now i am really feeling my test environment for rails project over this environment is running more than i expected. it really leads me to belief test driven approach over rails environment is really fast.
it must be some platform related significant changes, which only the expert on that platform can assure me.
by the way, i am really loving intelliJ IDEA and rails over my mac environment.
indeed nothing is special, but this post is about to remind me about the steps i followed to get my mac box with maven and jdk 1.5.
my requirements -
1. maven - 2.0.7
2. jdk 1.5
3. set maven bin to PATH variable.
i had 10.4.10 osx version.
to configure jdk 1.5 (jdk 1.4 is set as default jdk):
cd /System/Library/Frameworks/JavaVM.framework/Versions
sudo rm CurrentJDK
sudo ln -s 1.5 CurrentJDK
to configure maven:
download maven binaries, copy it in your preferred location.
in my case i had it in - /Applications/java/maven-2.0.7/bin/ here.
execute following line -
vi ~/.bash_profile
change PATH with following value -
PATH=/usr/local/bin:/Applications/java/maven-2.0.7/bin/:$PATH
test your configuration -
java -version
it should say - java version “1.5.0_0x”
mvn -version
it should say - Maven version: 2.0.7
thats all will make your maven and jdk 1.5 environment up and running.







| www.flickr.com |
Leave a reply