Warning: Declaration of LJXP_Walker_Category_Checklist::start_lvl(&$output, $depth, $args) should be compatible with Walker::start_lvl(&$output, $depth = 0, $args = Array) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php on line 796

Warning: Declaration of LJXP_Walker_Category_Checklist::end_lvl(&$output, $depth, $args) should be compatible with Walker::end_lvl(&$output, $depth = 0, $args = Array) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php on line 796

Warning: Declaration of LJXP_Walker_Category_Checklist::start_el(&$output, $category, $depth, $args) should be compatible with Walker::start_el(&$output, $object, $depth = 0, $args = Array, $current_object_id = 0) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php on line 796

Warning: Declaration of LJXP_Walker_Category_Checklist::end_el(&$output, $category, $depth, $args) should be compatible with Walker::end_el(&$output, $object, $depth = 0, $args = Array) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php on line 796

Warning: Cannot modify header information - headers already sent by (output started at /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php:796) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 60

Warning: Cannot modify header information - headers already sent by (output started at /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php:796) in /home/victorsergienko/victorsergienko.com/wp-includes/feed-rss2.php on line 8
code name http://victorsergienko.com Programming: Java, Groovy, C++, .NET, OOD, a little this and that Tue, 29 Mar 2016 17:03:01 +0000 en-US hourly 1 https://wordpress.org/?v=4.7.5 Documenting Python REST API whining http://victorsergienko.com/documenting-python-rest-api-whining/ http://victorsergienko.com/documenting-python-rest-api-whining/#respond Fri, 18 Oct 2013 12:35:34 +0000 http://victorsergienko.com/?p=219 A downside of Python dynamic nature is that REST API documentation won’t generate right out of your code, like Swagger does for Java.
The best you can get is http://pythonhosted.org/sphinxcontrib-httpdomain/, for which you need to duplicate all of your REST service method signatures in ReStructured text, a format I’m not a fan of.
One can get a pretty-formatted Twitter-Bootstrap-enabled doc for Eve REST framework. But I’m not using Eve, and one has to duplicate service methods API in a Cerberus schema description.

http://victorsergienko.com/documenting-python-rest-api-whining/feed/ 0
Fast Windows JSON pretty-printer http://victorsergienko.com/fast-windows-json-pretty-printer/ http://victorsergienko.com/fast-windows-json-pretty-printer/#respond Wed, 06 Feb 2013 11:07:34 +0000 http://victorsergienko.com/?p=210 Just built a Win32 version of yajl, a comandline C JSON pretty-printer and validator. Viva CMake.
Welcome to downoad.

http://victorsergienko.com/fast-windows-json-pretty-printer/feed/ 0
The dead end of Russian software engineer? http://victorsergienko.com/the-dead-end-of-russia-software-engineer/ http://victorsergienko.com/the-dead-end-of-russia-software-engineer/#respond Wed, 12 Dec 2012 17:00:08 +0000 http://victorsergienko.com/?p=202 Ex-USSR has got a great school of engineers. Russia is the 3rd software outsourcing country (market) in the world.
Russian (let’s use the name, though I’m Ukrainian, for instance) engineers are very educated and think out of the box.

We got OOP gurus, Java buddhas, UI Picassos, Haskell Lamas, agile addicts and tech team management professionals. Even some good business analysts.

This leads them nowhere. Most of them don’t have a decent area to apply their superior skills.

Most of them stay employed in software outsourcing, the best paid engineering area… with no perspective.

The whole essence of software outsourcing means you got CxOs (including CTO) onshore, and software team offshore. They don’t hire anyone higher than a team leader there, period.

If you got the experience to move into management area, still — people here rarely start their own companies — because of fear, procrastination, lack of business knowledge/education/infrastructure or connections, family that needs that daytime job, or because of the USSR anti-commercial culture that is still strong in engineering estate. I’m probably describing myself now.

So we got a lot of people who grew ready for CTO/VPE positions – very limited in a ways to found a company, find funding, or create an own product.

Apparently, the next step should be to go find an investor or a founder… I personally have no idea where to look. But I’m going to try.

http://victorsergienko.com/the-dead-end-of-russia-software-engineer/feed/ 0
Getting Glassfish stdout logging under control http://victorsergienko.com/getting-glassfish-stdout-logging-under-control/ http://victorsergienko.com/getting-glassfish-stdout-logging-under-control/#respond Wed, 21 Nov 2012 14:59:22 +0000 http://victorsergienko.com/?p=195 By default, Glassfish does an ugly thing: takes an application’s stdout/stderr and wraps it into its own log with INFO level for stdout and WARN level for stderr.
Other logging facility normally log to stdout.
In the end, a log entry looks pretty stupidly (and it’s damn multiline!):

