Saturday, December 31, 2016

Nuclear fission and atom bonding enegy

Avogardo constant defines the count of atoms per 1 mole.

The number is:
6.022140857(74)×1023 mol−1

Nuclear fission emits about 200MeV, from the bonding energy inside of the atom, when fission occurs. That's thousands of times more powerful than a standard fission of chemical fuels.
However, single atom's fission energy is not enough to do much. However, when multiplied by Avogardo's number, or even a higer value, it comes to a very high value.

PCA analysis explained (Python)

Here is a good tutorial showing how to reduce the number of dimensions / features using SVD and then PCA in Python.
First, we use SVD to obtain covariance matrix, and then we sort the eigenvectors in descending order. We use only top k eigenvectors to create a new projection space, where we transform data using only k dimensions.

Full tutorial:

Friday, December 30, 2016

DIY STM microscope

EM wave , diffraction, minimum hole size

Good discussion here on topic of EM waves passing through holes of different sizes:

You need to distinguish between conductors and non-conductors. If your material is non-conducting then the EM radiation can pass through any size of hole regardless of whether the hole is larger or smaller than the wavelength. The power transmitted is just the incident power per unit are multiplied by the hole area, exactly as you would expect. All very boring really.
But you mention the screen in a microwave, and in this case the screen is conducting, which completely changes the behaviour. The incident EM wave induces oscillations in the metal of the screen, and these oscillations reradiate EM that interferes with the incident wave. It's this process that blocks the incident wave. The process is purely classical and requires no appeal to the existance of photons.
Conducting screens like the screen in a microwave are generically known as Faraday screens or more commonly Faraday cages. Calculating the relationship between the hole size and the transmitted intensity is a somewhat tortuous business, but as it happens there is an excellent description of the calculation here on thi site in David's answer to What is the relationship between Faraday cage mesh size and attenuation of cell phone reception signals?.

Diggression: Entropy and Life

In physics. from the laws of thermodynamics, speaking freely, entropy as a term refers to the level of order in a system. Lower the entropy, higher the order in the system. Famous physicist Ervin Schrodinger said that life in this universe feeds on negative entropy. This actually makes sense. There doesn't seem to be anything else in the universe that works so hard to reduce entropy like life does. Everything that reduces entropy, improves predictability and utility of any system is a good achievement and it should help us concentrate on further and further problems we need to solve. Entropy reduction is the only way we can predict and use things. Otherwise, everything becomes unusable and random.

So, it might be our highest goal on this planet to preserve in our efforts for reducing entropy on the planet.  I see programming as a very powerful way of entropy reduction. It can provide quick and efficient solutions for complex, or seemingly unmanageable problems. It can help us improve ourselves in so many ways, as human beings and as a civilization.

Here's wiki link for the topic of "Entropy and Life":

Thursday, December 29, 2016

Online htpasswd tools don't work for WAMP Apache server

Scenario: You would like to password protect a folder in your website. You are running WAMP Server. The first thing you try is an online .htpasswd generation tool, but it fails to work. Solution: For WAMP server, you can find htpasswd.exe in C:\wamp\bin\apacheX.X\bin\htpasswd.exe. Simply generate contents of .htpasswd file with a command like this one: htpasswd -nb username1 password1 This will print out the resulting .htpasswd file to the console, and you can just copy/paste it to the .htpasswd file where needed. It works for WAMP servers. Probably, WAMP uses different encryption algorithm than standard Linux implementations of Apache. Documentation for Apache's htpasswd tool is here:

Curse of dimensionality

Wednesday, December 28, 2016

Good wiki article in Linear Systems and Machine Learning - Tikhonov Regularization

This is a good Wikipedia article on an important topic in Machine Learning - Regularization: When finding an inverse of matrix, it is possible that one is dealing with a ill-posed (ill-conditioned) problem: Multicolinearity:

Mass rename in BASH - change file extension for all files in folder with a single command

You want to change file extension for all files in a folder? No problem, here is a very quick BASH command for mass rename for all files in a folder. Example: rename .html .php *.html This will change extension from .html to .php for all .html files in the current folder. The command above works on both Linux terminal and Windows BASH editions (i.e. Git Bash for Windows).

GREP - find text in files

You can use grep -ilR: grep -Ril "text-to-find-here" / i stands for ignore case (optional in your case). R stands for recursive. l stands for "show the file name, not the result itself". / stands for starting at the root of your machine. Answer by fedorqui:

Tuesday, December 27, 2016

Lectures on physics and math - Richard Feynman

Super interesting lectures in math and physics from genius Richard Feynman:

Monday, December 26, 2016

FFT Windowing

