Monday, December 28, 2015

Improve Performance of ORM code (like Entity Framework & Active Record)

Below article is about improving performance of queries we write using Entity-Framework, but the problems & solutions are similar to other ORMs like Active Record (of Rails).

https://www.simple-talk.com/dotnet/.net-tools/entity-framework-performance-and-what-you-can-do-about-it/

Wednesday, November 25, 2015

git: clear credentials cache

Clear git credentials cache:

cd .git-credential-cache/
rm -rf .git-credential-cache

Monday, November 16, 2015

Ruby: Metaprogramming

Metaprogramming is the act of writing code that operates on code rather than on data. This involves inspecting and modifying a program as it runs using constructs exposed by the language.

Thursday, September 24, 2015

Rails related - 'locals'

From http://stackoverflow.com/questions/5255874/rendering-partial-with-locals-in-haml

You would use the :locals option if you're calling render from a controller. When calling render from a view, you would simply do this:
= render 'meeting_info', :info => @info

Monday, September 14, 2015

HTML5 Form Validation related

Form Inputs Browser Support Issue

Form Inputs Browser Support Issue
http://www.smashingmagazine.com/2015/05/form-inputs-browser-support-issue/

It's hard to believe that this is the state of the web in 2015. I cannot but think that Google, Apple, Microsoft are deliberately trying to make web application difficult w.r.t mobile. 

Google owns Android & Chrome browser.
Apple owns iOS and Safari browser.
Microsoft owns Windows Phone (now Windows Mobile) & IE (and Edge).

Clearly they have a conflict of interest here. Each of them wants to push their own mobile-app infrastructure and have more mobile apps when compared to mobile web sites. Creating problems with Form Inputs is a simple way of discouraging web application development for mobile. 

Firefox is opensource and does not have the above constraint, but Chrome, IE, Safari seem to make the disadvantages subtle enough so that they are not really visible to the user (on mobile), but are a big deal for web developers.


Weekly reading list related to Web Development - smashingmagazine.com

If you don’t want all your images be loaded directly on page load, this simple technique by Christian Heilmann might be for you: By wrapping images with a
Video - http://christianheilmann.com/2015/09/08/quick-trick-using-template-to-delay-loading-of-images/

Found the above at - smashingmagazine.com ; They are publishing a weekly reading list of 'what's happening in our industry' here - http://www.smashingmagazine.com/tag/web-development-reading-list/

Friday, September 11, 2015

"If You Haven't Done It Before, All Bets Are Off", Side Projects Benefits

http://prog21.dadgum.com/209.html

Above is the reason why I cannot give an answer, most of the times, to the question - how much time will it take?

Excerpt:
Except when it comes to figuring out how much work it's going to take. In that case, without having done it before, all bets are off.
This gives us another reason for doing those side-projects that never seem to take off. If we work on a side-project, then, when we encounter a similar problem at our day-job, we will be better positioned to give an estimate about the work. And for sure, we would be on that team that is going to do the project. So, this is how, you slide into the projects you want to work on. Hmm.. hopefully, I will act on this realization unlike all the previous instances of enlightenment..

F# related

http://tomasp.net/blog/2015/typed-revisited/

FunScript website -  http://funscript.info/samples/worldbank/
FunScript is a lightweight F# library that lets you rapidly develop single-page applications.
F# Data Library - http://fsharp.github.io/FSharp.Data/

F# and Data Science - http://www.tryfsharp.org/Learn/data-science

Monday, September 7, 2015

Friday, September 4, 2015

Improving performance in Ruby/Rails code

http://blog.skylight.io/fixing-the-mysterious-slow-request/?utm_content=buffer21003&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer

