Saturday, August 2, 2014

Javascript related

http://casual-effects.blogspot.ca/2014/01/an-introduction-to-javascript-for.html

Module

There are several ways of using functions to group state and implement module-like functionality. The simplest is to have modules be objects that contain functions (and constants, and variables...). 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use strict;
 
var module = (function() {
  // This cannot be seen outside of the module, so it will not create namespace
  function aPrivateFunction(z) { return Math.sqrt(z); }
 
  // Freezing and sealing are two ways to prevent accidental mutation of the
  // module after creation.
  return Object.freeze({
     // These are accessible as module.anExportedFunction after the definition
     anExportedFunction: function(x, y) { return x + aPrivateFunction(y); },
     anotherExportedFunction: function(x) { return 2 * x; }
  });
})();


Another variation mutates the global namespace object: 

?
1
2
3
4
5
6
7
8
9
10
use strict;
 
// Use function to create a local scope and persistent environment
(function() {
  function aPrivateFunction(z) { return Math.sqrt(z); }
 
  // Mutate the global environment
  this.anExportedFunction = function(x, y) { return x + aPrivateFunction(y); };
  this.anotherExportedFunction = function(x) { return 2 * x; };
})();

Friday, August 1, 2014

Asp.Net MVC 5 + Bootstrap Tutorial - 30 days

Using Javascript Code in Bookmarks - Part I - to create small tools (e.g. to delete Exchange emails when using the web client)

Tool: to use when accessing Microsoft Exchange email from web browser -

Check Checkboxes

Tip: Drag the above link to your Bookmark Bar


How and Why the above tool was created: 

"Check All Checkboxes" does not work when I access my company's Exchange email via a web-browser.

Below Javascript helps with that.
Below code will check all the checkboxes of emails that have one of the 2 strings : "log time", "iDoneThis Today"

// Modify search_strings as necessary
var search_strings = ["log time", "iDoneThis Today"];

var f = document.getElementsByTagName("frame")[1];
var d = f.contentWindow.document;
var checkboxes_array = d.getElementsByName("MsgID");
var i,j;
for(i=0;i < checkboxes_array.length;i++){
  var elem = checkboxes_array[i];
  var row_html = elem.parentNode.parentNode.innerHTML;
  for (j=0;j < search_strings.length;j++) {
    if (row_html.indexOf(search_strings[j]) >=0) {
      elem.click();
      break;
    }
  }
}


We can put the above code in a Bookmark by:

In Chrome:
-2) Right-Click on the Bookmark Bar & click on Add Page

-1) Name - give any name; URL - use the above code as outlined below


0) Do not use the comment line

1) putting the rest of the above code in one line

2) prefix with "javascript:"

e.g. javascript: var search_strings = ..........

Sunday, July 27, 2014

Data Analytics, Data Scientists - Nature of work, Academic Background Required, Industries that use it

From http://blogs.msdn.com/b/brunoterkaly/archive/2014/07/24/fundamentals-of-machine-learning.aspx :

Excerpt:

How to think about the analytics spectrum

One great way to think about machine learning is to break down analytics into 3 questions:
  1. What happened?
    • Historical
  2. What will happen?
    • Predictive
  3. What should I do next?
    • Prescriptive

How to think of the personas doing analytics

  1. The information worker
    • Typically using a self-service approach using Power BI.
      • Power BI for Office 365 is a self-service business intelligence (BI) solution delivered through Excel and Office 365 that provides information workers with data analysis and visualization capabilities to identify deeper business insights about their data
  2. IT professionals
    • Involved in data transformation, data warehousing, creating data merchant cubes for analytics, and data modeling
    • Work for GM's are directors
  3. Data scientists
    • Deeply technical and skilled not just with code, but with mathematics, statistics, and probability
    • Can use a variety of techniques to apply probability to predictions (ie, there is a 42% chance that prices will go up in the next 18 hours)
    • Like Monte Carlo simulations, parameterizing the model
    • What to look for in a data scientist
      • Domain Knowledge
      • Clear Understanding Of The Scientific Method
        • Objectivity, Hypothesis, Validation, Transparency
      • Strong in Math and Statistics
      • Intellectual Curiosity and Critical Thinking
      • Visualization and Communication
      • Advanced Computing And Data Management

Academic backgrounds

If you were to go to school, went to study to be a data scientist, what courses would you take?
  1. Applied Mathematics
  2. Computer Science
  3. Econometrics
  4. Statistics
  5. Engineering

Industries that really benefit from that of science

  1. Financial Services
  2. Telecommunications
  3. Information Technology
  4. Manufacturing
  5. Utilities
  6. Healthcare
  7. Marketing

Tuesday, July 22, 2014

Rails: try, respond_to?

User.find(5).email
- will blow up if 'email' property is not present

User.find(5).try(:email)  
- will return 'nil' if 'email' property is not present


respond_to? is a Ruby method for detecting whether the class has a particular method on it.


@user.respond_to?('eat_food')

Sunday, July 13, 2014

