Sponsored Links

December 29, 2017

How to Find any Wi-Fi Password on Windows

Sometimes you may forget the wifi password of your network you are connected or it may be difficult to remember password. So here is the simple command line trick to find out the password. Follow these steps if you’re using Windows 7,8 or 10.

  • Open CMD as an administrator.
  • Paste the following code:
  • netsh wlan show profiles
    You will get a list of the networks that are known to your computer.
  • Now paste the following code. Replace "profilename" with the network name.
  • netsh wlan show profile name=profilename key=clear
    Look for the "Content Key". That is your password.

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 13, 2017

Rare Euro Coins

2 Euros coin dedicated to Grace Kelly was put into circulation in 2007, and it costs between 600 to 1,000 euros. Just 20,000 of them were made. 1 Italian cent was released in Italy 15 years ago, and costs around 6,000 euros. Why? The coins, issued in 2002 have the same design as 2-cent coins.

December 9, 2017

How to clean your Windows Temp folder

The temp folder contains files that are only needed temporally. Unfortunately, these files that are meant to be deleted don't always get deleted after their job is done, resulting in wasted drive space.

To open the temp folder, click Start or go to the Windows 8 Search, type %temp%, and select the folder that appears first. Once the folder is opened, you can manually delete files and folders. But you probably can't delete all of them. Windows won't let you do away with those currently in use. That's fine. You don't want to delete those ones anyway.

In fact, you really don't want to delete any files created since the last time you booted your PC. So if you shut down Windows every night (and I mean shut it down, not sleep or hibernate), and boot clean every morning, you can safely delete any files in Temp not dated today. You can easily do it in an old-fashioned way, DOS-style batch file to automatically clean out the folder every time you boot. Here's the process:

Open Notepad, and type these two lines:

    rd %temp% /s /q
    md %temp%

Save the file as %appdata%\microsoft\windows\start menu\programs\startup\cleantemp.bat. This will create the batch file, cleantemp.bat, inside your Start menu's Startup submenu. Everything in that menu loads automatically when you boot. Windows 8 doesn't have a Start menu. But it still has the folder. And the trick still works.

Enjoy!!!

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.

Basic Linux Commands

Below are some of the commonly used linux commands.
Note: Think twice before using rm -rf / command. :D

Regular Expressions in JavaScript with Examples

Example 1 : To return all the matched strings
var a = "This is regular expression example.";
var regex = /regular/g; // to find string regular
var matches = a.match(regex);


Example 2:  To return all matched numbers
var a = "This is 1 apple, this is 2 apple";
var regex = /\d+/g;
var matches = a.match(regex);

Example 3:  To return number of spaces in the sentence
var a = "How many spaces are there in this sentence?";
var regex = /\s+/g;
var matches = a.match(regex).length;

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 jQuery Tricks

Some of cool jQuery functions usage:
1. To add bounce animation to any element:
 $(elem).addClass("animate bounce");

2. To add shake animation to any element:
 $(elem).addClass("animate shake");

3. To disable buttons or any control elements:
$(elem).prop("disabled", true);
You can also use attr() function, but attr() is deprecated. So use prop().

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);
    }

Automatically join any group when new user registers in Buddypress


function auto_join_group($user_id, $group_id) {
    if( !$user_id ) return false;

    // Join user to group with group id $group_id
    groups_accept_invite( $user_id, $group_id);
}

add_action( 'bp_core_activated_user', 'auto_join_group' );

Useful Buddypress Functions

bp_loggedin_user_id() = Get logged in user id
bp_displayed_user_id() = Get id of displayed user
bp_core_get_username($user_id) = Get username for the given id

Programmatically login user in wordpress

/**
 * Programmatically logs a user in
 *
 * @param string $username
 * @return bool True if the login was successful; false if it wasn't
 */
function programmatic_login( $username ) {
   // if user is already logged in then first log out
    if ( is_user_logged_in() ) {
        wp_logout();
    }

    add_filter( 'authenticate', 'allow_programmatic_login', 10, 3 );
    $user = wp_signon( array( 'user_login' => $username ) );
    remove_filter( 'authenticate', 'allow_programmatic_login', 10, 3 );
 
    if ( $user instanceof WP_User ) {
        wp_set_current_user( $user->ID, $user->user_login );

        if ( is_user_logged_in() ) {
            return true;
        }
    }

    return false;
}

/**
 * An 'authenticate' filter callback that authenticates the user using only the username.
 *
 * To avoid potential security vulnerabilities, this should only be used in the context of a programmatic login,
 * and unhooked immediately after it fires.
 *
 * @param WP_User $user
 * @param string $username
 * @param string $password
 * @return bool|WP_User a WP_User object if the username matched an existing user, or false if it didn't
 */
function allow_programmatic_login( $user, $username, $password ) {
    return get_user_by( 'login', $username );
}