12/14/2012

Conf Calls Howtos

 Do you keep falling asleep in meetings and seminars? What about those long
 and boring conference calls? Here's a way to change all of that.

 1. Before (or during) your next meeting, seminar, or conference call,
 prepare yourself by drawing a square. I find that 5x5" is a good size.
 Divide the card into columns-five across and five down. That will give you
 25 one-inch blocks.

 2. Write one of the following words/phrases in each block:
 * synergy
 * strategic fit
 * core competencies
 * best practice
 * bottom line
 * revisit
 * expeditious
 * to tell you the truth (or "the truth is")
 * 24/7
 * out of the loop
 * benchmark
 * value-added
 * proactive
 * win-win
 * think outside the box
 * fast track
 * result-driven
 * empower (or empowerment)
 * knowledge base
 * at the end of the day
 * touch base
 * mindset
 * client focused)
 * paradigm
 * game plan
 * leverage

 3. Check off the appropriate block when you hear one of those
 words/phrases.
 4. When you get five blocks horizontally, vertically, or diagonally,
 you must stand up and shout "BULLSHIT!"

 Testimonials from satisfied "BullShit Bingo" players:
 * "I had been in the meeting for only five minutes when I won."- Adam W.,
 Atlanta
 * "My attention span at meetings has improved dramatically."- David
 T.,Florida
 * "What a gas! Meetings will never be the same for me after my first win." -
 Dan J., New York City
 * "The atmosphere was tense in the last process meeting as 14 of us waited
 for the fifth box." - Ben G., Denver
 * "The speaker was stunned as eight of us screamed 'BULLSHIT!' for the third
 time in two hours."-Bob Q., Indianapolis
 

10/18/2012

Null, null, Nil, Nothing, None, and Unit in Scala

Null- is a subtype of all reference types; its only instance is the null reference. Since Null is not a subtype of value types, null is not a member of any such type.
null- Is an only instance of Null. Similar to Java null.
Nil- Represents an emptry List of anything of zero length. Its not that it refers to nothing but it refers to List which has no contents.
Nothing is a subtype of every other type (including scala.Null); there exist no instances of this type.
None This case object represents non-existent values. Just to avoid null pointer exception. Option has exactly 2 subclasses- Some and None. None signifies no result from the method.
Unit - There is only one value of type Unit, (), and it is not represented by any object in the underlying runtime system. A method with return type Unit is analogous to a Java method which is declared void.
Note: Any is supertype of AnyRef and AnyVal. AnyRef is the supertype of all the reference classes (like String, List, Iterable) in scala. AnyVal is the supertype of all the value classes (like Int, Float, Double, Byte, Short..). Null is a subtype of all the reference classes. null is its only instance. Nothing is subtype of every other type i.e of reference and value classes.
Think- AnyRef == Object in Java.
The above is a breif summary of a wonderful post by Matt Malone where he has explained all these concepts in depth with examples. Read the blog post here.

9/26/2012

Wrapping the call in Seam contexts

http://seamframework.org/Documentation/ReplacingServletsWithSeamResources#H-WrappingTheCallInSeamContexts

1. You can map the <web:context-filter/> in components.xml to wrap all calls on a particular URL pattern, see reference documentation.

2. You can wrap a call manually in a particular Servlet:

class MyServlet extends HttpServlet {

    protected void service(final HttpServletRequest request, final HttpServletResponse response)
            throws ServletException, IOException {

        new ContextualHttpServletRequest(request) {
            @Override
            public void process() throws Exception {
                doWork(request, response);
            }
        }.run();
    }

    private void doWork(HttpServletRequest request, HttpServletResponse response) {
        Component.getInstance(...);
    }

}

9/05/2012

Map request parameters as a Map in a controller method

@RequestMapping(value = "/selectAppsForAsset", method = RequestMethod.POST)
public @ResponseBody String selectAppsForAsset(@RequestParam(value = "pid") String assetPublicId, @RequestParam(value="map[]", required=false) String[] selectedAppNumbers) {
...
}


Here it is:
@RequestParam(value="map[]", required=false) String[] selectedAppNumbers

9/04/2012

Eсли ты заметил, что скачешь на дохлой лошади, – слезь с неё

Индейская мудрость гласит: «если ты заметил, что скачешь на дохлой лошади, – слезь с неё».

Но в жизни мы часто руководствуемся другими стратегиями:
– достаём более крепкий кнут;
– меняем всадника;
– говорим себе: «мы и раньше скакали на дохлой лошади»;
– создаём рабочую группу для изучения дохлой лошади;
– посещаем разные места,чтобы посмотреть, как скачут на дохлых лошадях там;
– создаём отдел по оживлению дохлой лошади;
– устраиваем тренировки,чтобы научиться лучше скакать на дохлой лошади;
– проводим сравнительный анализ всевозможных дохлых лошадей;
– изменяем критерии,устанавливающие, что лошадь мертва;
– нанимаем на стороне людей, якобы умеющих скакать на дохлой лошади;
– внушаем себе, что ни одна лошадь не может быть настолько дохлой, чтобы на ней нельзя было скакать;
– проводим исследования,чтобы узнать, есть ли более хорошие или более дешёвые дохлые лошади;
– объясняем себе, что наша дохлая лошадь быстрее, лучше и дешевле, чем другие;
– создаем совет по качеству, чтобы найти применение дохлым лошадям;
– пересматриваем условия работы для дохлых лошадей;
– расширяем сферу применения дохлых лошадей;
– и, наконец: образуем особый отдел, в котором изучают потребности именно дохлых лошадей.

8/30/2012

Removing duplicates from the table

SELECT DISTINCT a.*
  FROM dbo.AssetDealsConnections a
  JOIN dbo.AssetDealsConnections b
  ON a._fk_Asset = b._fk_Asset AND a._fk_stageID = b._fk_stageID AND a._pk != b._pk
  ORDER BY a._fk_Asset, a._pk;


 DELETE b
  FROM dbo.AssetDealsConnections a
  JOIN dbo.AssetDealsConnections b
  ON a._fk_Asset = b._fk_Asset AND a._fk_stageID = b._fk_stageID AND a._pk > b._pk;

8/06/2012

Using Spring @Configurable and @Autowire to inject DAOs into domain objects

http://sujitpal.blogspot.com/2007/03/accessing-spring-beans-from-legacy-code.html

http://stackoverflow.com/questions/4703206/spring-autowiring-using-configurable

7/24/2012

ConcurrentModificationException

ConcurrentModificationException usually has nothing to do with multiple threads. Most of the time it occurs because you are modifying the collection over which it is iterating within the body of the iteration loop. For example, this will cause it:

Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
    Item item = (Item) iterator.next();
    if (item.satisfiesCondition()) {
       collection.remove(item);
    }
}
In this case you must use the iterator.remove() method instead. This occurs equally if you are adding to the collection, in which case there is no general solution. However, the subclass ListIterator can be used if dealing with a list and this has an add() method.

7/18/2012

Hot Deployment in JBoss

compile war:war
(or package war:war, which is slower)
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <outputDirectory>d:\jboss5\server\default\deploy</outputDirectory>
                </configuration>
            </plugin>

The fastest way to delete a large folder in Windows

rmdir /s /q folder