Skip to content

Instantly share code, notes, and snippets.

View developerdino's full-sized avatar

Dean Tedesco developerdino

  • Verified International @verifedit
  • Melbourne, Australia
  • 17:08 (UTC +10:00)
  • X @developerdino
View GitHub Profile
@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 / 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 / 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 / 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 / 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/*'
# 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 / 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
@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 / setup_xdebug.sh
Last active March 6, 2022 10:17
Setup XDebug on Laravel Homestead 4.0 with PHP 7.0
#!/usr/bin/env bash
wget http://xdebug.org/files/xdebug-2.4.0rc3.tgz
tar -xvzf xdebug-2.4.0rc3.tgz
cd xdebug-2.4.0RC3
phpize
@developerdino
developerdino / Beanstalk_to_GitHub
Created September 23, 2015 01:59
Move Git Repository from Beanstalk to GitHub with full repository history
#Example moving the DPSG Global Library
# 1 Checkout the Beanstalk Repo
git clone --bare git@codeandtheory.beanstalkapp.com:/dpsg-global-library.git
# 2 Push into your desired GitHub repo. (Please note that you must create the github repo prior to this step)
git push --mirror git@github.com:codeandtheory/dpsg-global-library.git