IBlog

August 15, 2012

Filed under: electronics — Tags: , , , — Himanshu @ 12:22 pm

I got stuck in one puzzle of electronics. Was understanding resistance of electron flow, current, and voltage by little different experiments. In one of them, I had created a very basic circuit that was starting from +v end of 1.5v battery (showing 1.4v on multimeter without resistance), 470k resister and multimeter into the circuit ending at –v end of the battery. On multimeter, I noticed 0.95v.  470k resister was the cause for the drop of voltage and it was dropping voltage by 0.45v (1.4v – 0.95v = 0.45v).

I thought of using one more 470k resister expecting it to drop further 0.45v and confirm that voltage drops  to 0.5v after second 470k resister. My reasoning was: 1.4v – 0.45v – 0.45v = 0.5v. But to my surprise I was seeing 0.71v on multimeter! Multimeter wasn’t in agreement of my mathematics, but I wasn’t fully convinced with multimeter’s mathematics. All I was thinking is “Why” second resister was not dropping the voltage as equally as the first.

After further thinking and learning on V=IR, I notice very simple and basic property in numerical series in which next number is created by adding 1 to the predecessor viz. 1, 2, 3, 4, …n. And that simple and basic property is: 2 is double of 1 but 3 isn’t double of 2. Further, weight of 3 is 50% more than 2, but weight of 4 is not 50% more than 3.

Of course it’s obvious but it wasn’t so obvious to me before this experiment!

June 27, 2012

Installing ASP.NET MVC 3 and Web Platform Installer

Filed under: asp.net — Tags: , , , — Himanshu @ 12:01 am

I had a problem in using the Visual Studio Install that I had in my machine, due to which I decided to re-install everything related to Visual Studio , including Visual Studio itself.  During installation procedure, I reached to the point when I was ready with base Visual Studio 2010 installed, and next step was to update system with bunch of other frameworks and patches that included ASP.NET MVC 3, Visual Studio 2010 SP1, and some other. It was making sense to me to install all together with Web Platform installer. Added everything that I wanted to install in Web Platform installer and asked it to install. It happily declared everything done. But when I tried opening the project solution, Visual Studio complaint about missing ASP.NET MVC 3.

On further investigation about why and what, surprise! ASP.NET MVC 3 actually was missing on the system! Web Platform installer was fooling me when it said “Completed everything”. Finally I found that due to Latest NuGet install on my machine, installer for MVC 3, was not able to successfully install.

Leaky Abstraction!

June 12, 2012

Transistors are also De-amplifier

Filed under: electronics — Tags: , , , — Himanshu @ 1:08 pm

I’m enjoying my exploration of electronics. While understanding about different building blocks, I learnt about Transistor. And I also learnt that transistors are also called amplifiers. During learning about their amplification capability, I also realized that they are certainly amplifier but they don’t generate electricity from air (unfortunately!). They need two input voltage one at Base and another at Collector. When Base is positively charged – low voltage applied to it, they allow higher voltage applied at Collector to pass towards Emitter, and that’s how they are called amplifier.

Me being fresher in electronics, I recommend other fresher to also note that if you see through transistors from Base to Emitter they are certainly amplifiers, but if you see through Collector to Emitter, they are de-amplifiers as they don’t generate electricity from air.

June 7, 2012

SessionStorage on Safari

Filed under: html5 — Tags: , , , , — Himanshu @ 10:23 am

Like everything in life has quota, Safari allots specific size to each applications that it can consume to store information in session storage. If consumption exceeds, while calling setItem it throws QUOTA error.  While creating one HTML5 based application for one of the client. I found that Safari that comes on iPad 1 built on top of AppleWebKit 531.21.10 has two reason to throw this error. First like I said on exceeding the limit and another on when an key already exists. To workaround the second case, have to write our own function that first removes item using removeItem and then SetItem

July 20, 2011

Word documents and merging two branches

Filed under: ms office — Tags: , — Himanshu @ 11:46 pm

Do you create word documents? Do you send them for review to your boss? I think, answers of both of these questions will be “yes” for most people, and I’m not exception! MS Word have a good feature – Track Changes. As it’s name suggests, it  tracks the changes while document is being edited, and can show final (edited version) of the document or can show final document with highlighting changes . While changes are highlighted, they are easy to notice and can also navigation across changes easily.

But, if your boss forgot to start the change tracking, then? Well, not to worry, word can do merging of two different branches like a version control. Steps:

1. Very important! Make sure you are having extra copy (backup) of both the documents (your copy and boss’s copy). Just in case we create mess in the process, you don’t loose your valuable information in these documents.
2. After making sure both documents (e.g. “My Copy” and “Boss’s Copy”) are closed, open “Boss’s Copy” document in MS Word.
3. Invoke “Save as“ operation and try and save it over “My Copy” of the document. (Notice already open document name and Save as name in the image)
4. Word should prompt you for different available option, having one of them to be “Merge changes into existing files” (for example, as  depicted in image), select it and continue with “Save as” operation.

In the result of above, “My Copy” document will be updated as if Boss have changed the document while having “Change Track” on.

July 5, 2011

WaitHandles’ Switch

Filed under: .net,multi-threading — Himanshu @ 3:57 pm

I will say it again: “I like extension methods”. They provide great way of increase readability of the code in languages like C#.

Anyway this post is not about extension method. Have you ever needed to write code that will wait on different wait handles (WaitHandle) and execute different piece of code depending up on which handle is signaled. Here is one way to implement that:

```public static void WaitSwitch(this WaitHandle[] waitHandles, params Action[] actions)

{

waitHandles.DoEmptyOrNullArgCheck("waitHandles");

actions.DoEmptyOrNullArgCheck("waitHandles");

if (waitHandles.Length != actions.Length)

throw new ArgumentException("length of wait handles and actions has to be same");

var triggerIndex = WaitHandle.WaitAny(waitHandles);

actions[triggerIndex]();

}
And then client code will become as:
(new[] { shutdownTriggeredEvent, updateAvailableEvent }).WaitSwitch(

() => isShutdownRequested = true,

);
```

July 1, 2011

HTTP 404 while asp.net web forms and spring.net project

Filed under: asp.net,spring.net — Himanshu @ 3:32 pm

While doing some refactoring with the project, I suddenly start getting HTTP 404, and that to for all pages that exists and was working few minutes back. I was amused to get the error, with the fact that pages existed, I could see them and feel them! After a while, I noticed that I have deleted a existing .aspx file from project which I forgot to remove from spring.net configuration file.

If you add any .aspx in Spring.Net config that do not exists, Spring.NET brings you to yellow screen with appropriate message. But not when you delete one from project and forget to remove from config file! At least not all the time.

June 22, 2011

Scoping the search result in Firefox

Filed under: internet — Himanshu @ 3:31 pm

Do you know, in Firefox 5 it’s possible to scope the search results. For example if you suffix or prefix search text with *, results will be only from bookmarks! That’s helpful, isn’t it. And there are more such special characters that can be used to scope the search result.  More over that, combination of multiple such character is possible as well, that’s more helpful! See details here.

June 2, 2011

JavaScript, and var

Filed under: javascript — Tags: , — Himanshu @ 2:16 pm

While working in my current project, I re-learned this hard way.  And I don’t want to make same mistake again, hence noting it here. Many a times you remember something better when noted somewhere.

I had created a javascript that was similar as below:

` 1: function Type1(){`
` 2:     _type = "type1";`
` 3:     this.show = function() { alert(_type); }`
` 4: }`
` 5: function Type2(){`
` 6:     _type = "type2";`
` 7:     this.show = function() { alert(_type); }`
` 8: }`
` 9: o1 = new Type1();`
` 10: o2 = new Type2();`
` 11: o1.show();`
` 12: o2.show();`

And me being ignorant about what I have written, was expecting to see two alerts once with “type1” and another with “type2”.

Case that I had was more complex , hence I took more time to understand the problem, and then note that I haven’t have “var”! The code should be as:

` 1: function Type1(){`
` 2:     var _type = "type1";`
` 3:     this.show = function() { alert(_type); }`
` 4: }`
` 5: function Type2(){`
` 6:     var _type = "type2";`
` 7:     this.show = function() { alert(_type); }`
` 8: }`
` 9: o1 = new Type1();`
` 10: o2 = new Type2();`
` 11: o1.show();`
` 12: o2.show();`

Note and Remember, “var” defines the scope of variable as local!

Separate domain and Runas

Filed under: networking,windows plateform — Himanshu @ 1:45 pm

Have you ever wonder how can you run a specific application having awareness of different domain’s credentials? We have VPN setup between our different offices, and all offices are having complete separate windows domain tree. I’m in Pune office, that is having domain, which has not direct relation to our US office (e.g. it’s not welcomed in networking terms) – and believe me there is a good reason to be it that way.

While being in Pune, I needed to run an application on my machine (that is in Pune domain), with is aware that I also have valid credentials in our US office. And Runas worked well in that case as well. Runas.exe can be found in %WINDIR%\System32, checkout its short help by: %windir%\system32\runas.exe /? on command prompt.

I had used it as %WINDIR%\System32\runas.exe /netonly /user:<my US domain name>\<my username in US domain name> “<path to the application that should run within that credentials>”

Older Posts »