Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Delorier RDelorier

View GitHub Profile
View states_hash.json
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@RDelorier
RDelorier / example.html
Last active Jan 27, 2017
Vue js filter to use with select options
View example.html
//js
users = [
{ name:'foo', id:1 },
{ name:'bar', id:2 },
{ name:'baz', id:3 }
];
//html
<select
v-model="user.id"
@RDelorier
RDelorier / chosen_select.js
Created Nov 18, 2015
Notify Vue when chosen select updates
View chosen_select.js
"use strict";
import Vue from 'vue';
Vue.directive('chosen', {
bind(){
var event = document.createEvent('HTMLEvents');
event.initEvent('change', true, true);
$(this.el).chosen({
@RDelorier
RDelorier / encrypt.php
Last active Jan 20, 2016
Laravel compatible encrypt method
View encrypt.php
<?php
/**
* Encrypts the value in a way compatible with laravel 5.1
* @param $value value to encrypt
*
* @return string
*/
function encrypt($value)
{
View HasOneScoped.php
<?php
namespace App\Models\Relations;
use Illuminate\Database\Eloquent\Relations\HasOne;
class HasOneScoped extends HasOne
{
protected $attributes = [];
View Quill.vue
<template>
<div class="quill-editor">
<!-- Create toolbar container -->
<div id="toolbar" ref="toolbar" @click.prevent>
<select class="ql-size">
<option value="small"></option>
<option selected></option>
<option value="large"></option>
<option value="huge"></option>
</select>
View TransformsViaFractal.php
<?php
namespace App\Traits;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
trait TransformsViaFractal
{
/**
* Convert current item into a fractal instance.
@RDelorier
RDelorier / AccessToken.php
Created Jan 27, 2017
Passport jwt additional claims
View AccessToken.php
<?php
namespace App\Auth;
use Laravel\Passport\Bridge\AccessToken as BaseToken;
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Key;
use Lcobucci\JWT\Signer\Rsa\Sha256;
use League\OAuth2\Server\CryptKey;
use League\OAuth2\Server\Entities\ClientEntityInterface;
View .gitconfig
[user]
email = rdelorier@gmail.com
name = Ricky Delorier
[alias]
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
lg2 = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
[core]
excludesfile = /Users/rdelorier/.gitignore_global
View parse-slow-log.sh
## Slow requests grouped by function call
cat /var/log/php-fpm/www-slow.log | grep -A 1 script_filename | \
grep -v script_filename | grep -v -e "--" | cut -c 22- | sort | uniq -c | sort -nr
## Slow requests grouped by minute
cat /var/log/php-fpm/www-slow.log | grep 'pool www' | \
cut -d' ' -f2 | sort | cut -d: -f1,2 | uniq -c
## Top 25 1 minute groups of slow requests
cat /var/log/php-fpm/www-slow.log | grep 'pool www' | cut -d' ' -f2 | \