Sponsored Links

Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

April 1, 2019

How to disable right click on web page using jQuery

There are certain ways to disable right click on web page. One of most common ways is using following jQuery code in the web page. Add following code at the end of body inside script tag. Note that it uses jQuery. So import jQuery first.

$(document).bind("contextmenu", function(e) {
     e.preventDefault();
});

November 12, 2018

Hottest Trend in IT 2018

From various research and usage, following seem to be hottest trend in the industry right now.

Front End Development:
ReactJs
Angular

Learn about progressive web apps because it will soon take over android and IOS native mobile apps.
Progressive Web Apps

Learn about big data, machine learning and AI
Tensorflow
Hadoop
Spark

Improve your programming skills on javascript, python, java . 

Awesome Tips for Developers


There are many tips for becoming better developer if you search for. Among many ideas and tips following four points have more striking effects. Please read it and implement right away.
  1. Learn to code by hand on paper and a whiteboard first and then throw it into an IDE for syntax highlighting, this should become second nature to you.
  2. Develop deep knowledge of data structures , their strengths, and weaknesses in comparison to each other. I discovered that implementing data structures and their behaviors from scratch taught me so much more than what i knew from their abstract concepts.
  3. Completely understand Big O notation for both time and space complexities, this will pair perfectly with your algorithm and sorting questions.
  4. Grasp all major sorting algorithms because the difference in time/space complexities have the potential to derail your optimum solution for an algorithm you're trying to solve.

August 19, 2018

Top 30 ways to become better developer

Here are top 30 tips for becoming a better developer. If you follow all these steps then you already are a better developer.
  1. Read other people's code:
    You need to make a habit of reading code written by other developers. You can learn many things from this. Obviously there are BAD CODES out there but you need to have sharp selection for reading quality code. This will help you learn new techniques, languages and quality code from other developers.
  2. Write shorter methods/functions:
    Always try to make your functions as short as possible and to the point. Writing short methods will help to organize, maintain and test the code. And always remember one tasks one method.
  3. Learn New Language:
    Try learning new language whenever possible. No language is perfect and learning new language helps you to know work around and quirks of languages.
  4. Write a test before coding:
    Before starting to code to develop features first write a test for the feature. It will help to develop feature without possible bugs and going out of track.
  5. Single Responsibility Principle:
    Give single responsibility for a class. It is best practice to give single task to each class. Any class with more than one major responsibility should be broken up into smaller classes.
  6. Learn to Debug:
    Debugging is one of the crucial part of developers. Debugging a problem can take nasty amount of time if you are not used to it. There are many debugging tools out there for you. Use them and get used to it. It will pay you off in future.
  7. Write clean code:
    Writing a clean code is something that is achieved by practice. It won't happen over night. You need to write many lines of code, refactor them and improve them time and again. Also you should be consistent while coding like proper spaces, variable naming, formatting etc. Your code should be readable for other programmers and can understand the motive of code once then read them. Try to make your code as simpler as possible.


...to be continued

December 14, 2017

Things to Remember If You Are Developing Your Website

If your are starting to develop your website or starting website development then you should consider user experience also. I am giving some tips to get started here. If you do not know anything about typography, but you care about readability, you should try this as a starting point.

  1. A minimum of 18px font size.
  2. Line spacing of 1.6
  3. #333 for color or thereabouts.
  4. Limit your lines to a width of 700px.
These are few tips for starting. I will keep updating it with other useful tips for starting as developer.

5 Tips to Become a Web Developer

If you ever wanted to become a web developer then here are the five tips to get started with.
  1. You can volunteer or intern in different companies. This is the quickest way to get hired or work as a web developer. So find any local companies or any around you and ask for volunteer.
  2. Your goal is to gain experience in the real world as quickly as possible and build your portfolio. So say yes to every websites including unpaid ones.
  3. You need to build your portfolio to make it strong. So where do you put your work? Well, this can be your own web site and I recommend this if you want to look professional. You can host it on GitHub.com and GitHub.io all for FREE and you can buy your own domain also if you like.
  4. Find a mentor and join local or online coding groups.
  5. There are plenty of open source projects today. You can contribute little by little in those projects to make familiar with the web development world

December 5, 2017

Time Saving Tips for AngularJS Developer

Here are some of the tips while learning and coding on angularjs.

