No-hashes bidirectional routing in re-frame with silk and pushy

I recently replaced secretary with silk and pushy in a re-frameproject that was created fresh out of leiningen template and this is how I did it, but first, the reason.

What I like about silk is that it’s bidirectional. It not only parses URLs into data structures but also generates URLs from data structures. This is not unique to silk. bidi also does it and feature-wise they are almost equivalent. On bidi’s website you can find this table comparing various routing libraries:

Continue reading →

macro-key

Macros, the Lisp advantage

Learning about macros in Lisps was one of my biggest whoa-moments in my programming career and since then I’ve given presentations about them to audiences ranging from 1 to 100 people. I have a little script that I follow in which I implement a custom form of the if-conditional. Unfortunately, I don’t think I’ve managed to generate many whoa-moments. I’m probably not doing macros justice. It’s not an easy task as they can be complex beasts to play with.

As we are experimenting with Clojure, I eventually needed a tool that I knew was going to be a macro, and I built a simple version of it. The tool is assert_difference. I don’t know where it first appeared, but Rails ships with one and not satisfied with that one I built one a few years ago. In the simplest case it allows you to do this:

Continue reading →

safe

Forcing SSL in a Luminus application

We tend to be very security conscious at Carousel Apps and one thing we often do is force all our applications to run over TLS (aka SSL), that is, when you go to http://example.com we redirect you to https://example.com. This little article will show you how to do it in a Luminus application.

First, add Ring SSL to your project by editing project.clj , finding the list of dependencies and adding:

Continue reading →

desk or wall - dark

Finally happy with the creation of a web site

In the past, I never managed to build a web site and feel happy with the process. Every time I finished building a web site I would have a list of things to never do again. Until now! So, I thought I’d share.

First, by web site I mean content, like watuapp.com or screensaver.ninja, I don’t mean a web app. I’m happy with how I build web apps although I’m constantly improving and learning and trying new things. When it comes to content, you have to balance some opposing forces:

  • It should look amazing.
  • It should be flexible.

It should look amazing because it’s going to be compared to the ones produced by expert teams of designers at tech companies and if your web site is not indistinguishable from those, your web site will be perceived as unprofessional and as a result, so will you and your product.

I had web sites that looked very good. A graphic designed was hired to produce a pretty illustration of the web site and then a coder turned that picture into HTML and CSS. New pages were created by hand-coding them in HTML. The process of setting up the web site initially was ok, but after that, the workflow was horrendous.

Changes to the web site would come from non-coders, like the CEO, people in marketing or sales, copywriters, and they would be given to a developer to execute. Then we would have to prioritize between improving our web site or improving our product. Almost always product wins… only when the web site got the point of being embarrassingly out-of-date or broken we would consider doing something about it. This situation is annoying and frustrating for both developers and content generators.

The way to solve it is with a Content Management System, where things get flexible. With a CMS suddenly anyone with a browser and the right access can edit the site, add new pages, correct typos, add a FAQ, change a title, write a new blog post, etc. It’s as easy as Microsoft Word and the output is as generic, boring and bland as that of your average Word document. It might be ok for text files, but on the web, that screams unprofessional.

The problem is a tricky one. You might think there’s a nice separation between design and content but that isn’t true. A content writer might decide to have only one column of text instead of two because there’s not enough copy. But the difference between one and two columns is a big one when it comes to design. The content might call for a picture or even worst, a drawing. The design establishes the palette and style of that drawing.

A screenshot of Screensaver Ninja's web site

A screenshot of Screensaver Ninja’s web site at the time of this writing.

I just finished rebuilding the web site for Screensaver Ninja and for the first time I’m happy with the result. Not only how it looks, but the amount of work and funds require as well as the flexibility and workflow going forward.

The CMS we are using is WordPress and we host it at wpengine, which I really recommend. Not the cheapest, but if you care about your web site and you can afford it, you should go there.

One potential approach to having a beautiful site would be to go to 99designs and run a contest for a WordPress theme. My hesitation is around the flexibility of the result. Will the new design be completely hard-coded or will I be able to change the copy? What about changing more involved aspects like the amount of columns or images. I’m not sure and asking around did not reach any useful answers. If you have taken this approach, would you mind sharing how it works with me?

The approach we took was to use a very flexible and advance WordPress theme called X. We chose one of their many templates for a page that we felt would match our current branding and the message we wanted to communicate. We proceeded to fill it up with our own copy following this tenets:

  • Change as little as possible.
  • Ignore all images, just leave them blank.

Once copy was done, we hired a designer through a freelancing marketplace and ask her to produce images to fill in the blanks. We showed her our web site with the blank images as well as the original template with sample images and asked her to keep the style and palette. We provided some ideas for the images and she came up with some as well. After a couple of iterations we had all the needed images.

And that’s it. That’s how we produced that site. Yes, it’s possible that out there there are other sites that look exactly the same, but it’s not a big issue. It’s like worrying that somewhere out there there’s someone with the same t-shirt as you. The chances of you two being seen by the same person in a short period of time is small and even if that happens, whether the t-shirts fits you or not is more important. Nobody will care about your originality of clothing if they look horrible and the same goes for your web site.

Next time i have to build a web site for a product, I’ll do this exercise again and I recommend it to all entrepreneurs that are working in a small company and need to be efficient.

Couple Dancing

Are active women unattractive?

There’s this bit of popular knowledge: “Men find women that make the first move unattractive”. I would like to challenge it because I don’t think we have data to believe it’s true and it’s not a positive belief either.

Let’s start with the latter. If that is true, then, dating as a woman sucks (which as a side effect makes dating as a man suck but I’m focusing on women right now). Imagine going to a restaurant, looking at the menu, finding what you want and not being able to do anything about it. The waiter will come with random dishes and you can say no or yes, but not request the one you want. You can try batting your eyelids at the dish you want, but that’s it.

