Monday, January 30, 2017

ReactJS does not support variable interpolation inside of quotes

Beware, in ReactJS, these two things are different:

<li key={i}>

<li key="{i}">

The former is correct, the later is probably going to lead to  a syntax error:)

Friday, January 20, 2017

Official documentation on CSS overflow-x and overflow-y

Here's a link to the overflow-x, overflow-y specification in CSS3 (just as a reference):

Thursday, January 19, 2017

10 Reasons You're not a millionaie (yet)

Some very sound advice here:

1. You have no one guiding you in the right direction.

2. You aren’t willing to make sacrifices.

3. You fear failure.

4. Your goals aren’t clear, so neither are your actions.

5. You think other people can succeed but not you.

6. You think your background or location prevents your success.

7. You aren’t using the Internet.

8. You rationalize money can’t buy happiness and forget that it can buy freedom.

9. You hang out with the wrong crowd.

10. You play long shots like the lotto instead of building your skill set.

Tuesday, January 17, 2017

CSS - Popping out of a div with overflow-y:scrollable

If you would like to pop out an absolute div outside of a div with overflow:hidden, overflow:scroll or overflow-y:scroll, you need to:

1. Make sure your div with overflow:hidden / scroll is not a positioned div

2. Make sure parent elements of the div you want to move outside of the container are not positioned as well (remove position:relative , etc)

3. Make sure your outside div has position:absolute.


Monday, January 16, 2017

RF Design - Interactive online Smith chart

Interactive online Smith chart:

Useful and educational for impedance matching. Enter element values (resistance / inductance / capitance) and observe results in real time. Nice !

Sunday, January 15, 2017

Sales trend in 2017: renaissance of cold calling

According to this article, new-old trend for sales in 2017. is: COLD CALLING , again.

Here is an excerpt from the article:

I read that 84% of new business is being generated by referrals.

Again, this statistic is simply not true because in the main, that's an internal referral generated off of a savvy cold caller who has leveraged social engineering to do the triangulating and targeting. If the CMO flicks your email to the CEO, bingo: internal referral.
I hope this is giving you a lot of hope and a fire in your belly. There is a light at the end of the tunnel, and it's called "back to basics."
Think about how Rocky used to train for boxing matches to become the world champion. Pulling heavy things in the snow.
"I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times." - Bruce Lee
You can do it all with a phone or amp it up leveraging a smart, blended approach. I like to call this Combination Selling. But you can't do it without challenge and hard work. If you're having a blast clicking the mouse and it all seems so easy, you'll fail.
There will never be an easy button on sales success.
Social is a piece of quality selling. Social selling is not a thing, it's a feature - a crucial component of "whatever it takes."
I hate to burst your bubble, generation Z. A+ selling should strike terror in your heart: you can only win by talking to qualified prospects as often as possible. "Pipeline cures all ills!"

Look at the article at

Wednesday, January 11, 2017

UX propaganda techniques

A good article on propaganda through modern User Experience. Modern propagandist are using this clever tricks to make us buy and use their apps, sites, games and so on. However, this is not limited to software, the same techniques are applied all over the marketplace - from retail shops to online sales. If you intend to use them, make sure people benefit from your products! :)

UX Propaganda make your product addictive

Main points from the article:

Appeal to fear or shame

Prime motivator for taking action. An excerpt:

When faced with a threat, people are directed to respond, depending on:

The severity of the threat.
The probability of the threat occurring if no adaptive behavior is performed.
Availability of a solution.
The individual’s ability to execute on the solution.


Applications can use this tactics to notify their users about potential threats or make them feel ashamed if they are not actively using the application. One way of influencing the users is through frequent reminders.
This tactic is used my vast majority of big players in app world. Obviously, for a good reason.

Appeal to authority

People have a tendency to trust people they perceive as experts. When pressed by man in lab coats, people are willing to do anything that's required from them, no matter how good or smart that is, and no matter what they see or hear.

There is a well known quote regarding our willing to listen to people we trust and like:
“All other things being equal, people buy from people they know, like, and trust.”

Bandwagon effect

People in large groups and crowds are likely to behave differently from how they ususally behave, when they are alone or in small groups. People start sharing same ideas, same views, same likes and dislikes, and this behavior becomes stronger and stronger.
Tools of trade for this effect:
-Displaying shares and likes from other users
-Displaying reviews from other users

Exaple of bandwagon-driven success:

Other techniques covered in the article:

Beautiful People
People are attracted to good looking people.

Black and White fallacy 
(making a false dillema, and limiting the number of options)

Plain folks appoach
Use pretext which implies that opinion presented by the propagandist's is a precise replica of common sense approach.

Loaded language
Stay away from words and phrases that invite uncertainty. 

Repetition of same symbol or slogan is very important.

and also

Slogan, Third-party technique, Make your product sticky