Talks mostly about object allocations and how we can improve (reduce) them;
Read through quickly once;
Has some links within it which seem interesting (but i haven't read yet);
Has good simple examples

Stamplay & Build a Food Ordering app like JustEat

Stamplay - https://stamplay.com/ - The modular backend platform for web developers

Example:
https://blog.stamplay.com/create-a-food-ordering-app-like-justeat-with-angularjs/?utm_medium=social&utm_source=twitter&utm_campaign=tutorials&utm_content=justeat

Pricing:
Core Plan - Free
100K API calls / 100GB hosting transfer / 1GB hosting storage /stamplayapp.com subdomain

Sunday, August 9, 2015

jQuery code to get the selected radio button (and its value)

jQuery code to get the selected radio button and its value

.val() - it looks like we should not use this for radiobuttons.

$('input:radio[name=rblist]').val() - this was giving the value of the radiobutton that was selected (checked) when the page loaded.
If I changed the selection, and then checked .val(), it was showing the previous value still. 

To get the selected radiobutton, I had to iterate over the list of radio buttons and check each one if it is checked or not.

$('input:radio[name=rblist"]').each(function(){ 
  if ($(this).is(':checked')) { 
    rb_value = $(this).val(); 
    console.log("Selected rb value = " + rb_value); 
  } 
});

Friday, July 17, 2015

Tool to help fill forms

This tool can be helpful in filling forms.

How to use:
Drag & Drop the following bookmarklets to your Bookmarks bar in Chrome.

What these bookmarks do:

1) Form Values - Store    ← this is a link - Drag & Drop it to your Bookmarks bar
When you are on the page which has a form:
- Fill out the form
- before clicking Submit, click on 'Form Values - Store' bookmark
   -- this will save your form values to your browser's localStorage (so that you can use them later on).

2) Form Values - Load   ← this is a link - Drag & Drop it to your Bookmarks bar
When you are on a page that has a form, if you have previously saved form-values for it:
- Simply click this bookmark to fill up the form

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

Additional Notes:
1) With this tool, form data saved in Dev/Test urls can be used to fill up forms in Staging/Prod urls.
So, if you save form values in:                      http://dev-url/user/new
You can load those values for the form in:    http://staging-url/user/new

This could be helpful for QA engineers.

(This is because, the form values will be stored using - "/user/new" part of the URL. Even, query string part of the URL is ignored.)

2) Use for Developers:
For development work that involves forms, we usually need to repeatedly fill up the same form.
This tool can help save time in such scenarios.
Use for Testers/QA:
Same - a QA person can probably fill up the form using previous test-case's data and modify a couple of fields for the new test case.

3) Technique used:
Form values ares stored as a string in the browser's localStorage using the page's url as the key.

4) Because values are stored in browser's localStorage, if browser cache/history is cleared, the stored values will be deleted.



Sublime Text shortcut - Swtich between tabs

Switch back and forth between tabs in Sublime Text:

Ctrl + Tab
http://www.sublimetext.com/forum/viewtopic.php?f=3&t=845

Saturday, July 11, 2015

Windows 10 Thoughts - 1: Why adoption of Windows 10 will be different than that of Windows 8 & 8.1

(Over the last few years, there has been a lot of discussion about the design of Windows 8 & then 8.1, and how Microsoft got it wrong. Below are some simpler and different reasons why I think Windows 8 & 8.1 failed and why Windows 10 will be a success)

Since 2 weeks, I have been using a touchscreen laptop that has 16GB RAM. This is my first touchscreen laptop, and my experience with it, in this short period, has solved the biggest mysteries in recent times, at least for me - why did Microsoft get it so wrong with Windows 8 & 8.1 ?

Touch-Screen:

I hardly expected to find the touchscreen to be actually useful, but that is exactly what happened. With a combination of touchscreen and keyboard shortcuts, I now seem to be doing everything faster than before. Incredibly, I find web-browsing much more enjoyable with a touch-screen. Even websites that have not been designed for touch, I find that it not so difficult to use them.

I am amazed at how wrong I was about the usefulness of a touchscreen on a laptop. I have been using an iPad Mini for several months now, so I am not new to touchscreens. Even then, my prediction was way off.

Windows 8 & 8.1:

And I think most laptop users are like me, or how I used to be. Regarding Windows 8, most of them did not and still do not see the value of a laptop with a touchscreen. Since most people already own a perfectly-usable-laptop, I think they do not feel the need to go and buy a new laptop. I feel this is the main reason why adoption of Windows 8 & 8.1 was so less.

To state the reason in another way - the users did not feel the need to go for the hardware improvement - touchscreen, and this massively contributed to the failure in adoption of the software - Windows 8 & 8.1. This is important to note because, the failure occurred, for the most part, due to no fault of the software.

The above reason centers around new laptops with Windows 8 on them. But what about existing laptops/PCs? The most common criticism of Windows 8 is that - if Windows 8 was really good or even any good, users would have upgraded their existing laptops from Windows 7 to Windows 8.

