Skip to content

Got a StackOverflow careers invitation.

04-Aug-11
Google Buzz

They do a pretty cool thing: force you to tell “the truth” — no matter how subjective this term is — as opposed to emasculated official style:

  • what you really did (whatever it means to you);
  • what opensource/published projects did you participate in;
  • Top Stack questions you answered;
  • your professional reading and (sic!) writing.

Here I am: http://careers.stackoverflow.com/victors
(have to complete it still)

Got 5 invites btw.
Actually, just testing a new LiveJournal crosspost plugin.

Why I don’t like GMock

16-Feb-11
Google Buzz

I don’t like GMock.

It’s not as if it was badly written or designed. But it lets you to unit-test dirtier code, tying to method call structure instead of resulting data.

For instance, this GMock code can be rewritten:
More…

Groovy Comparator for class field names

15-Feb-11
Google Buzz

I wonder why this was not in JDK/Groovy Collections.

Just put together a Comparator for StackOverflow question – a Groovy Comparator that would sort class field names in the declaration order. Feel free to use:

class PropComparator implements Comparator {
    private Class clazz
    PropComparator(Class clazz) { this.clazz = clazz }

    int compare(Object o1, Object o2) {
        clazz.declaredFields.findIndexOf{it.name == o1}
          - clazz.declaredFields.findIndexOf{it.name == o2}
    }
}

Couple of Grails tricks to remember: reload scaffolding and fieldValue formatting

14-Dec-10
Google Buzz
  • Grails doesn’t reload scaffolding on-the-fly if you change local templates. But you can open a Groovy console inside application and run in it:
    org.codehaus.groovy.grails.scaffolding.view.
        ScaffoldingViewResolver.scaffoldedViews.clear()

  • In order to change default g:fieldValue formatting for, say, BigDecimal, have a CustomEditorRegistrar in your resources.groovy, and register custom PropertyEditor:
    registry.registerCustomEditor(BigDecimal.class, 'myProperty',
        new OurBigDecimalEditor(BigDecimal.class))

DB2 supports LIMIT and OFFSET syntax, in MySQL compatibility layer…

29-Nov-10
Google Buzz

It hasn’t even been a ten years that DB2, one of the most, er, expensive DBMSes, got a feature needed by every other application – dataset paging.

Before, you had to use window functions rownumber() and fetch first 40 rows only. When used by Hibernate, this resulted ugliness like:

select * from (
  select inner2_.*, rownumber() over(order by order of inner2_) as rownumber_
  from (
    select  ...
    fetch first 40 rows only
    ) as inner2_
  ) as inner1_
where rownumber_ > 20
order by rownumber_

Since this summer version – DB2 9.7.2 – you can just append LIMIT and OFFSET: More…

Prim’s allgorithm in Groovy: inspired by Fortran and Java versions

18-Oct-10
Google Buzz

A friend of mine defended Fortran against half-literate coders on an example of Prim’s allgorithm.

Good pretext for another language comparison. Let’s see Groovy vs Java vs good old Fortran.

Great Fortran implementation

Great Java implementation by Bruno R. Preiss, P.Eng. and scientist.

Some beginner’s C+ implementation (or is it just a link farm? Whatever).

And here’s the algorithm in Groovy, copied as precisely as possible from pseudocode in Russian Wikipedia article.
More…

Precise Redmine burndown chart

11-Oct-10
Google Buzz

I’m thinking of precise Redmine burdown chart, which is not so simple.

  • It has to build burdown chart for a given sprint (Version in Redmine).
  • It has to account issues added to Version and removed from during the sprint.
  • It, after all, has to account for what is considered “closed” status, which might be one of non-stock, custom statuses.

There are couple of Redmine addons, but for now I’m precautious about installing them. They are:

For now, I do it by hand. I put together a SQL query to get me the data:
More…

Google Buzz button for WordPress

12-Feb-10
Google Buzz

Just installed a shiny new Google Buzz button for WordPress by Tejaswini, Sanjeev.
I hacked it a bit, to align to the right. Download this plugin version here, until author updates it.

I’m replacing a diggIt button; Buzz fits my color scheme better :D

Enjoy.

“group by” clause in GORM/HibernateCriteriaBuilder

08-Feb-10
Google Buzz

Just in case someone needs a code snippet.
This one groups Prices by PriceProvider and was intended to pick only last 5 values for each PriceProvider – but sadly, it’s impossible without window functions. Which are not supported in Hibernate in any way.
More…

Hibernate join bug

03-Sep-09
Google Buzz

Hibernate bug 1895 seems to be still there since 2006.
If, for instance, in Grails, such a syntax won’t work for you (it won’t):

def books = Book.findAll("FROM Book AS b JOIN Chapter AS c WHERE c.active = :isActive")

with a NullPointerException in “HqlSqlWalker.createFromJoinElement” — just use alternative join syntax, via WHERE:

def books = Book.executeQuery("select b FROM Book AS b, Chapter AS c WHERE c.active = :isActive")

Move “WITH” conditions to “WHERE” as needed.

Self-update library for .NET using WiX: DotUpdater

03-Sep-09
Google Buzz

Just published a library I created on one of past jobs out of Updater Application Block and WiX’s ClichThrough component.
Please meet: DotUpdater
It can auto-update an application, just create a RSS feed of updates and Windows Installer (MSI) binaries.

Link Taxonomy Terms to Views in Drupal

07-Aug-09
Google Buzz

Imagine a task (actually, quite common), if you have:

  • a nodes (articles, ads, whatever) taxonomy in Drupal,
  • a taxonomy-based url path rewrites, like /monkeys/primates/homosapiens
  • and want to show a block/page View with articles only from current path term (and, maybe, its subterms).

It might be a hard time finding out the current term. One could try having two nested views, passing a current term as a parameter to nested view, like Dustin Currie did.

Though, Views has several pre-defined solutions. Just go to /admin/build/views/ and enable this one: “Default Node view: taxonomy_term”, (clone it to play safe), voila!

You got a View for the current term.