At a high / architecture level:

  1. Do not forget to write your tests. In Javascript, you don't have the compiler to hand hold you and tell you that you did something wrong. And you will want to pull your hair out the next time your app is broken because of a missing letter. And the large your application gets, having the comfort of making large scale changes and refactorings without worrying about broken functionality is amazing. And writing your unit tests is the only way to get there.
  2. Don't put too many things on the scope. The scope is expensive, as it is the one that undergoes dirty checks. Just put exactly what will be displayed on the UI on the scope, and leave the rest as variables in the controller, but not on the scope.
  3. Data is the truth. Let the data drive the app, and not any other way. You should purely focus on getting the data in the right places. The route controlling logic, the watches and the data binding should drive what is visible in the UI.
  4. If you need a UI widget like datepicker, autocomplete then think directive. Wrap all your third party components in directives for easy reuse, as well as to make your app modular. Being able to write <input datepicker> is way better than writing <input id="myinput"> and then in JS, $('#something').datepicker().
  5. Don't do DOM manipulation in your controllers, as well as your services. Try to restrict that work to directives.
  6. If you need to communicate between controllers, there are basically two options. Either create a service which is sigleton and use it to communicate or fire events on the scope, and have the other controller watch. Don't create your own new way outside of these two.
  7. Dependency Injection: Understand it, love it, breathe and live it. That should be the one and only way you ask for and work with services or any dependencies from any of your code.
  8. For directives, try and isolate the scopes so that you can reuse them without worries. Isolating the scope ensures that your directive does not depend on some particular method / variable on a parent scope, and thus can be reused. Pass in whatever you need as arguments to the directive. Use the databinding to ensure you get the updated value instead of the value at that instant.

How to Generate Random Number within the range

This example shows how to generate random number from the range of number given.
function generateRandomNumber(minNum, maxNum) {
        return Math.floor(Math.random() * (maxNum- minNum+ 1)) + minNum;
}
generateRandomNumber(5, 15);

Above code will generate random number between 5 and 15.

Cool JavaScript Tricks

Today I would like to mention some of the JavaScript tricks that many JavaScript programmers do not know. They are cool to have in our code, but some are not practiced in real world. Here are few of them.
  1. Use of .call() function:
    If you want to iterate over the properties of object.
    var listitems = document.querySelectorAll('li'); 
    [].forEach.call(items, function(item) {
    //your code here
    })
    
    Above code does the same as the code below
    for (i = 0; i < items.length; i++) {
    var item= items[i];
    // your code here
    }
    Reversing a string:
    var js = 'hello javascript';
    var sj = [].reverse.call(hey.split('')).join(''); // "tpircsavaj olleh"
    console.log(sj);
  2. Always use var while declaring variable for the first time.
  3. Use === instead of == .
  4. undefined, null, 0, false, "", NaN are all false values.
  5. Use semicolon (;) for line termination.
  6. Get random item in an array.
    var items = [12, 548 , 'a' , 2 , 5478 , 'foo' , 8852, , 'Doe' , 2145 , 119];
    var random = items[Math.floor(Math.random() * items.length)];
    
  7. Verify that the given argument is number
    function isNumber(n){
        return !isNaN(parseFloat(n)) && isFinite(n);
    }

November 24, 2017

Factorial By Recursion


import java.util.Scanner;

public class RecursionEx {
 //main
 public static void main(String args[]){
  Scanner temp = new Scanner(System.in);
  System.out.println("Enter number to find its factorial: ");
  long x = temp.nextLong();
  System.out.println(fact(x));
  
 }
 
 //fact
 public static long fact(long n){
  if(n<=1)
   return 1;
  else
   return n * fact(n-1);
 }
}

November 23, 2017

Program to sort numbers

class Sorting{
 public static void main(String args[]){
  int number[]={55,40,70,80,90,21};
  int n = number.length;
                System.out.print("Given list:");
                for (int i=0;i<n;i++)
                {
                    System.out.print("\t"+number[i]);
                }
                System.out.println("\n");
            //Sorting begins
                for(int i=0;i<n;i++){
                    for (int j=i+1;j<n;j++){
                        if (number[i]<number[j]){
                            //interchange values
                               int temp=number[i];
                               number[i]=number[j];
                               number[j]=temp;
                        }
                    }
                }
                System.out.print("Sorted list:");
                for(int i=0;i<n;i++){
                    System.out.print("\t"+number[i]);
                    
                }
 }

Hello World in JAVA

It is the trend to write the program to print "Hello World" while starting with any language. We will also do the same. Below is the program and I will also explain useful things used in program.

class Hello{
 public static void main(Strings[] args){
   System.out.println("Hello World!!!");
 }
}
  1. Open any text editor and write the above program. Note that some are in capital letters.
  2. Now save the file with name Hello.java
  3. Open command prompt and browse the location where the file is located.
  4. For eg: If the file is located in c:/javatut/ then goto the same folder location in cmd.
  5. Now type javac Hello.java
  6. This command will compile your java file and creates class file.
  7. Now type java Hello
  8. If the compilation worked then you will get the output.

Some explanations

  • The first statement defines the main class which is required and the class name should be in initial capital letter.
  • The second statement defines the main function or method of the class. The first letter of String is capitalized as it is the class name.
  • The third statement is used to display output. First letter of System is capitalized and the println statement creates new line after the output. You can also sumply use print only.

Basic rules while programming in JAVA

There are some of the ground rules while you are programming in JAVA. Before we start on writing the first program we will talk about common rules you must follow, which you must mock up.