" 2. Windowing Although performing an FFT on a signal can provide great insight, it is important to know the limitations of the FFT and how to improve the signal clarity using windowing. What is Windowing When you use the FFT to measure the frequency component of a signal, you are basing the analysis on a finite set of data. The actual FFT transform assumes that it is a finite data set, a continuous spectrum that is one period of a periodic signal. For the FFT, both the time domain and the frequency domain are circular topologies, so the two endpoints of the time waveform are interpreted as though they were connected together. When the measured signal is periodic and an integer number of periods fill the acquisition time interval, the FFT turns out fine as it matches this assumption. "

Saturday, December 24, 2016

Relation between image and resolution and wavelength required for taking non-fuzzy images

Q: I have been trying to find the explaination why the wavelength of a wave is the limit of the resolution of an image (i.e. one cannot see the detail smaller than the wavelength), which is sited as the reason why we cannot see an atom using visible light. I don't think I really understand why this is so. can someone please explain to me the physics behind resolving detail with wave and the reason behing this limit? Thank you. Reference A: Firstly, the diffraction limit is wavelength/2 (approximately) - actually a more precise formula is 0.67*wavelength/NA where NA is the numerical aperture of the imaging apparatus and has a practical maximum of about 1.4. When we image something, the light we collect is spatially modulated. That means if I measured the field as a function of distance, in the x direction for example - call it E(x), E(x) would vary with x, as opposed to being a constant. The best resolution we can get actually depends on the Fourier transform of E(x) - what is sometimes called the spatial frequency spectrum in the direction of x, and the label we give to spatial frequency is k (so the Fourier transform E(x), would be E'(k_x) since we are concerned with the x direction only). To further illustrate the above point - take transmission through an aperture at z = 0. E(x) will be a rectangular function at z = 0, and it's spatial frequency spectrum, E'(k_x) will be a sinc function. If we decrease the width of the aperture, the width of the spatial frequency spectrum increases. This is because higher spatial frequency components are needed to "resolve" smaller objects. So where does the diffraction limit come from? It comes from the fact that only a certain range of spatial frequencies can propagate in a vacuum. Take the dispersion relation of free space; c = f λ c=fλ which can also be written c = ω k c=ωk Where omega is the angular frequency and k is the wavevector. If we rearrange the previous equation thus; k 2 = c 2 ω 2 k2=c2ω2 Remember that k is a vector and can be broken down into its constituent components; c 2 ω 2 = k 2 = k 2 x + k 2 y + k 2 z c2ω2=k2=kx2+ky2+kz2 Only components of k that are real will reach the far-field. Imaginary components result in evanescent waves that die off exponentially with distance and thus do not reach the far-field. From the above equation, it is easy to see that; − c ω < k x < c ω −cω Original thread (Answer by Cluade): WIKI:

Friday, December 23, 2016

Remove border (outline) out of customly designed input elements

If your custom input box in HTML still displays default border when hovered, you can try to remove the outline property of it. Like this: input.yourclass{ outline: none; } More info:

Camera Tracking video in Blender- VFX, 3D objects to video

Here's the cool tutorial:

Thursday, December 22, 2016

Wednesday, December 21, 2016

Machine Learning course by Tom Mitchel


How to: Access a router in LAN which is not a DHCP server

If you would like to access admin panel of a router / managed switch in your LAN, and this router is not the DHCP server, and it's connected to DHCP server through the LAN port, you could try to switch your PC / device to manual static IP address, and set the gateway to be the default IP address of the router you want to acceess. The default IP address and username and password can be obtained from product's documentation / user manual. After you have made modifications, and you want to use DHCP on your laptop again, just set PC's IP settings to automatic. Of course , you need direct connection to the router, either via WLAN or LAN cable.

Tuesday, December 20, 2016

Fourier Transform, De Moivre's formula, Ratio test, Laplace Transform, z-plane

A lot of terms from signal processing are well explained in this short Quora thread:

Monday, December 19, 2016

WP -> ACF insert file into a File field inside of a repeater

In ACF, a File type is populated by providing an attachment (post) ID of the file.

Repeater field is populated by an array of arrays, where each nested array represents a single row in the repeater field.

In order to everything work properly all the time, you should provide ACF field keys instead of field names, for your repeater fields.

Here's a code which takes an uploaded file (using normal HTML Input File control) and saves it as a WP attachment:

After that, this attachment ID is used to populate the File field inside a repeater like this:

//$attach_id is obtained from the upload function. It's the attachment ID


"file_upload" => $attach_id,
"file_ description" => "DESC $attach_id",
"file_date" => date("Ymd")




WordPress ACF - how to populate a custom field of type "File" from code

If you would like to upload a new file and store it as an ACF file type, you should probably look at this thread:

