Saturday 28 July 2018

Find Largest Element of an Array using Function in Python

# Find Largest Element of an Array using Function

# python function to find maximum
# in arr[] of size n
def largest(arr,n):

# Initialize maximum element
max = arr[0]

# Traverse array elements from second
# and compare every element with
# current max
for i in range(1, n):
if arr[i] > max:
max = arr[i]
return max
# Drive Code
arr =[i for i in  range(100)]
   
n = input(" Enter total number of elements(1 to 100):")
n=int(n);

for i in range(n):
    arr[i]=  input(" Enter Number for index {0} ".format(int(i)));


Ans = largest(arr,n)
print ("Largest in given array is",Ans)


   


Thursday 26 July 2018

Swap two variables without using third variable in Python

# Swap two variables without using third variable in Python

a = input(" Please Enter the First Number: ")
b = input(" Please Enter the second number: ")
 
print('First Number {0} Second Number {1} '.format(a, b))

a=float(b)+float(a);
b=float(a)-float(b);
a=float(a)-float(b);   


print('After Swap First Number {0} Second Number {1}'.format(a, b))



Wednesday 25 July 2018

Two Number Sum in Python

# Simple Python program to Add Two Numbers

number1 = input(" Please Enter the First Number: ")
number2 = input(" Please Enter the second number: ")

# Using arithmetic + Operator to add two numbers

sum = float(number1) + float(number2)
print('The sum of {0} and {1} is {2}'.format(number1, number2, sum))



Thursday 12 April 2018

Track your Facebook login attempt


Facebook provides a feature which allows you to see all active sessions from different devices and apps together with the date it was last accessed, from where and which device type. In most cases, that should be enough information to find any suspicious activity.

This also comes in handy if you logged in to your friend's computer or on some public laptop, but forgot to log out.

To know if someone is logged into your Facebook account without your permission:-

Go to your settings page
Under option Security and Login you'll see the link "Where You're Logged In."

You will find all your active Facebook logins from desktop or mobile. It will also provide data on the location, browser and device. If something seems fishy, you also have the ability to "end activity" from individual or all devices. This means that the particular device or app cannot access your account anymore without your password.

Also keep in mind that the logged in location shown in report will not be accurate as some times it will show the gateway location of your internet provider which may be some different location. You can just check the device information from which account is accessed to confirm either it was wrong attempt.

Wednesday 4 April 2018

Convert AM/PM time to 24 hours format C#

C# hh:mm tt (12 Hours to 24 Hours Format) convert


using System.Globalization;

var cultureSource = new CultureInfo("en-US", false);
var cultureDest = new CultureInfo("de-DE", false);
var source = "03:00 PM";

 var dt = DateTime.Parse(source, cultureSource);
  Response.Write(dt.ToString("t", cultureDest));

Thursday 15 March 2018

MVC asp.net Multi Level Menu Bind


Model:


public class M_MenuModel
    {
        #region Variable
        public Int32   MMID { get; set; }
        public string MM_Name { get; set; }
        public string MM_Url { get; set; }
        public Int32 MM_Parent { get; set; }     
        public string MM_Icon { get; set; }       
        #endregion
    }

Controller :

 public ActionResult UserMenuShow()
        {
            ViewBag.Menu = BuildMenu();
            return View();
        }


 private IList<M_MenuModel> BuildMenu()
        {
IList<M_MenuModel> mmList = new List<M_MenuModel>(){
             
                // Parent
                new M_MenuModel(){ MMID = 1, MM_Name = "Home", MM_Parent = 0, MM_Url = "1"} ,
                new M_MenuModel(){ MMID = 2, MM_Name = "Admin", MM_Parent = 0, MM_Url = "1"} ,
                new M_MenuModel(){ MMID = 3, MM_Name = "Accounting", MM_Parent = 0, MM_Url = "1"} ,

                // Children

                new M_MenuModel() { MMID=21, MM_Name = "Create User", MM_Parent = 2, MM_Url="1", MM_Icon="" },
                new M_MenuModel() { MMID=22, MM_Name = "Create Group", MM_Parent = 2, MM_Url="2" },
                new M_MenuModel() { MMID=23, MM_Name = "Create Account", MM_Parent = 2, MM_Url="3"},

                new M_MenuModel() { MMID=31, MM_Name = "Manage Account", MM_Parent = 3, MM_Url="1" },
                new M_MenuModel() { MMID=32, MM_Name = "GL Accounts", MM_Parent = 3, MM_Url="2" },


                new M_MenuModel() { MMID=321, MM_Name = "Salary Accounts", MM_Parent = 32, MM_Url="1" },
                new M_MenuModel() { MMID=322,MM_Name = "Savings Accounts", MM_Parent = 32, MM_Url="2" },

            };

            return mmList;
}


