An important lesson in consumer protection (for small businesses owners)

I recently bought a desktop computer from Dell and by the time it arrived I was wondering if it was powerful enough, so, I took it for a spin and found out that my suspicious were correct. It was not powerful enough for my needs. We’ll, no big deal, all I had to do was give them a call to arrange for a return and a refund. Dell told me I had 14 days to return it.

When I started the process they asked me if I bought it as an individual or a business. Well, it was for business and it was paid by my business. I didn’t know it at that point, but that meant that the European Union laws for consumer protection didn’t apply.

The EU has a cool off period on online purchases of 14 days. Within those 14 days you can return an item without having a reason. This is for people, not companies. I was exempt of that protection and the terms of service of Dell is: no returns. I got so used to be able to return whatever I want, that this really surprised me. It was surreal.

Did you notice that Dell return policy is the absolute minimum that the EU requires? 14 days for consumers, no return for businesses. I thought most companies were accepting returns because keeping customers happy it’s good for business. Certainly some are, for example, Amazon never refused a return no matter whether it was a business or personal purchase.

This made me wonder: how many other companies look good because the EU is making them and not because they are good. What will happen when the UK leaves the EU? I bet many of these battles will have to be fought again, some will be lost, some will be won.

After a lot of whining and protesting, Dell accepted to take the computer back, but from now on I’ll think twice about buying things from Dell. Even when buying Dell products.

For example, for my new workstation I need a monitor and my research pointed me to one that Dell offers. If you I went to Dell’s web site, and clicked “For Work”, the monitor was 20% cheater than if I clicked “For Home”. Maybe that’s the cost of accepting returns, maybe it’s just dynamic pricing. Thankfully I found the monitor on Amazon, cheaper than the cheapest price Dell was charging, on prime, so delivery was even faster. I obviously ordered them on Amazon.

Picture by www.cafecredit.com

Advertisements

Goodbye Apple

My main computer was an Apple MacBook Pro for about 8 or 9 years. That is, until last January, when I said good-bye to Apple. It wasn’t easy, but the last iteration of the MacBook Pro is terrible.

I’m not against the touch bar. I think keyboards need more innovation and I applaud the effort. But aside from the touch bar, the keyboard feels weird because they tried to make their power-user product super thin.

Let me repeat that: for their power user product Apple favors a bit of thinness over usability.

I don’t know how much of that also pushed them to produce an underpowered product with not a lot of RAM, very expensive hard drive, very expensive in general.

At the same time as I was in need of a new laptop, I was putting together a gaming computer and I decided instead to add some more funding to that project and turn it into a proper workstation. For the price of a MacBook Pro, I got the most amazing workstation I could ever want. Granted, it’s not mobile, but I need my nice keyboard and monitors to work anyway, so, it suits me well.

I’m really surprised to be back using Microsoft Windows as my main operating system; something that hasn’t happened since Windows NT 4.0. And I’m happy about it.

Goodbye Apple, it was fun while it lasted.

Using Oracle’s JDK in CircleCI (with Gradle)

I’m evaluating re-writing Dashman in Java (instead of Electron). It’s too early to tell, but so far all the experiments and the early re-write are going well and it’s solving the issues I was having with Electron. This short post is about CircleCI.

Because now I’m using common, boring technologies, I decided setting a CI was going to be easy enough that I didn’t mind doing it and I chose CircleCI, mostly because of their free plan.

Sadly, my project didn’t work out of the box. JavaFX was nowhere to be found. The reason was that CircleCI uses OpenJDK instead of the Oracle’s JDK by default. I guess that’s enough for the vast majority of people. Switching to Oracle’s JDK was not hard, but I couldn’t find a straightforward post, so, this is it.

CircleCI gives you a configuration example that contains something like this:

version: 2
  jobs:
    build:
      docker:
        # specify the version you desire here
        - image: circleci/openjdk:8-jdk

I’m not very familiar with Docker and how CircleCI uses, all I know is that it’s a container system for, essentially, operating system images. CircleCI has a repo of Docker images and the one that include’s Oracle’s JDK is called circleci/jdk8. What comes after the colon in the config is the version of the Docker image (I think) which Docker calls tags and for this one, at the time of this writing, there was 0.1.1 but you can easily check the latest one here: https://hub.docker.com/r/circleci/jdk8/tags/

With that in mind, the config should now look like this:

version: 2
  jobs:
    build:
      docker:
        # specify the version you desire here
        - image: circleci/jdk8:0.1.1

And that’s it… well, unless you are using Gradle. That image doesn’t provide Gradle, so, you need to replace all the mentions of gradle with gradlew and use the wrapper that should be part of your repo. But before that will work, you need to make that file executable on the CircleCI server by calling chmod +x gradlew on it. The resulting config file for me looks like this:

# Java Gradle CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/jdk8:0.1.1

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/postgres:9.4

    working_directory: ~/repo

    environment:
      # Customize the JVM maximum heap limit
      JVM_OPTS: -Xmx3200m
      TERM: dumb

    steps:
      - checkout
      - run: chmod +x gradlew

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "build.gradle" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run: ./gradlew dependencies

      - save_cache:
          paths:
            - ~/.m2
          key: v1-dependencies-{{ checksum "build.gradle" }}

      # run tests!
      - run: ./gradlew test

And that’s it, that worked.

Setting (database) credentials on a Spring Boot project, the right way

