I started to get interested in web development in 1999 (15 years old), when I built my first HTML page. I started in programming with BASIC (for the TI-83 calculator) and C, by my own initiative. Have been doing PHP since 2001. I’ve been learning more languages over the years but it was with PHP that I gained more experience.

In 2002 I enrolled in an electronics engineering course in Oporto’s University but decided to interrupt my studies due to a change in life goals, having returned to my home town where I currently live (in the Azores, Portugal). I…


A logical fallacy is usually what has happened when someone is wrong about something. It’s a flaw in reasoning. They’re like tricks or illusions of thought, and they’re often very sneakily used by politicians and the media to fool people.

Thou shalt not commit logical fallacies is a website where we can learn from several logical fallacies that we commonly make in our argumentation. Each fallacy has a dedicated page which we can use to send to someone we believe have committed a logical fallacy.


Opening a set of html files locally in the browser is not a good reflection of what happens in a real web server. It’s ok for a javascript library demo but for other purposes it’s easy enough to have a basic HTTP server so why not?

Just as I wrote in my last tip, there’s another python module that runs a basic HTTP server in our current directory.

$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
# Or on a different port
$ python -m SimpleHTTPServer 8080
Serving HTTP on 0.0.0.0 port 8080 ...

I use this a lot, especially to preview the build result from my site, or from documentation I’m doing in Sphinx.


When I’m developing code that uses a web service, and since I always have a terminal window open, I like to check or test responses with curl.

The problem is it’s difficult to read JSON responses without indentation and line breaks, but that’s easily solved in any system that comes with python installed:

curl -s <url> | python -m json.tool

Before

$ curl -s "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%3D26189893%20and%20u%3D'c'&format=json"
{"query":{"count":1,"created":"2014-11-04T13:54:37Z","lang":"en-US","results":{"channel":{"title":"Yahoo! Weather - Ponta Delgada, PT","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Ponta_Delgada__PT/*http://weather.yahoo.com/forecast/POXX0020_c.html","description":"Yahoo! Weather for Ponta Delgada, PT","language":"en-us","lastBuildDate":"Tue, 04 Nov 2014 11:59 am WET","ttl":"60","location":{"city":"Ponta Delgada","country":"Portugal","region":""},"units":{"distance":"km","pressure":"mb","speed":"km/h","temperature":"C"},"wind":{"chill":"19","direction":"280","speed":"32.19"},"atmosphere":{"humidity":"94","pressure":"1015.92","rising":"0","visibility":"9.99"},"astronomy":{"sunrise":"7:09 am","sunset":"5:41 pm"},"image":{"title":"Yahoo! Weather","width":"142","height":"18","link":"http://weather.yahoo.com","url":"http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"},"item":{"title":"Conditions for Ponta Delgada, PT at 11:59 am WET","lat":"37.75","long":"-25.66","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Ponta_Delgada__PT/*http://weather.yahoo.com/forecast/POXX0020_c.html","pubDate":"Tue, 04 Nov 2014 11:59 am WET","condition":{"code":"28","date":"Tue, 04 Nov…

Sometimes you want to let some program running in SSH even after you logout. Putting it in background with & won’t work. Some people use GNU Screen, others nohup, but I prefer tmux.

tmux is a terminal multiplexer

What is a terminal multiplexer? It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. And do a lot more. See the manual.

I do a lot with tmux including development, but this post is about a specific use case I want to keep it simple, to be used as reference.

Keep a process running even after logging out


You have a site that sends emails once in a while, but you’re not using SMTP. You need to implement some authentication checks to avoid falling into SPAM. Besides SPF, it’s important to create a PTR (pointer) record, if at all possible by your ISP.

I just had some users that weren’t getting our emails because, after a recent migration to another service provider, we didn’t have those PTR records. Some email services reject right away any email sent from IPs without a reverse DNS lookup, so this is worse then falling in to SPAM.

A PTR record is the…


A Google search for what’s my ip gives us our public IP, but sometimes it’s useful to have that information in the command line to be used in scripts for automation.

Last week I created a script to automatically add my IP to a server’s firewall that I manage. The command I use to find my IP from the command line, using curl is:

curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+'

Or if you prefer wget:

wget -qO- checkip.dyndns.org | grep -Eo '[0-9\.]+'

I actually use an alias in my .profile so I don’t have to remember this:

alias myip="curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+'"

This way, anytime you just want to find your IP, from the command line you just need:

myip

For a while now I’ve adopted HTML5 and CSS3, but I’ve noticed that my colleagues are still a bit apprehensive with browser support.

Can I use these new standards today or is it still too soon?

I see HTML5 as being mainly focused in two areas. There’s the “markup” part in a web page development, and there’s the API part in constructing web applications (e.g., Gmail).

The new API brings many interesting technologies such as geolocation, offline support, threaded JavaScript, standardized communication between browsers and servers with Web Sockets, richer form support, native drag-and-drop between the elements on a page…


I’ve been experimenting with concurrent programming in C. I’ve forked processes and spawn threads with mutexes in the Mac (Darwin), but the counting semaphores were giving unexpected results. Apparently sem_wait() wasn’t working.

Eventually I found out that Mac doesn’t support unnamed semaphores (sem_init() and sem_destroy()), only named semaphores (sem_open()) and sem_close()). I also noticed that the sem_getvalue() function isn’t implemented (it’s optional in POSIX).

#include <stdio.h>
#include <semaphore.h>
int main(int argc, char *argv[]) {
sem_t semaphore;
int retval;
if (sem_init(&semaphore, 0, 1) == -1) {
perror("sem_init");
}
if (sem_getvalue(&semaphore, &retval) == -1) {
perror("sem_getvalue");
}
// do something…

This post is for any non-english programmer.

It wasn’t always like this but for a long time now, I write my variables, functions, classes and even comments in english.

More than once have people told me that since we’re in Portugal, lets speak Portuguese. Indeed, but since the programming languages that I use have their syntaxes in english, I do consider it more professional to program in that same language for internationalization reasons.

There are several benefits to this.

I like to read code like a prose. It’s strange to read a mixture of languages as in:

if (factura.getMontante() <…

Helder Correia

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store