Check out "Do you speak JavaScript?" - my latest video course on advanced JavaScript.
Language APIs, Popular Concepts, Design Patterns, Advanced Techniques In the Browser

forEach or not to forEach

posted in JavaScript on 2019-04-12   array foreach item component update react iteration position remove state

I had an interesting bug in my React application. It happened that the problem was in the fact that I was using forEach instead of for.

The bug that I was encounter was

read more

Implementing an async queue in 23 lines of code

posted in JavaScript on 2018-05-07   tasks taskindex getnexttask numofworkers function result promise task array process error run

Recently we had an interesting task at work. The user makes a selection of items and clicks a button. Then for every selected item we have to make a request to our API. The thing is that the user may click as many items as he/she wants. In order to speed up the process we decided to handle four requests in parallel and once some of them is finished we pull the next one. If you ask why exactly four requests in parallel read this paper.

read more

Unexpected usage of Array.length

posted in JavaScript on 2016-01-14   arr length array b c d string undefined elements c d arr var arr words text

I like reading code of other developers. It’s a nice way to learn patterns, techniques and small tricks. Recently I found something about Array.prototype.length which caught my attention.

read more

JavaScript's reduce could be really helpful

posted in JavaScript on 2015-12-25   testcase true patterns state reduce current cases expected return array test

I love using functions like map, filter or reduce. They are an important part of my arsenal and I simply can’t stop using them. Today I had to solve an interesting problem and I ended up using reduce.

read more

Win Free Copies of my new book – Node.js Blueprints

posted in Nodejs on 2014-08-12   node js book array top winners writing users tmp var array current array

Readers would be pleased to know that I have teamed up with Packt Publishing to organize a Giveaway of a new book written by me - Node.js Blueprints. And three lucky winners stand a chance to win 3 e-copies of this book. Keep reading to find out how you can be one of the Lucky Winners.

read more

Win Free Copies of the new book - Getting Started with Grunt

posted in JavaScript on 2014-04-15   grunt array winners book top task tasks users tmp shuffle

Hi guys, you would be pleased to know that I have teamed up with Packt Publishing to organize a Giveaway of the new book - Getting Started with Grunt: The JavaScript Task Runner. And three lucky winners stand a chance to win 3 digital copies of this book. Keep reading to find out how you can be one of the Lucky Winners.

read more

7 lines JavaScript library for calling asynchronous functions

posted in JavaScript on 2013-12-12   function var funcs callback scope queue function funcs var queue function array

I was surprised by the good feedback for JavaScript template engine in just 20 lines and decided to blog for another small utility function which I'm using often. While we are talking about JavaScript in the browser, most of the operations are asynchronous. We are dealing with callbacks all the time and sometimes we end up with awesome callback hell.

read more

An alternative JavaScript for loop syntax

posted in JavaScript on 2013-11-08   users var syntax user users var users undefined elements array

As javascript developers we all have to write a lot of for loops. Before a couple of months I saw an alternative syntax, which I really liked. It saves some time and it looks much nicer. However, one of my colleagues reported that this fancy syntax is not working as it should.

read more

PHP: please, please, clear my cookies

posted in PHP on 2013-10-31   time cookies result arr setcookie request_ids time setcookie app_request_type time store needed

I'm currently working on a JavaScript application which is using the facebook API. There are some things which I need to pass from one page to the other. So, I decided to use cookies. The storing works like a charm, but the deleting doesn't. I needed one hour to find the exact problem.

read more

PHP: simple captcha script

posted in PHP on 2013-08-08   array code expression alphabet result im

In my company, we have a lot of WordPress sites. Some of them require contact form with captcha field. The short way for solving such task is to use a plugin. However, as you may guess, the add-ons are available for everyone, which means that they could be easily explored and probably hacked. That's why I suggested a simple, custom script, which is developed by us.

read more

Dependency Injection in PHP. Create your own DI container.

posted in PHP on 2012-05-12   class key view show arguments array content navigation title skills

By my opinion one of the biggest problems in programming are dependencies. If you want to have a good well written application you should avoid dependencies between your modules/classes. There is a design pattern which could help and it's called Dependency Injection (DI). It allows you to inject objects into a class, instead of creating them there.

read more

MySQL vs JSON file data storing

posted in PHP on 2012-02-12   records requests data json ms time request mysql res count array function

I'm not exactly a performance perfectionist, but currently I'm working on a tool which will be used in a large system. It will deliver texts to a multi-language environment and there will be several sites/apps which will performe big amount of request to it. It is the right moment for me to choose how to speed up my code and the work of the tool overall.

read more

Adding outline of text or MovieClip in Flash with AS3

posted in ActionScript on 2010-10-06   outline filterarray color movieclip

As you probably know there is no such kind of option. We should deal with a little AS3 code.

read more

Cloning JSON object in JavaScript

posted in JavaScript on 2010-10-04   obj obj1 outpurarr var document write obj2 object getname function return obj var outpurarr clone obj var function clone obj

Simple and easy solution.

read more

Create your own tween manager class in AS3

posted in ActionScript on 2010-08-07   arr ease startpos calcendpos steps var calcendpos steps break object steps break case properties start public function

There are some features in Flash that we can't work without. Tween classes are among the most used ones. They give you ability to animate objects without using the timeline, to change the animation fast and easy. The idea of these classes is very simple. That's why I think that it is a good idea to have your own tween manager that you can modify to fit into your needs.

read more