Searching online for how to set up the credentials to access the database (or any other service) while in development leads to a lot of articles that propose something that works, but it’s wrong: putting your credentials in the application.properties file that you then commit to the repository.

The source code repository should not have any credentials, ever:

  • You should be able to make your project open source without your security being compromised.
  • You should be able to add another developer to your team without them knowing any credentials to your own development machine.
  • You should be able to hire a company that does a security analysis of your application, give them access to your source code and they shouldn’t gain access to your database.
  • You should be able to use a continuous integration service offered by a third party without that third party learning your database credentials.

If you want to see what happens when you commit your credentials to your repo, check out these news articles:

That’s probably enough. I hope I convinced you.

In an effort to find a solution for this, I asked in Stack Overflow and I got pointed in the right direction.

Leave application.properties where it is, in your resources of code folder, commit it to the repository. Instead, create a new file in ${PROJECT_ROOT}/config/application.properties and also add it to your version control ignore file (.gitignore, .hgignore, etc). That file will contain the credentials and other sensitive data:

# This should be used only for credentials and other local-only config.
spring.datasource.url = jdbc:postgresql://localhost/database
spring.datasource.username = username
spring.datasource.password = password

Then, to help onboard new developers on your project (or yourself in a new computer), add a template for that file, next to it. Something like ${PROJECT_ROOT}/config/application.template.properties that will contain:

# TODO: copy this to application.properties and set the credentials for your database.
# This should be used only for credentials and other local-only config.
spring.datasource.url = jdbc:postgresql://localhost/database
spring.datasource.username = 
spring.datasource.password = 

And voila! No credentials on the repo  but enough information to set them up quickly.

Disclaimer: I’m new to Spring Boot, I only started working with it a few days ago, so, I may be missing something big here. If I learn something new that invalidates this post, I’ll update it accordingly. One thing I’m not entirely sure about is how customary it would be to have ${PROJECT_ROOT}/config/application.properties on the ignore list. Please, leave a comment with any opinions or commentary.

Pedals and Wheels for Elite Dangerous and other cockpit games

In this video I’m showing you how I installed my pedals for Elite Dangerous and other cockpit games so they would be solid including dealing with the wheels in my chair.

The wheels:
US: http://amzn.to/2hvoIdt
UK: http://amzn.to/2wtiv4u

Elite Dangerous: https://www.elitedangerous.com/

My HOTAS setup: http://www.thrustmaster.com/en_UK/products/hotas-warthog
US: http://amzn.to/2v4yFDz
UK: http://amzn.to/2v4DBbK

My startup, Dashman: https://dashman.tech

Disclaimer: some of the links contain affiliate codes and I would get a commission.

My take on an AJAX re-frame effect handler

There’s already an AJAX re-frame effect handler provided by Day8, the same guy who made re-frame and there’s nothing wrong with it. From the documentation, this is how you use it:

(re-frame/reg-event-fx ::http-post
  (fn [_world [_ val]]
    {:http-xhrio {:method          :post
                  :uri             "https://httpbin.org/post"
                  :params          data
                  :format          (ajax/json-request-format)
                  :response-format (ajax/json-response-format {:keywords? true})
                  :on-success      [::good-post-result]
                  :on-failure      [::bad-post-result]}}))

That felt a little to verbose for my taste, so I made my own that you use like this:


(re-frame/reg-event-fx ::http-post
  (fn [_world [_ val]]
    {:ajax {:post            "https://httpbin.org/post"
            :params          data
            :on-success      [::good-post-result]
            :on-failure      [::bad-post-result]}}))

If you are familiar with cljs-ajax, you’ll notice the pattern. Day8’s solution uses the raw cljs-ajax API, while I use the higher level one. Day8’s is more versatile, mine is more compact.

This is my solution:

(ns ajax-fx-handler
  (:require [ajax.core :as ajax]
            [re-frame.core :as re-frame]
            [clojure.set :as set]))

(re-frame/reg-fx :ajax
  (fn http-effect [request]
    (let [request-verb (set/intersection #{:get :post :put :patch :delete :head :options :trace :purge}
                                         (set (keys request)))]
      (if (not= 1 (count request-verb))
        (throw (js/Error (str "When specifying an AJAX request, one and only one verb should be specified. Found: " request-verb)))
        (let [request-verb (first request-verb)
              url (get request request-verb)
              request (if (contains? request :on-success)
                        (assoc request :handler #(re-frame/dispatch (conj (:on-success request) %)))
                        request)
              request (if (contains? request :on-failure)
                        (assoc request :error-handler #(re-frame/dispatch (conj (:on-failure request) %)))
                        request)
              request (-> request
                          (dissoc request-verb)
                          (dissoc :on-success)
                          (dissoc :on-failure))
              ajax-fn (cond
                        (= request-verb :get) ajax/GET
                        (= request-verb :post) ajax/POST
                        (= request-verb :put) ajax/PUT
                        (= request-verb :patch) ajax/PATCH
                        (= request-verb :delete) ajax/DELETE
                        (= request-verb :head) ajax/HEAD
                        (= request-verb :options) ajax/OPTIONS
                        (= request-verb :trace) ajax/TRACE
                        (= request-verb :purge) ajax/PURGE)]
          (ajax-fn url request))))))

Feel free to use it, but, is it worth releasing it as a library? does anybody want that?