Thursday, April 21, 2016

Unit Testing a loading of correct View in MVC




[TestMethod]
public void AboutReturnsAboutView()
{
     HomeController controller = new HomeController();
     ViewResult result = controller.About() as ViewResult;

     Assert.AreEqual("About", result.ViewName);
}
Note that this will fail if you don't return an explicit view in your controller method, i.e. do this:


     Return(View("About"));
not this:


     Return(View());
Or the test won't pass. You should only need to do this if your method will ever return more than one view, otherwise you should return an implicit view anyway and not bother testing the framework.


Refer: Professional ASP.NET MVC 1.0 (book):

Metro tiles

.metro-tile {
background-color: #D8512B;
border-color: #DC6241;
width: 232px;
height: 104px;
padding: 5px;
color: #FFF;
font-family: sans-serif;
font-size: 12px;
border-width: 3px;
border-style: solid;
cursor: default;
-webkit-transition: 0.1s all;
-moz-transition: 0.1s all;
-ms-transition: 0.1s all;
transition: 0.5s all;
}

.metro-tile-small {
width: 104px;
height: 104px;background-color: #2878EC;
border-color: #2878EC;
}

div.metro-tile:hover {

transform: scale(1.3) perspective(400px) rotateY(0deg) rotateX(0deg);
border-width: 3px;
border-style:solid;
}

http://cssdeck.com/labs/windows-8-metro-tiles-with-css3

//#2878EC; blue

//#6CB71E; green

//#009719; dark green

//#3B5998; fb blue

Wednesday, April 20, 2016

Tip # 1: Avoid race condition in app variables

Application.Lock();
Application["tod"] = HttpUtility.HtmlEncode(tod.Text);
Application.UnLock();

using (System.IO.StreamWriter file = new System.IO.StreamWriter(Server.MapPath("~/App_Data/tod.txt"), false))
{
     file.WriteLine(tod.Text);
}


Tip # 2: Writing file data in single line of code in simplest way

System.IO.File.WriteAllText(Server.MapPath("~/App_Data/tod.txt"), tod.Text);


Tip # 3: For pages that are not to be cached always use this meta tag

<meta http-equiv="cache-control" content="no-cache" />
-Works with Chrome

<meta http-equiv="Pragma" content="no-cache" />
-Does NOT work with chrome but works with FF and IE


