Author: Bunty ( Site Admin )

  • go to particular commit in git

    Safe way to do this by creating a new branch with a particular commit hash.

    Here is an example:

    git checkout -b new_branch 6e559cb( replace with your hash )

    That’s it!!!

  • Apply svn patch and then undo the same patch via command line

    Apply svn patch

    patch -p0 -i path_of_patch_file.patch
    
    Example: patch -p0 -i /Users/blah/Downloads/7526.2.patch

     

    Undo svn patch

    svn patch --reverse-diff path_of_patch_file.patch
    
    Example: svn patch --reverse-diff /Users/blah/Downloads/7526.2.patch
  • Abort all running ajax on click jQuery

    There may be times you want to stop ajax request on some event like on click, hover etc…

    In my case, I wanted to run an ajax on click, but I wanted to cancel all other ajax request to be stopped before my ajax. So after lots of finding I found one solution here.

    I used the last snippet because I didn’t get how I to use the above 2 snippets.

    Below is the code worked for me:

    $( document ).on( 'ready', function () {
    
    	var xhrQueue = []; 
    
    	$(document).ajaxSend(function(event,jqxhr,settings){
    	    xhrQueue.push(jqxhr); //alert(settings.url);
    	});
    
    	$(document).ajaxComplete(function(event,jqxhr,settings){
    	    var i;   
    	    if((i=$.inArray(jqxhr,xhrQueue)) > -1){
    	        xhrQueue.splice(i,1); //alert("C:"+settings.url);
    	    }
    	});
    
    	window.ajaxAbort = function (){  //alert("abortStart");
    	    var i=0;
    	    while(xhrQueue.length){ 
    	        xhrQueue[i++].abort(); //alert(i+":"+xhrQueue[i++]);
    	    }
    	};
    
    })
    

    Then I used ajaxAbort(); on my click event. And that’s it!!! All the previous ajax is stopped as shown in the video.

     

  • Fix Node Sass does not yet support your current environment on macOS

    Video for who doesn’t like to read ;). And if you like the video then subscribe my channel and share this with others who has the same issue.

    Recently I came across this below error when I tried to run npm start command on my Mac.

    Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (79)
    For more information on which environments are supported please see:
    https://github.com/sass/node-sass/releases/tag/v4.12.0

    So you can fix this with 2 steps only.

    1. Open your package.json file and in “devDependencies” section, change “gulp-sass” version to “^3.0.1” and save the file.

     

     

     

     

     

     

     

    2. Run npm install

    After doing this, your issue should be fixed. Now you can run npm start

    And it’s done!!!!

    Ref: https://github.com/jakearchibald/wittr/issues/20#issuecomment-342740559

  • Change URL without reloading page using Javascript

    Change URL without reloading page using Javascript

    This will be possible if your browser supports HTML5. You can do that by below small code.

    var title = 'Your Title',
        url   = 'https://yoursite.url';
    if (typeof (history.pushState) != "undefined") {
        var obj = { Title: title, Url: url };
        history.pushState(obj, obj.Title, obj.Url);
    }

    You can remove a title from the object ( `obj` ) if you don’t want to change the page title. In that case, the second parameter in pushstate function will be blank. like below:

    history.pushState(obj, '', obj.Url);

    That’s it