Adding comments to the website

Honestly, when I saw that they write about it and give advice to beginners on other sites, I was a little horrified and decided to create my own note on this topic without a "fatal flaw". Mostly, I saw long pieces of code that implement adding comments to a site. Usually, for this, a form is created, its processing, storage, and also selection for display are implemented. But the advantages of such an approach are diminishing over time.

In this note, you will learn one of the simplest (but subjectively one of the most preferred) ways to add comments to a site - a simple example for beginners + options for more advanced webmasters.

Indeed, why invent the bicycle and write a lot of code that will have to be maintained, fixed, etc. in the future, if there are plenty of ready-made solutions from third-party services (we are talking about social networks + disqus)?

Asset versioning when using gulp

assetsWhen changing client code, you need to somehow force the client's browser to reload the modified files. This problem is quite common. Most likely, you will encounter it regardless of the technologies you use in web development. This example is about solving the problem when creating a frontend project using JavaScript and Gulp.

You can solve it in several ways.

Let's say, for example, 7e50961489 is the new version of the assets. Actually, it can be any version, the main thing is that it should be different from the previous ones. You can simply number them - 1, 2, 3, etc. But it's not very convenient. Later it will be clear why.

Sequence Master Game

Sequence Master Game - a game to test reaction speed. Click on the largest number among the available ones (you can choose multiple numbers at each step) and share your high score with friends.

Key features/gameplay:

1) There are 7 levels available

2) Within the given time, you must click the numbers from largest to smallest.

3) Points are awarded for each selection. The number of points depends on the player's selection speed and the value of the selected number. In case of a mistake, the game does not end, but a penalty is applied.

4) The game ends if you fail to select the correct number within the allocated time. After the game ends, you have the option to share your results.

5) Responsiveness (should work on smartphones), animation, and other bells and whistles =).

You can play by following this link:

Gulp file for frontend project

The solution is not perfect. But it is suitable for developing a small frontend project written in coffeescript and less. Important note: the use of backend is not provided. Nodejs is only used for building assets (this solution is convenient, for example, if you plan to create a hybrid offline application for smartphones).

The key features of our project, and as a result, the gulp file:

1) Supports different environments (prod, dev, etc)

2) Compilation and minification of less, CoffeScript files, combining multiple into one (concatenation)

3) Support for tests (jasmine)

4) In the dev environment, watch is functioning (dynamically rebuilds assets when source files are changed)

Where do geniuses come from? (Review of the book "Surely You're Joking, Mr. Feynman")

So where do geniuses come from? Unfortunately, the answer is unknown to anyone.
But some interesting assumptions can still be found in the book "Surely You're Joking, Mr. Feynman!".

Many will say that it all depends on genes. Yes, undoubtedly, genes are the main clue of any personality. It cannot be done without them. But there are other equally important circumstances.

Only a free world gives birth to free individuals, ready to take as much as possible from life. And give back as much, if not more. Almost all winners of the Nobel Prize and other prestigious world awards belong to the free world. Oppressed continents, which were the majority not long ago, do not produce geniuses.

And it is the geniuses that are the progress of the world. Humanity needs them to improve the lives of every individual. Now this quality multiplies not in centuries, but in decades.

But let's get back toRichard Feynman.
The book is a vivid example of how a person enjoys life, in a good, sublime sense.

Encapsulation using closures in JavaScript

One of the unusual features of JavaScript is encapsulation using closures. It is unusual because in many other programming languages, this mechanism is implemented using classes. In JavaScript, however, there is a different mechanism that may seem strange if you don't understand the nuances of variables and functions.

If a variable or object in JavaScript is not placed inside any function, they become global. All global elements in JavaScript are properties of the global object. For browsers, this object is window. At the same time, statements like for, if, and others do not affect the visibility of variables.

Creating global variables is generally undesirable as it can lead to hard-to-detect errors and makes it difficult to transfer code to other applications.

Remove the default block sonata.admin.block.admin_list in SonataAdminBundle.

When using SonataAdminBundle and SonataBlockBundle, I wanted to remove the default block.

It doesn't provide much benefit, as it simply duplicates the functionality of the side menu on the dashboard.

When installing SonataBlockBundle, if we simply write in the configuration:

    default_contexts: [sonata_page_bundle]
    blocks: []

(in the future we will add our own blocks, but for now we just leave an empty array), we will catch an error.

Symfony Blog Bundle

HarentiusBlogBundle - bundle for a blog/simple portal (or complex, if using bundle inheritance and extension). View of this site.

As a backend, SonataAdminBundle is used. Implemented:

1. Admin panel (WYSIWYG, ckeditor), image/audio uploading, player.

2. Tags, categories, archives, tag cloud

3. Statistics

4. RSS-feed (requires modification)

5. "Smart" caching of everything, content is served very fast

To "ease the soul":

1. Tests