All details can be found in the full article.

Tuesday, January 10, 2017

User-contributed, actual data on cost of living in different cities accross the world

A very interesting site:

They have information for many cities throughout the world. Information like: price of a simple meal, price of milk, price of clothes, etc, etc. They support comparisons, too! Very cool!

Java for Android: URLClassLoader throws NullPointerException - a bug?


In standard Java, URLClassLoader can be used to dynamically load a class to a Java program. And also, on Android, URLClassLoader should be able to load an external class, from a folder or JAR. However, Android implementation unfortunately fails, either with a ClassNotFoundException , or with NullPointerException.

Here's the test code:

File pathFiles=this.getApplicationContext().getFilesDir();

// /data/data/<appdir>/files

String path1=pathFiles.getAbsolutePath()+"/qoslib/";

File finalPath = new File(path1);

URL classUrl=null;
       try {
// classUrl = new URL("file:"+path1);
        classUrl = finalPath.toURI().toURL();

} catch (MalformedURLException e) {
// TODO Auto-generated catch block
       URL[] urls = {classUrl};
       URLClassLoader urlLoader1=null;
       urlLoader1=new URLClassLoader(urls, this.getClassLoader());
       try {
// urlLoader1.loadClass("com.example.agent2.orm.senders.SendMeetingSync2");
        Class classToLoad = Class.forName ("com.example.agent2.orm.senders.SendMeetingSync2", true, urlLoader1);

} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
int a;
       catch(Exception ex){
        int b=0;

My guess is that there's a bug inside of Andorid's URLClassLoader or it's badly documented and prone to security restrictions on OS-level, since NullPointerException returns no additional error information.

Some people have suggested to use DexClassLoader:

Hopefully,it's going to work properly.


There's an example of DexClassLoader in the Dalvik test suite. It accesses the classloader reflectively, but if you're building against the Android SDK you can just do this:
String jarFile = "path/to/jarfile.jar";
DexClassLoader classLoader = new DexClassLoader(
    jarFile, "/tmp", null, getClass().getClassLoader());
Class<?> myClass = classLoader.loadClass("MyClass");
For this to work, the jar file should contain an entry named classes.dex. You can create such a jar with the dx tool that ships with your SDK.

Answer by JFL seems to be promising. Need to verify.

Finally, here is a workflow that works:

#1 Extract the .class file you want to dynamically load (make sure you respect exact folder strcture as in original project). Put that folder to a folder temp1
So you have a structure like this:

#2 Move to temp1 folder and create normal jar using this command:
jar cvf myjar.jar ./*

This will generate jar1.jar inside of temp1 folder. Now we need to make Dalvik-ready JAR out of it.

#3 To make dalvik ready jar, we use dx tool:

Location of dx tool:

dx --dex --output=update1.jar jar1.jar

This will generate a Dalvik ready JAR which you can transfer to your device. There you can use the code above to successfully load it to your program at runtime!
If you have problems with /tmp directory, replace it with Context.getCacheDirectory().getAbsolutePath(). It's tested and it works!

Monday, January 9, 2017

Java : dynamically compile and load Java class


1. Take java class source code
2. Compile it to a .class file
3. Load the class into main program using URI
4. Run the class

Tools needed (Java libraries):


Dynamic replacement of malfunction parts of remote application...

Detailed instructions  on Java class loading can be found in this forum thread:

Java compile and load class

If wewould like to replace existing class, that will probably require us to write a custom class loader. Because, all default class loaders in Java will skip loading the class if the class with same name is already loaded.

One idea:

Reserve a dynamic name for updated class ,and first look for it in your code....

Thursday, January 5, 2017

Outlook error 0x800CCC0F when downloading email messages

Outlook error code:

The connection to server was interrupted.


postfix(courier-pop3d daemon) shuts down the connection when the number of requests from the same ip address exceeds the predefined size. The default value for MAXPERIP parameter is only 4.

This can be seen in /var/log/ on Ubuntu installs:
courier-pop3d: Maximum connection limit reached for [CLIENT IP]

Increase the max conn limit in confirg file: etc/courier-imap/pop3d
(MAXPERIP parameter)

IMPORTANT, make sure you restart courier-pop3d daemon by this call to shell script:

/etc/init.d/courier-pop3d restart
More details here:

This should be everything needed to resolve Outlook error 0x800CCC0F. Your email should work again :)

What are some ways of B2B lead generation

Leads are valuable. B2B leads are very very valuable. I'm sure most of us will agree with it. Nevertheless, most of us don't know how many ways of generating them exist. Business to Business leads can be generated in so many ways. Here is a list of some, just to refresh your memory or give you some new  creative ideas:

-Other Web 2.0 sites
-Rich Media
-Print Advertising
-Public Relations
-Online Display Ads
-Outer Media
-TV ads
-Direct mail
-Virtual, on-demand events
-Search Marketing
-Company Website
-Email or Electronic Newsletters
-Tradeshows, conferences
-Inside sales
-Executive Events

And how these rank, from coolest, to hottest? Well, it seems that Human-To-Human interaction is still a sure winner - look at it:

Wednesday, January 4, 2017

Valuable online book on the topic of Computer Networking

Good stuff here:

An interesting discussion on Neural Networks for Natural Language Processing


"Can't see the forest for the trees"

Dictionary definition for "Can't see the forest for the trees":

When you are too close to a situation you need to step back and get a little perspective. When you do you will notice there was a whole forest you couldn't see before because you were too close, and focusing on the trees. 
Simply that you have focused on the many details and have failed to see the overall view, impression or key point.

Does this happen to you? It's a very common thing in programming. You end up looking at single part of code, losing sight of the big picture. In my experience, a good piece of paper or a Excel spreadsheet can come handy to strip the whole process to most basic concepts and elements.

Either physical paper or a computer program can help you visualize the big picture. Yes, the program is much more complicated matter than just a few concepts interconnected with some arrows. However, if you don't have clarity at this high-level, the low-level is going to be a mess for sure.

So, let's get back to basic, pen and paper and draw the forest! 

Tuesday, January 3, 2017

Super difficult bug to identify in PHP Simple HTML DOM Parser Library

Insert/Edit/Append operations in PHP Simple HTML DOM library can silently fail, without any reason.

I suspect that the cause might be a internal logical bug inside of the library, or maybe just a memory leak, as the script seems to be pretty memory inefficient. Anyway, this bug looks like this:


You update an element using innertext or outertext method. It seems all good, but when you print your DOM object, it doesn't include the newly changed/added elements.


Call method ->clear() on $html object and reload it back from the string every now and then:


Recreating simple_dom_html object by the method above adds significant overhead in terms of page load time (~100ms in my tests). So,I've decided to investigate the issue in more detail. The result: I've found the bug to be linked with a line that's changed innertext of body tag:
$html->find("body", 0)->innertext.=$BOX;

After this call, any other call to innertext change would fail. So, I've decided not to directly expand body tag using this approach, but I have added a dummy child element to body tag,  and put $BOX content there. It worked well. So, I guess there must be a bug in simple_dom_html somewhere, which makes it silently crash upon change of body tags innertext. It seems that it doesn't have ability to recreate DOM tree if the root element is modified?

It seems that simple_dom_html really doesn't support changing dynamically loaded HTML (via innertext).

use a new $html2 object and process the tags, then return it back to string

Monday, January 2, 2017

CSS/LESS problem - parent of a floating element has no height

Scenario, you have a floating element (float:left for example), and its parent DIV shows height=0px.

Example, HTML:

<ol class="breadcrumb">

<a href="#"  class="active"> FIRST GALLERY</a>

<a href="#" > SECOND GALLERY</a>


LESS code:




        list-style: none;


Add this CSS code to make sure ol element gets proper height:

    /* force parent element to set its height properly, to contain floating element:  */
        content: "";
        display: block;

Maximum size of TEXT field in MySQL DB

Maximum size for TEXT field in a MySQL database is usually  64 Kilobytes. If you need more space, you can choose MEDIUMTEXT or LONGTEXT,as shown in table below.

Type       | Approx. Length     | Exact Max. Length Allowed
TINYTEXT   | 256 Bytes          | 255 characters
TEXT       | 64  Kilobytes      | 65,535 characters
MEDIUMTEXT | 16  Megabytes      | 16,777,215 characters
LONGTEXT   | 4   Gigabytes      | 4,294,967,295 characters
Please note: If you are using UTF8 or similar multi-byte encoding, 
the actual length will be lower.

Find method not working properly - A possible bug in simple_html_dom library for PHP

simple_html_dom library for PHP features a strange behavior in version 1.5. I think this is a bug.


You use str_get_html to load a string to html dom object

You add dynamic object with class .a2 to an existing object .a1, by modifying its innertext property.

You call find() method to search for .a2 objects, like this:

It returns 0 results. Nothing can be found.

The problem is probably that updates using innertext are not getting converted to proper HTML DOM nodes.

The workaround is to save HTML DOM object to string, after setting innertext value, and then to load it back again from string to a new HTML DOM object.

Sample code:


Some notes on NodeJS's async I/O

Many of us are sometimes confused with what it means that NodeJS is both single-threaded, and async. So, it's a bit more complicated than that.

NodeJS core contains an non-blocking loop for requests. The received requests is immediately sent for processing and the listening process resumes. This way, NodeJS's primary thread is almost always ready to accept new requests.  Data can be processed either in other threads or on other servers (like in case of a distributed system or a distributed database).

Here is a nice explanation by slebetman about the way NodeJS operates at its core:

Since you're asking a fairly low level question I'll answer with a low level answer. Hope you're comfortable with C.
First, a disclaimer: I'll be talking mostly about networking code because the only widely used database I know of that use file I/O is sqlite. Since you're asking about postgres I can assume you're interested about how socket I/O (be it TCP socket or unix local sockets) can work with only one thread.
At the core of almost all async systems and libraries is a piece of code that looks like this:
while (1)
  read_fd_set = active_fd_set;

  // This blocks until we receive a packet or until timeout expires:
  select(FD_SETSIZE, &read_fd_set, NULL, NULL, timeout);

  // Process timed events:
  timeout = process_timeout();

  // Process I/O:
  for (i = 0; i < FD_SETSIZE; ++i) {
    if (FD_ISSET(i, &read_fd_set)) {
      if (i == sock) {
        /* Connection arriving on listening socket */
        int new;
        size = sizeof(clientname);
        new = accept (sock,(struct sockaddr *) &clientname, &size);
        FD_SET (new, &active_fd_set);
      else {
        /* Data arriving on an already-connected socket. */
        if (read_from_client(i) < 0) {
          close (i);
          FD_CLR (i, &active_fd_set);
(code example paraphrased from a GNU socket programming example)
As you can see, the code above uses no threading whatsoever. Yet it can handle many connections simultaneously. If you take a look at the for loop it is also obvious that it is basically a simple state machine that processes sockets one at a time if they have any packets waiting to be read (if not it is skipped by the if (FD_ISSET...) statement).
Non-I/O events can logically only come from timed events. And that's where the timeout management (details not shown for clarity) comes in. All I/O related stuff (basically almost all your async code) gets called back from the read_from_client() function (again, details omitted for clarity).
There is zero code running in parallel.

Where does the parallelization come from?

Basically the server you're connecting to. Most databases support some form of parallelism. Some support mulththreading. Some even support node.js or vert.x style parallelism by supporting asynchronous disk I/O (like postgres). Some configurations of databases allow higher level of parallelism by storing data on more than one server via partitioning and/or sharding and/or master/slave servers.
That's where the big parallelism comes from -- parallel computing. Most databases have very strong support for read parallelism but weaker support for write parallelism (master/slave setups for example allow you to write only to the master database). But this is still a big win because most apps read more data than they write.

Where does disk parallelism come from?

The hardware. Mostly this has to do with DMA which can transfer data without the CPU. DMA is not one thing. It is more like a concept. Different systems like the PCI bus, SATA, USB even the CPU RAM bus itself has various kinds of DMA to transfer data directly to RAM (and in the case of RAM, to transfer data higher up to the various levels of CPU cache) or to a faster buffer.
While waiting for the DMA to complete. The CPU is not doing anything. And while it is doing nothing and there happens to be a network packet coming in or a setTimeout() expiring the code that handles them can be executed on the CPU. All while a file is being read into RAM.

But Node.js docs keep mentioning I/O threads

Only for disk I/O. It's not impossible to do async disk I/O with a single thread. Tcl has done that for years and many other programming languages and frameworks have too. It's just very-very messy since BSD does it differently form Linux which does it differently from Windows and even OSX may be subtly different form BSD even though it is derived from it etc. etc.
For the sake of simplicity and solid reliability node developers have opted to process disk I/O in separate threads.
Note that even for socket I/O it is not as simple as the code example I gave above. Since select()has some limitations (for example, you're forced to loop over ALL sockets to check for incoming data even though most won't have incoming data), people have come up with better APIs. And obviously different OSes do it differently. That is why there are a lot of libraries created to handle cross platform event processing like libevent and libuv (the one node.js uses).

OK. But postgres still runs on my PC

Asynchronous, event-oriented systems does not automagically give you performance superpowers. What they DO give you is choice: the app server is blazing fast so where you put your database servers and what database you use us up to you.

OK. But I can do this with threads. Why async?

Since 1999, many people have run many benchmarks and in the majority of cases single threaded (or low thread count), event-oriented systems have outperformed simple multithreaded systems. It was especially true in the old days of single CPU, single core servers. It is still partly true now (since cores are still limited).
That is why Apache was re-written into Apache2 to use a thread pool of async listeners and why Nginx was written from scratch to use a thread pool of async code.
Yes, on modern servers ideally you'd still want some threads in order to use all your CPUs. The alternative is a process pool like how the cluster module works in node.js. But you'd want the number of threads/processes to be constant or as constant as possible to avoid the overhead of context switching and thread creation.

Full thread on Stack Overflow.

Sunday, January 1, 2017

Genymotion device - black screen

If your virtual Genymotion tablet or phone is providing you with just a black screen, try to focus the emulator Window and press ESC key on the keyboard. It should render the screen properly then.

CNC tutorial

Very good CNC tutorial. Very detailed and practical:

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...