Skip to content

Instantly share code, notes, and snippets.

View deivamagalhaes's full-sized avatar

Deiva Magalhaes deivamagalhaes

View GitHub Profile
<?php
namespace App\Services;
use Analytics;
use Config;
use Illuminate\Support\Facades\App;
use Spatie\Analytics\Period;
/**
@deivamagalhaes
deivamagalhaes / php-engineer-improve-code.php
Last active April 17, 2019 00:38
SkyVerge - PHP Engineer - How would you improve this code? Please do not fork this Gist.
<?php
/**
* This code retrieves course data from an external API and displays it in the user's
* My Account area. A merchant has noticed that there's a delay when loading the page.
*
* 1) What changes would you suggest to reduce or remove that delay?
* I've refactored it to retrieve the data from the API using AJAX, so that this does not block the page.
*
* 2) Is there any other code changes that you would make?
* I'd also make the AJAX call secure (nonce) and move the JS and HTML to separate files