Skip to content

Instantly share code, notes, and snippets.

View thewinterwind's full-sized avatar

Anthony Vipond thewinterwind

View GitHub Profile
@thewinterwind
thewinterwind / helpers.php
Created March 28, 2014 22:18
Laravel 4 Helpers
<?php
/**
* Helpers for Laravel 4
* Author: Anthony Vipond
*/
// Preformat the dump and die function
if (!function_exists('d')) {
function d($mixed) {
@thewinterwind
thewinterwind / php-snippets.xml
Last active August 29, 2015 13:58
Sublime Text 2 Laravel 4 Snippet Collection
<overview>
pf = new function
comm = new function comment
fopen = open a form
fclose = close a form
</overview>
<snippet>
<content>
<![CDATA[
@thewinterwind
thewinterwind / log_laravel_db_queries_to_console.php
Created May 4, 2014 05:59
Log Laravel 4 Database Queries to the Console
@if (App::environment() == 'local')
@foreach (DB::getQueryLog() as $query)
<script>console.log(' {{ $query['query'] . ' (' . $query['time'] . ' secs)' }} ')</script>
@endforeach
@endif
@thewinterwind
thewinterwind / add-primary-key-to-existing-table.sql
Created May 8, 2014 09:10
Add primary key after table already exists (MySQL)
ALTER TABLE XXX add column id INT NOT NULL AUTO_INCREMENT FIRST, ADD primary KEY Id(id)
@thewinterwind
thewinterwind / remove-duplicate-rows-from-mysql-table.sql
Last active August 29, 2015 14:01
How to remove duplicate rows from a MySQL table
-- For example, a members table that has duplicate emails
-- Needs unique id field to work
create temporary table tmpTable (id int);
insert tmpTable
(id)
select id
from members m
where exists
<?php
use Leads\Repos\LeadRepoInterface;
use Illuminate\Foundation\Application;
class ExchangeController extends BaseController {
private $lead;
private $app;
@thewinterwind
thewinterwind / StoringController.php
Last active June 13, 2016 13:56
Code to count streaks in PHP (used with Yahoo API tutorial)
<?php
class StoringController extends BaseController {
public function store_streaks()
{
$date = date('Y-m-d');
$stocks = DB::table('stocks')->select('symbol')->orderBy('symbol', 'asc')->get();
@thewinterwind
thewinterwind / art.php
Last active August 29, 2015 14:02
Artisan Files for Streak Counting Tutorial (2 files combined here)
// this is /app/start/artisan.php
<?php
/*
|--------------------------------------------------------------------------
| Register The Artisan Commands
|--------------------------------------------------------------------------
|
| Each available Artisan command must be registered with the console so
@thewinterwind
thewinterwind / insert_many_rows.php
Last active December 12, 2016 13:59
How to insert millions of rows to the database with PHP (YT Tutorial)
<?php
class Stock {
public function store_stock_history()
{
$date = date('Y-m-d');
$files = File::files(app_path() . '/resources/historical_lists/' . $date);
@thewinterwind
thewinterwind / php-yahoo-finance.php
Created June 21, 2014 14:38
Lesson 8 - PHP & Yahoo Finance API
<?php namespace SS\Stock;
use DB, File, Cache;
class Stock {
public function __construct()
{
ini_set("memory_limit", "-1");
set_time_limit(0);