Jun 27, 2012

Getting Real

getting real

When a colleague recommended a book from 37singals I was skeptical, to say the least, not because it is a bad company, but I do kind of find them very cocky and also my first impression was "Isn't that going to be a something about Ruby?". But  I gave it a try and liked it enough to write a few good words about it.
So what is this book about? In my opinion, it's about agile software development at its core and to quote the authors "Getting Real" is a book about:
The smarter, faster, easier way to build a successful web application.
When I started reading it became obvious right away that this book is a great collection of short stories, tips, quotes and lessons from various companies and software developers and not just 37signals, although it had some very good ones from them also. In some places, the authors were direct about what is their standing, sometimes even cocky but definitely in a really good way.

Getting Real is about doing software with fewer features, fewer docs and less of everything that is not essential. The authors goal is to show a way of doing the software version of the famous Einstein's quote:
"Everything should be made as simple as possible, but not simpler."
The books are organized in various chapters about "priorities", "staffing", "code"... where there are great lessons like:
  • "It's a problem when it's a problem" 
  • "Hire the Right Customer"
  • "You can't Fake Enthusiasm"
  • "Actions, Not Words" and,
  • "Start with No"
While I can't say that I agree with them on all of the lessons I can say  for sure it's a book that should be on every programmer's reading list. Another awesome thing is that, even though, the book can be ordered in hard copy from places like Amazon, 37signals have made it available for free in pdf on the book's site.
I will finish with a quote found in the introduction that is not originally intended for software development, but it fits like a glove:

Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts. This requires not that the writer make all his sentences short, or that he avoid all detail and treat his subjects only in outline, but that every word tell.
                        -    William Strunk Jr., Elements of Style

Jun 16, 2012

HTML 5 data-* attributes, how to use them and why

It is always tempting to add custom attributes in HTML so that you can use the data stored there to do X. But if you do that there is no way of knowing if your HTML attribute will not be overridden in the future and used for something else and additionally you will not be writing valid HTML markup that can pass HTML 5 validator and with that you can create some very bad side effects. That is why there is a spec in HTML 5 called custom data attributes that enable number of useful features.

You may go around and read the specs, but the basic idea is very simple, you can add any attribute that starts with "data-" and that attribute will be treated as non-visible data for that attribute. By non-visible I mean that it is not something that gets rendered to the client so it does not affect the layout or style of the page, but it is there in the HTML so in no way this is private.
So let's get right into it, the following snippet is a valid HTML5 markup

  <div id="awesome" 
     data-hash="3e4ae6c4e30e50e4fdfc7bf439a09974">Some awesome data</div>

Great so now how do you read the data from there? Well, you can go through the elements and get the attributes you need or you can go and use jQuery if it is already there. Using jQuery's .data() API  you can work with the "data-*" elements. One method is .data(obj) added in jQuery1.4.3 that basically retrieves data for the selected element.
For example, if you want to get the value of the data-hash attribute with the following snippet:

 var dataHashValue = jQuery("#awesome").data('hash');

You can also use a JSON syntax in the data fields  for example if you have the following HTML:

<div id="awesome-json" data-awesome='{"game":"on"}'></div> 

Accessing data from js can be done directly just by adding the JSON key to the result:

  var gameStatus= jQuery("#awesome-json").data('awesome').game;

You can also set the data using .data(key,value) directly from JS. One important thing to remember is that the "data-*" attributes should be linked to the element in some way. They should add additional info about that element or the data it contains and not act just as a storage for everything 

You can go around and play with it in the following jsfidde.

Related links:

Jun 12, 2012

Available meta data in Confluence and JIRA

Atlassian uses  something called AUI or Atlassian User Interface that is basically a set of reusable, cross-browser tested UI components (markup, CSS and Javascript) that are based on jQuery and jQueryUI. They are used in most of Atlassian products like JIRA an Confluence.
Common trick for saving some meta-data about the web app and the currently logged in user is used.

<meta name="ajs-context-path" content="/wiki">
<meta name="ajs-version-number" content="3.6.0">
<meta name="ajs-build-number" content="XXX">
<meta name="ajs-remote-user" content="someusername">
<meta name="ajs-static-resource-url-prefix" content="/confluence/s/en/2155/5/_">

