New life goal

…not really… I just realized how crappy this blog is and I think I need to keep on writing posts so the old ones will disappear  just in case,  someone’s visiting this website.

I have also started a new photographic project… I might be slightly illegal though ’cause I am taking pictures of people without warning and unless I publish the work and accidentally have one of them come across it, they will never know!

Anyway, we live in London; we are being video recorded (I wanted to use the word filmed but I realised how wrong it is) all the time. When I am in public places I don’t expect privacy. Right? So I will check with my lawyer and let you know more. 😛

(I am also considering making an app just for this project as well.. Maybe I wont, but who knows)

Preparing for my interview

It’s been a few months now working for this big company. Contracting as a junior / graduate and tomorrow is the day.

I am interviewing for a permanent position.

I ‘ve heard that the level and the expectations are quite high and only one out of ten makes it. Thats the statistics, but statistics is the scientific way to support a lie, right?

I ‘ve prepared but never feel ready. There is always something missing, something that can go wrong. The stress, the mind clarity…

Tech interviews reminds me of the final school exams.

– Sit down and TDD that and explain your self and your thoughts and everything…

– Ok. Now how would you design this service that can handle 600 trillion request per millisecond and the bandwidth need is 800TB per second.

– Tell me about your flows. What is your biggest flow as a human being? Do you suck your finger before you fall sleep? Do you cry alone in a shady corner after jerking off in the middle of the night? (Why is there a shady corner in your room in the middle of the night?)

aaaaaahhh!

I love job interviews.

 

[edit] I got the job![/edit]

It’s only rock n roll

This Friday I made a childhood dream come true. Or simply killed it.

I went to The Rolling Stones concert. I didn’t know what to expect. I knew that I would feel goosebumps on the hearing of the famous announcement “Ladies and Gentlemen… the Rolling Stones” and I did. I was super excited.

I remember my first Rolling Stones albums I was 14. My parents weren’t big fans of the foreign music apart from some Italian pop song of the sixties, so I had never listened to the Rolling Stones before.

I went to the record store. I picked a record. Didn’t buy it.. too expensive. I gave it to the man who owned the shop and asked for a pirate copy.

I didn’t go to pick up, until he met me on the road and reminded me of the copy. I felt shame,  so I went to the store to pick it up the very next day.  To my surprise it was the best music I had ever listened to. I clearly remember the feeling of listening to “she’s a rainbow” for the first time. What an experience. I miss that excitement, I think I ‘ve lost the ability to get excited like that. I simply can’t get that feeling anymore. Have I grown old?

No filter tour, London

Configuring Spring boot with JPA, Postgresql and Liquibase

Ok folks, I know that you do not exist… I write this blog so I can keep record of my activities mainly for myself so I want be exhaustive on the topic. I will keep notes mainly for myself but if you feel like needing more elaboration on one of the topics then drop me a comment and I will see what I can do.

So what is Liquibase?

database-independent library for tracking, managing and applying database schema changes

Marvelous! Instead of having to create the DB tables with scripts liquibase is taking care of that and we do nothing apart from creating the db and configuring our app to point to that db.

Maven dependencies:

<dependencies>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
   </dependency>

   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
   </dependency>

   <dependency>
      <groupId>org.liquibase</groupId>
      <artifactId>liquibase-core</artifactId>
   </dependency>

   <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>42.2.2</version>
   </dependency>

   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
   </dependency>
</dependencies>

Liquibase file configuration

/src/main/resources/db/changelog/db.changelog-master.yaml

databaseChangeLog:
    - includeAll:
        path: db/changelog/changes/

schema

/src/main/resources/db/changelog/changes/v0001.sql

create table admin_user (
  id serial primary key not null,
  username varchar(25) not null,
  password varchar(255) not null,
  authenticationToken varchar(255),
  date timestamp without time zone
);

Be careful with the schema. If you run the application with this schema and you change the v0001.sql enough to change the file hash spring boot fails to fire up the application and then you need to delete the tables of the database. (Or something else I am not aware of at the moment)

In case you want to make a change you create another file ex. v0002.sql with the changes.

The POJO:

package gr.glab.blogpost.entities;

import javax.persistence.*;
import java.util.Date;
import java.util.Objects;

