Skip to content

Instantly share code, notes, and snippets.

View leantony's full-sized avatar
💭
I may be slow to respond.

leantony

💭
I may be slow to respond.
View GitHub Profile

FiniteAuditTrail Trait

Support for keeping an audit trail for any state machine, borrowed from the Ruby StateMachine audit trail gem. Having an audit trail gives you a complete history of the state changes in your model. This history allows you to investigate incidents or perform analytics, like: “How long does it take on average to go from state a to state b?”, or “What percentage of cases goes from state a to b via state c?”

Requirements

  1. PHP >= 5.4
  2. Laravel 4 framework
@leantony
leantony / array-sorting.php
Created June 9, 2016 15:27 — forked from MwirabuaTimothy/array-sorting.php
php - sorting an array of words by their relevance to a keyword
<?php
$query = 'ma';
$names = ['Kevin', 'Michael', 'Joseph', 'Mark', 'Edward', 'Velma', 'William', 'Mary', 'Kimani'];
// $target = ['Mark', 'Mary', 'Michael', 'Kimani', 'Velma', 'William', 'Edward', 'Joseph', 'Kevin'];
// $result = ['Mark', 'Mary', 'Kimani', 'Michael', 'Velma', 'William', 'Edward', 'Kevin', 'Joseph'];
// the slight difference is because the longer words have more irrelevant characters
function weights($query) { // return weight of letters determined by their order of appearance
$query = strtolower($query); // eliminate case sensitivity
create table oauth_client_details (
client_id VARCHAR(255) PRIMARY KEY,
resource_ids VARCHAR(255),
client_secret VARCHAR(255),
scope VARCHAR(255),
authorized_grant_types VARCHAR(255),
web_server_redirect_uri VARCHAR(255),
authorities VARCHAR(255),
access_token_validity INTEGER,
refresh_token_validity INTEGER,