The idea behind ACF's file type field is that it accepts a WP Attachment.  WP attachment is a special post type in WP, which can be generated by this function:


Friday, December 16, 2016

Stephen Wolfram

Stephen Wolfram, computational theory of everything - talking about space of  all programs that can be written:

Wednesday, December 14, 2016

adb devices command returns -> "No permissions"

If you run into the problem of having a device status Unknown in Eclipse or adb devices, especially stating "No permissions" in adb devices list -> you should make sure that you are running the adb server with with sudo command (or equivalent level).

grunt - cannot find module "*foo*"

If grunt cannot find a npm module, make sure the module installed with --save-dev flag.

Like this:

npm install less-plugin-autoprefix --save-dev

instead of:

npm install less-plugin-autoprefix -g

Pixel perfect design

Methods of achieving pixel perfect design.
Article incoming................

Font Consistency in Web Design

Here are a few useful articles and forum discussions on the topic of font consistency:

Monday, December 12, 2016

Debugging - reduction of state influencers

In any kind of debugging, especially in difficult problems, we should start debugging by reducing the number of function calls, properties and other state influencers around the Object Being Debugged (OBD).
In case of JS debugging, this means reducing the number of CSS classes on the OBD element, checking the temporal context and lifecycle of the OBD object, etc.
After identifying the corrupted influencer, we need to see why it is conflicting with the OBD and what can be done about it.

Sunday, December 11, 2016

AngularJS - update ng-model from jQuery on input box

If you change input field's value using jQuery, and your ng-model is not my being updated, you should add jQuery("selector").trigger("input").

Triggering input event will update ng-model.

Saturday, December 10, 2016

High ping times on WiFi can be reduced by repositioning the AP for just a single meter!

In my recent attempt to improve my WiFi signal reception at home, I've noticed that even just slight translations of Access Point in space(time :) ) can lead to huge variations in  WiFi connection quality.That's of course expected, but the variation is quite surprisingly high.

Before 1 meter move:
avg. 2500 ms

After the move:

Test method:

Tuesday, December 6, 2016

Java for Android - JobInfo scheduler runs too frequently


Your job service runs too fast. You have created it using JobBuilder class and executing it as a subclass of JobService class.

Potential problems and their solutions are discussed in these threads:

Sunday, December 4, 2016

Possible jQuery bug - jQuery, get fill color of a selector

jQuery seems to return "rgb(0,0,0)" when inline css value for "fill" property is not set.

In a call like this:

var ret = jQuery(".selector").css("fill");

Variable ret is set to "rgb(0,0,0)" when inline css value for "fill" is missing on the element.

Better approach is to use each() and iterate through all elements manually. Even pure JS can be used for this:


Also, to delete fill property from a single element, you can call:"fill") instead of jQuery(".selector").css("fill","").

Thursday, December 1, 2016

Make text non-selectable on double click in HTML - CSS way

There is a pure CSS3 way of making a paragraph, button or even SVG element non selectable. Here it is:

    -moz-user-select: none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    user-select: none;

<p class='nonselectable'>

You cannot select this text


Wednesday, November 30, 2016

Newlines got changed when downloading/uploading files using FTP client such as FileZilla

If your source code formatting is destroyed after FTP download or upload, it's probably because your FTP client's transfer mode is currently set to ASCII. Usually, line breaks are removed completely or added excessively to the text (source) files.

Try to switch your transfer mode to Binary. It should fix the problem. In FileZilla, this is located under Transfer->Transfer Type menu. You can choose default transfer type in FileZilla->Edit->Settings...

Thursday, November 24, 2016

10 biggest mistakes when selling something

Here is a short review of an useful article on selling. It lists the 10 following mistakes as the biggest mistakes in selling:

1. Not being prepared when it comes to making a sales presentation, either face to face--as in a retail environment--or over the phone, Skype etc.

2. Not looking the part--where the sales person is dressed inappropriately or the entire sales environment looks unprofessional and unappealing to the customer.

3. Not having enough knowledge about the products or services being sold. 
Customers deserve 1st class information.

4. Not asking the right questions. 
Result -> Not knowing what customer really needs.

5. Not listening to what the customer is saying.
De-motivates and frustrates the buyer.

6. Not getting back to the customer as promised--or in other words, they over promise and under deliver. 

7. Not having clear, specific sales goals. Very few people set goals but those that do tend to achieve them. If you have sales people working for you, you have to set targets. And these need to be talked about, measured and pushed. If you work by yourself, set your own sales goals.

8. Not reading the customer. This means being able to interact with the customer and see that you are connecting with them, that you are helping them and that you are doing your job as a sales professional.

