Friday, August 25, 2017

Dynamically populate a select element from JSON data with jQuery/Ajax

<html>
  <head>
    <script type="text/JavaScript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
  </head>
  <body>
    <select id="people"></select>
  </body>

The JSON file we’ll be using consists of a collection of ‘person’ data in a valid JSON form, such as:
{"person": [
  {
    "id": "1",
    "name": "Person1"
  },
  {
    "id": "2",
    "name": "Person2"
  },
  {
    "id": "3",
    "name": "Person3"
  }

]}

  <script type="text/JavaScript">

//getJSON
    //get a reference to the select element
    var $select = $('#people');
    //request the JSON data and parse into the select element
    $.getJSON('person.JSON', function(data){
      //clear the current content of the select
      $select.html('');
      //iterate over the data and append a select option
      $.each(data.person, function(key, val){
        $select.append('<option id="' + val.id + '">' + val.name + '</option>');
      })
    });

//AJAX
//get a reference to the select element
$select = $('#people');
//request the JSON data and parse into the select element
$.ajax({
  url: 'person.JSON',
  dataType:'JSON',
  success:function(data){
    //clear the current content of the select
    $select.html('');
    //iterate over the data and append a select option
    $.each(data.person, function(key, val){
      $select.append('<option id="' + val.id + '">' + val.name + '</option>');
    })
  },
  error:function(){
    //if there is an error append a 'none available' option
    $select.html('<option id="-1">none available</option>');
  }

});
  </script>
</html>
https://developerdan77.wordpress.com/2011/10/14/dynamically-populate-a-select-element-from-json-data-with-jquery/

Thursday, May 11, 2017

Enable gzip compression

Enable compression via .htaccess

For most people reading this, compression is enabled by adding some code to a file called .htaccess on their web host/server. This means going to the file manager (or wherever you go to add or upload files) on your webhost.
The .htaccess file controls many important things for your site. If you are not familiar with the .htaccess file, please read my working with .htaccess article to get some know how before changing it.
The code below should be added to your .htaccess file...
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
Save the .htaccess file and then refresh your webpage.
Check to see if your compression is working using the Gzip compression tool.

Enable compression on Apache webservers

The instructions and code above will work on Apache. If they are not working there is another way that may work for you. If the above code did not seem to work, remove it from your .htaccess file and try this one instead...
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

Enable compression on NGINX webservers

To enable compression in NGINX you will need to add the following code to your config file
gzip on;
gzip_comp_level 2;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

# Disable for IE < 6 because there are some known problems
gzip_disable "MSIE [1-6].(?!.*SV1)";

# Add a vary header for downstream proxies to avoid sending cached gzipped files to IE6
gzip_vary on;

Monday, August 29, 2016

How to Check Your Motherboard Model Number on Your Windows PC

Whether you need to update drivers, want to check hardware compatibility, or you’re just curious, it’s way easier to check your motherboard model number with these simple tricks than it is to crack open your computer case to check the board itself. Read on as we show you how to check your motherboard model number from the comfort of your keyboard.

Why Do I Want To Do This?

There are a variety of situations where knowing your motherboard’s model number is important: upgrading your drivers, buying new hardware (you’ll need the proper expansion slots for card-based upgrades and the right memory DIMMS for memory upgrades, etc.), and checking the capabilities of your board if you’re considering upgrading the entire thing.
If you kept the paperwork that came with your computer (or the individual components if you built it yourself) you can often times reference that. Even then, it’s best to check to make sure the documentation is correct. Rather than open the case and search for the model number, it’s easy to use tools within Windows to check things out.

Checking Your Model Number via CMD.exe

If you’re comfortable using the command line, you can easily check a variety of motherboard and hardware stats using the handy Windows Management Instrumentation Command-line (WMIC) a command-line interface for Microsoft’s powerful WMI tool.

Tuesday, August 9, 2016

Configure Gmail to send/receive email via your Hostgator Email

Configure Gmail to send/receive email via your Hostgator Email 



How To Set Up A Business Email Through Gmail For Free