Search This Blog

13 November 2016

Postman

    We were reminded to mention a great tool - Postman, because of this “New from Postman” issue:


    I don’t remember since when I started receiving these Postman newsletters, but they are great, Postman is great. And I am sure we would all be very surprised that there are a lot of people developing services or applications that consume services, that don’t use such tools. It may not be Postman, there are other solutions, but please do use something.

10 November 2016

Someone said let's self sign it

So I wanted to check my voting location for the Presidential elections in Bulgaria and I came across this on the GRAO website:https://www.grao.bg/elections 



Then in one of their pages they explain that the site is not secure and that the user has to install their root certificate in order to secure their connection to the website.




So they are using a self signed certificate and they are telling us it is OK.
Not cool guys. Don’t invent security. Just get a proper certificate !

01 November 2016

Store locations

Some time ago I came across an interesting puzzle:

http://www.questers.com/news/quest-wars-win-pass-jprime-2016

In short we have some customers home addresses/locations and we need to place our store where there is the biggest concentration of people.

Here is our solution as an Android application, which uses k-means clustering algorithm. This way the engineers and marketers sent on distant planets can map the location of the population and calculate where is the most convenient location for stores, star ports and other facilities to provide the best customer service :)

Link to the repository at GitHub:
https://github.com/ektodorov/EwokStore

 Initial screen



 We add the population (coordinates are from 0-100), and input the area that the store is going to cover  (size is from 0-100)





 We see the store coverage area (the lighter colored rectangle) and the biggest cluster of population (the darker colored rectangle).

05 September 2016

Java reference notes

    The other day I saw the notes of a Junior Java web developer and it looked like a textbook. Well may be not like textbook, but at least a good quick reference guide. So I asked to photocopy them and here they are for everyone that may need it:

31 August 2016

Java WeakReference counterpart

We have all heard of different reference types - weak, strong, soft. We think that the WeakReference class is very useful. But we noticed the lack of StrongReference class and we think it can be useful as well. So here is our implementation of StrongReference:


1:  public class StrongReference<T> {  
2:    
3:      private T mType;  
4:        
5:      public StrongReference()  
6:      {  
7:          super();  
8:      }  
9:        
10:      public StrongReference(T aType)  
11:      {  
12:          super();  
13:          mType = aType;  
14:      }  
15:        
16:      public synchronized T get() {return mType;}  
17:      public synchronized void set(T aType) {mType = aType;}  
18:  }  

We are using synchronzed on the get and set methods, because we use the StrongReference concurently, and this was the use case we had in mind when creating it in the first place. But if your use case is different you can remove them.

25 July 2016

Validating an expected JSON

    Let's say we are getting a JSON from a service and we want to know if it is following the contract that this service has promised. When we use the JSON we would handle cases of missing keys, but we have to look at the actual response to see if everything is OK with it, and that takes time. What if we want an indication prior to that, that there is something wrong with the data of the JSON. We have implemented a few short methods that take as arguments the JSON that we intend to use and a JSON that is a model of the data that we expect to get. The method traverses the model and checks to see if the JSON that we are going to use matches it.
    We can also use it as part of our automation test for our service.
    How does it work. We have two JSON strings. One is a response that we get from a service and the other is a model of the JSON structure that we expect the service to return - the contract of the service to the clients/users. We check that the response corresponds to the model - if all the keys and structure of the model are present in the response, then it is valid.
Here is a short description of the algorithm:

Validate JSON
Does the key from the model exist in the response:
    No - response is not valid
    Yes:
        is the value a JSON object:
            Yes -> validate JSON object
        is the value a JSON array:
            Yes -> validate JSON array
                    else continue to next key.

    The repository for the project is at GitHub and contains implementation for Objective-C, Java and Go:

15 June 2016

List with sticky headers and List with sticky headers and expandable items

    Here is a project that implement a list with sticky headers - list that has two types of list items (lets say sections and items in each section), when scrolled to the top the header sticks to the top of the list.
    The other project builds on the same implementation, but we can collapse and expand the sections of the list.


The project is at GitHub:

https://github.com/ektodorov/ListStickyHeadersExpandable