Blog

  1. Code linting with webpack and JSHint

    In this post, we are going to configure webpack to automatically check your code with JSHint with each build. First of all, you need to install the jshint webpack loader. Assuming you are using npm, type npm install jshint-loader in your project directory. This should download jshint-loader into your local node_modules directory and make it available to webpack. Now let’s look at how to configure the webpack JSHint loader. If you want to check your code before any transformations are applied (for instance, because you do not want JSHint to check code generated by a transpiler) you should configure JSHint as a preloader.

  2. Can you use React without JSX?

    That XML which appears to be mixed with JavaScript puts React newcomers off. This XML-like syntax is called JSX. Can you use React without JSX? You can, and it is easier than you imagine. I’ll show you how into this two-part series. First, we need to make something clear: JSX is not XML. Before you deploy your React.js code, you usually use the react-tools package to transform the source into plain JavaScript.

  3. ES6 classes as React components

    The upcoming JavaScript standard, commonly referred to as ES6, will introduce a new syntax to define classes. With React 0.13, you can do without React.createClass and define components with plain functions. You can use ES6 classes to smooth the component definition process. Let’s see how it works. The React functionality is available in the 0.13 beta. Of course, ES6 classes are not implemented in any browser yet, so you will need a transpiler.

  4. FixedDataTable React.js tutorial

    Recently, Facebook has released FixedDataTable , a library to build data tables with React. I tried it out to see how it stacks up against the alternatives. For reference, I have used DataTables, one of the most popular JavaScript table libraries. Setting up the table Creating the table is simple. You just compose and render the Table React component. You pass the data to the table through a rowGetter prop. rowGetter should be a function that takes a row number and returns a row.

  5. Uploading a directory to Amazon S3

    If you want to translate a directory structure on a disk to Amazon S3, you need to use the file path as the object key for the file. For instance, if you want to obtain the path /bar/foo/baz.jpg, you need to store ‘baz.jpg’ with an object key of ‘bar/foo/baz.jpg’. In the administration console, it is possible to create “folders”. There is no such thing in the API. Amazon has decided to introduce this concept in their interface.

  6. Automated deployment

    Recently, I’ve had to work on an application where, for reasons that are best glossed over, a lot of the business logic resides in the Apache configuration. This requires continuously updating a fairly complicated set of mod_rewrite configuration. The configuration needs to be installed on the test server and Apache itself restarted in order to test again. This is not terribly time-consuming, but repeating the over and over can become wearisome and above all, tempt you to modify the Apache config in place instead of keeping all changes under version control.

  7. Computing’s layer cake

    There is the ISA, an abstraction built on top of the physics of the materials out of which electronic calculators are built. From the standpoint of the application developer, the ISA, this incredibly powerful abstraction, is a meaningless mechanism. Its concepts, its meaning and its purpose are the fruits of further abstraction. So, in a computer at least, abstraction is a relative concept. One could fend off accusations of abstract thinking in more general matters by pointing out this fact.

  8. Scraping ISO country codes with Nokogiri

    The ISO country codes are used in many business settings to identify the countries of the world: for instance, to indicate the destination of a shipment. ISO makes the two-letter codes available for free, but the three-letter and the numeric codes are jealously guarded and even if you pay you will not receive them in a very friendly format (only PDF and Microsoft Access are available). Wikipedia has got a table containing all the ISO country codes you will ever need, so I have decided to write a little script to extract the ISO country codes from the web page.

  9. Simple Java builds with SBT

    SBT is a build and dependency management tool written in Scala. When I need to quickly setup a project with some dependencies, I often use SBT, because setting up a simple build is very easy and takes much less typing than with Maven. There are also a couple of other advantages with SBT, namely: sbt automatically recognises your application’s main class and can launch the application just by typing sbt run (no need for a plugin like the Maven exec plugin just to run the application).

  10. Client side web applications

    What happens inside the browser is real The more I develop using Backbone.js the more I realise that client-side heavy JavaScript applications using requires a conceptual shift. We are used to think that the canonical state of the application resides on the server; in a JavaScript application, the canonical state resides in the browser. You need to sync it with the server, but what the user sees and interacts is entirely inside the browser.

  11. The cost of writing

    After a manuscript contains certain number of words, the effort to add more to increases. A 200 page book takes much more than twice the effort of a 100 pages book. Anyone can write a mediocre short story, but you cannot write a some exercise. On the other hand, a book that is twice as long easily delivers less than twice the value to the reader. You can fix higher margins on shorter books.

  12. Jfokus 2012

    Here are my notes after attending the Jfokus in Stockholm this year. Tradition Java EE programmers seem to feel most at home in the JEE/patterns paradigms. Injection, repositories, DAOs are everyday fare. The Java worldview has been abundantly shaped by this ‘software engineering’ worldview. Hacking or intellectual sophistication of the mathematical kind come second. Attendee profile Striped shirts, higher education. Serious engineering. Big company culture. Mostly male, as always. Why aren’t there more women in software engineering?

  13. Fixtures vs Factories

    Many web frameworks integrate fixtures: a mechanism to define sample data to be loaded in the database for testing. The format of choice is often YAML, and the frameworks supplies classes for setting up and removing this data. But all too often you load data into the database when all you really need is to access sample objects in your test code. Inserting data into the database for each run slows down tests considerably.

  14. The refactoring dilemma

    It is an accepted principle that you should leave working code alone. But sometimes you need to modify its behaviour. Now admit that the existing code is fairly opaque, that there are no tests and that the application has never been used nor tested extensively. In any case, you will need to change. You could either introduce your change with minimal modifications refactor the existing code into something more understandable before introducing your change The second option seems riskier at first thought.

  15. Up and down the stack

    I am starting to become more and more convinced that to spot issues with a piece of software, you need to go take a wider view of what consitutes ‘the application’. In a typical Java server side application, ‘the application’ does not include only the code running on the JVM. For instance, looking at a database query log can be very instructive. It is amazing how much the number of generated queries can be reduced in some cases by some simple changes.

  16. How to sell tech books in a physical bookstore

    I am leaning towards the opinion that it is pointless to keep a tech book assortment in a physical bookstore, as the target audience is going to buy their books online and tech books run out of date so quickly that they probably are an inventory headache. There is a large general bookstore called Selexyz in Rotterdam. By all appearances, the least likely place where to look for an interesting tech book assortment.

  17. Mapping a composite key in JPA with @EmbeddedId

    Why @Embedded objects? JPA sits in the uncomfortable middle between managing relations stored in the database and providing object-oriented programming facilities. The general rule is that you annotate your classes with @Entity and each class will correspond to a separate table, with while each field of the class will correspond to a column in that table. The @Embedded and @Embeddable annotation exists to allow you to define two separate classes without using two separate tables in the database.

  18. Packet Analysis with Wireshark

    Some months ago I wanted to remind myself of how the Web works. In addition to Computer Networking I went through the second edition of Practical Packet Analysis, by Chris Sanders. Notwithstanding the general-sounding title, Practical Packet Analysis is very much about Wireshark, which is a GUI tool to analyse network traffic, released under the GPL version 2. On a Fedora Linux machine, running Wireshark is very easy, you just start it up and it does its magic; no configuration required except adding yourself to the wireshark group.

  19. Some Perl idioms

    Recently I have worked with Perl again for some system monitoring scripts. Some people at Lunatech, where I work, are real Perl mavens. Here are some quick reminders Constants use constant CONSTANT_NAME => "constant value"; creates a compile time constant. It is mainly useful for clarifying intent, although if the right side is a more complex expression, for instance a calculation, there might be some performance benefit. Learn more about constants in the official Perl docs.

  20. Classpath trouble

    Java programmers are haunted by inferiority complexes. Before the functional programming wave, a much ink had been spilled debating the benefits of dynamic languages such as Python and Ruby. While the discussion focused mostly on syntax and the pros and cons of dynamic typing, it recently struck me that the major reason something like Python feels so much more easy to experiment with than Java is that the interpreter manages to import most installed third-party libraries automatically.