View:



@{
    List<ProjectName.Areas.Admin.Models.M_MenuModel> menuList = ViewBag.Menu;
}


@foreach (var mp in menuList.Where(p => p.MM_Parent == 0))
                {

                    <li>

                        @if (menuList.Count(p => p.MM_Parent == mp.MMID) > 0)
                        {
                            <a href="#@mp.MM_Name" data-toggle="collapse" class="collapsed">@mp.MM_Name <i class="icon-submenu lnr lnr-chevron-left"></i></a>
                            @:<div ID="@mp.MM_Name" class="collapse">
                                @:<ul class="nav">
        }
                        @if (menuList.Count(p => p.MM_Parent == mp.MMID) == 0)
                        {
                            
                            @:<a href="@mp.MM_Url"> @Html.Raw(@mp.MM_Icon) @mp.MM_Name </a>
                        }

                            @RenderMenuItem(menuList, mp)

                        @if(menuList.Count(p => p.MM_Parent == mp.MMID) > 0)
                        {



                    @:</ul>
                        
                    @:</div>
                                            }

                    </li>
                }

@helper RenderMenuItem(List<Manav_Ashraya_V1.Areas.Admin.Models.M_MenuModel> menuList, Manav_Ashraya_V1.Areas.Admin.Models.M_MenuModel mi)
{
foreach (var cp in menuList.Where(p => p.MM_Parent == mi.MMID))
{


        @:<li>








    if (menuList.Count(p => p.MM_Parent == cp.MMID) > 0)
    {

            <a href="#@cp.MM_Name.Replace(' ','_')" data-toggle="collapse" class="collapsed">@cp.MM_Name <i class="icon-submenu lnr lnr-chevron-left"></i></a>

            @:<div ID="@cp.MM_Name.Replace(' ','_')" class="collapse">
                @:<ul class="nav">
        }
        if (menuList.Count(p => p.MM_Parent == cp.MMID) == 0)
        {
            @:<a href="@cp.MM_Url">@cp.MM_Name</a>


        }

        @RenderMenuItem(menuList, cp)
    if (menuList.Count(p => p.MM_Parent == cp.MMID) > 0)
    {
     @:   </ul>

    @:</div>
    }
    else
    {


         
        @:</li>
    }
}
}

Friday 9 March 2018

Update a table using JOIN in SQL Server

  1. UPDATE t1  
  2. SET t1.TID = t2.DOID  
  3. FROM dbo.Table1 AS t1  
  4. INNER JOIN dbo.Table2 AS t2  
  5. ON t1.CommonField = t2.[Common Field] 

Saturday 3 March 2018

Populate (Bind) DropDownList using AngularJS AJAX and JSON

Angular JS 

var AnguarModule = angular.module('CMS', []);
AnguarModule.controller('DashBoard', function ($scope, $http, ApiCall) {
  var result = ApiCall.GetApiCall("MasterDetails", "ASYears").success(function (data) {
        $scope.ASYearsDetails = data;
        $scope.ASYearsD = $scope.ASYearsDetails[0];
    });
});

AngularService

AnguarModule.service('ApiCall', ['$http', function ($http) {
    var result;

    // This is used for calling get methods from web api
    this.GetApiCall = function (controllerName, methodName) {
        result = $http.get(controllerName + '/' + methodName).success(function (data, status) {
            result = (data);

        }).error(function () {
            alert("Something went wrong");
        });
        return result;
    }; 
 

} ]);



HTML: 

 <div class="content" ng-app="CMS">

<div class="col-lg-4  col-md-6" ng-controller="DashBoard">

<select ng-model="ASYearsD" ng-options="items.ASYears for items in ASYearsDetails"
                ng-change="ShowUnfiled()" ng-init="ASYearsD = data[1].AsYr" id="ASYearsD">
                <option value="">-- Select --</option>
            </select>
