Skip to content

Instantly share code, notes, and snippets.

View ericlbarnes's full-sized avatar
🎵
git push it, git push it real good

Eric Barnes ericlbarnes

🎵
git push it, git push it real good
View GitHub Profile
@ericlbarnes
ericlbarnes / bower.json
Last active January 8, 2024 01:52
Gulp, Bower, Bootstrap Sass, FontAwesome
{
"name": "project",
"version": "0.0.0",
"authors": [
"Eric Barnes <me@example.org>"
],
"license": "MIT",
"private": true,
"ignore": [
"**/.*",
@ericlbarnes
ericlbarnes / foreach_limit.blade.php
Last active July 13, 2023 07:51
Limit a foreach with Laravel blade
@foreach (array_slice($posts->toArray(), 0, 5) as $post)
<h1>{{ $post['title'] }}</h1>
@endforeach
<?php
namespace App\Services;
use App\Post;
class Slug
{
/**
* @param $title
@ericlbarnes
ericlbarnes / common.php
Created July 29, 2012 03:50
Stringify Attributes
/**
* Stringify attributes for use in html tags.
*
* Helper function used to convert an array or object of
* attributes to a string
*
* @param mixed
* @return string
*/
function _stringify_attributes($attributes, $js = FALSE)
@ericlbarnes
ericlbarnes / .bowerrc
Created January 17, 2015 03:33
Laravel Elixir With Bootstrap Sass
{
"directory": "vendor/bower_components"
}
@ericlbarnes
ericlbarnes / filters.php
Created July 16, 2013 17:30 — forked from anonymous/filters.php
Laravel CSRF Ajax
/**
* Filter to check for CSRF attacks from the ajax requests.
*/
Route::filter('csrf_header', function()
{
if (Session::token() != Request::header('x-csrf-token'))
{
throw new Illuminate\Session\TokenMismatchException;
}
});
@ericlbarnes
ericlbarnes / PewPewPew.php
Created May 7, 2020 15:12
Hold up... Wait a minute... It's a Laravel Chopper
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class PewPewPew extends Command
{
protected $signature = 'pewpewpew';
protected $description = 'Command description';
server {
listen 80;
listen [::]:80;
server_name site.com;
root /home/forge/site.com;
# FORGE SSL (DO NOT REMOVE!)
# ssl on;
# ssl_certificate;
# ssl_certificate_key;
@ericlbarnes
ericlbarnes / app.js
Created July 22, 2015 02:18
Example delete request
$(document).ready(function() {
$("button.remove").on('click', function(e){
e.preventDefault();
if ( ! confirm('Are you sure?')) {
return false;
}
var action = $(this).data("action");
var parent = $(this).parent();
$.ajax({
type: 'delete',
this.selectize = this.$("#js-tags").selectize({
persist: true,
maxItems: null,
valueField: "tag",
labelField: "tag",
searchField: ["tag"],
options: tags.toJSON(), // Backbone collection
render: {
item: function(item) {
return "<div><i class='icon-tag'></i> " + item.tag + "</div>";