There are a few utility functions that can be useful:
AJS.Data.get("some key") ex.AJS.Data.get("remote-user")

AJS.params.somekey  ex. AJS.params.loggedInUser
and if you want to see list of all available params in FireBug console just write
AJS.params and magic happens. You can get info about the current user's username, the locale or the app context path. Please note the depending on the version and the app that you are using like Confuence, Jira or other you will get a lot of params in the list that are version or app specific.

Jun 11, 2012

NSND 2012 Кирилица - Struga

Java and Python joined together
Nista se nece dogodite (NSND)  or roughly translated into English - Nothing will happen is a geek/hackers unconference  where people get together to share knowledge about pretty much anything, starting from programming and computer networks going to growing food on top of buildings and women's rights. The full list can be found on the flowing ether-pad http://piratepad.net/nsndstruga. This year the main event in Macedonia was in Struga and there were very cool talks. I missed some of them but  so here are few that I can take a note of:
  • Happy food production by Luca Pescatore(http://www.pescatoreluca.com)
    File:CDC South Aquaponics Raft Tank 1 2010-07-17.jpgHe talked about aquaponics, windows farming, deep water culture, compositing and basically how to do farming almost anywhere and not just that but also how to farm efficiency. His main idea was to encourage everyone to just try things out. One cool experiment that he did was creating a small farm on top of building.

  • Why python has special methods and why in the world would I use them anyway - Baze Petrushev(twitter)  
    He talk was mostly about the magic methods in python and how they can be used  http://www.rafekettler.com/magicmethods.html. Some considered this a good thing other bad but anyway it was an interesting way to see the operator over-overloading in Python used for good.
  • Wireless Mesh Networks with sensors, Internet Of Things, Open Network project Valent, Valentino, Jasna, Aleks (www.wlan-si.net, www.otvorenamreza.org)
    As the title states the talk was basically about running open networks and how one can setup various sensors and then use the data is gathered via the sensors.
  • ZeroMQ in python - Baze Petrushev and Damjan Gergievski (http://damjan.softver.org.mk/)
    Basically, they covered the idea behind ZeroMQ and they showed us a few small examples on how to get started:
  • I didn't get the chance to see: 
    • Rabsbery Pi by Glisha and Chombe(Chombium)
    • Non-Commercial potatoes by Andrea
    • Free Android by Ivo 
    • Hacklab collaboration disquisition  by Marcel 
      , but from what I heard they were all really inspirational and cool.
  • And last but not least was Women in IT + Open Eduction discussion that became very heat-et. We raised the question on:
  • IBM computers in 1957, 1:1 male female ratio  
    • Do male and female programmers  have equal opportunity?
    • Why is there so small percentage of girls in engineering?
    • Why their only a handful open-source project leaders that are female? 
    • Are program's like Google summer of Code and Gnome women outreach good for improving that percentage and is that artificial?
    • What do Hacker-spaces do right or wrong to have so small percentage of females?

      I cannot say that we had unanimous answers or a simple solution on any of these questions but most definitely the talks were interesting and led to various opinions on the subject.
Females in Engineering talks

Overall it was a great NSND where we had a lot of fun and I hope to see everyone on the next one. Until then:

Jun 7, 2012

Git ignore for Java/JVM projects

Github has this great project hosted on ... GitHub.  What so great about it? Well, it contains git-ignore files for various development environments and programming languages. This gives you a great starting point when creating a new project in any language and any environment.

So this is my starting git ignore on every new java project:


# eclipse specific git ignore

# Intellij 

# External tool builders

# Locally stored "Eclipse launch configurations"

It covers maven based projects with eclipse and using of combination local.properties for overriding  other *.properties that I prefer. Additionally it removes all eclipse specific "settings" that I'm opposed to having them in version control since most of the time it makes no sense for them to be there since they are generated. It's my believe that never eclipse settings should be part of the version control since for almost all of them there are appropriate  maven plug-ins.
The same thing can also be done for InteliJ files.