</div>
</div>


JSON :


[{"AsYr":"2017","ASYears":"2016-17","Selected":"1"},{"AsYr":"2016","ASYears":"2015-16","Selected":"0"},{"AsYr":"2015","ASYears":"2014-15","Selected":"0"},{"AsYr":"2014","ASYears":"2013-14","Selected":"0"},{"AsYr":"2013","ASYears":"2012-13","Selected":"0"},{"AsYr":"2012","ASYears":"2011-12","Selected":"0"},{"AsYr":"2011","ASYears":"2010-11","Selected":"0"},{"AsYr":"2010","ASYears":"2009-10","Selected":"0"},{"AsYr":"2009","ASYears":"2008-09","Selected":"0"},{"AsYr":"2008","ASYears":"2007-08","Selected":"0"},{"AsYr":"2007","ASYears":"2006-07","Selected":"0"}]




Wednesday 31 January 2018

SQL CharIndex Example

  1. DECLARE @PW_MPID NVARCHAR(max)  
  2. set @PW_MPID='1555|2555|35|'  
  3.   
  4. DECLARE @PW_MPIDPostion Varchar(max) = CHARINDEX('|',@PW_MPID)                                                                                      
  5. rint @PW_MPIDPostion                                                       
  6. DECLARE @TempPW_MPID Varchar(max)                                                                                          
  7. WHILE(@PW_MPIDPostion > 0)                                                   
  8.          BEGIN                          
  9.                SET @TempPW_MPID = SUBSTRING(@PW_MPID ,1,@PW_MPIDPostion-1)       
  10.                print @TempPW_MPID  
  11.                  
  12.                 SET @PW_MPID =SUBSTRING(@PW_MPID,@PW_MPIDPostion +1,LEN(@PW_MPID))                                                     
  13.                       print @PW_MPID                                                                     
  14.    SET @PW_MPIDPostion  = CHARINDEX('|',@PW_MPID)     
  15.    print @PW_MPIDPostion                                        
  16.  END   

Tuesday 30 January 2018

ROLES AND RESPONSIBILITIES

Sr .Net Developer Responsibilities and Duties

If you are considering a job as Sr .Net Developer here is a list of the most standard responsibilities and duties for the Sr .Net Developer position.

Design, develop, test, support and deploy desktop, custom web, and mobile applications.

Gather customer software requirements and develop related software applications and programs.

Research and evaluate software related technologies and products.

Design and develop testing and maintenance procedures and activities.

Develop and write high quality coding that meets customer requirements.

Create software documentation and update existing documentation.

Design, develop and implement critical applications in a .Net environment.

Assist and support other team members on multiple projects.

Drive team members to keep up with projects deadlines and within the clients’ budgets.

Implement best practices, standards and procedures including quality and delivery methodologies.

Ensure compliance with the documented software processes and procedures throughout the life cycle of software products.

Senior Developer Responsibilities and Duties

If you are considering a job as Senior Developer here is a list of the most standard responsibilities and duties for the Senior Developer position.

Develop and document design, source base and architecture.

Maintain and manage existing source bases.

Design, develop and implement solutions to users’ needs and requirements.

Review and improvise code.

Run tests and fix bugs.

Coordinate with architects and business analysts to determine functionalities.

Develop technical solutions to complex business problems.

Design and develop technical solutions for enterprise-level projects.

Design and develop data analysis solutions.

Design and develop logical and physical data models that meet application requirements.

Senior Programmer Responsibilities and Duties

If you are considering a job as Senior Programmer here is a list of the most standard responsibilities and duties for the Senior Programmer position.

Architect, develop and implement software programs to meet business requirements.

Develop application code and modules for business and technical requirements.

Tune up design for maintainability, scalability and efficiency.

Develop and implement programs, designs and codes.

Design and develop systems, sub-systems and programs.

Coordinate and support technical staff, operations and vendors.

Interact with clients to determine their requirements and needs.

Resolve and troubleshoot problems and complex issues.

Perform unit tests and fix bugs.

Integrate best qualitative practices in design and development aspects of programs

Senior Software Engineer Roles & Responsibilities…

If you are considering a job as Senior Software Engineer here is a list of the most standard responsibilities and duties for the Senior Software Engineer position.