9. Not being compelling. If you don't believe what you are selling, don't sell it. Being compelling generally translates to being believable and sales people already have a stereotype to overcome. If you don't believe what you are saying, your customers won't either.

10. Not caring about the sale. This is the situation where the sales person really doesn't care if the person buys a product or not. They still get paid the same amount so their attitude towards their customers can reflect this.

I find #7, #9 and #1 most interesting. However, probably any one of these can be the weakest link in our sales presentation. What do you think?

View full article here

Tuesday, November 22, 2016

Creating a proper PDF out of HTML

If you have ever wanted to generate a nicely looking, non-rasterized, PDF out of HTML, you probably know that's its hard to find a good library for that. So, I think I have something good for you - PhantomJS!PhantomJS seems to offer a great way to generate PDF documents out of HTML pages:

Here is an example:{url:%22,renderType:%22pdf%22}

That sample, and many others, can be found here:

Original thread discussing phantomjs as a means of generating PDF is here:

Original command:

phantomjs.exe examples/rasterize.js sample.html sample.pdf

Even better option would be Webkit to PDF (the same core is used):

Could not verify Recurly's SSL certificate


XAMPP on Windows


You are trying to issue a CURL request to a SSL based endpoint. Your request fails with an error stating that the SSL certificate cannot be verified. In case of Recurly, subscription management system, this error says something like "Could not verify Recurly's SSL certificate".

The actual cause of this is your php's inability to find valid root CAs. One way of fixing this is to manually add a line to your active php.ini:


where, of course, cacert.pem is the valid CA certificate. After this, restart of Apache / PHP is required.

The original idea for this came from this great blog post:
Stop turning off CURLOPT_SSL_VERIFYPEER and fix your PHP config

Saturday, November 19, 2016

25 Most Productive Ways to Spend Time on the Internet - a list of great web places

1. Duolingo
2. Kahn Academy
3. Justin Guitar
4. Cooking for Engineers
5. The Dating Specialist
6. Nerd Fitness
7. MIT Open Courseware
8. Investopedia
9. Quora
10. Information is beautiful
11. Spreeder
12. Project Gutenberg
13. Codeacademy
14. GeographyIQ
15. Anki
16. Lumosity
17. CliffsNotes
18. TED
19. Pinfruit
20. Mindtools
21. Learn Street
22. HowStuffWorks
23. OneLook
24. The World Factbook
25. Couchsurfing

Original thread on Quora:

Wednesday, November 16, 2016

PHPDOMParser library's selectors are very whitespace-sensitive

PHP Simple DOM Parser is a very nice tool for parsing HTML using CSS-like tag selectors.

However, be very careful with whitespaces inside of selector expression,as they might cause silent failure. These are two different expressions:

$elem = $html->find(".container1[container_type=picture]>div", 0);


$elem = $html->find(".container1[container_type=picture] > div", 0);

The second expression has 1 extra whitespace ( > ), and that will cause failure while trying to obtain the first div element inside container.

Saturday, November 12, 2016

Live editing of SVGs using JS - problem analysis


How to make dynamic SVGs which can be controlled from JS? For example, we would like to change foreground text, or background image on a SVG. How to do it?

Available tools:
JavaScript (JS), CSS3, PHP and HTML5

Methods used for solving this problem:

*Prerequisite: Inline SVG*

In order for SVGs to become parsable and editable by JS, we need to load it as an inline SVG. A simple src tag to a SVG image will display the image, but it won't allow us to edit it's parts using JS and CSS.

Method #1
Direct access to parsed HTML elements and modification of their properties and content, same as in case of any other HTML document.

Method #2
Using HTML5 Canvas, convert inline svg to a canvas drawing, and further exporting it to a PNG image. Here's an example how to do this:

Android development, adb device status Unknown / Offline

Area: Android app development Problem: When you would like to connect to your mobile device using adb running at your Linux desktop , you receive a device state Unknown / Device Offline error. What you should try: Run this command: sudo adb kill-server After a few seconds, run this one: sudo adb start-server At least in case of Ubuntu Linux distro, it's VERY important to include sudo in these commands. Otherwise, your device remain in state Unknown (Offline).

Tuesday, November 8, 2016

Solved: Angular 1 - Error: [$compile:ctreq]$compile/ctreq?p0=ngModel&p1=ngOptions

If you receive this error message:

 Error: [$compile:ctreq]$compile/ctreq?p0=ngModel&p1=ngOptions

It might be that you haven't added ng-model directive to the select tag you're trying to populate with ng-options.

This code will produce the error above:

<select ng-options=" as for item in organizations">

The solution is simple addition of ng-model directive , like this:

<select ng-model="mychoice"  ng-options=" as for item in organizations">

