Skip to content

Instantly share code, notes, and snippets.

View tommymarshall's full-sized avatar

Tommy Marshall tommymarshall

View GitHub Profile
@dillinghamio
dillinghamio / @role.md
Last active April 20, 2021 00:39
@ROLE Blade Directive For Laravel Spark

@role Blade Directive For Laravel Spark

Assumes you're using teams

Add this to the boot() method of your AppServiceProvider

\Blade::directive('role', function($roles) {

 $user = auth()->user();
@rileypaulsen
rileypaulsen / functions.php
Created August 19, 2014 16:08
Add Advanced Custom Fields Fields to the WP REST API
function wp_api_encode_acf($data,$post,$context){
$data['meta'] = array_merge($data['meta'],get_fields($post['ID']));
return $data;
}
if( function_exists('get_fields') ){
add_filter('json_prepare_post', 'wp_api_encode_acf', 10, 3);
}
@tommymarshall
tommymarshall / routes.php
Last active October 18, 2019 13:23
Simple Laravel + Craft integration
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
@rbin
rbin / scss2sass.sh
Created January 30, 2013 02:29
Look for any SCSS files in a Directory, and change them to minimal-style .sass! (The better version!
#!/bin/bash
for f in *.scss; do sass-convert $f ${f%scss}sass ; done
rm *.scss
@brianblakely
brianblakely / rem-calibrate.css
Created July 13, 2012 18:55
Simulate vw with rems
/* Android stock browser won't let you set font-size smaller than 8px unless you apply this. */
:root {
-webkit-text-size-adjust: none;
-moz-text-size-adjust: none;
-ms-text-size-adjust: none;
-o-text-size-adjust: none;
text-size-adjust: none;
}
@averyvery
averyvery / Guardfile
Created July 3, 2012 21:06
Retina images with Guard
guard 'process', :name => 'shrink-images', :command => 'ruby resize-mobile-images.rb mobileretina' do
watch /^images\/mobileretina\/.+/
end
@nhunzaker
nhunzaker / gist:2830256
Created May 29, 2012 19:42
My FED Pre-Commit Hook
#!/usr/bin/env ruby
errors = false
# Create a simple line break
puts ""
# Now let's get a list of the changed files that have been staged
changed_files = `git diff --staged --name-only HEAD`.split("\n")
@jgarber623
jgarber623 / _layout.php
Created May 1, 2012 15:21
Basic layout/view-style templating with PHP
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?php echo $page_title; ?></title>
</head>
<body>
<?php echo $content_for_layout; ?>
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@lqez
lqez / gist:2404749
Created April 17, 2012 09:07
Modified swipe.js to get callback point on beginning swipe.
/*
* Swipe 1.0
*
* Brad Birdsall, Prime
* Copyright 2011, Licensed GPL & MIT
*
*/
window.Swipe = function(element, options) {