Skip to content

Instantly share code, notes, and snippets.

View TiagoSilvaPereira's full-sized avatar
💻
Always coding...

Tiago S. P. Rodrigues TiagoSilvaPereira

💻
Always coding...
View GitHub Profile
@TiagoSilvaPereira
TiagoSilvaPereira / app.js
Created October 24, 2019 20:55
BabylonJs Scene - PBR - Example
var app = {
init() {
this.createScene();
},
createScene() {
this.scene = new BABYLON.Scene(this.engine);
this.scene.clearColor = new BABYLON.Color4(0, 0, 0, 0);
@TiagoSilvaPereira
TiagoSilvaPereira / index.html
Created February 13, 2021 18:13
Alpine.js Image Viewer template
<div x-data="imageViewer()">
<div class="mb-2">
<!-- Show the image -->
<template x-if="imageUrl">
<img :src="imageUrl"
class="object-cover rounded border border-gray-200"
style="width: 100px; height: 100px;"
>
</template>
@TiagoSilvaPereira
TiagoSilvaPereira / Handler.php
Created October 14, 2021 18:05
Laravel Exception Handler for API
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Arr;
use Throwable;
class Handler extends ExceptionHandler
@TiagoSilvaPereira
TiagoSilvaPereira / create_recipe_items_table.php
Last active July 14, 2021 17:24
Receipe items migration
<?php
// ...
public function up()
{
Schema::create('recipe_items', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->integer('quantity');
<?php
// ...
public function up()
{
Schema::create('recipes', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
@TiagoSilvaPereira
TiagoSilvaPereira / component02.js
Created February 13, 2021 18:24
Alpine.js image viewer with fileChosen method
function imageViewer() {
return {
imageUrl: '',
fileChosen(event) {
this.fileToDataUrl(event, src => this.imageUrl = src)
},
fileToDataUrl(event, callback) {
if (! event.target.files.length) return
@TiagoSilvaPereira
TiagoSilvaPereira / component01.js
Created February 13, 2021 18:08
Alpine.js Image Preview tutorial
function imageViewer() {
return {
imageUrl: '',
}
}
@TiagoSilvaPereira
TiagoSilvaPereira / UserController.php
Last active December 3, 2020 21:08
Laravel Controller generated with Vemto Code Generator
<?php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\Hash;
use App\Http\Requests\UserStoreRequest;
use Illuminate\Support\Facades\Storage;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@TiagoSilvaPereira
TiagoSilvaPereira / CrudController.php
Last active April 18, 2020 17:34
AbstractCrudController 02
<?php
namespace App\Http\Controllers\Base;
use ReflectionClass;
use Illuminate\Support\Str;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;