Design, develop and implement applications that support day-to-day operations.

Provide innovative solutions to complex business problems.

Plan, develop and implement large-scale projects from conception to completion.

Develop and architect lifecycle of projects working on different technologies and platforms.

Interface with clients and gather business requirements and objectives.

Translate clients’ business requirements and objectives into technical applications and solutions.

Understand and evaluate complex data models.

Design, develop and implement new integration.

Execute system development and maintenance activities.

Develop solutions to improvise performance and scalability of systems.

Software Developer Responsibilities and Duties

If you are considering a job as Software Developer here is a list of the most standard responsibilities and duties for the Software Developer position.

Evaluate, assess and recommend software and hardware solutions.

Develop software, architecture, specifications and technical interfaces.

Develop user interfaces and client displays.

Design, initiate and handle technical designs and complex application features.

Develop, deliver and test software prototypes.

Assist software personnel in handling ongoing tasks as required.

Build flexible data models and seamless integration points.

Innovate and develop high-value technology solutions to streamline processes.

Initiate and drive major changes in programs, procedures and methodology.

Coordinate with other developers and software professionals.

Software Programmer Responsibilities and Duties

If you are considering a job as Software Programmer here is a list of the most standard responsibilities and duties for the Software Programmer position.
Design and develop systems integration, related issues and processes.

Perform analysis, design and develop computer programs and applications.

Perform unit testing and maintain software programs and applications.

Perform coding data acquisition routines and access issues.

Develop custom reports for large data sets.

Assist and support in integration of GIS analysis applications.

Develop and deploy unit testing, load testing and tracking system software support.

Configure, maintain and support production databases.

Develop and implement application to application data feeds.

Configure and maintain multi-site data processes and issues including synchronization.

Software Engineer Responsibilities and Duties 

If you are considering a job as Software Engineer here is a list of the most standard responsibilities and duties for the Software Engineer position.

Design, develop and manage software projects for clients.

Analyze and evaluate user needs and develop software solutions.

Write supporting documents for projects developed and tested.

Develop Microsoft .net based web applications.

Develop MS SQL server applications like views, triggers and stored procedures.

Design and develop web user interfaces with back-end databases and other tools.

Recommend technical feasibilities and solutions.

Evaluate new technologies in the light of emerging trends and technologies.

Modify and update existing technologies improvise performances.

Troubleshoot and resolve difficult problems relating to software applications and programs.

Software Analyst Responsibilities and Duties

If you are considering a job as Software Analyst here is a list of the most standard responsibilities and duties for the Software Analyst position.

Perform complex analysis, designing and programming to meet business requirements.

Maintain, manage and modify all software systems and applications.

Define specifications for complex software programming applications.

Interface with end-users and software consultants.

Develop, maintain and manage systems, software tools and applications.

Resolve complex issues relating to business requirements and objectives.

Coordinate and support software professionals in installing and analyzing applications and tools.

Analyze, develop and implement testing procedures, programming and documentation.

Train and develop other software analysts.

Analyze, design and develop modifications and changes to existing systems to enhance performance.

Software Architect Responsibilities and Duties

If you are considering a job as Software Architect here is a list of the most standard responsibilities and duties for the Software Architect position.

Develop, leverage and architect technical solutions to scale business initiatives.

Develop roadmaps for subsystems in accordance with product related technologies.

Execute product related technologies, technology platforms, architects and design principles and advancements.

Design, develop and architect evolution applications across multi-generation product releases.

Generate business requirements, verify, validate and implement.

Architect all software development lifecycle including requirements gathering, designing, implementing, testing, and releasing.

Architect and implement appropriate technologies according to business requirements.

Assess and evaluate technology tradeoffs.

Select technologies to architect product roadmaps.

Develop and implement appropriate technologies to troubleshoot functional issues and risks.

Software Consultant Responsibilities and Duties

If you are considering a job as Software Consultant here is a list of the most standard responsibilities and duties for the Software Consultant position.

Analyze and understand detailed business requirements.

Provide mapping requirements and software solutions.

Provide recommendations for software developments and implementations.

Document business requirements, gatherings and issues and updated business process flows.

Document results of software research tools and applications.

Execute program modifications and changes.

Interface with clients, software professionals and consultants to develop solutions applications.