Tip # 4: Reading file data using single line of code in simplest way

 HttpUtility.HtmlEncode( System.IO.File.ReadAllText(Server.MapPath("~/App_Data/tod.txt")


instead of

//string text = System.IO.File.ReadAllText(@"C:\Users\Public\TestFolder\WriteText.txt");
        // System.IO.File.WriteAllText(@"C:\Users\Public\TestFolder\WriteText.txt", text);
    }

Monday, April 18, 2016

5 proven ways to motivate and retain your technology team

Are you looking to build an environment for your technology professionals that fosters loyalty and growth?

5 proven ways to motivate and retain your technology team, and learn about the key areas that you need to pay a certain amount of attention if you plan on retaining your tech staff:

The work environment
Education
Hardware/software programs
Perks of hard work
Recognition



http://pluralsight-assets.s3.amazonaws.com/pdf-assets/Pluralsight_Guide_Motivate_rebranded.pdf

Warning:Unable to find optional library: org.apache.http.legacy

In lollipop development the library containing http protocols wont work, for that you have add this line to the gradle.

useLibrary 'org.apache.http.legacy'

and then sync it



Warning:Unable to find optional library: org.apache.http.legacy


guess, the easier way to solve this issue without having to reinstall the SDK is to create a file called optional.json in <sdk-path>\platforms\android-23\optional\ directory with the following content:

[
  {
    "name": "org.apache.http.legacy",
    "jar": "org.apache.http.legacy.jar",
    "manifest": false
  }
]
It solved the problem for me.

EDIT: Information taken from @domoch's answer below on how to locate your SDK location

To Locate your Android SDK's Location
Go to Android Studio Settings -> Appearence & Behavior -> System Settings and look for Android SDK Location. In Windows, it usually would be pointing to C:\Users\<username>\AppData\Local\Android\sdk.

Reduce Java software maintenance costs by 30-40% by efficient engineering of technical debt


Attended. Speaker was very good.


2:50 PM 7/31/2015
Reduce Java software maintenance costs by 30-40% by efficient engineering of technical debt

Speaker 1: Raja Nagendra Kumar, CTO, TejaSoft
Speaker 2: Choudary Kothapalli, Architect, MaintainJ Inc

Why technical debt is unavoidable during development and maintenance of large enterprise applications
Different forms of technical debt
How the technical debt results in significantly higher costs in all phases of the maintenance life cycle
Current techniques and tools used to manage the technical debt (after the technical debt occurs)
Static analysis techniques and tools Vs. Runtime analysis techniques and tools
Discuss the tools and techniques to reduce the costs in all phases of maintenance life cycle

Friday, March 11, 2016

How to capture value of a radio button in Java script?



Today I am answering a few questions newbies ask time and again.

Topic - JavaScript

How to show value of an variable?

var num = 5;
alert(num);


How to display value of an element?

alert(document.getElementById("txtName").value);


How to capture / read value of radio button?

alert(document.getElementById("isNew").checked);




I have written one example for demonstration of radio button use.
Please save this as an demo.html file and open in browser

<!DOCTYPE html>
<html>
<body>

<p>Please select gender:</p>

<form>
  <input type="radio" name="gender" value="Male"> I am boy<br>
  <input type="radio" name="gender" value="Female">I am girl<br>
  <br>
  <input type="button" onclick="go()" value="GO">
  <br><br>
  <input type="text" id="txtDisplay" size="50" value="Make selection">
</form>

<script>
function go() {
    var gender = document.forms[0];
    var txt = "";
     for (var i = 0; i < gender.length; i++ ){
        if (gender[i].checked) {
            txt =gender[i].value ;
        }
    }

    document.getElementById("txtDisplay").value = "You have selected gender as " + txt;
}
</script>

</body>
</html>

Please comment if you read this post.
Like it Share it so that someone else will also benefit.

Saturday, April 05, 2014

Synchronous call to ASP.NET WebAPI

Being on older technology stack I was unable to use the Async based code sample for webAPI
so this is my current work around. I am using VS 2010 .NET framework 4.0

public string testapi()
 {
using (var client = new HttpClient())
{
var response = client.GetAsync("http://localhost:3507/api/course").Result;
var result = response.Content.ReadAsStringAsync().Result;
return result;
}
}

Thursday, March 20, 2014

Product Management & Marketing: Recipe for Successful Product Development Team

Trust Your Team :
Only trust can hold the team together and supply the everlasting energy to execute at take risk at some courses.

Indecision is  Sin :
Decide and move ahead , come what may. Nothing demotivates like an undecided manager.

Say no to Fear:
Fear is bound to surround in product development as the stakes are high. Let go whatever is holding you back. Drop your doubts worries and fear. Even the failures can be turned around if you are fearless.

Finally the most important ingredient I feel is

Clarity Of Vision
Be crystal clear about your vision only. If the vision is clear to team members they can judge their actions themselves and would save you from petty decisions that waste your time.

Effective delegation :
Delegate and empower your team to take action . Delegate - verify - delegate more. Sure way building accountability .


Personal opinions based on my experiences in product development and team building.

- Vishwajit Girdhari

Product Management & Marketing: Recipe for Successful Product Development Team

Friday, February 01, 2013

Adding click event to button through Javascript using addEventListener


Adding button to DOM and futher adding click event to button through Javascript using addEventListener

<!DOCTYPE html>
<html>
<head>
<script>
function btnclick(person)
{
alert(person + " is free tomorrow!");
}


function load()
{
alert("Just one question...");
var s = document.getElementById("page-content");
var i = document.createElement("button");
i.innerHTML="myBtn";
s.appendChild(i);

if(i.addEventListener)

i.addEventListener('click',function (){btnclick("Vinayak");}, true);
}
 
}
</script>
</head>

<body onload="load()">
<div id="page-content"></div>
<p>Who is free from tomorrow?</p>
</body>
</html>

- Vishwajit Girdhari, .NET Enthusiast 

Friday, October 12, 2012

Adding jquery calendar control to DotNetNuke module



jQuery provides with calendar and they call it datepicker
DotNetNuke provides with inbuilt jquery.js and jquery-ui.js so you don't have to bother to link them separately
In regular html / asp.net application you would have to add following lines in <head> tag
     <script src="http://code.jquery.com/jquery-1.8.2.js"></script>     <script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>     <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" />

You dont need them in DNN.
If you are developing a custom DNN module add this to your user control view.ascx file.
I have txtStartDate as a text field on the form where I wanted my calander to be rendered on click.
To achieve this I added this code at the top of my ascx page after the standard includes.
<script type="text/javascript" >
$(function () {
    $("#<%= txtStartDate.ClientID %>").datepicker();
});
</script>
The calender takes the size based on your text size if it is appearing bigger that your expectation
set it style like this
<style>
div.ui-datepicker{
font-size:10px;
}
</style> 

