Full Trust European Hosting

BLOG about Full Trust Hosting and Its Technology - Dedicated to European Windows Hosting Customer

European Visual Studio 2017 Hosting - HostForLIFE.eu :: Visual Studio IntelliCode Preview Available

clock August 24, 2018 11:08 by author Peter

Recently, Microsoft has announced the availability of Preview of Visual Studio IntelliCode in its Build 2018 developer’s conference. This is a new experimental tool for Visual Studio users bringing more of the company’s artificial intelligence smart to software development.

It is a set of AI-assisted capabilities which improves the developer’s productivity with features like contextual, IntelliSense and focused reviews for pull requests.
 
The company states -
“The IntelliCode extension augments productivity features in Visual Studio 2017 with insights based on understanding your code combined with machine learning. The first iteration of this extension enhances your IntelliSense experience by sorting completion items—which are recommended in your code context--to the top of the list.”
 
According to the company, IntelliCode is now applicable only for C# code but in future, it will be upgraded to support more languages.

 



Windows Server 2016 SSD Hosting - HostForLIFE.eu :: How To Securely Delete Files From Your Servers?

clock August 15, 2018 11:40 by author Peter

Do you know what happens when you delete a file in a GUI or run rm file.txt on the command line? If you said the file is deleted, you are only half right. In fact, the data stays just where it was before you “deleted” it. You can’t see it because the link the operating system used to identify the file and show it to you no longer exists. But the data is untouched until the operating system uses the space for a different file.

It’s easy to restore data that has not been securely deleted. That’s bad news if the hard drive the data is on is sold, leased to someone else, or thrown in the trash. There are business, security, and legal consequences if server data is not securely deleted.

The only way to securely delete data is to overwrite it. You could also destroy the drive, but businesses typically lease servers that they don’t have physical access to or they own. They need to be able to securely delete data remotely. A quick rm doesn’t cut it.

Before I outline the best way to securely delete a file or volume, a word of warning. If you do this, the data will be gone forever — that’s the point. Before running any of these commands, make sure you really mean it.

Securely Deleting A File

As I have already said, rm removes directory entries. It does not delete data. To securely delete the data, you must use a tool that both removes the link and overwrites the data.

One such tool is shred, which will repeatedly overwrite the file’s data with random bytes.

shred -u file.txt

Shred overwrites the file three times with random data, although you can specify how many times the data is overwritten with the -n option. If you don’t use the -u option, shred will overwrite the data but it won’t remove the file.

Securely Deleting A Drive

The shred utility can securely erase drives, but we’ll explore an alternative.

Before running these commands, check that you have correctly identified the drive you want to erase. The command will run on the boot and root drives without warning.

Linux represents drives as files. For example, the file /dev/sda1 represents the “first” drive on your server. The dev directory is not a normal directory, but a collection of special files representing devices connected to the server.

To see the drives connected to a server, run this command,

`fdisk -l`

Identify the drive that you intend to erase all data from and take note of the special filename. We’re going to use dd to overwrite the data on this drive with either random data or zeroes. The dd command “converts and copies a file”.

In this case, we’re going to take data from a special file and overwrite our target drive with it. Linux provides several special files that generate a stream of data, including /dev/zero and /dev/urandom, which contain lots of zeros and pseudorandom data respectively.

dd if=/dev/urandom > /dev/ss__ # replace __ with drive number

Here, we designate /dev/random as the input file and direct its data to overwrite the drive. This will destroy all data on the drive.

For added security, you can repeat the dd command several times or alternate between random data and zeros with:

dd if=/dev/zero of=/dev/sd__ # replace __ with drive number

On modern high-density drives, multiple passes are usually not necessary, but it doesn’t hurt.

Limitations

There are some limitations to this approach that you should be aware of. If the data is being backed up to a different drive, it may remain accessible. If the drive uses a modern journaling filesystem like ext4, some data may not be erased properly. SSD wear leveling can also interfere with secure deletion.

For sensitive data, it may be best to use an encrypted volume rather than relying on secure deletion. The data from an encrypted volume cannot be recovered without the key even if it has not been securely deleted.