Review and evaluate technical design and technical quality issues and processes.

Coordinate and collaborate workflow processes and issues in designing, programming and testing.

Develop highly functional qualitative modifications and system changes.

Software Designer Responsibilities and Duties

If you are considering a job as Software Designer here is a list of the most standard responsibilities and duties for the Software Designer position.

Design, develop and execute unit test plans, test designs, test cases and test strategies.

Design, develop and execute subsystem test plans, procedures and processes.

Document all test plans, test cases and strategies procedures and issues.

Design and implement test scripts on test tools and scripting languages.

Coordinate and collaborate with outside test partners.

Design, develop and implement program and process improvements.

Design and develop coding, code reviews, unit testing and release management.

Develop design specifications in accordance with business requirements and issues.

Recommend strategic improvements to optimize performances.

Perform analyses and interpretations of strategies and software applications.

Monday 15 January 2018

SQL Server: Make all UPPER case to Proper Case/Title Case

CREATE FUNCTION [dbo].[fnConvert_TitleCase] (@InputString VARCHAR(4000) )
RETURNS VARCHAR(4000)
AS
BEGIN
DECLARE @Index INT
DECLARE @Char CHAR(1)
DECLARE @OutputString VARCHAR(255)

SET @OutputString = LOWER(@InputString)
SET @Index = 2
SET @OutputString = STUFF(@OutputString, 1, 1,UPPER(SUBSTRING(@InputString,1,1)))