Sunday, November 6, 2016

WP API with ACF - a crash course / quick tutorial

WP Restful API is frequently implemented with help of the following WP Plugin:


Support for fetching ACF fields tied to the posts is added via this WP Plugin:

Once you have these two plugins activated, you should be able to use these URLs to fetch posts via a RESTful API:

This will return first 10 posts from your site. The total number of records will be appended to HTTP Response Headers of the REST API call. 

In case you would like to obtain ACF fields tied to a post (i.e. post_id = 892), you can issue a RESTFul GET call like this:

It will return full list of ACF fields tied to the post with ID = 892. 

Also , there is an option  to extend the response by adding a custom field like this:

In the example above, we add a new field to JSON output - acf1. The field acf1 will contain everything that can be obtained by get_fields(ID). So, the next time you issue a RESTful call like this:

your JSON result will contain basic fields of the posts , like id, date ,etc. However, every record will contain the acf1 field , too!


By default, WP-API returns 10 records per page. In caase you would like it to return all records, you should set per_page parameter to -1, like in the following code:

Note that the filter is CPT dependent. This filter will be only executed on market CPT.

Emanuele Feronato - this guy can teach you how to create amazing video games

Today, I would like to introduce you to a very talented game programmer from Italy. His name is Emanuele Feronato. I've first stumbled upon his website a few years ago. Since then, I've been following his updates regularly. Every time I visit his site, I find something really helpful and interesting to read. The site is a blog-based website containing thousands of high quality articles revolving around:

Game design
Mathematical concepts behind every game
New tools and programming languages
Hands on short tutorials covering the game building process from start to the actual delivery
Monetization (making money on the games you have already enjoyed building :) )
All kinds of news and updates from game development world

Personally, what I like the most at the website, is the collection of full tutorials on how to build HTML5 fun and addictive games in matter of hours. It's pure fun to create and to play this type of games. Emanuele's site is located at:

Be sure to visit it. I hope you will find it useful! 

Saturday, November 5, 2016

PHP - require_once inside function requires use of global keyword

In PHP, require_once function locates a file and inserts its content into the the script. Its uses in PHP applications vary from simple loading of configuration files to supporting complex, hierarchical template systems. Typically, require_once is called at the beginning of the script execution. That way, the script is dynamically expanded to include new functionality, originating from the included source file. That scenario is common and straightforward to follow. However, there's a tiny peculiar detail in the behavior of PHP's require_once function:

If you are going to declare a variable V in file1.php and include file1.php into a function func() in file file2.php, you have to use global keyword to reference the V variable in function func() in file2.php.

Here's a simple scenario:

Thursday, November 3, 2016

Solved: CSS width 100% not working.


Element A inside another element B, won't take the full width of its parent element (B).

For example, in Bootstrap layout:

If textarea element won't fill the whole parent column, you can simply try to replace CSS's width property with min-width property. Min-width property is likely to extend the textarea to the full width of its parent element. 

So, the new code would look like this:

Sunday, October 30, 2016

mod_rewrite testing with XAMPP should be done carefully. RewriteCond %{REQUEST_FILENAME} !-f can cause some confusion

Web Server: XAMPP (both applies to other packages as well)

Problem: Strange , unexpected results from simple .htaccess mod_rewrite operations. RewriteRule doesn't seem to work.

When you would like to test your apache's .htaccess URL rewrite, make sure you test with a proper URL.

For example, if you have a RewriteRule like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ".*/$1" "/public/index.php?p=pageabc&t=$1" [NC,L,R=301]

Make sure you're testing your site with a URL like this:

and not with something like this:***********************

The reason is obvious. The first RewriteCond won't be true and the rule won't apply.

Also, please note that by default, the url directory to your .htaccess file is automatically removed from the request's URL. So you can fetch only the part after or, if your .htaccess is inside of subdir folder.

Also, if you don't want to redirect user to target URL (2nd parameter of RewriteRule), you should remove R=301 from the RewriteRule.

Caching of URL rewrites

You should be aware of the fact that your browser might save some URL redirects and serve them any time you surf the website in future. This means that you should clear your browser cache before testing URL rewrites.

Your .htaccess doesn't get called?

A good trick to see if your .htaccess is actually getting fired at all, is to try to input a syntax error into it. That should crash the site if .htaccess is processed.

Saturday, October 29, 2016

Learn Angular 2 fast - a tutorial

Here is a crash course / tutorial in Angular 2 basic concepts. This document will be updated regularly.

Angular 2 is a modern, useful and popular JS framework. It's backed by Google and builds upon the good foundations laid by Angular 1, which is widely used by large software companies.

The basic concepts in Angular 2 are:


