Skip to content

Instantly share code, notes, and snippets.

View jpmurray's full-sized avatar
🏠
Working from home

Jean-Philippe Murray jpmurray

🏠
Working from home
View GitHub Profile
@jpmurray
jpmurray / insertIntoCollection.php
Last active March 5, 2018 21:38
[Laravel Collctions] insertBefore and InsertAFter
<?php
// at some point I wanted to insert stuff before/after specific item in a collection, and this was made.
// use it at your own risk.
Collection::macro('insertBefore', function ($target, $value, $new_key = null) {
if (is_int($target)) {
$this->items = array_merge(array_slice($this->items, 0, $target), [$value], array_slice($this->items, $target));
return;
}
@jpmurray
jpmurray / @roles.md
Last active May 17, 2020 14:54 — forked from dillinghamio/@role.md
@roles Blade Directive For Laravel Spark

@roles Blade Directive For Laravel Spark

Assumes you're using teams

Add this to the boot() method of your AppServiceProvider

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

 $user = auth()-&gt;user();

Keybase proof

I hereby claim:

  • I am jpmurray on github.
  • I am jpmurray (https://keybase.io/jpmurray) on keybase.
  • I have a public key whose fingerprint is 269C A39D 1B45 B107 356C C606 750B 56DD 2A88 23B6

To claim this, I am signing this object:

@jpmurray
jpmurray / gist:22c023359e49bd475664
Created February 24, 2016 15:32
Itunes Podcast categories in a select element
<select>
<option value="Arts">Arts</option>
<option value="Design ">&nbsp;&nbsp;&nbsp;Design </option>
<option value="Fashion &amp; Beauty ">&nbsp;&nbsp;&nbsp;Fashion &amp; Beauty </option>
<option value="Food ">&nbsp;&nbsp;&nbsp;Food </option>
<option value="Literature ">&nbsp;&nbsp;&nbsp;Literature </option>
<option value="Performing Arts ">&nbsp;&nbsp;&nbsp;Performing Arts </option>
<option value="Visual Arts ">&nbsp;&nbsp;&nbsp;Visual Arts </option>
<option value="Business">Business</option>
<option value="Business News ">&nbsp;&nbsp;&nbsp;Business News </option>
@jpmurray
jpmurray / laravel.js
Created January 8, 2016 01:50 — forked from soufianeEL/laravel.js
You use Laravel 5 and you want to send a DELETE request without creating a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. To use, import script, and create a link with the `data-method="DELETE"` and `data-token="{{csrf_token()}}"` attributes.
/*
Exemples :
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}">
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}" data-confirm="Are you sure?">
*/
(function() {
@jpmurray
jpmurray / itunes_genre.xml
Created July 21, 2015 00:16
iTunes Store genre mapping into XML format
<?xml version="1.0" encoding="UTF-8" ?>
<0>
<category>33</category>
<genre />
<subgenre />
<name>Movies</name>
</0>
<1>
<category>33</category>
<genre>4401</genre>
@jpmurray
jpmurray / itunes_genre.yml
Created July 21, 2015 00:15
iTunes Store genre mapping into YAML format
---
-
category: 33
genre: null
subgenre: null
name: "Movies"
-
category: 33
genre: 4401
subgenre: null
@jpmurray
jpmurray / itunes_genre.json
Created July 21, 2015 00:14
iTunes Store genre mapping into JSON format
[
{
"category": 33,
"genre": null,
"subgenre": null,
"name": "Movies"
},
{
"category": 33,
"genre": 4401,
@jpmurray
jpmurray / itunes_genre.csv
Created July 20, 2015 23:50
iTunes Store genre mapping into CSV format
category genre subgenre name
33 Movies
33 4401 Action & Adventure
33 4434 African
33 4402 Anime
33 4431 Bollywood
33 4403 Classics
33 4404 Comedy
33 4422 Concert Films
33 4405 Documentary