Wikipedia

Search results

21 September 2015

JS E Patterns

Events in JS are pretty amazing, and notifications or emits or emissions or what have you are quite often fundamental to programming with JS. In the case of UI it's literally every user interaction; and for pubsub mechanisms the same also holds true.

JS has a method Event.stopPropagation that here I will make the case introduces an anti-pattern to your code.

Here's the scenario:

user clicks submit on a form button, the code would look like the following:

submit.onclick = function(e) {
e.preventDefault() // similar method here
// .. do your thing
e.stopPropagation(); // stop furthering the event
}

1) Event occurs, and there is one file, and one method that the event is used.

Stopping event propagation here is nominal. This is a good use case, although it wouldn't make much difference to use stopPropagation.

2) You have multiple files that have multiple event listener methods.

Using stopEventPropagation should be avoided because it can act as an anti-pattern, here's how:

Let's say we have two different methods, and in two different files:

method1, file1

function eListener1(e, p) {
// tasks of eL1
}

and

method2, file2

function eListener2(e, p) {
// tasks of eL2
}

By definition, the layout of your code is completely different in the two scenarios .. one you're very much in the same place, and the other you leave to the great open yonder, not knowing exactly why or who is going to use something from somewhere as you're buidling.

To stop event propagation here is a mistake, and it would block tasks including delegation, and future use cases. For instance, suppose that your event is currently active in eL1 above; and now you want to create another event listener in another class or file that you will call eListener3 to perform some task on the same event. You would not be able to do this with stopPropagation; in effect you've limited your own possibilities, and another rate limiting step added to the soup is now that method that I will argue should have been avoided.

Stopping propagation is appropriate for a terminal event, such as deleting an item that has a known end; and not for general user interaction events. Signing out, for instance, could be another use case, however, would be redundant in many cases.

For general events, it's wasted energy. The consideration for stopEventPropagation at the general event level is perhaps at the heart of the rift between TCP or UDP versus TCP/IP.


In general, it's a good idea to avoid exotic methods unless you know exactly why you're using them. However, if you are building massively scaled TCP/IP request based systems that send large amounts of data, then this may not apply to you. 

A potential or real benefit of stopEventPropagation is saving computing and/or bandwidth resources.

So what's someone to do without stopping propagation?? Glad you asked, it's the simple conditional. The key here is to add a unique identifier to your object (i.e. this.supercalifradgilisticexpialidocious = 'here it is';), and in every one of your listeners you'd have your conditionals:

function eListener3(e, p) {
if (e === 'click') {
switch (p.foo.supercalifradgilisticexpialidocious) {
case 'here it is': {
// do func
break;
}

default: break;
}
}
}

05 September 2015

Local Sublime Text via remote SSH

Initially, for myself, and quite ashamedly as with many other facets .. I created an alias to access my SSH .. as a way to avoid lookup of the IP address you know? I cringe now, believe you me.

Well, then I needed to have access to Sublime Text in my remote environment as a way to make life a wee more convenient (i.e. in this case WAY more convenient), and figured to let you know how I did in case it may help.



There are good articles about how to configure your local and SSH environments with Sublime Text, such as this one written by Limina Studio and this one written by Daniel Demmel.

One other key piece of information is the function of the ~/.ssh/config file itself. There's a great writeup available from Nerderati available from this link.

The workflow is as follows:

1. Install the rsub plugin from the Package Control of Sublime or instructions provided from the public Github repository,

2. In your local environment edit your ~/.ssh/config file and specify your SSH IP address and User:
Host yourAlias
    HostName "$IP"
    User "$USER"
    RemoteForward 52698 127.0.0.1:52698
3. In your SSH environment, as root, do:
# wget -O /usr/local/bin/rsub https://raw.github.com/aurora/rmate/master/rmate
# chmod +x /usr/local/bin/rsub
# shutdown -r now
4. Henceforth, you may now access your SSH similar to what would be an alias:
$ ssh yourAlias
5. Restart Sublime, SSH in, and there will be an added advantage of being able to edit files via your local environment's Sublime Text editor.


01 September 2015

Guidelines for clinicians

Pleased to announce Guidelines a resource for clinicians.

This was a project long overdue.

1) Single site access to gold standard guidelines is surprisingly still not addressed

The purpose of Guidelines is very pure and simple: frequently or semi-frequently the world leading associations issue recommended guidelines that clinicians utilize on a daily basis to treat medically compromised patients.

The variety and scope of these publications may be wide, however, there are a number of well defined sources that are pre-selected as the authority or gold standard of care. Therefore, curation of these Guidelines is not as labor intensive or time consuming to warrant an establishment for their organization; and thus, remain neglected.

2) Clinicians should conveniently be able to access Guidelines

Of anyone with their plate already full, the clinician will foreseeably be too consumed in other activities to maintain a dedicated, and convenient, point of entry towards their access to the most current, and relevant, standards.

The clinician may not even have convenient access to a list of gold standard resources they once may have had. Once a clinician enters private practice, they risk becoming isolated and sandboxed out of such resources that may often go unnoticed or unappreciated.

As a result, the clinician may compromise their ability to receive a thorough, and up to date, criteria or list of standards they may study. Subsequently, patients are the population who bear the results of this risk.

3) When clinicians have access to resources, patients benefit

The sole purpose of a clinical practice, and hence Guidelines, is to benefit the patient.

There should not be an issue that exists today caused by a barrier of access to information that is readily available over the wire. Therefore, instruments such as Guidelines exist to facilitate the transfer of information to maintain a peer reviewed, updated, thorough, and accessible list of resources available to clinicians via a multitude of avenues.

OPEN CALL FOR CLINICAL SCIENCE CONTRIBUTORS

ALL DISCIPLINES OF HEALTH CARE


PROJECT AVAILABLE ON GITHUB FOR IMMEDIATE CONTRIBUTION