C#: Suggestions to improve performance - Boxing & Collections

Below blogpost talks about how to use a Memory Profiler also - dotMemory.

http://blog.jetbrains.com/dotnet/2014/07/10/unusual-ways-of-boosting-up-app-performance-boxing-and-collections/
When you introduce some struct type, make sure that methods that work with this struct don’t convert it to a reference type anywhere in the code. For example, one common mistake is passing variables of value types to methods working with strings (e.g.,String.Format):Fixing boxing A simple fix is to call the ToString() method of the appropriate value type:Fixing boxing 2

Thursday, July 10, 2014

jquery: checkbox & radiobutton related

Is checkbox checked:
 if ($('#order_use_billing').is(':checked')){

}

Wiring up event-handler to Radiobuttons & checking which one was selected:
$('[name=use_existing_billing_address]:radio').change(function(){
  if ($('[name=use_existing_billing_address]:checked').val() == 'yes') {
   
  }
  else {
 
  }
}

System Administration Screencasts

Tuesday, July 8, 2014

git - cherry pick

http://nathanhoad.net/how-to-cherry-pick-changes-with-git
First, from within your feature branch, copy the first six or seven characters of the ID of the commit that you want to bring in:
Selecting a commit hash
Now jump into the branch that you want to insert the commit into (I'm using master):
git checkout master
And then cherry-pick your commit:
git cherry-pick c90fd66
Now if you do a git log you will see your cherry-picked commit at the top.

Saturday, July 5, 2014

Something that is worse than Failure - becoming Progressively Worse

What Could Possibly Be Worse Than Failure?
http://thedailywtf.com/Articles/What_Could_Possibly_Be_Worse_Than_Failure_0x3f_.aspx

Author writes about:
- is making it to Production = Success ?
- if we do not recognize/admit failure
  - a developer/team could become progressively worse



Saturday, June 21, 2014

jQuery - .load() vs .html() - w.r.t javascript

.html() - will strip out any javascript if present
.load() - will not
http://stackoverflow.com/questions/19614511/javascript-not-executing-after-ajax-partial-rendering-in-rails

Brevity vs Flexibility vs .....

Pimp My Code, Part 14: Be Inflexible! - http://blog.wilshipley.com/2007/05/pimp-my-code-part-14-be-inflexible.html

Excerpt:
 In coding, you have many dimensions in which you can rate code:

- Brevity of code
- Featurefulness
- Speed of execution
- Time spent coding
- Robustness
- Flexibility

Now, remember, these dimensions are all in opposition to one another. You can spend a three days writing a routine which is really beautiful AND fast, so you've gotten two of your dimensions up, but you've spent THREE DAYS, so the "time spent coding" dimension is WAY down.

So, when is this worth it? How do we make these decisions?

The answer turns out to be very sane, very simple, and also the one nobody, ever, listens to:

"START WITH BREVITY. Increase the other dimensions AS REQUIRED BY TESTING."
  
 

Friday, June 6, 2014

Against finely grained management

Below blogpost talks about the negatives of finely-grained project-management (that tools like Jira bring).


Excerpt:
.....
..... 
Why did it all go so wrong? 
Finely grained management of software developers is compelling to a business. Any organization craves control. We want to know what we are getting in return for those expensive developer salaries. We want to be able to accurately estimate the time taken to deliver a system in order to do an effective cost-benefit analysis and to give the business an accurate forecast of delivery. There’s also the hope that by building an accurate database of estimates verses actual effort, we can fine tune our estimation, and by analysis find efficiencies in the software development process. 
The problem with this approach is that it fundamentally misunderstands the nature of software development. That it is a creative and experimental process. Software development is a complex system of multiple poorly understood feedback loops and interactions. It is an organic process of trial and error, false starts, experiments and monumental cock-ups. Numerous studies have shown that effective creative work is best done by motivated autonomous experts. As developers we need to be free to try things out, see how they evolve, back away from bad decisions, maybe try several different things before we find one that works. We don’t have hard numbers for why we want to try this or that, or why we want to stop in the middle of this task and throw away everything we’ve done. We can’t really justify all our decisions, many them are hunches, many of them are wrong. 
If you ask me how long a feature is going to take, my honest answer is that I really have no idea. I may have a ball-park idea, but there’s a long-tail of lower-probability possibilities, that mean that I could easily be out by a factor of 10.
What about the feature itself? Is it really such a good idea? I’m not just the implementer of this software, I’m a stake holder too. 
What if there’s a better way to address this business requirement? What if we discover a better way half way through the estimated time? What if I suddenly stumble on a technology or a technique that could make a big difference to the business? What if it’s not on the road map?
.....
..... 
However, my opinion is that -  Jira or any tool for project management, serves to get at least the 'minimum' work output. And that is valuable, very valuable I think. 

However, if we want to target the 'maximum'  work ouput (including quality of solutions, code-quality, amount of code written),  too much dependence on Jira (or tools that do finely grained management) can become a hindrance as described in the above blogpost.

Followers

Blog Archive