Angular-like multi slot transclusion in React

I would like to share here a method, which I use for children passing to ‘slots’. Say, for example, you need to develop menu with different backgrounds for menu items: <div class=”my-menu-parent”> <div class=”my-menu-item-red”> <a href=”#”><img src=”http://fullhdwall.com/wp-content/uploads/2016/09/Best-World.jpg” /></a> </div> <div class=”my-menu-item-yellow”> <span>My second menu item</span> </div> <div class=”my-menu-item-blue”> <span>My Blue menu item</span> </div> </div To […]

CSS: creating responsive element with a padding-bottom: % trick

<style> #rubber { padding-bottom: 100%; width: 100%; position: relative; } #inner { position: absolute; height: 20px; width: 20px; top: 50%; left: 50%; margin: -10px 0 0 -10px; } </style> <div id=’rubber’><div id=’inner’></div></div> CSS: padding-bottom in percents is calculated based on width of the parent. Thus we get container(div#rubber), which height will depend on width of […]

Once in a boring evening .. I wrote a basic promise

I wrote a basic promise just to fill the promises better. If anyone wants an exercise, please fill free to add Promize.prototype.all and Promize.prototype.race //just added custombind function, just because I can. Normally I would use js, bind function function custombind(newthis) { return ()=>{ this.apply(newthis, arguments)}; } Function.prototype.custombind = custombind; function Promize(control) { let states […]

JavaScript developer interview questions.

I searched for a job not far ago and visited a lot of interviews. Here I would like to post some of questions, which I find interesting. 1) explain the difference: apply, call and bind 2) rules and order of determination of this (context) 3) count some of the two arrays with Array.reduce. For ex.: […]

Self appriciation as way to job success

High self-estimation is key factor to success. When you fall down, you usually get up, clean your dress and continue your way. The same you should do when your self-estimation is threatened. If something bad happens, your self-estimation falls down, and you need to get it up. To continue being active in life. Avoid telling […]

$ctrl, this, $scope, assigning variable to view

I wrote this article basically for myself. Maybe it will be useful for someone. Angular allows to access variables via: $ctrl, controllerAs, this, $scope, simple variable name $ctrl – is default name for controller in view. So you can use it to access variables inside templates: function SearchInputController($scope, $log){ var ctrl = this; $scope.$log = […]

WordPress: image upload from url

In case you have WordPress powered e-shop you most probably will need to add products to it filling them with pictures from web. When adding it you will see such an dialog: ‘Select Files’ dialogue will open (in case you are on Windows) Windows Explorer, so you can choose file from your PC to upload. It […]

Doctrine 2 QueryBuilder getResult and getArrayResult

When using Doctrine 2 hydration you can sometimes encounter issue when you get one result instead of many results. Doctrine 2  requires every entity to have Id annotation. Please use it carefully, because when using Doctrine 2 QueryBuilder \Doctrine\ORM\AbstractQuery::getResult You will not get records having not unique @Id fields. And no even PHP warnings. \Doctrine\ORM\Internal\Hydration\ObjectHydrator::hydrateRowData will […]