Skip to content

Instantly share code, notes, and snippets.

View developerdino's full-sized avatar

Dean Tedesco developerdino

  • Verified International @verifedit
  • Melbourne, Australia
  • 19:49 (UTC +11:00)
  • X @developerdino
View GitHub Profile
@developerdino
developerdino / ThrottleRequests.php
Created February 16, 2016 04:12
Lumen Middleware for rate limiting - based on Laravel's implementation.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Response;
use Illuminate\Cache\RateLimiter;
class ThrottleRequests
{
@developerdino
developerdino / parent-categories.sql
Created April 18, 2016 23:37
Get all parent records for a child category - is good for getting the records for a breadcrumb trail. Thanks to http://stackoverflow.com/questions/2441821/getting-all-parent-rows-in-one-sql-query
select t2.id, t2.name
from (
select
@r as _id,
(select @r := parent_id from categories where id = _id) as parent_id,
@l := @l + 1 as lvl
from
(select @r := :id, @l := 0) vars,
categories h
where @r <> 0) t1
# Commands for setting time on servers
# FOR TESTING PURPOSES ONLY #
# Disable NTP syncing
sudo timedatectl set-ntp 0
# Set time to when you want
sudo timedatectl set-time "2016-07-01 08:00:00"
# Enable NTP syncing
@developerdino
developerdino / handy_git_commands.sh
Last active May 9, 2017 23:55
Handy GIT Commands
# remove all tags from origin that end in digits (/[0-9]*)
# remove --dry-run to actually do the deletions
git ls-remote --tags | grep -o 'refs/tags/.*/[0-9]*' |sort -r |xargs git push --dry-run --delete origin
# sync all remote tags with your local repo so you don't push them all back up to the remote
git fetch --prune origin '+refs/tags/*:refs/tags/*'
@developerdino
developerdino / article-collection.json
Last active September 6, 2017 09:33
Using Laravel 5.5 Resources to create your own {JSON:API} formatted API - Medium Gists
{
"links": {
"self": "http://example.com/articles",
"first": "http://example.com/articles?page=1",
"last": "http://example.com/articles?page=2",
"prev": null,
"next": "http://example.com/articles?page=2"
},
"data": [
{
@developerdino
developerdino / article-item.json
Last active September 7, 2017 01:24
Using Laravel 5.5 Resources to create your own {JSON:API} formatted API - Medium Gists
{
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!"
},
"links": {
"self": "http://example.com/api/articles/1"
}
}
@developerdino
developerdino / ArticleController.php
Last active September 6, 2017 10:12
Using Laravel 5.5 Resources to create your own {JSON:API} formatted API - Medium Gists
<?php
namespace App\Http\Controllers;
use App\Article;
class ArticleController extends Controller
{
/**
* Display the specified resource.
@developerdino
developerdino / standard-article-response.json
Created September 6, 2017 10:14
Using Laravel 5.5 Resources to create your own {JSON:API} formatted API - Medium Gists
{
"id": 1,
"title": "JSON API paints my bikeshed!",
}
@developerdino
developerdino / jsonapi-org-example.json
Created September 6, 2017 10:15
Using Laravel 5.5 Resources to create your own {JSON:API} formatted API - Medium Gists
{
"links": {
"self": "http://example.com/articles",
"next": "http://example.com/articles?page[offset]=2",
"last": "http://example.com/articles?page[offset]=10"
},
"data": [{
"type": "articles",
"id": "1",
"attributes": {
@developerdino
developerdino / CreatePeopleTable.php
Last active September 7, 2017 01:20
Using Laravel 5.5 Resources to create your own {JSON:API} formatted API - Medium Gists
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePeopleTable extends Migration
{
/**
* Run the migrations.