logo

Magic Trick in IE11 (some JavaScript knowledge required)

So, do you want to see some JavaScript in the amazing world of IE11? Well it's simple: Open IE developer tools by pressing F12 and try out:

typeof ActiveXObject

intriguing the result is:

"undefined"

Did Microsoft dropped support for ActiveXObjects? Is this real life? Then miraculously when you call:

new ActiveXObject("Microsoft.XMLDOM")

you do actually get:

[object] { }

You just miraculously created an undefined object. Good job!

Fascinating implementation indeed. 

CodeEditor has now PowerShell support

If you want to edit your Joomla or Wordpress article. and you want to insert a programming code sample, you can do that by the click of a button with Ciplogic's CodeEditor. The good thing now is that you can also add PowerShell into your article, this being the new programming language added in version 1.2.

Here is a sample on how it looks for a random script from the Internet:

1
2
3
$greeting = "Hello"
$name = read-host "What iyour name?"
"$greeting, $name!"

Happy blogging.

JavaScript Debugging 1 : A small utility function

In this small series, I'm going to start explaining how to do JavaScript debugging, namely bug tracing at the advanced level, since I can't seem to find tutorials except how to actually run the debugger itself.

So in order to start, let's build first an utility class that we'll use in several places, the onceMany utility function:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(function() {
 
if (!window.ciplogic) {
    ciplogic = {};
}
 
ciplogic.onceMany = function(once, many) {
    var firstGenerated = false;
    return {
        next : function() {
            if (firstGenerated) {
                return many;
            } else {
                firstGenerated = true;
                return once;
            }
        }
    }
};
 
})();

As you can see at line 3, we will keep everything in the ciplogic namespace. From this moment on, we can call:

1
2
3
4
5
6
var comma = ciplogic.onceMany("", ", "),
    result = "";
 
for (var i = 0; i < arguments.length; i++) {
    result += comma.next() + parseArgument(arguments[i]);
}

And we don't need to keep a new array for join operations.

 

Problems With JavaScript Worker Threads

I recently just updated a library to handle worker threads under GWT, and I got to learn a bit more about the unique design of worker threads from javascript.

Here is a quick overview, in case you don't know much about them:

  1. There is no locking in javascript, so worker threads start asynchronously, and the only way to communicate with them is via the postMessage/onmessage API. There is no join(), wait(), synchronized blocks, or other sane threading paradigm you grew used to.
  2. There is no shared state, so every single message is transparently serialized back and forth. Did your thread processed 100MB of data? Well let me serialize that for you to get it on the other thread. Is there some global structure you want to work on parallel with multiple threads - like an image for example? Forget about it.
  3. There is no shared code, so worker threads must be created with their source independently - as a constructor argument. Packaging must be done basically separately for your "thread".

Let me translate this for you: Worker threads are a pain to even package in their own files, you can't call something like:

1
2
3
new Worker(function() { // this would be the worker instance.
    this.postMessage("send data back to parent");
});

No, that would be too easy, since from that method I could be able to access shared state, so let's make it awkward and weird, why not:

1
new Worker("my-worker.js");

and from the new file call:

1
self.postMessage("send message back to parent");

All the libraries, that you use both in your worker, or in your main code? Better load them twice.

But wait, there's more!

The window and document objects are not visible (that would be shared state, invalidating the fabric of JavaScript itself), so adding new scripts can be done via the importScripts function, but that's only if you are from inside a worker. importScripts for the window context? You must be talking the crazy talk. So you get a different approach even in loading external scripts from the different context window/worker.

There is a new object visible named self, that is the worker reference (if it's a script inside a window, self == window). 

So let's say you would want to process async a bunch of data, whenever it's being sent from the parent - again, there is no shared context, well why not go with:

1
2
3
4
5
6
7
8
9
10
11
function doActualProcessing() {
  //...
}
 
self.onmessage = function(ev) {
  // could be long running
  var result = doActualProcessing(ev.data); 
  
  // I hope for your sake, result isn't big in size.
  self.postMessage(result);  
}

Looks simple, isn't it? Except it's in a different bloody file, and did I mentioned that breakpoints in the worker thread code don't stop?

Fascinating.

Script Kiddies

So I was checking how's the bruteforce going on my website:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@ciplogic ~]# lastb -20
root     ssh:notty    ratpaw.com       Sat Jul 13 19:50 - 19:50  (00:00)    
root     ssh:notty    ec2-75-101-251-9 Sat Jul 13 11:52 - 11:52  (00:00)    
root     ssh:notty    ec2-75-101-251-9 Sat Jul 13 11:52 - 11:52  (00:00)    
root     ssh:notty    ip-208-109-184-8 Sat Jul 13 08:44 - 08:44  (00:00)    
root     ssh:notty    180.96.23.74     Sat Jul 13 01:16 - 01:16  (00:00)    
root     ssh:notty    180.96.23.74     Sat Jul 13 01:16 - 01:16  (00:00)    
root     ssh:notty    125.46.13.163    Fri Jul 12 20:23 - 20:23  (00:00)    
root     ssh:notty    125.46.13.163    Fri Jul 12 20:23 - 20:23  (00:00)    
root     ssh:notty    125.46.13.163    Fri Jul 12 20:23 - 20:23  (00:00)    
root     ssh:notty    125.46.13.163    Fri Jul 12 20:23 - 20:23  (00:00)    
root     ssh:notty    125.46.13.163    Fri Jul 12 20:23 - 20:23  (00:00)    
root     ssh:notty    183.232.32.24    Fri Jul 12 11:55 - 11:55  (00:00)    
root     ssh:notty    199.195.212.145  Fri Jul 12 01:11 - 01:11  (00:00)    
root     ssh:notty    199.195.212.145  Fri Jul 12 01:11 - 01:11  (00:00)    
root     ssh:notty    199.195.212.145  Fri Jul 12 01:11 - 01:11  (00:00)    
root     ssh:notty    199.195.212.145  Fri Jul 12 01:11 - 01:11  (00:00)    
root     ssh:notty    199.195.212.145  Fri Jul 12 01:11 - 01:11  (00:00)    
root     ssh:notty    199.195.212.145  Fri Jul 12 01:11 - 01:11  (00:00)    
root     ssh:notty    199.195.212.145  Fri Jul 12 01:11 - 01:11  (00:00)    
root     ssh:notty    199.195.212.145  Fri Jul 12 01:11 - 01:11  (00:00)    

My hosting has shorewall (or some form of it), that automatically bans people who have too many atempts, and my config has for sshd:

1
2
[root@ciplogic ~]# cat /etc/ssh/sshd_config | grep Root
PermitRootLogin no 

Keep knocking.

Silly people.

More Articles...

  1. Three things I love about Internet Explorer
  2. Free visual editor for code samples Joomla/Wordpress available (including GeSHi support)
  3. Simple tracing of JavaScript.
  4. Adding custom CSS to your Joomla site

Page 1 of 7

Hot Projects

Germanium

The one to rule them all. The browsers that is.

SharpKnight

SharpKnight is an Android chess game.

MagicGroup

MagicGroup is an eclipse plugin.