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.

Friday, May 23, 2014

John Resig: Write Code Everyday

(John Resig is the creator of jquery)

http://ejohn.org/blog/write-code-every-day/

- Very good blogpost about a strategy to consistently get work done for side-projects
- Suggestion is to - spend a minimum of 30 minutes doing coding everyday
- Maintaining a 'streak' removes the problems that occur when picking-up-where-we-left-off
(This is we what we usually call 'flow' also)

.Net Fiddle

Wednesday, May 14, 2014

Interactive Resources by Language

Interactive Resources by Language - for Java, Ruby, Python, Javascript
Beginner to Advanced 

Friday, May 9, 2014

TDD related - Disadvantages of Test Driven Development

Bold, underline, text-color added by me (to make it easier to ready for myself).
Text content unchanged

http://stackoverflow.com/questions/64333/disadvantages-of-test-driven-development

If you want to do "real" TDD (read: test first with the red, green, refactor steps) then you also have to start using mocks/stubs, when you want to test integration points.
When you start using mocks, after a while, you will want to start using Dependency Injection (DI) and a Inversion of Control (IoC) container. To do that you need to use interfaces for everything (which have a lot of pitfalls themselves).
At the end of the day, you have to write a lot more code, than if you just do it the "plain old way". Instead of just a customer class, you also need to write an interface, a mock class, some IoC configuration and a few tests.
And remember that the test code should also be maintained and cared for. Tests should be as readable as everything else and it takes time to write good code.
Many developers don't quite understand how to do all these "the right way". But because everybody tells them that TDD is the only true way to develop software, they just try the best they can.
It is much harder than one might think. Often projects done with TDD end up with a lot of code that nobody really understands. The unit tests often test the wrong thing, the wrong way. And nobody agrees how a good test should look like, not even the so called gurus.
All those tests make it a lot harder to "change" (opposite to refactoring) the behavior of your system and simple changes just becomes too hard and time consuming.
If you read the TDD literature, there are always some very good examples, but often in real life applications, you must have a user interface and a database. This is where TDD gets really hard, and most sources don't offer good answers. And if they do, it always involves more abstractions: mock objects, programming to an interface, MVC/MVP patterns etc., which again require a lot of knowledge, and... you have to write even more code.
So be careful... if you don't have an enthusiastic team and at least one experienced developer who knows how to write good tests and also knows a few things about good architecture, you really have to think twice before going down the TDD road.
share|edit|flag
5
Using tools like Pex & Moles you can quite easily avoid writing interfaces for every small damn thing. Moles will help you with that tremendously. –  Robert Koritnik Oct 13 '10 at 9:53
6
Seems like a critism of unit testing and object oriented programming, not TDD. –  plmaheu Feb 5 '13 at 16:13

Wednesday, May 7, 2014

Software Engineer or Software Writer? Is TDD dead?

DHH , creator of Rails, recently wrote a blogpost saying that he is giving up on TDD. 
Big war started i think in twitter, and other sites. 

Then he gave this talk, a few days back in RailsConf (which seems to be an important Rails related conference) - 

Tip: Watch it at double-speed using the Settings in YouTube..since it is a 1hr talk.

There are several interesting points in this talk. Below are the ones that immediately come to my mind, but I will have to watch again, and improve this post:

1. Software Writers - 

Difference between 'computer science' and what typical programmers like me are working on..I think everyone has that in their mind, but he gave a new term to us - 'software writers', instead of 'software engineers', and that we should focus on clarity, readability just like writers of stories, articles do.. 

He used an analogy of piano creators vs piano players:
Computer Scientists/Software Engineers ~= people who make pianos
Software Writers ~= people who play the piano

When put like that, it really shows how different those two are.

2. Patterns are not really helpful
We become better at creating applications by writing applications, reading others' code, and in the process by developing 'an eye' for it. There is no short cut, like learning patterns etc.

3. TDD is not useful in most cases 

TDD is useful when we know exactly know what is needed - this goes in, and this has to come out. 
In cases, where we are figuring out what the app needs to do, it is not that useful, and is in fact harmful to the code (if you stop believing the idea that functions becoming testable is the ultimate goal).

4. Drafts

The first time we write a class or some unit of code that works, should be considered as a Draft (analogous to drafts of emails/articles/stories etc).
Then we should improve upon that Draft.

-----------------------------------------------------------------------------------------------------------------------------------------------------

Response from Kent Beck (it seems he invented TDD) -

