Thursday, October 8, 2015

Edit Mac Hosts File In Terminal With Nano

you can edit host file directly in Terminal using the UNIX Nano Text Editor, which is built in to OS X.

To get started, launch Terminal, type the following command, and press Return. As with all sudo commands, you’ll need to also enter your admin password to execute it:

sudo nano /private/etc/hosts

You’ll now see the hosts file open in the Nano editor. To navigate and edit the file, use the arrow keys on your keyboard.



Just as we did with the TextEdit method, above, we can add, edit, or remove hostname mappings at will. Because we launched Nano using sudo, any changes will be authenticated and saved directly to the original hosts file, without the need to copy it outside of its home directory.

When you’re done making changes, press Control-X to exit the editor, Y to save, and Return to overwrite the existing hosts file. As we mentioned earlier, make sure to flush your DNS cache if you notice that your new mappings aren’t working properly.
Share your thoughts

Thursday, October 1, 2015

How to Check checkbox checked property using JQuery



Question:I need to check the checked property of a checkbox and perform an action based on the checked property using jQuery.

For example, if the age checkbox is checked, then I need to show a textbox to enter age, else hide the textbox.

But the following code returns false by default:
if($('#isAgeSelected').attr('checked')) {
$("#txtAge").show();
} else {
$("#txtAge").hide();
}
How do I successfully query the checked property?

Answer1:
The .checked property of a checkbox DOM element will tell give you the checked state of the element.

Given your existing code, you could therefore do this:
if(document.getElementById('isAgeSelected').checked) {
$("#txtAge").show();
} else {
$("#txtAge").hide();
}
However, there's a much prettier way to do this, using toggle:
$('#isAgeSelected').click(function () {
$("#txtAge").toggle(this.checked);
});



Answer2:
Use jQuery's is() function:
if($("#isAgeSelected").is(':checked'))
$("#txtAge").show();  // checked
else
$("#txtAge").hide();  // unchecked
Source : Stackoverlow
Share your thoughts