Tuesday, March 29, 2016

Google Maps API Credentials - HTTP referrers (web sites) errors

When you want to embed the defacto basic Google Map into website properly you going to have to request a Google API key to manage, monitor and secure your Google map queries.

Many CMS Themes (Wodpress, Joomla, etc) are purchased and come with a non-key version of Google maps which causes errors in the console, and get blocked because they surpass the  25,000 / per day limit or are getting HTTP referrers errors.

That's right, new modern themes are using AJAX deferred api's libraries and there a big difference in requests rate granted by Google

  • Google Maps JavaScript API has 25,000 request per day (hip)
  • Google Maps Embed API has 2,000,000 request per day (old)


So you may thing on first blush according to the that you need the Google Maps Embed API but that for very old sites and now AJAX sites are using the Google Maps JavaScript API.

Check for this in your source code -
https://maps.googleapis.com/maps/api/js?sensor=false

So now you are forced to upgrade to get an Google API key, but they certainly make that very easy process.

Head over to Googles Developer Console - https://console.developers.google.com/apis/credentials/ and sign-up.

You want to add Google Maps JavaScript API



























Now under Credentials Tab, you be assigned a new API Key, but you have to choose your Accept requests from these HTTP referrers (web sites) to come from your website.

The prescribed *.example.com/* did not work for me! Here's what finally worked;





























Now change your code to reflect your new active key, and best practice to add version of library you are using to the URL ?v3

https://maps.googleapis.com/maps/api/js?v3&key={your API key}

and follow this
https://google-developers.appspot.com/maps/documentation/javascript/demos/markers/markers

If you get this then your referrer is set incorrectly, you get a browser pop-up alert with following error:

This page was unable to display a Google Maps element. Please contact the site administrator. If you are the administrator of this site, please check the JavaScript console or check the following page for troubleshooting: http://g.co/mapsJSApiErrors

check your browser console and it will indicate the offending referring URL.

Check this again; and add your website with http(s)://





Thursday, February 18, 2016

Copy files without permissions, Robocopy cmd line or Richcopy GUI for Windows

Need to back-up laptop and desktop drives without file permissions getting in the way? 
1) Command Line - GUI tool see below
 

Use RoboCopy (Robust File Copy) a command-line file copying tool built into Windows. It is designed for high-speed multi-threaded reliable copying to target destination, especially with long and peculiar file names that Windows Explorer has trouble copying. 
This particularly useful when back-up from old drives to external USB drive, in this example. Additionally, you can specify that file permission NOT be included when copying the files over so, any computer that uses the external harddrive can see those files.

This command worked well for me.

  1. Restartable mode (/Z) has to do with a partially-copied file. With this option, should the copy be interrupted while any particular file is partially copied, the next execution of Robocopy can pick up where it left off rather than re-copying the entire file. That option could be useful when copying very large files over a potentially unstable connection.
  2. Backup mode (/B) has to do with how Robocopy reads files from the source system. It allows the copying of files on which you might otherwise get an access denied error on either the file itself or while trying to copy the file's attributes/permissions. You do need to be running Command Prompt or Poweshell as Administrator context or otherwise have backup rights to use this flag.

This command works well and the /B swicth ignores file permissions. Make sure you understand the other switches, see below.

RoboCopy Command Line Syntax:

RoboCopy has a handy command line progress indicator too which comes useful while copying large files and will indicate what and which files failed to copy. Summary is excellent as well.
    Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :      318         0         0         0         0         0
    Files :     773         0         0         1         0         0

    Bytes :   2.158 g   2.158 g       0         0         0         0

    Times :   0:05:00   0:05:00    0:00:00   0:00:00   
0:00:00   0:00:00

    Speed :             7717714 Bytes/sec.

    Speed :             441.611 MegaBytes/min.

    Ended : Thur Feb 18 12:23:14 2016

Robocopy is built-in on the following Operating Systems: Windows 10, Windows 8, Windows 7, Windows Vista, Windows Server 2008 
Robocopy was available for free download with the Windows 2003 Resource Kit since Windows NT 4.0., Windows Server 2003, Windows XP, and Windows 2000 or Microsoft Windows NT version 4.0.

If you have a problem following command lines, then there's


2) RichCopy a utility with a GUI available from Microsoft MSDN Magazine.
This is an improvement and separate tool from Robocopy GUI.
Get RichCopy download  and the full MSDN Article about this is here. Help here.

RichCopy is a free utility that comes to us from Ken Tamaru of Microsoft. The tool was first developed in 2001. It too is multi-threaded will allow you to ignore file permissions.

Multi-threaded means that rather than copying one file at a time in serial order, RichCopy can open multiple threads simultaneously, allowing many files to be copied in parallel and cutting the total time required to complete the operation several times over. You can also pause and resume file copy operations, so if you lose network connectivity at any point, you can just pick up where you left off.

How to ignore file attributes (permissions) when copying
Firstly, choose Advanced














Choose Copy Options













Select 1) File attributes, Error Handling and then Unheck 2) File Attributes 





























Additionally, you can select which File attributes to set or File Attributes to remove. The tool is very extensive!  Tool comes with help file, but for reference Online help is here.

Richcopy errors with Path Too Long Issue

Richcopy just bombs out and closes when it runs into an errors such as path too long errors and permission errors.

3)  FastCopy 


FastCopy is free open source C project written by Shirouzu Hiroaki 

Touted as "The Fastest Copy/Delete Software on Windows."  and  "It supports UNICODE and over MAX_PATH (260 characters) file path names."


This means you can over come "paths too long" or "Source Path is too long" "Destination Path is too long"  or  "File cannot be copied" errors in most cases.

How? You can copy all you long paths to new location with shorter path.

However, this is only 1/4 of the solution. This does not solve the problem of the filename itself is too long, and your are still perpetuating this error.  You will still get these errors "The file name(s) would be too long for the source/destination folder", next time you copy. To correct these errors, see Path Tool Long Auto Fixer tool below.

4)  Path Too Long Auto Fixer 


Better still, get Path Tool Long Auto Fixer tool I build to solve this issue completely. It's the 1st tool of it's kind to find all directories and files that are too long and auto correct them!

It supports UNICODE as well and finds paths and fixes over the MAX_PATH (260 characters) limit.

Download free demo at https://pathtoolongautofixer.blogspot.com

Preview

Tuesday, January 19, 2016

OneDrive 2016 Direct File Download URL Maker







Microsoft OneDrive Direct File Download URL Maker




<iframe src="https://onedrive.live.com/embed?cid=8F99649728BEB2F3&resid=8F99649728BEB2F3%211010&authkey=AFo8ZQ_-qj84DEQ" width="98" height="120" frameborder="0" scrolling="no"></iframe>  see instructions below, if you don't know how. NOTE : For images there an extra step below.



https://onedrive.live.com/embed?cid=8F99649728BEB2F3&resid=8F99649728BEB2F3%211010&authkey=AFo8ZQ_-qj84DEQ and populate the textbox below, click "Get Download Link" button.



4. Click on Get Download Link button.
Textbox will be highlighted so you can copy the full link. To copy, right-click and choose  "Copy" or simply (ctrl-c) to copy link. Note: Entire URL is automatic selected for your convenience.





 


How to get a Microsoft OneDrive Embed Code (see instructions and images below)



  1. Goto OneDrive (https://onedrive.live.com/)
  2. Upload you file

  3. Right-click to "Embed" your uploaded file 

  4. Click Generate HTML Button.

  5. Copy and Paste HTML Code to Notepad

  6. Copy the all the embed code ie. <iframe src="embed link"... >...</iframe> and paste into textbox here



    Click Get embed link button to get the embed link and copy (ctrl-c).
  7. Paste (crtl-v) the file link into OneDrive Embed Link textbox above and click "Get Download Url" button. Proceed as usual.
  8. Right-click and "Copy" or simply press ctrl-c keys to copy the link to your clipboard.
  9. Now Paste (ctrl-v) the OneDrive Share Direct Download Link in emails to share!
  10. Done!

API Change for Images 



  1. Right-click to "Share" your uploaded file

  2. Pop-up will appear and choose "Get a link", click "Create link" dark blue button.
  3. Right-click and "Copy" the highlighted link.  Updated June 07, 2016 API change.
  4. You should get a similar "shortened" url as this

    https://1drv.ms/i/s!AvOyviiXZJmPlSc1CjtKuwc_gqVu

    Paste into http://www.linkexpander.com/ and copy that URL.


     
  5. Resulting url looks like this  https://onedrive.live.com/redir?resid=8F99649728BEB2F3!2727&authkey=!ADUKO0q7Bz-CpW4&ithint=photo%2cjpg
  6. Paste link into OneDrive Share Link textbox and click "Get Download Url" button.
  7. Right-click and choose "Select all" and "Copy".
  8. Paste the OneDrive Share Direct Download Link in emails instead.
  9. "Shorten link" was a feature in the old API windows now gone, June 07, 2016.  This is done by default now.

  10. OR for image only 
  1. Updated June 07, 2016 API change! Right-click Embed now gives you direct download URL! So you do not need to do the above! 
Google Chrome Warning: Very large PDF files do not preview in Chrome

PDF files approx. over 100Mb in size, do not preview in Chrome, and you get a splash page to "For the best experience, open this PDF portfolio in Adobe Acrobat or Adobe Reader"

You have to save the file first then open in Adobe Acrobat/Reader.







  • https://onedrive.live.com/redir?resid=8F99649728BEB2F3!2737&authkey=!ACnO8wuwLQ07PqI&v=3&ithint=photo%2cgif
It should look something like URL above and must contain the required file id (resid), authentication key (authkey) and file type (ithint). We'll use this link to get a direct file download.




 
OneDrive for Business File Share Link is the download link by default;)


Bonus : For images, read Using OneDrive as a Content Delivery Network (CDN)