Skip to content

Instantly share code, notes, and snippets.

View jdavidbakr's full-sized avatar

J David Baker jdavidbakr

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / field_multiplier.js
Created June 8, 2015 21:42
JavaScript: Field Multiplier
var FieldMultiplier = {
makeSum: function(e) {
/**
* Look for any elements with the same class as this one
* and sum them, multiplying by the multiplier attribute.
* The sum will go into the elements that match the sum attribute.
*/
var sum = 0;
var sum_selector = '.'+e.getAttribute('class');
var elements = document.querySelectorAll(sum_selector);
@jdavidbakr
jdavidbakr / page_change_warning.js
Last active August 29, 2015 14:24
JavaScript: Page change warning - alerts the user before allowing the window to close
var PageChangeWarning = {
unload_message: "You have unsaved changes on this page.",
display_warning: function() {
return this.unload_message;
},
change_made: function() {
window.onbeforeunload = this.display_warning.bind(this);
},
saved: function() {
window.onbeforeunload = null;