Configuring maximum number of simultaneous open WebSockets (for IE)

Given I’ve got this JS application. All client side JS communicating using web sockets. One page may have multiple web sockets open as many as 10-15.

Firefox and Chrome handle this many open web sockets at once just fine. IE11 seemed to have a limitation of 6 open web sockets at once.

Once I open that 7th web socket, regardless of socket call to the third-party server, I got an error thrown by IE, which closes the socket and gives the general error “SecurityError” and expanding the __proto__ section it gives me . The error seems to be pretty generic.

At first it looks as if there may be a trusted zone type issue with IE, but even after adding the client site to trusted zone as well as the server providing the data, the error still persisted.

Solution

This site shows the max connections settings for IE. It’s a registry setting in Windows that controls the amount of web socket connections.

Interestingly enough, By default, windows doesn’t have that registry key, but there is still a limit. Therefore you have to add the Registry in order for this to work.

The MSDN Section mentions:


WebSocket Maximum Server Connections

Internet Explorer 10. When enabled, the FEATURE_WEBSOCKET_MAXCONNECTIONSPERSERVER feature sets the maximum number of concurrent WebSocket connections allowed to a single host. The minimum number that can be specified is 2 and the maximum value allowed is 128.

The default value for this setting is 6 in Internet Explorer and applications hosting the WebBrowser Control. To modify this feature by using the registry, add the name of your executable file to the following setting.

HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
   SOFTWARE
      Microsoft
         Internet Explorer
            Main
               FeatureControl
                  FEATURE_WEBSOCKET_MAXCONNECTIONSPERSERVER
                     contoso.exe = (DWORD) 0x00000006 (6)

This should fix the problem.

Source

MSDN

Fetch GET parameters in JS/jQuery

If you have a URL with some GET parameters as follows:

www.test.com/t.html?a=1&b=3&c=m2-m3-m4-m5 

and need to get the values of each parameters then below is a nifty piece of code solving your requirement.

JavaScript has nothing built in for handling query string parameters.

You could access location.search, which would give you from the ? character on to the end of the URL or the start of the fragment identifier (#foo), whichever comes first.

You can then access QueryString.c

jSoup: Java HTML Parser

jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods.

jsoup implements the WHATWG HTML5 specification, and parses HTML to the same DOM as modern browsers do.

  • scrape and parse HTML from a URL, file, or string
  • find and extract data, using DOM traversal or CSS selectors
  • manipulate the HTML elements, attributes, and text
  • clean user-submitted content against a safe white-list, to prevent XSS attacks
  • output tidy HTML

jsoup is designed to deal with all varieties of HTML found in the wild; from pristine and validating, to invalid tag-soup; jsoup will create a sensible parse tree.

Example

Fetch the Wikipedia homepage, parse it to a DOM, and select the headlines from theIn the news section into a list of Elements (online sample):

Document doc = Jsoup.connect("http://en.wikipedia.org/").get();
Elements newsHeadlines = doc.select("#mp-itn b a");

Open source

jsoup is an open source project distributed under the liberal MIT license. The source code is available at GitHub.

Getting started

  1. Download the jsoup jar (version 1.8.3)
  2. Read the cookbook introduction
  3. Enjoy!

Resources

Top 5 online JavaScript Beautifier

From a developer’s point of view, developing code ad hoc is a bad practice and bad for maintenance. And Tabbing manually is a pain to work with.

jsBeautifier

Here is a list of JavaScript Beautifiers available online for use free of cost.

Color Thief

A script for grabbing the color palette from an image.
Uses JavaScript and the canvas tag to make it happen.

How to use

Get the dominant color from an image

var colorThief = new ColorThief();
colorThief.getColor(sourceImage);
getColor(sourceImage[, quality])
returns {r: num, g: num, b: num}

Build a color palette from an image

In this example, we build an 8 color palette.

var colorThief = new ColorThief();
colorThief.getPalette(sourceImage, 8);
getPalette(sourceImage[, colorCount, quality])
returns [ [num, num, num], [num, num, num], ... ]

Demo More from Original Author

JQuery not working in wordpress

Since WordPress version 2.x, jQuery is a build-in JavaScript library, explicitly include the jQuery library into WordPress is not necessary.

$(document).ready(function(){
  alert('test');
});

the above code will be giving an error in the console of your code:

$ is undefined

In WordPress, the $() syntax is always used by other scripting library, and causing the conflict issue and fail to call the jQuery function. You should use jQuery() instead…

jQuery(document).ready(function(){
  alert('test');
});

Alternatively, you can use noConflict()

$j=jQuery.noConflict();

// Use jQuery via $j(...)
$j(document).ready(function(){
  alert('test');
});

P.S jQuery.noConflict();http://wordpress.org/support/topic/141394

Never use jQuery handy function $() in WordPress plugin. You have to use jQuery() or jQuery.noConflict() to work between jQuery and WordPress.

Source

Make content of a webpage as editable

Just for pranking friends to make them believe that you are some sort of a hacker…

Try this:

 

This is not much, but just enough to have fun…:D

The changes would not be affecting the page itself. When you reload the page, you will again get back the original

How to expand collapse (toggle) div layer using jQuery

Thanks to http://designgala.com/how-to-expand-collapse-toggle-div-layer-using-jquery

In almost all of my projects, I have been using jQuery to toggle the layer. So, I thought of sharing how easy it is to expand div layer and collapse panel using jQuery. When user clicks on the header, the content gets displayed by sliding down and when you again click on the header, the content collapses.

Step 1: Include jQuery Library in head section of your html file.

Step 2:

Come up with your own html elements in body section. I chose div ‘layer1′ to be the main container where collapsible/expandable content would reside.

Next, class ‘heading’ is given to header while div ‘content’ holds the show hide layer for that heading


Header-1


Lorem ipsum dolor sit amet, consectetuer adipiscing elit orem ipsum dolor sit amet, consectetuer adipiscing elit

Header-2


Lorem ipsum dolor sit amet, consectetuer adipiscing elit orem ipsum dolor sit amet, consectetuer adipiscing elit

Header-3


Lorem ipsum dolor sit amet, consectetuer adipiscing elit orem ipsum dolor sit amet, consectetuer adipiscing elit

Step 3:

CSS: Now it totally depends on you to write css for your heading, div. Here’s my version of CSS for this example.

.layer1 {
margin: 0;
padding: 0;
width: 500px;
}

.heading {
margin: 1px;
color: #fff;
padding: 3px 10px;
cursor: pointer;
position: relative;
background-color:#c30;
}
.content {
padding: 5px 10px;
background-color:#fafafa;
}
p { padding: 5px 0; }

Step 4:

Again lets go to head section to add few more javascript codes.


jQuery(document).ready(function() {
jQuery(".content").hide();
//toggle the componenet with class msg_body
jQuery(".heading").click(function()
{
jQuery(this).next(".content").slideToggle(500);
});
});

Thats it!! Expandible-Collapsible panel is ready.

What? You want to see a demo…….This post is the demo in itself 🙂

Caution: When using this in blogger

Because the blogger already has a div with class content which is the parent of all the divs in the page. Hence You need to rename the content class to some other suitable name, before you try to use it with blogger.