Browsed by
Month: June 2019

Recursive Backtracker maze – more features and animation with Matplotlib and Python

Recursive Backtracker maze – more features and animation with Matplotlib and Python

In the previous post, I generated a simple maze. I wasn’t sure the algorithm worked as intended unless I debugged or animated it. I chose the second option. I also added marking the beginning and end of the maze quest.

Read More Read More

Maze generation algorithm in Python – drawing and arrays

Maze generation algorithm in Python – drawing and arrays

There are plenty of maze generation algorithms, some are described here and here. I decided to use one to learn some Python. I chose Recursive Backtracker. You can find longer descriptions in both links, but briefly:

  • choose a random cell in the maze
  • walk in a random direction
  • when there is no possibility to walk farther, go back (backtrack) to find the first cell from which it is possible to proceed
  • the algorithm ends when there is no possibility to move from any cell

Read More Read More

My favorite graphing tool – Graphviz

My favorite graphing tool – Graphviz

I used to create many graphs, usually the kind of dependency/hierarchy (see the previous post about Programming paradigms in JavaScript).

A long time ago I discovered a perfect tool for a developer to create and maintain various graphs – Graphviz. You can download it and use offline, but there are also online interpreters for quick experiments, for example:

Read More Read More

Programming paradigms in JavaScript – callbacks, Promise, async/await, promisify, functional Ramda and reactive RxJS

Programming paradigms in JavaScript – callbacks, Promise, async/await, promisify, functional Ramda and reactive RxJS

As a quick exercise, I wanted to read all URLs from my page’s sitemap instead of crawling the site. Just after I added a nested callback I decided to apply the Single Responsibility Principle and convert calls to Promises. Later I experimented with async/await and automatic conversion with Node’s promisify. Finally, I rewrote the solution in functional style using Ramda and reactive using RxJS. Read on to follow the evolution of callbacks in JavaScript.

Read More Read More

CSS – two headers – big and smaller sticky

CSS – two headers – big and smaller sticky

In modern web, you often see pages that have a big fancy header with a menu. It would be impractical to keep that menu visible all the time when scrolling because it would occupy too much of screen space. Therefore those pages often introduce a smaller header just with the navigation and logo that will be displayed as user scrolls down. I will show how to easily create such a header and add some animation to it.

Read More Read More

JavaScript – hoisting, var, let, const

JavaScript – hoisting, var, let, const

This post is a quick summary of the differences in JavaScript variable declaration.

Before ES2015 (previously named ES6), there was only one keyword to declare variables: var. The newer standard introduced two extra useful keywords: let and const.

Briefly:

  • var declares “almost global” variables
  • let declares block variables
  • const declares block read-only variables

Explanation follows.

Read More Read More

WordPress – add custom widgets on home page

WordPress – add custom widgets on home page

I once had a desire to provide a list of shortcuts on the home page for my blog’s new users. I didn’t like the default WordPress’ blog page to be just a list of posts. I didn’t think that sidebar widgets grouping posts by date, category or tag would be helpful enough to grasp the versatility of the topics I cover here. I wanted to display a clear list of links with what a user can read about.

Read More Read More

GitHub contribution by Pull Request – crash course

GitHub contribution by Pull Request – crash course

If you want to fix an issue or enhance others’ GitHub repository, don’t be afraid – it’s fairly simple. I will show by example all the steps that are necessary.

I wanted to add support for two languages (TypeScript and JSON) to a WordPress plugin providing a Code block. You can read more about my choice and configuration in WordPress for developers – displaying source code and review of code sharing services.

Read More Read More