However I feel that such an upgrade did not happen for a far simpler reason - most people had not done this before; i.e. the not so trivial step of wiping out their machine and installing a new operating system. The secondary issue was that, the upgrade was not free. The upgrade fee was very less only for a little while, if I remember correctly. Even if the upgrade was made free at that time, it is asking a lot for any user to wipe out their perfectly familiar OS and install something new. Most users would keep on postponing that kind of a thing indefinitely.

Windows 10:

Now, the next obvious question is - given that very little has changed w.r.t user behavior towards laptops with touchscreens, will Windows 10 achieve greater adoption amongst users?

Surprisingly, my answer to that is a big Yes.

It is a Yes not because Windows 10 reviews have been overwhelmingly positive.
And it is a Yes not because Windows 10 is going to be a free upgrade from Windows 7/8/8.1.
It is a Yes because, this time touchscreens are not the only 'hardware improvement' that users will be getting if they get new laptops. There is another hardware improvement - that of RAM size, this time around. Unlike the past 6-8 years, when RAM sizes in affordable laptops have stagnated at 4GB, it is very likely that, someone buying a new laptop will get 8GB or even 16GB RAM size, because 8GB/16GB RAM have started showing up in affordable laptops.

Why users have traditionally purchased new laptops/PCs - prior to 2007-2008?

In my opinion, size of RAM & CPU speed were the only 2 things that have ever truly driven users to buy new PCs/laptops in the last 20 years. This used to happen every 2-3 years previously.

All of us try to be intelligent & informed buyers. And in my opinion, previously, we had gotten trained to looking at RAM sizes & CPU speeds as the 2 main hardware specs when we looked to evaluate a laptop/PC.

That, the timeframe coincided with Microsoft releasing a brand new OS, made the upgrade to a new machine, all the more sweet, usually.

Post 2007-2008 to 2015:

Prior to 2007-2008, if I got a new laptop/PC, it usually had a new OS, had double the RAM size, and more CPU speed when compared to my old laptop/PC. I had already heard about Moore's Law by then, and it seemed that Moore's Law was in effect till then.

But Windows Vista and Windows 7 were the last of the OS upgrades for which, we 'felt', we got significant CPU and RAM upgrades.

By the time Windows 8 was released, my 2009 home laptop was ~2GHz and had 2GB RAM. As years passed by to 2015, the only difference that stood out, between my 2009 laptop and best-affordable-laptop-of-the-time seemed to be that of 2GB RAM vs 4GB RAM. The processor speeds had stagnated, with cores starting to increase in number - dual core, quad core etc. For some reason, the cores did not make a real impression, when comparing my old laptop with the current ones. I suspect, this is the case for other laptop users as well.

Performance wise, even now, in 2015, my 2009 laptop is able to run Windows 8.1 smoothly, and so performance is not a factor.

In effect, laptops with 4GB RAM have been the 'best configuration' possible for almost 7-8 years.

It is no surprise that this is exactly when laptop/PC sales have started to slow down/drop off etc.

Smartphones & Tables eroding demand for laptops/PCs:
I don't have much info or opinion on this aspect. However I feel that the smartphone market is a completely different market. Most users will definitely own a smartphone and then either own a laptop or a tablet, more likely a laptop than a tablet. Previously a laptop could not be thought of as a real replacement for a tablet. With a touchscreen, the laptop certainly becomes a real replacement for a tablet.

Conclusion:
So, in my opinion, improvements in traditional hardware specs like RAM will be the real drivers of laptop sales, and thus Windows 10 adoption as well. (Perhaps this observation will apply to the smartphone market as well.) Non-traditional hardware improvements like touchscreen are yet to catch on in the Windows world.

In the coming few months, following are the specs users will be seeing for new laptops: 8GB/16GB RAM, touchscreen, Windows 10. Now that is a solid case for buying a new laptop.

Summary & Next Question:

1) With a touchscreen, my laptop does not feel antiquated anymore when compared to my 5 inch Lumia 535 phone.

2) At the time of Windows 8, the hardware improvement was not in the traditional areas of RAM & CPU speeds (at which all the buyers were looking at), but it was in the area of touchscreens - and users did not really feel the need for touchscreens on laptops at that point (and even now, I am sure that a lot of users do not view it as a necessity, and hence the demand is not as much as it should be).

3) After several years, > 4GB RAM sizes are showing up in affordable laptops. I suspect that this very reason will make everyone go and get new laptops. Since these new laptops will have the latest OS - Windows 10, this will contribute to the success of Windows 10.

