Skip to content

Instantly share code, notes, and snippets.

Nigel James njames

Block or report user

Report or block njames

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View UsedByTeams.md

UsedByTeams Model Trait For Laravel Spark

Automatically limit your models to the current team

So you're using spark, and you have teams enabled. You start creating models and want to have them be team specific. Instead of writing, Model::where('team_id', auth()->user()->currentTeam->id)->get(); use this trait to add that behind the scenes so that every time you call on your model, it's assumed that you mean for the current team.

This assumes that the model has a team_id, while it adds a scope of where team_id = currentTeam->id.

Note: Implicit Route Model Binding in 5.2, auth session doesn't exist at the point of this trait causing issue. fixed in 5.3

View Spark User Team Seeding.md

Seeding Users & Teams In Laravel Spark

Makes 5 users each with 1 team that has 5 members

Add a team factory to database/factories/ModelFactory.php

$factory->define(App\Team::class, function (Faker\Generator $faker) {
    return [
        'name' => $faker->sentence,
@QuantumGhost
QuantumGhost / example.puml
Last active Nov 13, 2019
A simple template for PlantUML to draw ER diagram.The basic idea comes from http://plantuml.sourceforge.net/qa/?qa=331/database-modeling
View example.puml
@startuml
' uncomment the line below if you're using computer with a retina display
' skinparam dpi 300
!define Table(name,desc) class name as "desc" << (T,#FFAAAA) >>
' we use bold for primary key
' green color for unique
' and underscore for not_null
!define primary_key(x) <b>x</b>
!define unique(x) <color:green>x</color>
!define not_null(x) <u>x</u>
@mitsuruog
mitsuruog / bind.js
Last active Apr 6, 2018
multiple property databinding on SAPUI5
View bind.js
new sap.m.Text({
text: {
parts: [
{path: "Width"},
{path: "Depth"},
{path: "Height"},
{path: "DimUnit"}
],
formatter: function(width, depth, height, dimUnit){
return width + " x " + depth + " x " + height + " " + dimUnit;
@whatnickcodes
whatnickcodes / base64.js
Created Apr 24, 2014
How to Encode and Decode Strings with Base64 in JavaScript
View base64.js
// Create Base64 Object
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r
@rothgar
rothgar / main.yml
Last active Dec 3, 2019
Generate /etc/hosts with Ansible
View main.yml
# Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source.
# Will include all hosts the playbook is run on.
# Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html
- name: "Build hosts file"
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['all']
@JDMcKinstry
JDMcKinstry / apiCCB.php
Last active Jul 22, 2019
Simple PHP class for interacting with the Church Community Builder (CCB) API.
View apiCCB.php
<?
/***
* class apiCCB
*
* @author Jeremiah D. McKinstry <jdmckinstry@gmail.com>
* @date Wednesday, August 14, 2013
* @version 1.0.0
* @see https://cdn6.ccbchurch.com/2/documents/pwt_implement.pdf
*
* @copyright This class is free: you can redistribute it and/or modify
@elsewhat
elsewhat / sapui5_sources_latest.sh
Created Jul 26, 2013
Get latest SAPUI5 for eclipse update site
View sapui5_sources_latest.sh
#!/bin/bash
echo "1. Download the main file from the eclipse update site"
wget --no-check-certificate https://tools.hana.ondemand.com/juno/content.jar
echo "2. Unzip the content.jar to content.xml (and delete content.jar)"
unzip content.jar
rm content.jar
echo "3. Generate urls for the components to fetch com.sap.ui5"
@viniciustavanoferreira
viniciustavanoferreira / Z_RTTI_VTF.abap
Created May 21, 2013
Run Time Type Identification (example).
View Z_RTTI_VTF.abap
*&---------------------------------------------------------------------*
*& Report Z_RTTI_VTF
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z_RTTI_VTF.
TYPES in_type TYPE i.
@domenic
domenic / README.md
Created Mar 29, 2012
Cross-platform git hooks for Node.js
View README.md

Here's how this works:

  • Include a git_hooks/ directory in your project, with these two files (plus other hooks if you want, written in a similar style).
  • Add "npm" to your devDependencies in package.json, so that the pre-commit hook can do its magic.
  • Add test and lint scripts to your package.json, e.g.
    "scripts": {
        "test": "mocha",
        "lint": "jshint ./lib --show-non-errors"
You can’t perform that action at this time.