  • The file name must be same as the main class name you used.
  • Class name must be start with the initial capital letter. Java is case sensitive language.
  • Any classes you used in the program must start with the capital letter and the method name with small letter.
  • The class file is obtained after the compilation of the program and it is the bytecode that can run in any platform which hava JDK.
We will start with the first program and syntax in out next post. Till then stay tune...

How to set path for JDK

In the previous post i have mentioned about the software and hardware requirements to get started with java programming. Only having those requirements is not enough. We need to set path of the JDK as the environment variables. There are two ways for doing this.

Process 1

We can set the path from the command prompt. The steps are mentioned below.
  1. Open the command prompt.
  2. Type javac and press enter.
  3. If the result is shown as the command is not recognized, that means path is not set. Or if some help commands are shown then path is already set.
  4. To set path first you need to copy the location of jdk installed in your drive.
  5. Goto c:\program files and find java folder. Inside the java folder search for folder with jdk and its version. Inside it goto bin folder. And click on any file and view properties and there copy the path. It looks like this "C:\Program Files\Java\jdk1.5.0_09\bin" . Copy it.
  6. In the command prompt, type "set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin" without the double quotes. The path is only sample example. It may vary according to the JDK version.
  7. Now to check whether the path is set correctly or not, type javac and press enter. Now the results are shown instead of showing error. Now you can run the java program.

Process 2

  1. Goto the windows properties.
  2. Click on advanced system setting.
  3. Click the environment variables.
  4. In the system variables, click on add new.
  5. Then enter "PATH" in variable name and in the variable value enter the path that is copied as in process 1.
  6. To check do as in process 1.
Sometimes following process 2 may not work properly, so process 1 is followed mostly. In the next post I will write the first program and ways to run in the command prompt.

November 14, 2017

10 Ways to Become a Better Developer

  1. Read other people's code.
  2. Get someone to read your code.
  3. Fix bugs before writing new code.
  4. Learn a new technology.
  5. Keep it simple.
  6. Write a blog post about your code.
  7. Contribute to open source.
  8. Fix it, Don't hack it.
  9. Increase code coverage by 1%.
  10. Leave your desk every hour.

Future For Computer Geeks

This generation that we are living is the computer age. Everything in this today's world are somehow connected to the computer and the technology. Alright lets just talk about the computer. For those who want their future in the computer may be for engineers, programmers, designers and so on they have a very bright future if only they can struggle. Many people in this field have earned much more wealth and this is just in increasing trend. So in this blog i am writing about everything for a computer geek. If you are also a beginner in this field then every post are equally important. I will post the tutorials, codes, important steps and many more here. What you mist do is stay tuned.

We will soon meet in next post.


How to fix Duplicate error with ng-repeat in angularjs

While working with angularjs directive ng-repeat, you may have encountered with the problem of duplicate error with ng-repeat. Here is the proper description and problem and the solution of it.
In order for angular to know exactly what items have changed, it calculates a hash for each item within the ng-repeat. Otherwise, if you had 5 items with the exact same contents, how would it be able to determine which of those items was modified? When it determines that duplicates exist, it prints out that error.
In this case, to get around this, there's a track by expression that you can add to the end of the ng-repeat expression. This expression lets you define a property that uniquely identifies each item in the array. For arrays with primitive types, one approach is to use track by $index which tracks each item in the array by the objects position within the array.
  
<div ng-repeat="num in [1, 2, 2, 3] track by $index">
 {{num}}
</div>
  
 
By adding the track by $index, you will not get the duplicate error. 

September 24, 2017

How to choose the right laptop for programming

For the best result in the programming one must be very careful while choosing right laptop. Choosing the right laptop for programming can be a tough job. So you must have proper research on this matter. It’s easy to get confused while researching the various options. There are many different laptop models out there, each with a different set of trade-offs.


You can write code on most laptops. Yet, your productivity will improve if you use a machine suited to the type of tasks that you perform. There are different types of development, and various tools are required with each specialization. So, there is no one-size-fits-all approach to buying a development machine.
Hence, I made the following assumptions in this article:
  1. You are a web developer.
  2. Your laptop is your primary development machine.
Here are some considerations before purchasing your next laptop.

Mobility

Laptops come in all shapes and sizes. You need to figure out how portable you want your laptop to be. If you do not need to carry your laptop around often, you might want to consider a 15'' laptop. These will usually have better specs and more screen estate for multitasking. If you work in different locations or travel a lot, a 13-14'' laptop may be best for you. They are lighter and provide longer battery life. Unless you’re buying a 2-in-1 laptop, a touchscreen does not provide enough benefits to justify the extra cost. I’d suggest you avoid the touchscreen.