how to get to user preferences in website using JavaScript

1. JavaScript code for setting cookies

First we have some generic code that will set a cookie with a given name and value. In this example we’ve set the expiry date (when the cookie will be removed from your browser) to 30 days and all cookies will be set with a path value of ‘/’ (the root level of the website):

var today = new Date();
  var expiry = new Date(today.getTime() + 30 * 86400 * 1000); // plus 30 days

  function setCookie(name, value)
  {
    document.cookie = name + "=" + escape(value) + "; expires=" + expiry.toGMTString() + "; path=/";
  }

Then comes the form handler function which is also quite simple. We first populate an associative array, prefs, with the selected name-value pairs and then loop through that array setting a cookie for each value:

 var prefs = new Array();

  function setPrefs(form)
  {
    prefs['fontfamily'] = form.fontfamily.options[form.fontfamily.selectedIndex].value;
    prefs['overflow'] = form.overflow.options[form.overflow .selectedIndex].value;
    for(var x in prefs) setCookie(x, prefs[x]);
    return true;
  }

A better approach is to use a single cookie to hold all the values rather then one for each. The reason for this is that browsers will only hold a certain number of cookies from a domain before they start deleting the oldest. 

2. PHP code for reading cookies

In the PHP code that displays the template for this website we add the following code to the HEAD of the HTML page (inside the STYLE tags).

First for the font famliy:

  if(isset($_COOKIE['fontfamily']) && $_COOKIE['fontfamily']) {
    echo "  body { font-family: \"{$_COOKIE['fontfamily']}\"; }\n";
  }

and for the display setting:

  if(isset($_COOKIE['overflow']) && $_COOKIE['overflow']) {
    echo "  #content { max-height: {$_COOKIE['overflow']}px; overflow: auto; }\n";
  }

and so on for other values. You can see the extra CSS properties in the HEAD of each page by viewing the HTML source.

Because the cookies are set with a path of ‘/’ they apply to all pages in this domain. And because we use a single template for every page the preferences you select will apply to the entire site.

The advantage of using JavaScript to set the cookies is that they’re recognised by the browser immediately. If we submitted the form and used PHP to set the cookies then they wouldn’t appear immediately in the $_COOKIE array as the browser hasn’t yet told the server that it has them yet. That would happen on the next request.

To get around this you have to do something like the following:

<?PHP
  if(isset($_POST['fontfamily'])) {
    setcookie('fontfamily', $_POST['fontfamily'], time() + 30 * 86400, '/');
    $_COOKIE['fontfamily'] = $_POST['fontfamily']);
  }
?>

The first command tells the browser to set the cookie, and the second adds it to the $_COOKIE array so our script (above) can see the value right away.

Video editing tips for Video Bloggers

Shoot with editing in mind

The best time to start thinking about editing is during the writing phase. By planning your edits early on, you can anticipate how your video will look and how you want your viewers to react.

Consider your camera positions, angles and movements. Think about how your video will open and close, and what the key moments in between are. For larger projects, you can make a simple ‘shot list’ – writing down all the shots that you’ll need so you don’t forget anything.

Ask yourself:

  • When should I do multiple takes to get the right shots?
  • Will I need extra footage for my B-roll, trailer or teasers?

As you get more experienced with editing, you may decide to buy a more sophisticated editing program. When shopping around, consider these points:

  • Budget. There are many budget-friendly apps on the market and starter apps at budget prices. Higher-end video editing apps are typically used for more elaborate projects. Check for trials or education discounts.
  • Equipment. Are you using a smartphone, DSLR or pro camcorder? Recording in SD or HD? Review the tech specs of each app to see which types of cameras and file formats are supported. Also check the system requirements for your computer.
  • Features. Even affordable programs typically offer a wide range of features, such as colour correction for making your footage really pop. Higher-priced apps may deliver more complex capabilities such as shared team projects and customisable workspaces.

