Skip to content

Instantly share code, notes, and snippets.

View jdavidbakr's full-sized avatar

J David Baker jdavidbakr

View GitHub Profile
@jdavidbakr
jdavidbakr / UploadAWS.php
Last active August 29, 2015 14:22
Laravel: UploadAWS
<?php
/**
* Conversion of the old upload_aws class from the global repo.
* Handles management of the AWS files, with utitilies to resize images
* and generate signed URLs.
*
* Utilizes aws/aws-sdk-php-laravel. Optionally add a 'bucket' key to the aws config file.
*
* @todo: Could probably extend the use of the UploadFile class beyond the constructor
*/
@jdavidbakr
jdavidbakr / TableHeaderGenerator.php
Last active February 20, 2016 10:15
Laravel: Ajax pagination table header generator
<?php
namespace App\Services;
class TableHeaderGenerator {
/**
* Returns an array for the table view's header data that includes sort links
* @param Array $data array of arrays with keys 'label' and 'col'
* @param string $current_sort
@jdavidbakr
jdavidbakr / paginate.js
Last active August 29, 2015 14:22
JavaScript: Ajax pagination script
function paginate(url) {
microAjax(url, function (res) {
process_json(res);
});
return false;
}
@jdavidbakr
jdavidbakr / AjaxPaginationPresenter.php
Last active February 20, 2016 09:33
Laravel: Ajax Pagination Presenter
<?php
namespace App\Presenters;
use Illuminate\Pagination\BootstrapThreePresenter;
/**
*
* To use:
*
@jdavidbakr
jdavidbakr / php-class.sublime-snippet
Created May 22, 2015 17:19
Snippet: PHP Quick Class
<snippet>
<content><![CDATA[
<?php
namespace ${1:App};
class ${2:ClassName} {
${3}
}
?>
@jdavidbakr
jdavidbakr / view-composer.sublime-snippet
Created May 22, 2015 17:18
Snippet: Laravel View Composer
<snippet>
<content><![CDATA[
<?php
namespace ${1:App\Http\ViewComposers};
use View;
use Illuminate\Support\ServiceProvider;
class ${2:My}ViewComposer extends ServiceProvider {
@jdavidbakr
jdavidbakr / service-provider.sublime-snippet
Created May 22, 2015 17:18
Snippet: Laravel Service Provider
<snippet>
<content><![CDATA[
<?php
namespace ${1:App\Providers};
use Illuminate\Support\ServiceProvider;
class ${2:Service}ServiceProvider extends ServiceProvider {
@jdavidbakr
jdavidbakr / controller.sublime-snippet
Created May 22, 2015 17:17
Snippet: Laravel Controller
<snippet>
<content><![CDATA[
<?php
namespace ${1:App\Http\Controllers};
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ${2:My}Controller extends Controller {
@jdavidbakr
jdavidbakr / table.blade.php
Created May 22, 2015 17:14
Laravel Blade: table
@if(!empty($table))
<table class='data'>
@foreach($table['rows'] as $row)
<?php
$row['attributes']['class'] = (!empty($row['attributes']['class']) ? $row['attributes']['class'] . ' ' : '') . $classes[$current_class];
$current_class = ($current_class + 1) % 2;
?>
<tr @if(!empty($row['attributes'])) @foreach($row['attributes'] as $key=>$value) {{ $key }}="{{ $value }}" @endforeach @endif >
@foreach($row['cells'] as $cell)
<{{ !empty($cell['dom']) ? $cell['dom'] : 'td' }} @if(!empty($cell['attributes'])) @foreach($cell['attributes'] as $key=>$value) {{ $key }}="{{ $value }}" @endforeach @endif >
@jdavidbakr
jdavidbakr / sync-remote
Last active August 29, 2015 14:21
Script: Watch & Upload Directory
#!/bin/bash
LOCAL_PATH=$1
REMOTE_SERVER=$2
REMOTE_PATH=$3
CHANGED_FILE=$4
echo Changed File: $CHANGED_FILE
FILE=`echo $CHANGED_FILE | sed 's|'$LOCAL_PATH'/||'`