Skip to content

Instantly share code, notes, and snippets.

@unstoppablecarl
unstoppablecarl / how-i-use-vuex.js
Last active June 17, 2020 14:59
How I use vuex
// within a vue component only use mapGetters, mapActions, or this.$store.dispatch(...)
// never directly reference state or mutations from within a vue component
// clearly shows what state data should be exposed and should be internal
import Vue from 'vue'
import Record from '...'
import api from '...'
const store = {
state: {
foo: true,
@unstoppablecarl
unstoppablecarl / README.md
Last active March 6, 2019 15:40
SCRIPT-8
<?php
namespace App\Services;
use Illuminate\Support\Debug\Dumper;
use Illuminate\View\Compilers\BladeCompiler;
use Illuminate\View\Factory;
class BladeDirectives {
<?php
namespace App\Services\Auth;
use App\Exceptions\PrimaryRoleNotFoundException;
use App\Exceptions\RoleNotFoundException;
use App\Models\Role;
use App\Models\User;
class UserPermissionsHelper {
const NOT_FOUND = 'NOT_FOUND';
const cache = {};
const db = [
{
id: 1,
name: 'steve',
email: 'steve@example.com'
},
{
<?php
// 5.3
class Foo {
protected $cache = false;
protected $dep;
public function __construct(Dep $dep, $cache = false) {
$this->dep = $dep;
$this->cache = $cache;
'use strict';
var findFirstWithKey = function(bindings, key) {
for (var i = 0; i < bindings.length; i++) {
var val = bindings[i][key];
if (val) {
return val;
}
}
return false;
<?php
namespace App\Http\Middleware;
use Closure;
class ValidJson {
/**
* Handle an incoming request.