Below is a comment that seems to suggest where TDD can be useful and where it is not -

Vasileios Mitrousis TDD is a perfect fit for corporate software, when all the requirements have been written down the last two years of discussion. But when working in a dynamic environment where the specs are changing every day it starts to be an overhead. On the other side, when a system is in production, TDD applied on any patches made can make you sleep well at night. I don't believe TDD it's a history, but cannot be applied to everywhere.


https://www.destroyallsoftware.com/screencasts - Unix, Vim etc related screencasts

7 simple steps to implementing a programming language

Google's web fundamentals handbook for multi-device web development

A Crash Course in Modern Hardware


10 Secrets to Becoming a Great Remote Developer

Very good tips for remote-developers like me:
http://x-team.com/2014/05/10-secrets-to-becoming-a-great-remote-developer/

Excerpts from above article:
Contribute trust every day
It all begins with trust. If you only read one thing here, I hope it’s this.

The very definition of a team is a group of individuals who are bound by trust.
Physical teams suffer from physical barriers (such as a floor for each department) which consequently create tribes and ultimately compartmentalize trust.
physical teams are still able to operate even with weakened trust.
Remote teams, however, live and die by their trust. 
Secret 1: Communicate more than you did with your first girlfriend 
And it’s not just about saying “Hello” every day. It’s about:

When you step away from your desk, you let your team know.
When you realize you’re not going to hit a deadline, you let your team know.
When you have some free time, you let your team know you’re there to help.
When you learn about some awesome new framework, you let your team know.
When you see your team falling behind or bad code getting committed, you let your team know.
You will never collaborate with developers more than on a remote dev team. You are forced to collaborate (it’s collaborate or die, really)
Secret 2: Find time for Focus
It’s really important that you cut out 3-hour blocks of time each day to do nothing but focus on the must-finish tasks of the day. It’s easier said than done, but you’ll love the feeling once you get into a rhythm of doing it consistently.
Secret 3: Find your hedgehog 
And so the idea is to do one thing, do it really well, and you will succeed in life, in your career, and in avoiding getting eaten by a fox.
So find your hedgehog in the development world. If it’s Drupal theming, do that. If it’s node.js, do that. If it’s infrastructure, do that. It doesn’t matter what it is, the point is to focus.

Why? Because companies today only need remote developers when they realize they can’t find specialized developers in their geographic location for niche development technologies.
If, on the other hand, you try to be a jack of all trades, someone who knows front-end, back-end, infrastructure, JS, PHP, .NET, everything…you’re less valuable. It’s much easier to find a jack of all trades within your geographic location. Companies that go remote have specific challenges that require a specific skillset that only hedgehogs have.
The best remote teams are filled with hedgehogs.
Secret 7: Have the right attitude
At X-Team, we have a culture of #sleepcanwait, which means our team doesn’t sleep until they’ve said: “Hey team, how can I help?”
It also makes you feel really good to say that line every day. It feels incredibly good helping out your team every day
Remote teams hire almost entirely based on attitude, because contributing trust every day all starts with having the right selfless attitude.
Secret 9: Your word is everything
When you say you’re going to get something done, you need to follow through with that, and if you can’t, then you need to let the whole team know so they can adjust their own timelines.
Remember: The second you aren’t contributing trust to the team, you won’t be on the team very long. 
Secret 10: Be proactive
If you want to know the #1 secret to contributing trust every day, here it is.
The definition of being proactive is quite simple: it means you make things happen before they become problems.
Proactive means bringing in new ideas around workflow to the team. Proactive means always keeping progress moving forward. Proactive means that you are truly ready to be on a remote team because you don’t need someone to babysit you.
Instead, you are proactive; you get up, you get to work, you know what needs to be done, you check in with your teammates often, and you keep things moving.
If you let laziness seep into your work ethic because you have so much flexibility, you will fail.

Sunday, May 4, 2014

Nice Quote


"the solution that solves all your problems is not going to be the best solution for all your problems."

Friday, May 2, 2014

iOS tutorial

A colleague pointed me towards this site:
http://www.tutorialspoint.com/ios/ios_quick_guide.htm

Has Ruby tutorial also

Thursday, May 1, 2014

A Journey of a software project & developer

Nice blogpost on medium.com -  https://medium.com/p/19784e23163b

