Skip to content

Instantly share code, notes, and snippets.

View matterson11's full-sized avatar

Matthew Matterson matterson11

View GitHub Profile
@matterson11
matterson11 / portfoliocontrroller.php
Created July 9, 2016 13:30
Laravel Session Flash
public function addNew(Request $request)
{
$client = new ApiClient();
$query = Request::input('symbol');
$search_term = htmlspecialchars($query, ENT_QUOTES);
$symbol = $search_term;
@matterson11
matterson11 / database.php
Created June 24, 2016 10:49
Register and Log In Scripts PHP
<?php
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'database_name';
$dbconfig = mysqli_connect($host,$username,$password,$database);
@matterson11
matterson11 / contact.js
Created June 15, 2016 08:26
Php Mailer inside Godaddy - I had a lot of trouble trying to get the Php Mailer to work inside a GoDaddy server.
<script>
function submitdata() {
var formMessages = $('#form-messages');
var fullname = document.getElementById("fullname").value;
var email = document.getElementById("email").value;
var subject = document.getElementById("subject").value;
var message = document.getElementById("message").value;
var dataString = 'fullname=' + fullname + '&email=' + email + '&subject=' + subject + '&message=' + message;
@matterson11
matterson11 / db_connection.php
Created June 4, 2016 11:18
Search using PHP, Mysqli, AJAX, JQuery
<?php
define('_HOST_NAME', '......');
define('_DATABASE_USER_NAME', '....');
define('_DATABASE_PASSWORD', '....');
define('_DATABASE_NAME', '....');
$dbConnection = new mysqli(_HOST_NAME, _DATABASE_USER_NAME, _DATABASE_PASSWORD, _DATABASE_NAME);
if ($dbConnection->connect_error) {
trigger_error('Connection Failed: ' . $dbConnection->connect_error, E_USER_ERROR);
}
@matterson11
matterson11 / 20DayMovingAverage.php
Created June 4, 2016 11:11
An updated version of the previous script on how to calculate the 20 day moving average of a company listing on the FTSE Index
<?php
require '../vendor/autoload.php';
function TwentyDayAvg($symbol)
{
$client = new Scheb\YahooFinanceApi\ApiClient();
$endDate = new DateTime();
@matterson11
matterson11 / AnalystRatingsController.php
Created June 4, 2016 10:37
FTSE 100 - Analyst Ratings. Using the simple_html_dom.php script to web crawl the Reuters site and gather stock market information. This Reuters web crawler script is a back up for incase my other crawlers are unable to gather the required information from the primary Yahoo finance pages
<?php
include('simple_html_dom.php');
require 'vendor/autoload.php';
include("Helper.php");
include("BaseController.php");
$client = new Scheb\YahooFinanceApi\ApiClient();
// Uploading the price target from Yahoo Finance for every company listed in the company table
@matterson11
matterson11 / 20_day_moving_average.php
Last active January 22, 2021 12:29
Building a site that uses the Yahoo Finance Api to gather data on individual company shares. The Yahoo Api provides the 50 day and 200 day moving averages. I built this function to calculate the moving average over 20 working days.
<?php
require 'vendor/autoload.php';
// https://github.com/scheb/yahoo-finance-api
// The extremely useful scheb yahoo finance api is used extensively through our site
function TwentyDayAvg($symbol)
{
$client = new Scheb\YahooFinanceApi\ApiClient();
@matterson11
matterson11 / ContactType.php
Created February 12, 2016 13:51
Symfony2 contact us form with Gmail
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Collection;
class ContactType extends AbstractType
{
@matterson11
matterson11 / PDF Links
Last active February 12, 2016 13:35
Add Links to our Front Page connecting a PDF document stored inside AWS
@matterson11
matterson11 / Changes
Created February 12, 2016 13:29
Modifying the Front Page
Our site is a scroll down design split into several sections. My modifications included:
Removing 2 sections of code and the corresponding css code
Rewriting the content