Thursday, July 28, 2016

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

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

More details here:
http://www.developwebsites.net/match-backslash-preg_match-php/

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

Details:
http://blog.minitab.com/blog/adventures-in-statistics/when-should-i-use-confidence-intervals-prediction-intervals-and-tolerance-intervals

Thursday, July 21, 2016

Home Made Plastic Extrusion System

Very cool video, home made mini plastic factory:

https://www.youtube.com/watch?v=anqKC0i0a7Y

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.

UPDATE:

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

Scenario:
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:

THIS DOES NOT WORK ( NO ERROR , BUT EMPTY CLASS PROPERTY ON THE RESULTING HTML ELEMENT:

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"]
        },



    ]
},


THIS WORKS WELL:

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:
https://github.com/react-toolbox/react-toolbox/issues/567
and here
https://github.com/webpack/css-loader#css-modules


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
SOLUTION
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
NOTE:

http://stackoverflow.com/questions/19293572/how-to-solve-microsoft-visual-studio-vs-error-unable-to-connect-to-the-conf


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.

Monday, July 4, 2016

ReactJS - > nothing can happen if the outer engine for parsing (babel) is not loaded before the bundle.js(x) created by webpack

If your React app doesn't render anything, and produces no errors, that might be because it's main js(x) file is being skipped, due to missing loader in index.html (babel-core for example).

Here's a sample working reactjs setup using webpack and babel

Friday, July 1, 2016

IISExpress - Accessing ASP.NET MVC 4 development sites in LAN

This page by Microsoft describes how to set up access to IIS Server Express from other computers on the local network.
In a nutshell:
1) from a command prompt with admin privileges:
netsh http add urlacl url=http://[your ip address]:8181/ user=everyone
2) In Windows Firewall with Advanced Security, create a new inbound rule for port 8181 to allow external connections
3) In applicationhost.config, in the node for your project, add:
<binding protocol="http" bindingInformation="*:8181:[your ip address]" />
Do NOT add (as was suggested in another answer):
<binding protocol="http" bindingInformation="*:8181:*" />
The above wildcard binding broke my access from http://192.168.1.6:8181/

FROM HERE:
http://stackoverflow.com/questions/4831097/bad-request-invalid-hostname-iis7

Also,

edit applicationhost.config in C:\Users\USER\Documents\IISExpress\config:

Find <site name="YOURSITE">
and add a new binding like this:
<bindings> <binding protocol="http" bindingInformation="*:2959:127.0.0.1" /> <binding protocol="http" bindingInformation="*:2959:192.168.1.107" /> </bindings>

(Here it's added for 192.168.1.107)


IMPORTANT NOTE:

If, usually after some time, you cannot open your site from remote ip (i.e. 192.168.1.107), and you receive HTTP Error 500 Service Unavailable, and even restarting the whole computer doesn't help, than you should try to switch to a new port ( ideally, something around 50000 - like 52959) and re-apply the process above. That seems to be some kind of IIS bug.

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