4) A secondary contributor to Windows 10 adoption will obviously be the free upgrade option that Microsoft is giving for Windows 7/8/8.1 users.

5) When a user buys the latest (affordable) laptop, there is a good chance that that laptop will have a touchscreen. Once users start using the touchscreen, they will get hooked, and from then onwards, they can see the value in an operating system like Windows 10.

That leads us to the next question - how will user behavior/requirements change once they get used to Windows 10? Will Apps catch on? Or will web applications continue to dominate?

Wednesday, June 24, 2015

Rails - list of things to learn apart from Ruby

Rails - how to preload scopes

http://www.justinweiss.com/blog/2015/06/23/how-to-preload-rails-scopes

It seems Scopes can result in N+1 queries if not used properly since they cannot be preloaded...And author shows a way of how to use them correctly (i.e. without resulting in N+1 queries).

To learn about eager loading - http://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations

More on the topic:

Preload, Eagerload, Includes and Joins - 

http://blog.bigbinary.com/2013/07/01/preload-vs-eager-load-vs-joins-vs-includes.html

Saturday, June 20, 2015

.Net related - Collapse of .Net EcoSystem

https://onedrive.live.com/view.aspx?resid=1E5AA35A965D3234!26479&ithint=file%2cdocx&app=Word&authkey=!AHbAQ1i_GgwNxJY

I definitely agree with the below point. It has been the most frustrating part for me as a .Net developer.
Excerpt:
2) It’s hard to make long term investments when Microsoft’s ever revolving door of new technologies continuously makes previous codebases obsolete. That climate makes both businesses and developers afraid to invest resources in potentially defunct technologies. Remember when WinForms was replaced by WPF? Only to be replaced by Silverlight? Then by Windows Phone apps? Which were replaced by Universal apps? Or what about how Web Services were replaced by WCF only to be replaced by Web API?
And here is the reddit thread (where most people disagree with the article):
http://www.reddit.com/r/programming/comments/385kq2/the_collapse_of_the_net_ecosystem_i_wrote_this/ 

Rails Resources

Monday, June 1, 2015

Article: The Argument for Teaching Computer Science Without Computers

http://motherboard.vice.com/read/the-argument-for-teaching-computer-science-without-computers?trk_source=homepage-lede
http://csunplugged.org/

Excerpt:
Teaching computer science as a way of arranging reality rather than a way of arranging syntax or data structures—what's more appropriately known as programming or even coding—is among the arguments made by Thomas J. Cortina, a computer science professor at Carnegie Mellon, in a recent issue of ACM Communications. His general point, which is only sketched here, is that we should be aggressively advancing programs like CS Unplugged, which is a kid-focused curriculum of sorts developed by a group at the University of Caterbury in New Zealand, with a stated goal being the teaching of computational principles rather than programming and technical details. It's a great idea.
By being physically part of the solution to a problem as it is being solved, kids learn from observations and experiences.
Activity examples range from teaching data compression via rhymes, graph theory via mud, finite state automata via pirates, and so on. It's surprisingly deep given the target audience (though maybe algebra and trig would seem that way too if we weren't so used to it).

Sunday, April 12, 2015

Windows 10 development related

Windows 10 development related:

http://blogs.windows.com/buildingapps/2015/01/22/windows-10-is-empowering-developers-to-dream-again-3/

Excerpt:

What’s next?

We’re more committed than ever to making sure that you can leverage your work to reach more customers, regardless of where they are, what device type they’re on, or what operating system they’re running. The best way to start preparing for Windows 10 is to start building universal Windows apps today for Windows 8.1.
Here are some great resources to get started:

Official Documentation

Comprehensive Online Training

  • If you are currently a Windows Phone Silverlight developer, there’s never been a better time to investigate moving your development over to Windows XAML, which provides the ability to deliver universal Windows apps. We recently released a comprehensive set of materials detailing how. Check them out here.

Sunday, March 15, 2015

Difference between 'input' & 'button' tags

http://api.jquery.com/submit-selector/
Note that some browsers treat <button> element as type="submit" implicitly while others (such as Internet Explorer) do not. To ensure that markup works consistently across all browsers and guarantee that it is possible to consistently select buttons that will submit a form, always specify a typeproperty.
http://www.w3schools.com/tags/tag_button.asp
If you use the <button> element in an HTML form, different browsers may submit different values. Use <input> to create buttons in an HTML form.

Followers

Blog Archive