Author: Bunty ( Site Admin )

  • Fix 404 error on nginx

    Fix 404 error on nginx

    Sometimes you get unexpected 404 error from Nginx server. And I am going to tell you how I fixed the issue.

    You can fix that easily by the following steps:

    Step 1 (Debugging):

    You first need to find out the reason. For that, you can the first login to your server via ssh and check the error log for Nginx server.

    Open the following file: /var/log/nginx/error.log and check the latest errors.

    In my case I was having the following error:

    2020/02/28 08:19:02 [error] 17627#17627: *14299 upstream sent too big header while reading response header from upstream, client: 172.31.4.43, server: yoursite.com, request: "GET /wp-login.php?action=switch_to_user&user_id=2928&nr=1&_wpnonce=9085bda773&redirect_to=https%3A%2F%yoursite.co%2Fmembers%2Fdesigner-buddyboss%2F HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.1-fpm.sock:", host: "yoursite.co", referrer: "https://yoursite.co/members/designer-buddyboss/"

    Step 2 (Solution):

    After exploring on google I found this solution which worked for me. We need to add the following lines into the Nginx config file:

    client_max_body_size 128m;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;

    Now the following file could be responsible for your site:

    Check if this file available /etc/nginx/sites-enabled/your_site.conf ( This was the responsible file in my case )

    OR

    /etc/nginx/sites-available/your_site.conf

    OR

    /etc/nginx/sites-available/nginx.conf

    Open one of the files.

    Step 3 (Apply Solution):

    Now add those 3 lines into the config file like this

    After adding this restart Nginx server by the following command:

    sudo service nginx restart

    That’s it!!!!

  • 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