Skip to content

Instantly share code, notes, and snippets.

View tuto1902's full-sized avatar

Arturo Rojas tuto1902

View GitHub Profile
@tuto1902
tuto1902 / publish_subscribe
Created January 27, 2014 17:08
Publish / Subscribe
Application.vent.on('someEvent', function(someData){
console.log('Event triggered with ' + someData);
});
Application.vent.trigger('someEvent', 'some data');
@tuto1902
tuto1902 / TestCase.php
Created July 25, 2017 04:09
Laravel TestCase base class with exception handling helper methods
<?php
namespace Tests;
use Exception;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use App\Exceptions\Handler;
use Illuminate\Contracts\Debug\ExceptionHandler;
abstract class TestCase extends BaseTestCase
@tuto1902
tuto1902 / resumes.sql
Last active September 20, 2019 03:53
Resumes Database Schema
CREATE DATABASE resumes;
CREATE TABLE resumes.users (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
first_name varchar(50) NOT NULL,
last_name varchar(50) NOT NULL,
email varchar(255) NOT NULL,
phone varchar(10) NOT NULL,
password varchar(255) NOT NULL,
remember_token varchar(100) NULL DEFAULT NULL,
@tuto1902
tuto1902 / users.sql
Last active November 2, 2019 01:50
Simple users database
CREATE TABLE homestead.users (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
first_name varchar(50) NOT NULL,
last_name varchar(50) NOT NULL,
email varchar(255) NOT NULL,
password varchar(255) NOT NULL,
created_at timestamp NULL DEFAULT NULL,
updated_at timestamp NULL DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY users_email_unique (email)

SSL for Local Development

Generate key file

openssl genrsa -des3 -out rootCA.key 2048

Generate certificate

openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem

@tuto1902
tuto1902 / ext-xdebug.ini
Created April 24, 2021 19:46
XDebug configuration file
[xdebug]
xdebug.start_with_request=yes
xdebug.discover_client_host=true
xdebug.max_nesting_level=256
xdebug.remote_handler=dbgp
xdebug.client_port=9000
xdebug.idekey=VSCODE
xdebug.mode=debug
xdebug.client_host=host.docker.internal
@tuto1902
tuto1902 / launch.json
Last active June 28, 2024 20:16
VSCode Debugger Launch Configuration
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"log": false,
"externalConsole": false,
"pathMappings": {
@tuto1902
tuto1902 / app.blade.php
Created August 25, 2022 22:36
App Layout File
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ config('app.name') }}</title>
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<svg class="animate-spin ml-2 mr-2 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
@tuto1902
tuto1902 / validate_cron_expression.php
Created March 15, 2023 23:38
Validate a Cron expression using regex
<?php
if (!preg_match('/^(\*|[0-9,\-\/\*]+)\s+(\*|[0-9,\-\/\*]+)\s+(\*|[0-9,\-\/\*]+)\s+(\*|[0-9,\-\/\*]+)\s+(\*|[0-9,\-\/\*]+)$/', $cronExpression)) {
// Invalid expression
}