Several interesting points like the below:
Excerpt:
"I decided to quit my part time job and work full time on the app with the hope to focus my time on it and get it out sooner. I would later realise this was a bad move and it had the opposite effect. Having the two jobs allowed me to set apart my time and therefore I could set apart my focus on them, giving me much better bursts of productivity. It forced boundaries upon me in terms of how much time I could put into the app each week. Instead, the time I had just ended up becoming one large giant blur and I got bored easily."

Monday, April 28, 2014

Abstractions & Duplication

This is a tweet from someone

Don't abstract too early. Duplication is far easier to deal with than the wrong abstraction. (OO version of YAGNI)

Thursday, April 24, 2014

Against the use of Frameworks (Javascript frameworks, ORMs etc)

Very good blogpost about  'No Frameworks' strategy. (Have to read the Comments section & follow-up bloposts as well)
http://codeofrob.com/entries/look-ma,-no-frameworks.html
Abstractions should be used because there is a pain that needs solving, whether that be because you're talking to third party code, or slow remote calls that need hiding during testing or because there is complexity that needs hiding. Putting abstractions in before we feel any of this pain just means more code to wade through when trying to get stuff done - no thanks.
This goes against current-popular-thinking as of today.

The strategy for No Frameworks would be -
We start off a project without a framework.
After a certain point, if the requirements start giving us 'pain', then we pull in a framework, whichever one is appropriate.
We'll have to refactor our existing code to use the framework.

A very important pre-requisite for the above strategy to work -
We need to know at least one or two frameworks, and know them pretty well, in order to know how they will benefit us. Otherwise, we will not know, at which point in the project, a framework could start being helpful.

Wednesday, April 16, 2014

Tools - Free tools for software teams

Except Digital Ocean, all of the below are Free, but some are freemium

Trello.com - for listing features/bugs

iDoneThis.com - for daily updates

HipChat  - Group Chat, IM - for staying in touch throughout the day
(free for teams upto 5 - https://www.hipchat.com/pricing)

Jing - quick video captures to report issues
(5min captures are free)

git & Github.com -  Source Code Management

Skype, Google Hangouts - Audio/Video calls

Skype, Teamviewer, Google Hangouts - for ScreenSharing

Teamviewer, Google Hangouts - for giving presentations to large group of people, Group Meetings

Teamviewer + Skype - Pair programming, Mob programming
(Teamviewer - in Meeting mode, we can give control to meeting-participants. This works in the free version also, so TeamViewer can be used for 'mob programming')

Digital Ocean - hosting, creating remote dev machines

Yammer.com - Enterprise Social Network

Balsamiq - Wireframing tool

Rails: start server using a port other than 3000

rails s -p 10524
This is useful when trying to run multiple rails applications during development.

Sunday, April 13, 2014

Azure - VM experiment (Ubuntu 12.04)

1. default username - azureuser  (password - what we specify while creating the VM)
2. Install Teamviewer
http://techs2resolve.blogspot.in/2013/12/how-to-install-teamviewer-9-in-ubuntu.html
3. See http://www.tonisoto.com/?p=215  for "Launching Teamviewer remotely through SSH"
teamviewer --info     -> should give the ID
and set the password using : teamviewer --passwd [PASSWD]
If not, see http://serverfault.com/questions/547206/how-to-find-my-teamviewer-id-on-ssh
To see all commands : teamviewer --help

Stuck - Not able to connect via Teamviewer

4. Alternate option to Teamviewer
http://blogs.technet.com/b/uktechnet/archive/2013/11/12/running-a-remote-desktop-on-a-windows-azure-linux-vm.aspx

Status - Able to connect via RDP, but nothing is visible on the screen


Saturday, April 12, 2014

Digital Ocean - VM experiment

Useful instructions here - http://10kb.nl/blog/setup-and-keep-up-with-the-latest-versions-of-a-complete-rails-dev-stack

0. Create droplet
0. tasksel  (and select Lubuntu )
1. Install Teamviewer
2. Add user 'sai' using 'adduser' command (because we cannot run browser as 'root')
add user sai
3. Give sudo privileges to 'sai'
 sudo usermod -a -G sudo sai
4. install Mysql (and mysql workbench)
5. install git
sudo apt-get install git-core
(https://www.digitalocean.com/community/articles/how-to-install-git-on-ubuntu-12-04)
6. install sublime text 2
https://www.digitalocean.com/community/articles/how-to-install-git-on-ubuntu-12-04

Status - Able to connect via Teamviewer; Have to install Ruby, RVM etc
Problems - LXTerminal is not working properly

To reboot - sudo reboot
To poweroff - sudo poweroff

Followers

Blog Archive