Component represents a view. It's a TS class whose properties are going to be renedered as HTML, using the template provided by the component.


Service deals with HTTP REST calls and anything else not directly tied to view.


Router is a class capable of reading URL and its parts.


Directive is a class which extends HTML tags. For example, we can make an directive called HighlightTextbox, and use it like this in our HTML:

<input HighlightTextbox type='text' />

and this directive would add borders and make fonts larger. Angular 2 comes with tons of built in directives, so make sure you investigate them :)

All these four elements of Angular 2 applications, are simple TypeScript (TS) classes. TypeScript is chosen because it's easy to learn and it supports any standard ES5 JavaScript code.

This tutorial is going to be updated from time to time. Meanwhile, for a hands on tutorial, make sure you check this one on YouTube:

Here is a super cool tutorial, where you are going to build your first Angular 2 REST-based Web application in less than 60min:

Building your first Angular 2 app, cool step by step video

Friday, October 28, 2016

Solved: Eikon 510 usb fingerprint scanner not working under Windows 10

If your Eikon 510 USB fingerprint scanner doesn't seem to work under Windows 10 (or any other Windows probably), you should consider this solution:

1. Go to Control Panel ->Device Manager

2. Find "TouchChip Fingerprint Coprocessor (WBF advanced mode)" and open it's properties

3. Go to power management tab.

4. Disable "Allow the computer to turn off this device to save power

You should see the blue light coming from the Eikon 510 device immediately. It's a signal that device is up&running. The actual driver you should use is probably already included in your Windows update drivers.

If this doesn't help, you should try to find this driver:

                TouchChip Device Add-On for U.are.U SDK for Windows

It will add a new device:

TouchChip Fingerprint Coprocessor
 under Authentication Devices

JavaScript (JS) and block level variables and closures

Be careful when dealing with JavaScript (JS) block level variables. JS block level variables don't follow our intuition when they are paired with closures.

For example, imagine a for loop which instantiates a new local variable c in each iteration. Now, imagine that you increase the value of that variable c by 1 in each iteration. If you would like to print c to output console, 500ms after each increment, you would probably expect all iterations to have different values, right? However, what will happen is that all the print outs will contain the very same value.

In order to get a true block level variable in JS, we should enclose the iteration code in an anonymous function. This way, each anonymous function comes with its own scope, and closures (and setTimeout construct is a closure), will print correct (different) values.

Here is the example:

Friday, October 21, 2016

WP ACF fails to save/load data silently and intermittently


Similar to the update_field() function, using a field’s key rather than it’s name allows ACF to correctly find the field if no existing value has been saved. To expand on this, if no repeater field value exists, this function will fail unless field key’s are used.

It seems that we must ALWAYS use field_keys to avoid super strange and intermittent problems with ACF Pro.

Tuesday, October 18, 2016

AngularJS stopPropagation() in ng-click

To stop event propagation / bubbling in angular's ng-click directive, just add $event.stopPropagation(); to the existing ng-click handler.

Like this:

..  ng-click='kd_dd_toggle_group(kd_gui_offers_by_cta_group[group]);$event.stopPropagation();' ...

Saturday, October 1, 2016

VirtualBox won't start after Windows 10 anniversary update

If your VirtualBox GUI won't even open after Windows 10 anniversary update, you need to download the latest version of Virtual Box(currently 5.1.6) and install it.

Friday, September 30, 2016

cx_oracle - use oracle db from python

Start by downloading and installing cx_oracle:

oracle - sqlplus connect from remote machine

sqlplus username/password@host:port/service

oracle 12 - prebuilt vm credentials


Default user:


Default password:


Connecting to db



List user tables in db:
select table_name from user_tables;

Thursday, September 29, 2016

mysql db import fails with message : MySQL server has gone away!

Check the max_allowed_packet size and increase it (i.e. to 64M):

Saturday, September 17, 2016

CSS opacity influences triggering on mouseenter and mouseleave

If an element's opacity<1, then all the mouse events for the divs behind semi-transparent div will fire!

Thursday, September 15, 2016

CSS flex- solution for vertical centering

For container:

  align-items: center;

    -webkit-flex: 1; /* Safari 6.1+ */
    -ms-flex: 1; /* IE 10 */
    flex: 1;

    align-items: center;

More details:

Tuesday, September 13, 2016

AngularJS - if you are calling a function from outside of Angular / scope , always do it inside of $apply()

Otherwise, it will silently fail.

So , this is ok:

function get_ang_scope(){

    var appElement = document.querySelector('[ng-app=kalaApp]');
    var $scope = angular.element(appElement).scope();

    return $scope;


var scope=get_ang_scope();

scope.$apply(function () {
//    scope.updateCustomRequest(data, type, res);


jquery.attr setter wont execute if val is undefined

jQuery tip:

jquery.attr setter wont execute if val is undefined

Sunday, September 11, 2016

Absolute div clipped inside of a relative div

If this happens, make sure that the div which acts as bounding box has it's overflow set to visible. Not to auto or anything else!

Be careful with separate setting of overflow-x and overflow-y, it will probably set other dimension to auto mode.

Thursday, September 8, 2016

Unable to load DLL , added to references - C# 4

Unable to Load DLL xxxxxxxxxxxxxxxxxx: The Specified module could not be found. (Exception from HRESULT 0x8007007E).

The problem could be that a native dll which is need for running the xxxxxxxxxxxxxxxxx DLL is missing. You can either copy it to output/exe folder or add it to path...

Monday, September 5, 2016

Centering absolute divs horizontally

This is potentially useful snippet for centering an absolute div inside of it's relative parent:


It might be necessary to set width for the element too.

:focus class is sometime is ignored, but it can cause problems

If you are having problems determining the causes for your li or div tags odd behavior once you click them, make sure you check the behavior of :focus class on those elements. Maybe default behavior kicks in and makes problems for your design.

Also, if your background color acts strange, you might want to add more tags to your selector. Like

instead of

Sunday, September 4, 2016

Decision trees in Python and R

A nice and helpful article on Decision Trees and their implementation in Python and R.

Sunday, August 28, 2016

CSS - relative element appears in front of absolute element, ignoring z-index

CSS - relative element appears in front of absolute element, ignoring z-index:

Make sure that the elements have the same stacking context.
This usually means that you need an ancestor of both of these with position:relative or something similar.

More details:

Sunday, August 21, 2016

Decision Trees , ML

Cool link / interactive tutorial on Decision Trees:

Saturday, August 20, 2016

Fitting and forecasting with ARIMA in Matlab

Useful discsussion here:

I am using Matlab to forecast time series data using ARIMA algorithm. I am able to get forecasted values, but unable to get the fitted values. This is what I mean. In R:
 model <- auto.arima(data)");
 forecasted <- forecast.Arima(model, h=36)
forecasted$fitted will give the data which has been fitted to the original data by the ARIMA algorithm. But I cannot see anything like that in Matlab. This is what I have done so far:
model = arima(1,1,0);
[est, ~, logL, info] = estimate(model, data);
[output, YMSE] = forecast(est, 10);
output gives me the 10 values Arima has forecasted, but not the original data values it has fitted. I would like to know those.
Any help is appreciated.

I believe what you want can be indirectly obtained using the function infer.
As in general the actual fitted values from an ARIMA model are of little use themselves, what MATLAB returns is the residuals vector (somewhat oddly). In your case after you have estimated the parameters of the ARIMA model of your choice (model) given your observed univariate time series (data), you can use the model containing the parameter estimates (est) to infer the residuals of your model. So you want something like:
residuals = infer(est,data);
Following that you actual estimated values (est_data) are simply:
est_data = data - residuals;
Take note that infer function uses default setting regarding presample data. I do not know what are R is doing to get its estimates so I would advice you to look at the notion of presample before continuing. You might be surprised about what assumptions are put in place by different packages.

Monday, August 15, 2016

Google Maps JS v3 API - unable to display multiple Google maps on the same page

If the maps are coming out as blank gray, then you will probably have to use such a function:

window.maps = new Array();

function refresh_maps() {

    setTimeout(function () {

        var lenx = window.maps.length;

        for (var i = 0; i < lenx; i++) {

            var cur_map = window.maps[i];

            google.maps.event.trigger(cur_map, 'resize');




    }, 1000);


It refreshes all the Google Maps by raising a resize event. Also, it's important to re-center them.

The looping which adds maps to the array can look like this:


        map.xxcenter = myLatlng;


Wednesday, August 10, 2016

Grant Cardone - video on preparation

Another important video from Grant Cardone:

phpmyadmin won't export certain JOIN queries

If phpmyadmin won't export the results of some INNER JOIN / LEFT JOIN queries in CSV, you can try to first make a view out of the query, and then export.

This seems to be a bug in some versions of phpmyadmin.

Tuesday, August 9, 2016

Monday, August 8, 2016

The science behind decision making

7 smart mental models:

jQuery - when bind-first plugin is not enough to disable a button

If you want to conditionaly disable a button, without knowing the handlers attached to it, this code might interest you:







var resp=confirm("This action will empty the contents of your current cart. Are you sure you want to proceed?");


return true;


return resp;


jQuery(this).attr("disabled", false);
return true;


Basically, we attach to mouseup, which happens before "click" event, and conditionally disable the button!
Also, if it doesn't work, you can add it inside a setTimeout block, so you make sure it's not being overwritten by some other JS code.

Number of phone calls it takes to make something massively successful

Watch this great interview with Grand Cardone, it reveals a lot on sales:

Grant claims that he made 100,000+ phone calls in his career! That's why he has got massive successs. :)

Sunday, August 7, 2016

FIR,IIR filters explained

An intuitive approach to FIR/IIR filters can be found in this thread:

Wednesday, August 3, 2016

Monday, August 1, 2016

Binary XML file line #11: Error inflating class android.webkit.WebView

If your Android app is crashing with an Exception like this:

Binary XML file line #11: Error inflating class android.webkit.WebView

Then you probably need just to install WebView system component (you can find it on Google Play, and it should be already packed with every device) on that errorneus device.

The same fix applies to this problem:

AndroidRuntimeException:$NameNotFoundException: (which is the root cause of Inflating Error Exception here).

Thursday, July 28, 2016

How to match backslash (escape backslash) with preg_match in php

Like this (4 backslashes):
\    =>  \\\\\

More details here:

Confidence intervals vs Prediction Intervals

Here's some good information on this one important topic in Statistics.

Confidence intervals determine the probability that the real value of mean falls inside of its borders (CI borders).

Prediction intervals determine the probability that sample means will fall inside of its borders (PI borders).


Thursday, July 21, 2016

Home Made Plastic Extrusion System

Very cool video, home made mini plastic factory:

Tuesday, July 19, 2016

RegExp in JS - dont forget to put double backslashes

This works:

var s_reg=cssgroup +"-\\d";

var regexp1= new RegExp(s_reg,"i");

This doesn't work:

var s_reg=cssgroup +"-\d";

var regexp1= new RegExp(s_reg,"i");

jQuery UI droppable classes for hover

Version of jQuery UI - 1.11

This does not work:

jQuery( ".droppable" ).droppable({

   accept: ".draggable",
   classes: {
     "ui-droppable-active": "ui-state-active",
     "ui-droppable-hover": "ui-state-hover"


This works:

jQuery( ".droppable" ).droppable({

   accept: ".draggable",

   activeClass: "ui-state-hover",
   hoverClass: "ui-state-active",


Saturday, July 16, 2016

WP 4.5.3 - Just FTPing wp plugin content to plugins folder is not enough anymore for WP to load it?

It seems that you need to use Plugins->Add New->Upload new plugin from ver 4.5.3.
Otherwise, it doesn't seem to appear in WP Plugin list.
This needs some testing.


After testing, this proves to be wrong. You can  upload new plugins the same way as before (by simple FTPing).

My problem here was with a 3rd party plugin, which added a handler on all_plugins filter and removed some plugins from the plugin list.

This reminded me on fact that WP design has some flaws. Any plugin can do anything it wants, and can influence any other plugin (no separation between their contexts). Just like programming was in old DOS days.

Thursday, July 7, 2016

webpack + react-toolbox - CSS class names not loading

React-toolbox with webpack.

webpack command works without errors. Page loads without errors. But the css information on the html element is missing (empty).

The cause was this:


module: {
    loaders: [
            //tell webpack to use jsx-loader for all *.jsx files            test: /\.js$/,
                  loader: 'babel',
                    exclude:path.resolve(__dirname, 'node_modules/')


            test: /(\.scss|\.css)$/,
            loaders: ["style", "css", "sass"]



module: {
    loaders: [
            //tell webpack to use jsx-loader for all *.jsx files            test: /\.js$/,
                  loader: 'babel',
                    exclude:path.resolve(__dirname, 'node_modules/')


            test: /(\.scss|\.css)$/,
            loaders: ["style", "css?modules", "sass"]


More details here:
and here

To learn from this:

Always use the starter kit if possible, don't try your configuration for webpack.config.js file.

Tuesday, July 5, 2016

IIS Express fails to start with error Access is denied

up vote39down voteaccepted
This means that you are missing the right for using it. Create it with Netsh Commands for Hypertext Transfer Protocol > add urlacl.
1) Open "Command Line Interface (CLI)" called "Command shell" with Win+R write "cmd"
2) Open CLI windows like administrator with mouse context menu on opened windows or icon "Run as administrator"
3) Insert command to register url
netsh http add urlacl url=http://{ip_addr}:{port}/ user=everyone

If you dont want to add these urlacl's, you need to run visual studio as administrator. Otherwise, with everything else properlys set up , you will receive HTTP error 400 - Bad Request.

PSR-1 and PSR-2 coding standards for PHP

Visual aspects of code play a significant role in raising or drowning developer's productivity. In case that there's too much clutte...