IMG_1891-0.jpg

Goodmorning to the sea

[Bug 1462311] Re: proftpd mod_copy issue (CVE-2015-3306)

A remote execution bug was reported in ProFTPd one month ago and it’s still unfixed in Debian 7 and Ubuntu 12.04 – scary.

Source: [Bug 1462311] Re: proftpd mod_copy issue (CVE-2015-3306)

Working with objects, in JavaScript

JavaScript is designed on a simple object-based paradigm. An object is a collection of properties, and a property is an association between a name and a value. A property’s value can be a function, in which case the property is known as a method. In addition to objects that are predefined in the browser, you can define your own objects. This chapter describes how to use objects, properties, functions, and methods, and how to create your own objects.

Source: Working with objects – JavaScript | MDN

Common mistakes: UNION vs. UNION ALL › Cybertec – The PostgreSQL Database Company

In my role as a PostgreSQL consultant and trainer there are a couple of issues, which pop up on a regular basis.

Source: Common mistakes: UNION vs. UNION ALL › Cybertec – The PostgreSQL Database Company

Little things you’d better remember.

Faces – a flickr gallery

 

A flickr gallery I like a lot. I’m not a photographer but if I were I’d love to short portraits like these.

 

Elon Musk Debuts the Tesla Powerwall – YouTube

 

Wireless keyboard on a phone

I’m writing this post by typing on wireless keyboard into my phone. It’s the first time I connect a wireless keyboard to my iPhone 5 and I have to say it’s a pretty interesting experience. 

I’m typing directly into the WordPress app’s input field. There’s some lag, which makes it feel odd. I don’t know if it’s the bluetooth connection, if it’s the input field itself that does not expect such a fast input sequence. 

I suppose this input field is somehow translating what I type into HTML, doing some extra work at each keystroke. In a previous test I did with the Notes app the input was pretty smooth with no lag at all.

On a quick search on Amazon I saw there are some interesting models, including one which is capable to swtich quickly among up to three devices. Very nice.

Why would one use such a keyboard to type into the phone? I don’t know but I suppose that when you are on a gig and you want to be free to draft a blog post without carrying your laptop with you, such setup may be a pretty good alternative. On a tablet it makes definitely much more sense. 

Anyway the experience is positive and I’m considering buying one for myself (this is the Apple keyboard I borrowed from a friend’s home computer).

Do you ever use a wireless keyboard on a phone/tablet device? I’m curious to know about your work/entertainment setup.

My favourite light-background colorschemes for VIM

I’m addicted to Vim colorschemes. I change them very frequenty, I’m unable to settle to a favourite one. Sometimes light backgrounds, sometimes dark ones. During the last few months I’ve come up with a list of the ones I switch more frequently.

Here is a list of the light background ones, unranked. Most of them you can find among the deafult Gvim installation.

Buttercream

Selection_012

This is pretty neat and probably one of my favourites.

Autumnleaf

Selection_013

The one thing I don’t like about this one is the cursive for strings.

martin_krischik

Selection_014

Sometimes you are in the mood for background highlight.

Papayawhip

Selection_015

Sometimes you need the world to be more on the pink shades.

Fine_blue

Selection_016

Ice ice baby.

Biogoo

Selection_017

This is the one I turn on more frequently when I need  a light background which is not too bright.

Conclusion

I intentionally left out two important choices, which are Solarized and Dawn. I know they are popular, I gave them a try but they didn’t stick.

What about you? I’d like to read about your favourite ones.

Scaling Elasticsearch for Production at Verizon: 500 Billion Documents & Counting | Elastic

Elastic{ON} Video of the Week: Scaling Elasticsearch for Production at Verizon: 500 Billion Documents & Counting | Elastic.

 

Postgres essentials: window functions

Window functions in Postgres allow you to perform computations related to the set of rows being returned by your query. Imagine you can group your query by a certain column, and have computations be limited by the boundaries of that group (in other words, a window).

To better explain the concept, let’s look at a very simple example (data can be downloaded here).

Imagine we have a table with 100 records, with four columns:

  • id (primary key)
  • name
  • a performance score from 1 to 100
  • marital status field

Something like this:

Selection_542

Now let’s suppose you want to view the best performers in each marital status. First thing to do is to order the list by marital status and performance. From the following image you can see what a window is:

Selection_547

Now that we have clear what a window is, we can introduce the concept of window functions. Very easily, window functions are functions which operate on those windows of data, in other words on those sub-recordsets. We can add columns with the result of a function that takes into account only the values of other rows inside the boundaries of the window. 

We can use the rank() function to show the rank of each record in its own window. A rank is not like a row number. A ranks output an equal value for an equal input inside a given set. 
 
Let’s write this query: 
 
Selection_549
 
Which leads to the following result: 
 
Selection_550
As you can see ranking restarts when a new window starts
 
Now go back and take a look at the query. Right after the call to the rank() function we define a partition criteria and a sorting. Those two parameters are required to specify the scope, the field of action of the window function. 
 
Now let’s suppose we want to query for just the first ranked people in each marital status. It’s very easy now that we have rank column in place. Just wrap everything inside a subquery and add a where condition. 
 
Selection_001
Selection_002
 

Conclusion

Before window functions it was not that easy to get the same result. I don’t know precisely because I’m not that old. Anyway I suppose the same result was a matter of nested subqueries and similar sorcery.

There’s much more you can do with window functions. Have a look a the documentation page for the feature and for the available functions.

I hope you found this useful. Here you can download the data I used for this post, in case you want to try it yourself.