Let’s move on to the main part of the argument. Do men really find active women unattractive?

I have a few female friends that are close enough to confide in me about their dating shenanigans. They often tell me that when they tried taking an active role and approaching men their dating is extremely unsuccessful. It’s like being active somehow made them very unattractive. The problem I find with this statement is that they are comparing approaching more or less random people against being approached by group that self selected for finding them attractive.

They say things such as “I messaged 10 guys and got no response” when it’s not uncommon for a man to message 500 women to get around ten responses of which 9.9 disappear in the middle of a conversation without even saying goodbye.

The truth is that the dating game is brutal and if you take an active role you’ll get constantly rejected. The unattractive people, that is, the people that rarely get approached by someone (maybe 90% of men and 10% of women) have no other option than to deal with it or be alone.

I would be interested in knowing other people’s experiences and if someone knows of proper science done around this I’d like to know about it. Furthermore if some women would like to attempt some home made science, I’d like to participate.

All or nothing is not an option (or why I love Beeminder)

This post is about a better way of creating good habits in your life. I’m going to start with my desire to have the habit of working out. The lessons here can be applied to everything and I’m going to show you some more examples at the end.

I could track my physical exercise to make sure I keep up. I could use an app like Google Fit. The first day I meet my goal, but eventually, my days will look something like this:

Google FitI already have two missed goals. It’s very easy to get discouraged by missing a goal one day, or a few days in a row, and then drop out of the plan to improve fitness. This is a very bad way of creating new habits.

The problem with this, as with recurring to-do items is that the granularity is too low: a day. Google fit is telling me I failed two days out of four and not counting than on those two other days I made up for it. If Google fit was measuring activity in four days intervals that would have been a success, instead of a half success.

But four days might be too short too. A long weekend and boom! You are out! Maybe we should go for a week or even a month. A month is a nice chunk of time, but it has another problem: it’s so big, you might not know you are actually failing until you are too close to the end to fix it. And even if you fix it, working out like mad on the lat 4 days of every month is not healthy or habit forming.

What we need is something that won’t punish us for a day of rest, but will still keep pushing us up every day. That is Beeminder. Look at my working out chart:

Beeminder chart for working out

Beeminder legend

The pink line with green dots are my data points, the information about when and how much I worked out. It is measured in Fitocracy points, but it could be time working out, kilometers run, kilocalories burnt or anything else you want.

The yellow brick road is my goal. I want to always be above it. The yellow brick road keeps going up every day, so I need to keep on working out to reach my goal. Crossing it is called derailment and you can see it actually happened around mid October. When you cross it, the system resets, gives you a week of advantage and then re-starts. What happened around mid October is that I had a trip, but that’s not excuse. You see… if you allow things like a trip to be an excuse, it’s easy to lose a good habit.

How do you deal with eventualities then? You build up a buffer. Towards the end of November, for example, I did that. Unfortunately then I got a cold and that ate most of my buffer right away, but I’m going up again, building a buffer and staying on the good side of the yellow brick road.

The beauty of this system is that it doesn’t judge a single day, it judges your progress, but it keeps reminding you that you should be making progress.

Another advantage of Beeminder is keeping up with good habits without a routine. If you ask most gym-goes when they go to gym, they have a routine: Monday and Wednesdays! or something like that. I have preferred days, but I don’t have a strict routine, my life just doesn’t allow it, it’s too chaotic. When you don’t have a strict routine it’s very easy to forget to go to the gym because our brains are very bad at correctly keeping track of how much we worked out this week.

You may have noticed the big two numbers on the background of the chart. 10d means 10 days, and that’s how big the buffer is. I could sit on my ass for 10 days and not derail. But then I would be in a very precarious situation in which any eventuality will cause me to derail. I don’t want that to happen, so, I’ll attempt to keep my buffer at 10 days or more. Which leads me to the second number.

$5 is how much derailing will cost me. Those are real dollars, the ones you have to work for. Talk about an incentive! That’s Beeminder’s business model, that’s how they sustain themselves. And it’s a beautiful system because it only hurts when you do something bad, and that penalty is what makes the system work, so you are paying Beeminder only for doing its job. If you never fail, it’s free.

And each time it fails, the amount will go up, so, further failures will be more expensive. I been tinkering with my workouts recently, trying to find the right amount to do every week, so I keep reseting the amount to $5, but once things are stable, I’ll let it go up.

Another thing that I’m doing for my fitness and health is meal tracking. Meal tracking also has this insidious property of an all or nothing system. I started tracking them and one day I forgot. The next day I didn’t forget, but since the data was corrupt already, more corruption wouldn’t be that bad (broken window syndrome?) and the day after that I completely forgot I was doing meal tracking.

I’m still not sure if incomplete meal tracking data is useful or not, but I know the all-or-nothing situation is not conducive to forming habits. Enter Beeminder! First I tried entering how many meals a week I was tracking, but that allowed every day to be corrupt. It’s easy to track meals, it’s harder to track snacks. Allowing every day to be corrupt means you can just track meals, ignore snacks and be successful in the eyes of Beeminder.

Right now I’m experimenting with forcing myself to track 2 days a week, and I’m doing well:

 

Beeminder for meal tracking

That’s where the angle of the yellow brick line comes from. In that chart is 2 per week. If I continue to do well, I’ll keep increasing it, possibly up to 5 or 6.

These are just a couple of examples of what I’m tracking right now. Beeminder comes ready packages with many settings for different tasks and they keep adding them. Take a look at the screen for creating a new goal to have an idea:

Beeminder create goal

Beeminder is not that easy to use. It’s a power-tool, but I really recommend it. Whenever you want to have a new habit in your life, that’s the way to go.