[#|2012-11-21T11:25:07.225+0200|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=100;_ThreadName=Thread-2;|11:25:07.225 [http-thread-pool-8080(2)] DEBUG c.mycompany.packages.SomeClass - Finally, some useful text!

One can replace a Glassfish logging server-wide.
There’s a logging.properties file in the root of Glassfish domain, it has a “handlers” property that one can swap for Logback’s handler.
Of course, this requires adding Logback JUL bridge to Glassfish classpath.

http://victorsergienko.com/getting-glassfish-stdout-logging-under-control/feed/ 0
Rendering QR codes to SVG http://victorsergienko.com/rendering-qr-codes-to-svg/ http://victorsergienko.com/rendering-qr-codes-to-svg/#respond Wed, 21 Nov 2012 13:12:58 +0000 http://victorsergienko.com/?p=191 Had a hard time rendering a QR-code to SVG. Drawing simple rect-s didn’t work well, visible gaps appeared between bars.

I looked for a SVG QR renderer, but apparently neither zxing nor other libraries have a gapless algorithm. There is an online renderer by Kerem Erkan that uses path tag, but the author is apparently not intending to publish the code.

The closest algorithm that CAN be used to render a QR code as a whole path is marching squares, with a usable implementation here. Still there’s a lot to be done in order to render a whole path, mostly hole detection.

Luckily, it was enough to group the rect-s together with a g tag.

http://victorsergienko.com/rendering-qr-codes-to-svg/feed/ 0
Now on free CDN http://victorsergienko.com/now-on-free-cdn/ http://victorsergienko.com/now-on-free-cdn/#respond Wed, 11 Apr 2012 10:13:40 +0000 http://victorsergienko.com/?p=182 Thanks to Dreamhost, now running on CloudFlare CDN.
WP Super Cache happily supports it.

BTW CloudFlare got a free plan, and it’s easy to set up so that it doesn’t interfere:

  • Add a cdn subdomain to your hosting;
  • Add your domain to CloudFlare;
  • On CloudFlare, disable CDN for all subdomains except for cdn.
  • Set up your site to serve static content from cdn.*. Do it by hand, by mod_rewrite or whatever — I am using WordPress “WP Super Cache” plugin here.
http://victorsergienko.com/now-on-free-cdn/feed/ 0
Got a StackOverflow careers invitation. http://victorsergienko.com/got-a-stackoverflow-careers-invitation/ http://victorsergienko.com/got-a-stackoverflow-careers-invitation/#comments Thu, 04 Aug 2011 13:51:26 +0000 http://victorsergienko.com/?p=173 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.

http://victorsergienko.com/got-a-stackoverflow-careers-invitation/feed/ 9
Why I don’t like GMock http://victorsergienko.com/why-i-dont-like-gmock/ http://victorsergienko.com/why-i-dont-like-gmock/#respond Wed, 16 Feb 2011 10:55:51 +0000 http://victorsergienko.com/?p=161 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:

        loggingService.sendNotification(match{ !it.shouldNotify() }).stub()
        loggingService.sendNotification(match {
            it.shouldNotify() && it instanceof HubOfflineNotification && it.deadEntities == [hub]
        loggingService.saveEvent(LogEventType.HUB_BECAME_OFFLINE, match { it }, customer)
        loggingService.saveEvent(LogEventType.CAMERA_DIED, match { it }, customer).never()

        play {



        assertEquals 1, LogEvent.countByEventType(LogEventType.AGENT_BECAME_OFFLINE)
        assertEquals 0, LogEvent.countByEventType(LogEventType.METER_BECAME_DEAD)
        assertEquals 1, LogEvent.countByEventType(LogEventType.SENDING_NOTIFICATION)

which relies only to call outcome, and not to implementation details.

http://victorsergienko.com/why-i-dont-like-gmock/feed/ 0
Groovy Comparator for class field names http://victorsergienko.com/groovy-comparator-for-class-field-names/ http://victorsergienko.com/groovy-comparator-for-class-field-names/#comments Tue, 15 Feb 2011 14:23:19 +0000 http://victorsergienko.com/?p=157 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}

http://victorsergienko.com/groovy-comparator-for-class-field-names/feed/ 2
Couple of Grails tricks to remember: reload scaffolding and fieldValue formatting http://victorsergienko.com/couple-o-grails-tricks-reload-scaffolding-and-fieldvalue-formatting/ http://victorsergienko.com/couple-o-grails-tricks-reload-scaffolding-and-fieldvalue-formatting/#comments Tue, 14 Dec 2010 15:29:09 +0000 http://victorsergienko.com/?p=149
  • 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:
  • 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))
    • ]]> http://victorsergienko.com/couple-o-grails-tricks-reload-scaffolding-and-fieldvalue-formatting/feed/ 3 DB2 supports LIMIT and OFFSET syntax, in MySQL compatibility layer… http://victorsergienko.com/db2-supports-limit-and-offset/ http://victorsergienko.com/db2-supports-limit-and-offset/#respond Mon, 29 Nov 2010 13:28:35 +0000 http://victorsergienko.com/?p=133 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:

      SELECT ... LIMIT 5 OFFSET 10

      No wrapping into 2 (!!!) external SELECTs.
      One downside is that mighty DB2 does have MySQL compatibility layer mode. Turn it on when starting DB2:

      $ db2stop
      $ db2start
      http://victorsergienko.com/db2-supports-limit-and-offset/feed/ 0
      Prim’s allgorithm in Groovy: inspired by Fortran and Java versions http://victorsergienko.com/prims-allgorithm-in-groovy-inspired-by-fortran-and-java-versions/ http://victorsergienko.com/prims-allgorithm-in-groovy-inspired-by-fortran-and-java-versions/#comments Mon, 18 Oct 2010 09:43:02 +0000 http://victorsergienko.com/?p=126 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.

      class Edge {
          Integer v1
          Integer v2
          Integer weight
          Edge(Integer v1, Integer v2, Integer w) {
              this.v1 = v1
              this.v2 = v2
              this.weight = w
          boolean contains(Integer v) { v1 == v || v2 == v }
          Integer otherThan(Integer v) { v1 == v ? v2 : v1 }
      class Graph {
          List<Integer> V
          Collection<Edge> E
          // Dumbest implementation
          List<Integer> getIncident(Integer v) { E.findAll{ it.contains(v) }.collect{ it.otherThan(v) } }
          Edge findEdge(Integer v1, Integer v2) { E.find{ it.contains(v1) && it.contains(v2) } }
          Number weight(Integer v1, Integer v2) { findEdge(v1, v2)?.weight ?: Double.POSITIVE_INFINITY }
      Collection<Edge> prim(Graph G) {
          Set<Edge> T = []
          Map<Integer, Number> d = [:] + G.V.collect { new MapEntry(it, Double.POSITIVE_INFINITY) }
          Map<Integer, Integer> p = [:] + G.V.collect { new MapEntry(it, null) }
          d[G.V[0]] = 0
          List<Integer> Q = G.V.collect{it}
          Q.metaClass.extractMin = { ->
              // Dumbest implementation
              int minimum = Q.min { d[it] }
              int indexOfMinimum = Q.indexOf(minimum) // here Groovy fails to make a shortcut.
              return Q.remove(indexOfMinimum)
          Integer v = Q.extractMin()
          while (!Q.isEmpty()) {
              G.getIncident(v).each { Integer u ->
                  if(Q.contains(u) && G.weight(u, v) < d[u]) {
                      d[u] = G.weight(u, v)
                      p[u] = v
              v = Q.extractMin()
              T << G.findEdge(p[v], v)
          return T
      void testPrim() {
          Set<Edge> expected = [
              new Edge(1, 2, 1),
              new Edge(2, 3, 1),
              new Edge(3, 4, 1),
              new Edge(4, 5, 1),
          Set<Edge> edges = [
              new Edge(1, 3, 2),
              new Edge(1, 4, 3),
              new Edge(1, 5, 2),
              new Edge(2, 4, 7),
              new Edge(3, 5, 2),
          Graph G = new Graph(V: 1..5, E: expected + edges)
          Set<Edge> T = prim(G)
          assert expected.equals(T)
          println "it worked!"

      Not too bad, er? I see only a couple of Groovy overhead points: constructing a Map from collect{}, and absence of findIndexOfMin().
      Of course, we could avoid long type declarations, but I like strict typing.
      Make your conclusions.

      http://victorsergienko.com/prims-allgorithm-in-groovy-inspired-by-fortran-and-java-versions/feed/ 2
      Precise Redmine burndown chart http://victorsergienko.com/precise-redmine-burndown-chart/ http://victorsergienko.com/precise-redmine-burndown-chart/#comments Mon, 11 Oct 2010 09:28:30 +0000 http://victorsergienko.com/?p=119 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:

        i.id, i.subject, i.estimated_hours, 
        j.created_on, jd.value, s.name new_status,
        old_versions.name old_version,
        new_versions.name new_version
        issues i
        inner join journals j on j.journalized_id = i.id and j.journalized_type = 'Issue'
        inner join journal_details jd on jd.journal_id = j.id
        inner join versions on i.fixed_version_id = versions.id
        left outer join issue_statuses s on s.id = jd.value
        left outer join versions old_versions 
          on jd.prop_key = 'fixed_version_id' 
            and jd.old_value = old_versions.id
        left outer join versions new_versions 
          on jd.prop_key = 'fixed_version_id' 
            and jd.value = new_versions.id
        (versions.name = '1.0.8' or old_versions.name = '1.0.8' or new_versions.name = '1.0.8')
        and property = 'attr'
        and jd.prop_key in ('status_id', 'fixed_version_id')
      order by i.id, created_on
      http://victorsergienko.com/precise-redmine-burndown-chart/feed/ 4
      Google Buzz button for WordPress http://victorsergienko.com/google-buzz-button-for-wordpress/ http://victorsergienko.com/google-buzz-button-for-wordpress/#respond Fri, 12 Feb 2010 10:09:44 +0000 http://victorsergienko.com/?p=116 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 😀


      http://victorsergienko.com/google-buzz-button-for-wordpress/feed/ 0
      “group by” clause in GORM/HibernateCriteriaBuilder http://victorsergienko.com/group-by-clause-in-gormhibernatecriteriabuilder/ http://victorsergienko.com/group-by-clause-in-gormhibernatecriteriabuilder/#respond Mon, 08 Feb 2010 17:33:08 +0000 http://victorsergienko.com/?p=110 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.

      def c = Price.createCriteria()
      c.list {
          priceProvider {
              company {
                  country {
                      eq('currency.id', 1L)
          order('timestamp', 'desc')
      http://victorsergienko.com/group-by-clause-in-gormhibernatecriteriabuilder/feed/ 0
      Hibernate join bug http://victorsergienko.com/hibernate-join-bug-createfromjoinelement/ http://victorsergienko.com/hibernate-join-bug-createfromjoinelement/#comments Thu, 03 Sep 2009 17:35:44 +0000 http://victorsergienko.com/?p=102 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.

      http://victorsergienko.com/hibernate-join-bug-createfromjoinelement/feed/ 1
      Self-update library for .NET using WiX: DotUpdater http://victorsergienko.com/self-update-library-for-net-using-wix-dotupdater/ http://victorsergienko.com/self-update-library-for-net-using-wix-dotupdater/#comments Thu, 03 Sep 2009 11:48:43 +0000 http://victorsergienko.com/?p=97 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.

      http://victorsergienko.com/self-update-library-for-net-using-wix-dotupdater/feed/ 20
      Link Taxonomy Terms to Views in Drupal http://victorsergienko.com/link-taxonomy-terms-to-views-in-drupal/ http://victorsergienko.com/link-taxonomy-terms-to-views-in-drupal/#respond Fri, 07 Aug 2009 13:46:30 +0000 http://victorsergienko.com/?p=90 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.

      http://victorsergienko.com/link-taxonomy-terms-to-views-in-drupal/feed/ 0
      Diff a Micorosoft Office documents inder SVN? http://victorsergienko.com/diff-a-micorosoft-office-documents-inder-svn/ http://victorsergienko.com/diff-a-micorosoft-office-documents-inder-svn/#respond Mon, 13 Jul 2009 15:56:28 +0000 http://victorsergienko.com/?p=85 In case you, like me, need to compare version of Office documents (under Windows), just know that TortoiseSVN got a pretty set of scripts for that.
      It works out of box!
      You can compare Office documents just like plaintext files!.
      Just tried it and it worked. If you were afraid of trying, like me – don’t be.

      http://victorsergienko.com/diff-a-micorosoft-office-documents-inder-svn/feed/ 0
      Grails: mocking domain objects in unit tests http://victorsergienko.com/grails-mocking-domain-objects-in-unit-tests/ http://victorsergienko.com/grails-mocking-domain-objects-in-unit-tests/#comments Mon, 13 Jul 2009 09:13:19 +0000 http://victorsergienko.com/?p=79 We’re trying Grails, Rails-like web application framework for Java.
      It’s fine, just that Groovy debugger support is, er, imperfect, even in the best Gruoovy IDE – IDEA.

      And, if you want to unit test, you won’t have fancy domain class methods addTo* – like Customer.addToOrders().
      They’re generated by Grails on startup.
      In order to have addTo*(), inherit from GrailsUnitTestCase and call mockDomain(Customer) in setUp().

      Oh, if you get "NullPointerException: Cannot invoke method containsKey() on null object", add super.setUp() to yout testcase’s setUp().

      Having proper save() is more tricky. Implementation from mockDomain() works to some extent: it won’t save connected objects.
      So, in order to get save() working, you have to do something like this:

          def savedCustomers = []
          void setUp() {
              Customer.metaClass.save = { saveCustomer(delegate) }
              mockDomain(Customer, savedCustomers)
          private def saveCustomer(c) {
              if (c.orders != null) {
                  c.orders.each { x -> x.save() }
      http://victorsergienko.com/grails-mocking-domain-objects-in-unit-tests/feed/ 3