Category: Code

  • How to Run Node.Js Application as Different User?

    In your .env file add USER=www-data Note: I have choose to run node as the user www-data you can choose any other appropriate one. Now Run $ npm i userid –save At the top of your app.js or index.js file add const userid = require(‘userid’);const user = process.env.USER;const uid = parseInt(user), 10);// Set server’s uid […]

  • Permanently (301) Redirect Old Domain URL to New Domain URL Using .htaccess – Linux Server

    [php] # BEGIN WordPress RewriteEngine On RewriteCond %{HTTP_HOST} ^ RewriteRule (.*)$1 [R=301,L] # END WordPress [/php] Make sure to change url for and

  • How to Convert GET URL Structure to Array and Reverse

    [js] function URLToArray(url) { var request = {}; var pairs = url.substring(url.indexOf(‘?’) + 1).split(‘&’); for (var i = 0; i < pairs.length; i++) { var pair = pairs[i].split(‘=’); request[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); } return request; } function ArrayToURL(array) { var pairs = []; for (var key in array) if (array.hasOwnProperty(key)) pairs.push(encodeURIComponent(key) + ‘=’ + encodeURIComponent(array[key])); return […]

  • How to Get Posts Using Post IDs in The Order It was Given on WordPress?

    How to Get Posts Using Post IDs in The Order It was Given on WordPress?

    Example: We have an array containing post ids [php] $post_ids = array(56, 4, 66, 34, 56, 6); [/php] Now if we want to get those posts we can use any of wordpress query functions such as get_posts(), query_posts() or WP_Query. In the order they will be received you can control it via ‘orderby’ and ‘order’ […]

  • How to Fix WordPress 404 Permalink Error on Localhost

    How to Fix WordPress 404 Permalink Error on Localhost

    Go to your servers httpd.conf file and open it up with notepad or any text editor (not MS word!). Now press ctrl+F to open up the search function and search for this line # LoadModule rewrite_module modules/ and remove the # before the line. Restart the server. If you still having problem please comment and […]

  • How to Remove Bubble – Google Maps

    How to Remove Bubble – Google Maps

    To remove the Address or Info Bubble on Google Map embed code you will need to set iwloc parameter something other than default on source attribute of iframe tag. First copy your embed from google map and paste on any text editor and find check if the iwloc parameter already exists if it exists then […]

  • How to Check on jQuery if a DOM Element Exists

    Below is how you will able to know if a dom element exists 🙂 Quite simple! [javascript] if($("#dom").length > 0){ //dom exists }else{ //dom doesn’t exists } [/javascript]