Skip to content

Instantly share code, notes, and snippets.

View developerdino's full-sized avatar

Dean Tedesco developerdino

  • Verified International @verifedit
  • Melbourne, Australia
  • 03:46 (UTC +10: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
{

REST API Data Query Grammar

WHERE

GET /{tablename}?where[<column>][]=o:<operator>;v:<value>

WHERE BETWEEN / WHERE BETWEEN COLUMNS

GET /{tablename}?whereBetween[<column>]=v:<value 1>,<value 2>
@developerdino
developerdino / upload-files-to-s3.md
Last active June 1, 2022 13:20
Upload lots of files to S3 bucket without hitting cli limits

Shell script for uploading files to S3 bucket

Got a lot of files to upload to an S3 bucket? This little script will do it one file at a time without hitting command line limits, etc.

Usage

./upload-files-to-s3.sh <bucket-name> <directory-with-files-to-upload> <aws-profile>

<aws-profile> is optional and defaults to default

@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 / DebugServiceProvider.php
Last active April 22, 2021 01:34
Laravel: Log all queries with bound parameters observer.
<?php
namespace App\Providers;
use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\ServiceProvider;
class DebugServiceProvider extends ServiceProvider
@developerdino
developerdino / headers.conf
Created June 22, 2020 05:53
CORS nginx config using maps
add_header "Access-Control-Allow-Credentials" $cors_allowed_credentials;
add_header "Access-Control-Allow-Headers" $cors_allowed_headers;
add_header "Access-Control-Allow-Methods" $cors_allowed_methods;
add_header "Access-Control-Allow-Origin" $cors_allowed_origin;
add_header "Access-Control-Max-Age" $cors_max_age;
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class ArticleRelationshipResource extends Resource
{
/**
* Transform the resource collection into an array.

Keybase proof

I hereby claim:

  • I am developerdino on github.
  • I am dino (https://keybase.io/dino) on keybase.
  • I have a public key whose fingerprint is 680C BE5C 0B0B 0531 E0F8 BE5C A78A E054 C4A0 64F8

To claim this, I am signing this object:

{
"data": [
{
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!"
},
"relationships": {
"author": {
<?php
namespace App\Http\Resources;
use App\Comment;
use App\People;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Collection;
class ArticlesResource extends ResourceCollection