Tuesday, September 18, 2012

Getting Current User Info in DotNetNuke

// DNN Get Current User


// The Current user information can fetch using UserController and
// is availble as UserInfo object:
 

 private UserInfo _currentUser =
                   DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();

// To get UserID of the current user we can then access the fetched UserInfo object:

 int UserID = _currentUser.UserID

Tuesday, September 04, 2012

DotNetNuke Error: System.Web.UI.UserControl' does not contain a definition for 'CreatedByUser'


Another tiring issue because of  automatic code generation of .designer.cs while building
DotNetNuke Module from asp.net User Control.

My asp.net user control was working flawlessly when I converted it in to DNN Module it was
not getting build. It was giving this error.

Error 16 'System.Web.UI.UserControl' does not contain a definition for 'CreatedByUser' and no extension method 'CreatedByUser' accepting a first argument of type 'System.Web.UI.UserControl' could be found (are you missing a using directive or an assembly reference?)


Solution:

I found the reason.. Apparently when a rename occurs the definitions are changed.
Originally the definitions where these:
protected global::DotNetNuke.UI.UserControls.LabelControl lblContent;
protected global::DotNetNuke.UI.UserControls.ModuleAuditControl ctlAudit;


After the renaming, they magically became these:
protected global::System.Web.UI.UserControl lblContent;
 protected global::System.Web.UI.UserControl ctlAudit;

As did every other control in the .designer.cs files!


Ref : http://www.dotnetnuke.com/Resources/Forums/forumid/199/threadid/355899/scope/posts.aspx


DNN Error - Could not create type 'DotNetNuke.Modules.Journal.ProfilePic


'Error 21 Could not create type 'DotNetNuke.Modules.Journal.ProfilePic''  
I was getting this error in when I was trying to compile latest DotNetNuke Community Edition CMS Version 06.02.0
This issue was appearing weird as the file contained no code. There was nothing could be done about it.
But finally it seems to build packaging problem from DNN Team. 

"You may safely delete this file." is what the DNN guys says. huh. thats a big relief ! !

>>Reply from DNN<<

There seems to be a file in the install package that shouldn't have been included. If you see a file named ProfilePic.ashx in the DesktopModules/Journal directory you can safely delete this file. This file was created before we moved to handler that was integrated with the core project.

Will Morgenweck
Director of Product Management
DotNetNuke Corp.

Tuesday, August 21, 2012

Ek Tha Tiger




He lived/s in Kahna ....

Was visited by Tigers Adventure Campers ....
www.tigers9.com


Thursday, August 09, 2012

IIS Server on Windows 7 Home Basic



To Install IIS 7.5 on Windows 7 Home

Click Start and then click Control Panel.

In Control Panel, click 'Programs and features' then click 'Turn Windows features on or off'.

In the Windows Features dialog box, click Internet Information Services and then click OK.

Developers are recommended to select Application Development Features or Web Management Tools in the  check boxes associated with those features.

P.S. Getting ready on DNN Module Development. Keep watching this blog for more updates on same ...  ;)

Friday, September 30, 2011

Form Validation in flex 2.0 programatically

There are couple of approaches for performing form validation in flex.
Here I would be presenting the combination that appeared to me more logical and eligant.



< height="100%" width="100%">
<mx:formitem required="true" label="User ID" >
< id="txtUserId" width="235" height="20" focusout="performRequiredFieldValidation(event);">


do what you like ........

Monday, November 27, 2006

Introduction to Flex Data Services 2

Introduction to Flex Data Services 2
11/28/2006
2:00 PM US/Eastern

http://www.adobe.com/cfusion/event/index.cfm?event=track&id=539086&loc=en_us

Tuesday, November 14, 2006

Calling web services in ActionScript


Calling web services in ActionScript


private function initMe(e:Event):void {

con.useProxy = false ;
con.wsdl = http://localhost/TestService.asmx?wsdl;
if (con.canLoadWSDL()){
con.loadWSDL();
}

con.login.addEventListener("result", loginResultHandler);
con.addEventListener("fault", wsFaultHandler);

}

private function loginClickHandler (event : Event ){

con.login(t1.text , t2.text );
}

private function wsFaultHandler (fault : Object ){

Alert.show(""+fault.faultString);
}