@Entity
public class AdminUser {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    private String username;
    private String password;
    @Temporal(TemporalType.TIMESTAMP)
    private Date latestLoginDate;
    private String authenticationToken;

    public AdminUser(){}

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getLatestLogginDate() {
        return latestLoginDate;
    }

    public void setLatestLogginDate(Date latestLogginDate) {
        this.latestLoginDate = latestLogginDate;
    }

    public String getAuthenticationToken() {
        return authenticationToken;
    }

    public void setAuthenticationToken(String authenticationToken) {
        this.authenticationToken = authenticationToken;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AdminUser user = (AdminUser) o;
        return Objects.equals(id, user.id) &&
                Objects.equals(username, user.username) &&
                Objects.equals(password, user.password) &&
                Objects.equals(latestLoginDate, user.latestLoginDate) &&
                Objects.equals(authenticationToken, user.authenticationToken);
    }

    @Override
    public int hashCode() {

        return Objects.hash(id, username, password, latestLoginDate, authenticationToken);
    }

    @Override
    public String toString() {
        return "User{" +
                "id='" + id + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", latestLogginDate='" + latestLoginDate + '\'' +
                ", authenticationToken='" + authenticationToken + '\'' +
                '}';
    }
}

I know… but at the moment I don’t like lombok.

And finally the controller, which will need an AdminUser like json body (or an empty json will do since its not required) and it will always return 200 😛

package gr.glab.almaadmin.controllers;

import gr.glab.almaadmin.entities.AdminUser;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/user")
public class AuthenticatorController {


    @RequestMapping(value = "auth", method = RequestMethod.POST)
    public ResponseEntity<?> authanticateUser(@RequestBody AdminUser user) {
        return new ResponseEntity<>(HttpStatus.OK);
    }
}

The best part is now. Running a psql image on a docker container and make it work with the app…

After we make sure that we have docker installed, we type the following in the command line to run the image:

sudo docker run --name <container-name> \
 -p 5432:5432 \
 -e POSTGRES_DB=<db-name> \
 -e POSTGRES_PASSWORD=<user's password> \
 -d postgres

We can name our container however we want and we need to make sure that the db-name will be the same as the one in the configuration file which is presented bellow.

So in the application properties file we have the following:

/src/main/resources/application.properties

spring.datasource.url=jdbc:postgresql://172.17.0.1:5432/<db_name>
spring.datasource.username=postgres
spring.datasource.password=<type the password here>
spring.datasource.driver-class-name=org.postgresql.Driver

spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false

How do we get the ip on the above file? In the console:

$ docker inspect <container-id>

and we are looking for the gateway.

How do we access psql running on the container from the command line?

 $ psql -h localhost -p 5432 -U postgres -d almadb

That was it… Now let’s write some code…

Uk boobies for noobies

I am gonna write about my introduction to british trash press.

best friend's cousin got us both pregnant
it can happen even to the best families (as a greek phrase suggests)

I had an amusing flight to Marseille learning about how important it is to be proud of your boobs and other important things. Of course sharing is always beneficial!

all boobs are awesome... be proud of yours
κερνάμε και βυζγια σ’ αυτο το μπλογκ (I cannot translate that)

So my flight was powered by ‘The Sun’ which has an even more amusing subtitle considering the content. ‘for a greater Britain’ – is it the size of boobs and does the size really matter?
What can I say. I guess the marketing team did a very good job on that.

Anyway, that reminded me of how people keen on boobies but too shy to admit used to go on the ‘movies’. Those movies were a bit special though. There was a random film playing but nobody cared. Everyone was waiting for this instant clip of porn that was embedded on the film of the advertised movie every few minutes. This instand clip of porn was called tsonda; and now tsonda is the most common word for porn in the greek language.

That of course was happening a few years ago when the ethics and savoir vivre were heavily (and negatively) impacting a nation known to be the number one in the world in terms of sex frequency. Unfortunately things have hardly changed and there is a reason for that. For me it’s called marketing. It’s easier to use sexuality if it has the taste of something forbiden. People are more interested under those circumstances.

Anyway; I don’t want to get too serious here. So take my partner’s 6-year old nephew dealing with it.