European Visual Studio 2017 Hosting - HostForLIFE.eu :: Customize Visual Studio Code Shortcuts

clock August 10, 2018 11:13 by author Peter

A couple of months ago, I started using Visual Studio Code for my development activities. I found myself very uncomfortable with the keys and shortcuts. I have been using Visual Studio for more than 6 years now. So, I was very comfortable with the keys and shortcuts of that. The difference in shortcuts was creating a challenge for me. Should I remember a different set of shortcuts for VS Code? Should I start using some other editor?

Then, I started to customize the VS Code shortcuts. If you are also facing the same issues, then it's time you should consider customizing the Visual Studio Code shortcuts. It’s not worth spending energy on remembering a new set of shortcuts for a specific editor. Following are some tips,

  1. Open keyboard shortcuts in Visual Studio Code and update the shortcuts as per your need.
    Press ctrl+K, ctrl+s to open the keyboard shortcut window. This looks something like below.
  2. You can see the Edit button on the right side of the row (highlighted one). On click of the Edit button, it will ask you to change the combination you want to execute the command for.

    You can change the combination for your convenience.

  1. You can open keybindings.json file and update as per your need.
    To open the keybindings.json, you need to open the Keyboard shortcuts first by pressing ctrl+k, ctrl+s. You can click on the keybindings.json file.
  2. This will open the default keybindings. This is a JSON file which can be modified to get your desired shortcuts.
  1. You can have your custom JSON file with your shortcut commands.
    When you open default keybindings.json file in the right-hand side window, it opens a keybindings.json file where you can write your custom keys and commands.

Given are a couple of commands I have added in the keybindings.json file to work with the VS Code. Please let me know your feedbacks/ comments. Are there better ways I am not just aware of?



Node.js Hosting in Europe - HostForLIFE.eu :: Forgot Password Email Notification Using Node js

clock August 8, 2018 09:22 by author Peter

Before starting the code you need an account in send grid which will send the notification to your mail. Generally we use email notifications for forget passwords in your applications. You can follow the below steps to get the task done and if you have any queries please leave a comment below.

We require a few modules from npm to send the notification through the mail.

  • npm install formidable
  • npm install crypto
  • npm install async
  • npm install nodemailer

In my router.js file the following code will be present 
app.route('/forgotpasswordResponse') 
.post(userCtrl.forgotpasswordResponse); 


When I run my services and hit the above Url  from postman it will take you to the forgotpasswordResponse method. We are using post method in postman where we need to pass Email id as parameter

