Skip to content

Instantly share code, notes, and snippets.

View jasonvarga's full-sized avatar
🇦🇺

Jason Varga jasonvarga

🇦🇺
View GitHub Profile
@jasonvarga
jasonvarga / ClickHandler.js
Created February 6, 2019 18:39
Vue component that handles single and double clicks
export default {
render() {
return this.$scopedSlots.default({});
},
data() {
return {
listener: null,
timer: null,
@jasonvarga
jasonvarga / aliases.sh
Created January 8, 2019 17:30
Turn off xdebug while running phpunit
# First, copy ext-xdebug.ini to ext-xdebug.ini.bak
alias xdebug-disable='echo "" > /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini'
alias xdebug-restore='cat /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini.bak > /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini'
function phpunit {
xdebug-disable
./vendor/bin/phpunit "$@"
xdebug-restore
}
<?php
namespace App\Factories;
abstract class Factory
{
public function instance()
{
return $this;
}
@jasonvarga
jasonvarga / aliases
Last active May 2, 2017 15:36
Interchangeable "please" and "artisan" regardless of Laravel/Statamic project type.
alias artisan='art_plz'
alias please='art_plz'
alias art='art_plz'
alias plz='art_plz'
function art_plz {
if [ -e artisan ]; then
php artisan "$@"
elif [ -e please ]; then
php please "$@"
@jasonvarga
jasonvarga / protect.md
Created September 23, 2016 16:48
Statamic 2 Content Protection

Protecting Content {#protecting-content}

You may protect your content from unwanted visitors with the protect variable. By setting this variable you can allow or deny people in various ways. There are a number of schemes used for protecting content:

The protect variable can be placed in a number of places:

@jasonvarga
jasonvarga / readme.md
Created May 24, 2016 22:01
Statamic Docs

Statamic Documentation

We allow users to contribute to the Statamic docs. The content is stored separate from the actual site so our users view and modify content but the site can be hidden.

Folder structure

/
|— /docs.statamic.com
| |— statamic
title overview id
Laravel Blade
Blade is the templating engine supplied with Laravel. We think its neat and we won't even be offended if you want to use it. Here's how.
efa34b0d-b4c3-43fc-bb91-a6d331dc6026

The Blade Templating Language

You can find out how to use Blade, the templating language over on the Laravel docs.

@jasonvarga
jasonvarga / _readme.md
Last active August 29, 2015 14:23
Restricting an account to specific sections in the CP

Simple Statamic CP edit restrictions

  • Add the hooks file to _add-ons/restrict_to/hooks.restrict_to.php.
  • Add the restrict_to tags field to your _config/bundles/member/fields.yaml.
  • To restrict pages, add them to the restrict_to field. eg. /blog, /calendar. They will only be allowed to edit pages that begin with this url.

Warning

If your member listing is visible, (it is by default), they can edit their own restricted pages.

@jasonvarga
jasonvarga / mod.trim_at.php
Last active August 29, 2015 14:21
ltrim_at Statamic Modifier
<?php
class Modifier_trim_at extends Modifier
{
public function index($value, $parameters=array())
{
return ltrim($value, '@');
}
}
/*
@jasonvarga
jasonvarga / calendar_month.html
Last active October 2, 2015 19:48
Creating a single page dynamic URL calendar. This assumes a URL scheme like /calendar/month/2015/01
{{ calendar:set_month folder="calendar" year="{ segment_3 }" month="{ segment_4 }" }}
<h1>{{ calendar:month_name }} {{ segment_3 }}</h1>
{{ calendar:prev_month }}
<a href="/calendar/month/{{ year }}/{{ month }}" title="{{ month_name }} {{ year }}">&larr; Prev</a>
{{ /calendar:prev_month }}
{{ calendar:date_select attr="id:month-select" }}