You can optimise your videos in YouTube Studio by adding end screens and trimming sections of your video before or after publishing. You can also add music and sound effects to your video with the Audio Library in YouTube Studio. 

Editing like a pro

Often, the best way to improve your editing is through practice. These tips can help you take your editing to the next level:

  • Know your software. Whichever video editing software you use, try looking up keyboard shortcuts for your most repeated tasks. You can also find lots of videos on YouTube (and other sites) showing you how to do cool editing tricks.
  • Edit for pacing. Think about the pace and rhythm of your video. Do you want to move quickly from shot to shot, to build intensity and excitement? Or do you want to allow viewers more time to absorb and reflect upon what’s happening in front of them? Some editors use ‘jump cuts’ to cover up unwanted lines or filler words.
  • Turn to your audience. What matters most is how you connect with your target audience. If you’ve uploaded some videos already, try looking at your audience retention in YouTube Analytics. Dips can mean that viewers skip those parts or leave your video. Think about the reasons why your top videos kept viewers engaged and how editing might have played a role.

We recommend

Start with what you have. Often, phones and computers come with pre-installed editing software.

(#200) You do not have permission to access this field.

There is no permission called “contact_email”, there is only “email”.

That being said, you need a Page Token to post “as Page”. Use /me/accounts to get Page Tokens for your Pages. The permission error most likely means that you don´t have the appropriate permissions to post to the Page with your Access Token. Make sure it is a Page you manage, and make sure the Access Token includes the publish_pages permission. You can debug your Access token in the Debugger: https://developers.facebook.com/tools/debug/

If this error occur during WhatsApp API configuration, Call me for this solution.

Samsung Galaxy Watch4 Bluetooth(4.0 cm, Black, Compatible with Android only)

Email : adityaypi@yahoo.com, Mobile : +91-9555699081

activity store in file or MySQL database using php which is better

Logs using files are more efficient, however logs stored in the database are easier to read, even remotely.

however that connecting and inserting rows into the database is error prone (database server down, password wrong, out-of-resources).

Log to db instead if you need other people needs to read logs in a web interface or if you need the ability to search through logs. As someone else has pointed out also concurrency matters, if you have a lot of users log to db could scale better.

Yes, it’s faster to write to files but it’s far faster for you to find what you need in the logs if they are in a database.

I think storing logs in database is not a good idea. The pros of storing logs to databases over files is that you can analyze your logs much more easily with the power of SQL, the cons, however, is that you have to pay much more time for database maintenance. You’d better to set up a separate database server to store your logs or your might get too much log INSERT which will decrease your database performance to production use; also, it’s not easy to migrate, archive logs in database, compared with files.

Error logging is best limited to files in my opinion, because if there is a problem with the database.

When using filesystem careful with :

  • Confidentiality : Put documents outside of your Apache Document Root. Then a PHP Controller of yours will output documents.
  • Sharded path : do not store thousands of documents in the same directory, make different directories. You can shard with a Hash on the Filename for example. Such as /documents/A/F/B/AFB43677267ABCEF5786692/myfile.pdf.
  • Inode number : You can run out of inodes if you store a lot of small files (might not be your case if storing mostly PDF and office documents).

Video equipment tips for Video Bloggers

Being a YouTube creator requires at least a foundational knowledge of video equipment. You might be asking yourself: What type of camera will I use? How will I handle sound and lighting? Here’s an overview of some common production equipment choices that can help you get started.

Cameras

There’s no ‘one size fits all’ – consider what you want to achieve with your videos. Here are two common types:

  • Point-and-shoot cameras are simple, all-in-one devices that are great for frequent vlogging in almost any setting. Some models have a reversible LCD screen so that you can see your shot. These no-fuss cameras can deliver full HD (1080) image quality, and many creators use them in their everyday videos.
  • DSLR cameras can deliver a more cinematic look, but may require a learning curve to operate. They use interchangeable lenses, are much heavier and are sometimes trickier to focus. These cameras cost more and they are typically used by creators who want a more artistic or professional look.

You can always start with your mobile device’s camera. It’s a great option before you invest in a standalone camera.

Take a look at camera reviews from other YouTube creators to find out what brands and models they recommend.

Sound

Good sound is a must. Viewers often don’t mind imperfect lighting, but they are less accepting of poor sound quality in the video.

If you’re using your camera’s onboard mic, you may need to stay about a metre away from the camera for the best audio.

  • Some creators buy a ‘shotgun’ mic; since these have directional recording, they can be effective at picking up natural sound from a longer range.
  • When you need to record at a distance, you can use a wireless lavalier mic, which can be attached to you. For example, a lav mic might be appropriate for the instructor in a fitness video.

Confirm whether your camera has a port for an external mic before buying one.

Lighting

  • Many creators use a ‘two-point’ lighting system. This involves lighting your main subject from two light sources at opposing directions. In this setup, the ‘key light’ gives the primary lighting, while the ‘fill light’ balances out the shadows.
  • Another option would be ‘soft lights’, which sometimes cost less, consume less power and are more flattering. A single soft light can be great for close-up shots. You can add lights to illuminate the background or other parts of the scene, as needed.
  • Don’t forget about one of the brightest (and cheapest) lights in existence – the sun! Try recording outside or using natural daylight through a window.
  • For shooting on the go, consider camera-mounted lights.

We recommend

  • If you have a lot of questions, consider your creative style and production goals as you select the right equipment. Some creators aim for a highly polished video, while others are OK with something casual and authentic.
  • If you want to keep costs down, you could buy the most affordable equipment and upgrade later based on your video-making needs.
  • Often, the best piece of equipment is the one you have to hand. Use your mobile device to get started immediately.

Python code for store system load into file and display stored system load

Python code for store system load into file

#!/usr/bin/python

import os
try:
    t = os.popen('uptime').read()[:-1]
    #print(t)
    f=open("/home/website/public_html/public/load.txt", "a+")
    f.write("%s\r\n" %t)
    f.close()
    f.flush()
except IOError as (errno,strerror):
    print "I/O error({0}): {1}".format(errno, strerror)

Python code for display system load stored into file

#!/usr/bin/python

import os
try:
    f = open("/home/website/public_html/public/load.txt", "r")
    print(f.read())
    f.close()
    f.flush()
except IOError as (errno,strerror):
    print "I/O error({0}): {1}".format(errno, strerror)

Interesting facts about Hummer

  • AM General began manufacturing High Mobility Multipurpose Wheeled Vehicles (HMMWV) or Humvees for the U.S military in 1983, and made the first civilian Hummer in 1992. Later, the company officially named it ‘Hummer’.
  • General Motors acquired the ownership and marketing rights of the Hummer from AM General in 1999. However, AMG continued to design the H1 exclusively for the civilian market. While, the H2 was the first product built under the flagship of the GM. The H3 was the last generation of the SUV, which was discontinued when the company shut down in 2010. Therefore, Hummer cars in India and around the world are quite a rare sight.
  • Despite being classified as a Class 3 truck, it doesn’t require a special driving license.
  • Hummer dealers across the world were complied to organize four Hummer off-road events per year.
  • The SUV is especially geared for off-road driving. The H1 and H2 can climb on a 22-inch and a 16-inch vertical wall or mountain, run up to 30-inch and 20-inch of water, respectively. Both the models can navigate a 60% grade and cross 40% side slop.
  • The H2 is based on the GM truck platform, also used for GMC and Chevy pickups, in 1999, which is now found on the Yukon, Suburban, Escalade Tahoe and other GM SUVs and trucks.
  • The Hummer can drive through 30-inches deep water without floating, and maintaining traction under water. Most components of the SUV are sealed against the elements that make it an amphibian-cum-submarine vehicle. It has drain plugs in the floor that released the water that enter in the car underneath.

The Hummer, discontinued in 2010, will always be admired for its glorious history, exceptional off-road capabilities and commanding road presence. There are several other new cars in the market, but no one can replace the legendary civilian Hummer. We never had sales outlets of Hummer cars in India, thus its buyers got them imported directly

WordPress best performance .htaccess file content

# compress text, html, javascript, css, xml:
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


#BEGIN EXPIRES HEADERS
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default expiration: 1 hour after request
ExpiresDefault "now plus 1 hour"
# CSS and JS expiration: 1 week after request
ExpiresByType text/css "now plus 1 week"
ExpiresByType application/javascript "now plus 1 week"
ExpiresByType application/x-javascript "now plus 1 week"
# Image files expiration: 1 month after request
ExpiresByType image/bmp "now plus 1 month"
ExpiresByType image/gif "now plus 1 month"
ExpiresByType image/jpeg "now plus 1 month"
ExpiresByType image/jp2 "now plus 1 month"
ExpiresByType image/pipeg "now plus 1 month"
ExpiresByType image/png "now plus 1 month"
ExpiresByType image/svg+xml "now plus 1 month"
ExpiresByType image/tiff "now plus 1 month"
ExpiresByType image/vnd.microsoft.icon "now plus 1 month"
ExpiresByType image/x-icon "now plus 1 month"
ExpiresByType image/ico "now plus 1 month"
ExpiresByType image/icon "now plus 1 month"
ExpiresByType text/ico "now plus 1 month"
ExpiresByType application/ico "now plus 1 month"
# Webfonts
ExpiresByType font/truetype "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
</IfModule>
#END EXPIRES HEADERS

# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
 <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
 Header set Cache-Control "max-age=2592000, public"
 </filesMatch>
 <filesMatch "\.(css)$">
 Header set Cache-Control "max-age=604800, public"
 </filesMatch>
 <filesMatch "\.(js)$">
 Header set Cache-Control "max-age=216000, private"
 </filesMatch>
 <filesMatch "\.(x?html?|php)$">
 Header set Cache-Control "max-age=600, private, must-revalidate"
 </filesMatch>
</ifModule>
# END Cache-Control Headers


# ENABLE LITESPEED CACHE START
<IfModule LiteSpeed>
CacheEnable public
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^GET|HEAD$
RewriteCond %{HTTP_HOST} ^sample.com|sample.net|sample.org [NC]
RewriteCond %{REQUEST_URI} !login|admin|register|post|cron
RewriteCond %{QUERY_STRING} !nocache
RewriteRule .* - [E=Cache-Control:max-age=300]
</IfModule>
# ENABLE LITESPEED CACHE END

# START ENABLE KEEP ALIVE
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
# END ENABLE KEEP ALIVE


<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedEnableFilters rewrite_css,combine_css
ModPagespeedEnableFilters recompress_images
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
ModPagespeedEnableFilters collapse_whitespace,remove_comments
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

Step by step overview guide for setup business WhatsApp API

Step by step overview guide for setup business WhatsApp API with Facebook business account

What is the criteria to check my business Facebook is active for WhatsApp api

after that your WhatsApp api is fully activated.

  1. Must have Facebook business account setting
    a. WhatsApp account added into Facebook business setting
    b. Add system user
    c. Assign an App to system user via add assets
    d. Generate token for final use of WhatsApp api with selected permission
  2. Create app and add it into business Facebook account
    Note : for use WhatsApp api app type must be business

*Step by step overview guide for setup business WhatsApp API
*What is business WhatsApp API
*How to implement WhatsApp API

Download Hindi font google

Making the web more beautiful, fast, and open through great typography.

HindHind is an Open Source typeface supporting the Devanagari and …
नोटों साँस देवनागरीNoto is a global font collection for writing in all modern and …
MuktaMukta is a Unicode compliant, versatile, contemporary …
RobotoMaking the web more beautiful, fast, and open through great …