Skip to content

Instantly share code, notes, and snippets.

Anthony Vipond thewinterwind

Block or report user

Report or block thewinterwind

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thewinterwind
thewinterwind / repo-proposal.md
Last active Jun 27, 2017
Proposal for service platform and repository pattern
View repo-proposal.md

Service Platform w/ Repository Pattern Proposal

This document will outline a proposal for a service platform (API) and a repository pattern as a business layer for IC.

Benefits

  • Have a data layer that is independent of models and controllers.
  • Have repo methods that can be consumed from other parts of the web application and from the command line.
  • Reduce logic in controllers and models, allowing controllers to focus on HTTP level work (request data, cookies, responses) and models to focus on creating relationships, casting columns, mutators, etc. The controllers should instead delegate work to the repos.
  • Repository methods can be reused by different parts of the web application and to perform work for an API request coming from outside (i.e. if we use a mobile platform like React Native it can call the API endpoints which in turn consume the repositories)
  • Have repo methods be easily unit tested as they will not be accessing session data, request data or external constants. They only
@thewinterwind
thewinterwind / disable_multiple_tabs.js
Created Apr 29, 2017
Detect website being accessed in a new tab
View disable_multiple_tabs.js
<script>
// helper function to set cookies
function setCookie(cname, cvalue, seconds) {
var d = new Date();
d.setTime(d.getTime() + (seconds * 1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
// helper function to get a cookie
@thewinterwind
thewinterwind / demo.php
Created Dec 1, 2014
Get next id in table using Laravel
View demo.php
<?php
// select min(id) as id from `property` where `id` > 1;
DB::table($table)->select(DB::raw('min(id) as id'))->where('id', '>', $id)->id;
@thewinterwind
thewinterwind / Stock.php
Created Jun 23, 2014
Entire Stock class for tutorial on using PHP with the Yahoo Finance API
View Stock.php
<?php namespace SS\Stock;
use DB, File, Cache, Input, Response;
class Stock {
public function __construct()
{
ini_set("memory_limit", "-1");
set_time_limit(0);
@thewinterwind
thewinterwind / php-yahoo-finance.php
Created Jun 21, 2014
Lesson 8 - PHP & Yahoo Finance API
View php-yahoo-finance.php
<?php namespace SS\Stock;
use DB, File, Cache;
class Stock {
public function __construct()
{
ini_set("memory_limit", "-1");
set_time_limit(0);
@thewinterwind
thewinterwind / insert_many_rows.php
Last active Dec 12, 2016
How to insert millions of rows to the database with PHP (YT Tutorial)
View insert_many_rows.php
<?php
class Stock {
public function store_stock_history()
{
$date = date('Y-m-d');
$files = File::files(app_path() . '/resources/historical_lists/' . $date);
@thewinterwind
thewinterwind / art.php
Last active Aug 29, 2015
Artisan Files for Streak Counting Tutorial (2 files combined here)
View art.php
// this is /app/start/artisan.php
<?php
/*
|--------------------------------------------------------------------------
| Register The Artisan Commands
|--------------------------------------------------------------------------
|
| Each available Artisan command must be registered with the console so
@thewinterwind
thewinterwind / StoringController.php
Last active Jun 13, 2016
Code to count streaks in PHP (used with Yahoo API tutorial)
View StoringController.php
<?php
class StoringController extends BaseController {
public function store_streaks()
{
$date = date('Y-m-d');
$stocks = DB::table('stocks')->select('symbol')->orderBy('symbol', 'asc')->get();
View gist:9dbc9265101f826740c3
<?php
use Leads\Repos\LeadRepoInterface;
use Illuminate\Foundation\Application;
class ExchangeController extends BaseController {
private $lead;
private $app;
You can’t perform that action at this time.