#javascript

The Magic of Fractal Snowflakes

This post has dynamic interactions. If you are reading this through a feed reader, it probably won’t work as expected.

The winter ❄️ has finally come. I have been wishing for snow for a long time. Coming from a warm country such as Portugal, snow is not the most common thing to see. In fact, I only saw snow in Portugal once when I was a kid when I went to Serra da Estrela, the highest mountain in continental Portugal.

Since then, I’ve only seen snow a few other times when traveling, but never that experience of being outside while it is actually snowing. That has changed! The Netherlands has been suffering from low temperatures, reaching even -15°C where I’m living. It’s been over a week without positive temperatures!

READ MORE

Just fixed the flickering issue by inlining the required JavaScript, which is a really small snippet. If you’re curious about the code I’m using to toggle between the dark and light themes, following the user’s choice and falling back to the OS settings, here it is:

const mql = window.matchMedia('(prefers-color-scheme: dark)');

function toggleT (to) {
  localStorage.setItem('t', to);
  theme(mql);
}

function theme (query) {
  const userOption = localStorage.getItem('t');

  document.body.id = userOption === null
    ? (query.matches ? 'dark' : '')
    : (userOption === 'd' ? 'dark' : '');
}

mql.addListener(theme);
theme(mql);

How To Create a Node.js Command-Line Application

Nowadays, node.js is one of the technologies which is always talked about when the subject is related with real-time applications or even CLI (Command-line interface) apps.

Node.js is a cross-platform platform (which is very redundant) built on Chrome’s JavaScript runtime. They say that with Node.js we can create network applications, but we can do a lot more.

READ MORE

Diferenças Entre '==' e '===' Em PHP

É habitual utilizarem-se diversos operadores quando o assunto é programação. Existem vários até: aritméticos, comparativos e outros.

Dentro de cada categoria existem vários sendo que a dos comparativos não é excepção e hoje trago-vos dois operadores comparativos, muito parecidos… ou talvez não: == e ===.

READ MORE

Chamadas Ajax Com jQuery e PHP

A biblioteca jQuery é das mais conhecidas e utilizadas em JavaScript. Com esta biblioteca podemos proceder a chamadas ajax muito facilmente através de poucas linhas de código.

Vamos aprender a efetuar pedidos POST e GET com Ajax, obtendo os dados do lado do servidor utilizando PHP e responder a essa mesma chamada.

READ MORE