In forgotpasswordResponse my code is somthing like this,
exports.forgotpasswordResponse = function(req, res, next) { 

var input=req.body; 
//console.log(input); 
async.waterfall([ 
function(done) { 
    crypto.randomBytes(20, function(err, buf) { 
        var token = buf.toString('hex'); 
        done(err, token); 
    }); 
}, 
function(token, done) { 
    MongoClient.connect(url, function(err, db){  
        var dbo = db.db("Here is your DB Name"); 
        //console.log(req.body.Email); 
        var query = { Email : req.body.Email }; 
        dbo.collection('CLC_User').find(query).toArray(function(err,result){ 
            if(result.length == 0){ 
                req.flash('error', 'No account with that email address exists.'); 
            } 
            var myquery = { Email: result[0].Email }; 
            var newvalues = { $set: {resetPasswordToken: token, resetPasswordExpires: Date.now() + 3600000 }}; 
            dbo.collection("CLC_User").updateOne(myquery, newvalues, function(err, res) { 
                if (err) throw err; 
                console.log("1 document updated"); 
            }); 
             

           // console.log(result[0].Email); 
            done(err, token, result); 
        }); 
    }); 
}, 
function(token, result, done,Username,password) { 
    var emailVal = result[0].Email; 
    console.log(emailVal); 
    var Username=""; 
    var password=""; 
    MongoClient.connect(url, function(err, db){  
    var dbo = db.db("Here willbe your db name"); 
    dbo.collection('Accountsettings').find().toArray(function(err,result){ 
        if (err) throw err; 
        Username=result[0].UserName; 
        password=result[0].Password; 
       // console.log(Username); 
       // console.log(password); 
           // res.json({status : 'success', message : 'Records found', result : result}); 
     

    // console.log(Username); 
    var smtpTransport = nodemailer.createTransport({ 
        service: 'SendGrid', 
        auth: { 
          user: Username, 
          pass: password 
        } 
      }); 

    const mailOptions = { 
        to: emailVal, 
        from: '[email protected]', 
        subject: 'Node.js Password Reset', 
        text: 'You are receiving this because you (or someone else) have requested the reset of the password for your account.\n\n' + 
            'Please click on the following link, or paste this into your browser to complete the process:\n\n' + 
            'http://' + req.headers.host + '/reset/' + token + '\n\n' + 
            'If you did not request this, please ignore this email and your password will remain unchanged.\n' 
    }; 
    smtpTransport.sendMail(mailOptions, function(err) {                
        console.log("HI:"+emailVal); 
        res.json({status : 'success', message : 'An e-mail has been sent to ' + emailVal + ' with further instructions.'});             
        done(err, 'done'); 
    }); 
}) 
}); 

 
], function(err) { 
if (err) return next(err); 
 
}); 


In my case  I am using waterfall methologie for this method with will execute acyn in method, In the above code initially I am updating the collection with resetPasswordToken and resetPasswordExpires using email id and getting my send  grid credentials from db form  Accountsettings collections. If you can observe in mailOptions text "req.headers.host" will be the link which will get in you mail with token.

When you click on Url which you got in the email it will redirect you to another page to set the password.

Again we need to go to route.js and the code will be some thing like this. It will take to html page which we can reset the password,
app.route('/reset/:token') 
.get(Resetpassword.resetpasswordResponse);  

This time I am passing the token which I stored in db as "resetPasswordToken". Now it will take you to resetpasswordResponse method and the code is below,
exports.resetpasswordResponse = function(req, res) { 
console.log("welcome"); 
MongoClient.connect(url, function(err, db){ 
var dbo = db.db("Here is you db"); 
dbo.collection('CLC_User').findOne({resetPasswordToken: req.params.token, resetPasswordExpires: { $gt: Date.now() } }, function(err, user) { 
    if (!user) { 
        res.json({message: 'Password reset token is invalid or has expired.'}); 
    }else{ 
        console.log("coming"); 
        fs.readFile("api/Controllers/resetpassword.html", function (error, data) { 
            console.log("its working"); 
            if (error) { 
                console.log(error); 
                res.writeHead(404); 
                res.write('Contents you are looking are Not Found'); 
            } else { 
                //res.writeHead(200, { 'Content-Type': 'text/html' }); 
                res.write(data); 
            } 
            res.end(); 
        }); 
    } 
}); 
}); 


Your html code in resetpassword.html will be like this,
<!DOCTYPE html> 
<html> 
<head> 
<title>Reset Password</title> 
<script src="https://code.jquery.com/jquery-1.12.4.js"></script> 
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 
</head> 
<body> 
<h4 class="postdata" style="text-align:center;"></h4> 
<div class="main-agileits"> 
<h2 class="sub-head">Reset Password</h2> 
<div class="sub-main">     
    <form method="post"> 
        <span class="senddata"></span><br><br> 
             
        <input placeholder="Enter Password" name="password" class="password" type="password" required=""><br><br> 

        <input placeholder="Confirm Password" name="confirmpassword" class="confirmpassword" type="password" required=""><br><br> 
         
        <input type="submit" name ="submit" value="RESET PASSWORD"> 
         
    </form> 
</div> 
</div> 
</body> 
</html> 


<script type="text/javascript"> 

$( document ).ready(function() { 
$("input[name='submit']").on("click", function(){ 
$(".senddata").html(""); 
var url = window.location.href; 
var password = $('.password').val(); 
var confirmpassword = $('.confirmpassword').val(); 

if( password == confirmpassword){ 
    $.post(url,{Password : password},function(result,status){ 
    var msg = result.status; 
    var msgdata = result.message; 
    if(msg == "success"){ 
        $(".postdata").html(msgdata); 
        $(".main-agileits").css("display","none") 
    }else{ 
        return false; 
    } 
}); 
}else{ 
    $(".senddata").html("Passwords did not match"); 
}        
return false; 
}); 

}); 

</script>


the next step is send the Email notification after changing the password.The code is
app.route('/reset/:token') 
.post(setpassword.setpasswordResponsemail); 

exports.setpasswordResponsemail = function(req, res) { 
async.waterfall([ 
function(done) { 
    MongoClient.connect(url, function(err, db){ 
        var dbo = db.db("Your Db name goes here");  
        dbo.collection('CLC_User').findOne({resetPasswordToken: req.params.token, resetPasswordExpires: { $gt: Date.now() } }, function(err, user) { 
            if (!user) { 
                res.json({message: 'Password reset token is invalid or has expired.'}); 
            } 
            //console.log(user); 
            var myquery = { resetPasswordToken: req.params.token }; 
            var newvalues = { $set: {Password: req.body.Password,resetPasswordToken: undefined, resetPasswordExpires: undefined, modifiedDate : Date(Date.now()) }}; 
            dbo.collection("CLC_User").updateOne(myquery, newvalues, function(err, result) { 
                if (err) throw err; 
                //console.log("result ======" + result); 
                console.log("1 document updated"); 
            }); 
            done(err, user); 
        }); 
    }); 
}, 
function(user, done) { 
    MongoClient.connect(url, function(err, db){  
        var dbo = db.db("Your db name goes here"); 
        var Username=""; 
        var password=""; 
        dbo.collection('Accountsettings').find().toArray(function(err,result){ 
            if (err) throw err; 
            Username=result[0].UserName; 
            password=result[0].Password; 
        }) 
    }) 
    var smtpTransport = nodemailer.createTransport({ 
        service: 'SendGrid', 
        auth: { 
            user: Username, 
            pass: password 
        } 
    }); 
    var mailOptions = { 
        to: user.Email, 
        from: '[email protected]', 
        subject: 'Your password has been changed', 
        text: 'Hello,\n\n' + 
            'This is a confirmation that the password for your account ' + user.Email + ' has just been changed.\n' 
    }; 
    smtpTransport.sendMail(mailOptions, function(err) { 
        res.json({status : 'success', message : 'Success! Your password has been changed.'}); 
        done(err); 
    }); 

], function(err) { 
if (err) return err; 
}); 
}

Hope this code will help someone who really needs  it. Thank you.



European Visual Studio 2017 Hosting - HostForLIFE.eu :: How To Open Browser Or Run Program Directly From Visual Studio Code

clock August 3, 2018 09:39 by author Peter
Visual Studio Code is a Editor for running your code efficiently. It is now very popular editor for running your Source Code. Its features are very awesome and anyone can shift to Visual Studio Code. The best part is, it is free to use and free to download. The developers who are get bored from the OLD, Simple looking, Boring HTML code Editors can also shift to Visual Studio Code. It is Developed by Microsoft.Nowadays developers facing problems while running a simple HTML code directly from the Editor as Visual Studio Code does not have any in-built direct feature to run the code like other Editors or its own Visual Studio. But here is a solution to run the code directly from the Editor.

Start the Visual Studio Code Editor. On the left panel click on the Extensions Tab. Or Press (Ctrl + shift + X)


Then in the search bar search for "open in browser". You will get a list of plugins. For simplicity select first plugin and click install

After completion of the installation process it will ask for RELOAD.Just RELOAD the VSC(Visual Studio Code) Editor it will not cause any damage to your unsaved data.

After reloading just right click on your html file and select "Open in Other Browsers".

Select your required Browser and See your Output.

Another way to run is a Short cut key from your keyboard is (Alt+Shift+B).



About HostForLIFE

HostForLIFE is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2019 Hosting, ASP.NET 5 Hosting, ASP.NET MVC 6 Hosting and SQL 2019 Hosting.


Tag cloud

Sign in