WHILE @Index <= LEN(@InputString)
BEGIN
    SET @Char = SUBSTRING(@InputString, @Index, 1)
    IF @Char IN (' ', ';', ':', '!', '?', ',', '.', '_', '-', '/', '&','''','(')
    IF @Index + 1 <= LEN(@InputString)
BEGIN
    IF @Char != ''''
    OR
    UPPER(SUBSTRING(@InputString, @Index + 1, 1)) != 'S'
    SET @OutputString =
    STUFF(@OutputString, @Index + 1, 1,UPPER(SUBSTRING(@InputString, @Index + 1, 1)))
END
    SET @Index = @Index + 1
END

RETURN ISNULL(@OutputString,'')
END

Friday 12 January 2018

Using WebGet and WebInvoke with example

Using WebGet and WebInvoke
Services can be exposed using the WebHttpBinding binding using either the WebGet or WebInvoke attributes. Each of these attributes specifies the HTTP verb, message format, and body style needed to expose an operation. We will examine each of these attributes and reasons to use each.

WebGet
The WebGet attribute exposes operations using the GET verb. The GET has significant advantages over other HTTP verbs. First, the endpoint is directly accessible via a Web browser by typing the URI to the service into the address bar. Parameters can be sent within the URI either as query string parameters or embedded in the URI. Second, clients and other downstream systems such as proxy servers can easily cache resources based on the cache policy for the service. Because of the caching capability, the WebGet attribute should be used only for retrieval.

WebInvoke
The WebInvoke attribute exposes services using other HTTP verbs such as POST, PUT, and DELETE. The default is to use POST, but it can be changed by setting the Method property of the attribute. These operations are meant to modify resources; therefore, the WebInvoke attribute is used to make modifications to resources.

Shows a service that defines services that are exposed in the WebGet and WebInvoke attributes. The WebGet attribute is used to retrieve customer information. The WebInvoke attribute is used for those operations that modify data such as adding or deleting customers. Last, the UriTemplate property is specified on WebGet and WebInvoke attribute to identify a customer resource using the URI.



  • using System;  
  • using System.ServiceModel;  
  • using System.ServiceModel.Web;  
  •   
  • namespace WCFExample  
  • {  
  •     [ServiceContract]  
  •     public class CustomerService  
  •     {  
  •         [OperationContract]  
  •         [WebGet(UriTemplate="/customer/{id}")]  
  •         public Customer GetCustomer(int id)  
  •         {  
  •             Customer customer = null;  
  •   
  •             // Get customer from database  
  •   
  •             return customer;  
  •         }  
  •   
  •         [OperationContract]  
  •         [WebInvoke(Method = "PUT", UriTemplate = "/customer/{id}")]  
  •         public void PutCustomer(int id, Customer customer)  
  •         {  
  •             // Put customer in database  
  •         }  
  •   
  •         [OperationContract]  
  •         [WebInvoke(Method = "DELETE", UriTemplate = "/customer/{id}")]  
  •         public void DeleteCustomer(int id)  
  •         {  
  •             // Put customer in database  
  •         }  
  •     }  
  • }  
  • Tuesday 9 January 2018

    How to Kill all the Blocked Processes of a Database

    1. DECLARE @DatabaseName nvarchar(50)  
    2.   
    3. --Set the Database Name  
    4. SET @DatabaseName = N'TESTDB'  
    5.   
    6. --Select the current Daatbase  
    7. SET @DatabaseName = DB_NAME()  
    8.   
    9. DECLARE @SQL varchar(max)  
    10. SET @SQL = ''  
    11.   
    12. SELECT @SQL = @SQL + 'Kill ' + Convert(varchar, SPId) + ';'  
    13. FROM MASTER..SysProcesses  
    14. WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId  
    15. and spid IN (SELECT blocked FROM master.dbo.sysprocesses)  
    16.   
    17. exec @SQL

    Monday 8 January 2018

    11 Things You Should Never Put On A Resume

    #1 - Unprofessional Email Addresses

    You would be surprised at the types of email addresses that exist on resumes. Things like HotGuy25 or PartyGirl2003. How is a recruiter supposed to take you seriously? If you don't have a professional account, go create one! It will save your image.

    #2 - Objective Statement

    There is never value in you simply telling a recruiter what you want. They already know what job you are applying for. Instead, transform this space. Use it to provide a career summary. Think elevator pitch for your resume. It will sell who you are and what you bring to the table far better than an objective statement.

    #3 - Graduation Dates

    The only dates that should be listed on a resume are dates of employment. No one needs to know when you graduated high school or college. The most important piece is that you graduated. Dates have a way of opening up the possibility the recruiter could guess your age. While there isn't necessarily something wrong with that, age is a protected class. That means it has nothing to do with your ability to do the job so it shouldn't be part of the decision to interview or hire you.

    #4 - Photos

    The only time a photo should be included with a resume is if you are working in modeling or acting. My team used to laugh whenever a resume came in with a photo on it. In reality, it opens a lot of gray area. The recruiter can make assumptions about you based on how they think you look in the picture. All of those assumptions have nothing to do with your quality as a candidate for the job. It's best to only let them evaluate you based on the skills you bring to the table, not how you look.

    #5 - Personal Information

    There are still a lot of people that list personal information on their resume. Things like your marital status, hobbies, how many kids you have, or your social security number have no place on your resume! It would seem these things help paint a picture of your character. However, they really have no bearing on your fit for the job. Plus it opens the door to the possibility of stereotyping to exist. Leave it off entirely. Instead, fill that space with career accomplishments.

    #6 - Every Single Job

    If you have been out of school for 20 years, the recruiter doesn't necessarily care about the first job you held. A good rule of thumb is to only include the last 10 years of your employment. However, you should also think about what experience is most relevant to the job you are applying for. That is what the recruiter needs to see.

    #7 - Salary Information

    The moment you share any salary information you have lost power during the negotiation. Oftentimes recruiters will screen you out if they think you want to make (or have made) more than this job will offer. It's best to withhold salary history until you begin the process of discussing an offer. This ensures you get the opportunity to sell yourself through an interview before you are eliminated from the mix.

    #8 - References (or On Request)

    References are the biggest space wasters, especially if you are trying to achieve a 1-page document. Even simply listing "available on request" is a waste. Leave it off completely and use that space for something else. Recruiters know they can always ask you for references. In fact, their online application likely requested them already.

    #9 - Mistakes

    Double and triple check your resume for grammar mistakes and typos. Have someone else with fresh eyes read it as well. Nothing ruins your chances more than a mistake. Another area to focus on is ensuring your contact information is accurate and valid.

    #10 - Full Sentences

    A resume is not a place for full sentences. It needs to be brief, impactful, and easy to scan. So cut everything down to bullet points. Then rework it using great action verbs to make it succinct and detailed.

    #11 - Multiple Contact Details

    There is no reason to list multiple phone numbers or email addresses on your resume. All it does is cause confusion. Simply list one of each. Let it be exactly where the recruiter can best reach you. Your goal is to be easy to contact!