Skip to content

Instantly share code, notes, and snippets.

View pepeloper's full-sized avatar
🚀

Pepe pepeloper

🚀
View GitHub Profile
@pepeloper
pepeloper / events-api.postman_collection.json
Last active January 17, 2025 15:03
API Postman para eventos
{
"info": {
"_postman_id": "e54c880d-ad6c-4855-94b4-ce89c519b298",
"name": "Events API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "3317557"
},
"item": [
{
"name": "Auth",
@pepeloper
pepeloper / README.md
Last active January 17, 2025 19:12
Documentación del ejercicio para la API del Sistema de Tickets

Documentación del ejercicio para la API del Sistema de Tickets

El objetivo de este ejercicio es crear una API para gestionar eventos, productos y pedidos. El entregable es el código de la API subido a un repositorio de GitHub. Vuestro entregable deberá funcionar con la colección de Postman que tenéis disponible.

Consideraciones previas:

  • Todas las rutas están bajo el ámbito de una empresa (company).
  • Todas las rutas (excepto auth y crear un pedido) requieren un token JWT válido en la cabecera de autorización:
    • Authorization: Bearer {token}
  • Todos los precios se manejan en céntimos de euro.
@pepeloper
pepeloper / snippets.test.js
Created January 13, 2025 16:41
API Testing con express
import './test.config.js';
import request from 'supertest';
import { app } from '../main.js';
import { connect, clearDatabase, disconnect } from './setup.js';
import jwt from 'jsonwebtoken';
import bcrypt from 'bcrypt';
import User from '../users/user.model.js';
const TEST_USER = {
username: 'testuser',
@pepeloper
pepeloper / git
Created July 18, 2018 07:39
Delete merged branchs
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
@pepeloper
pepeloper / Timestamp.php
Created May 8, 2018 10:25
Laravel validation rule for request
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
use Carbon\Carbon;
class Timestamp implements Rule
{
/**
@pepeloper
pepeloper / ProfileJsonResponse.php
Created December 15, 2017 08:56
Middleware to use Laravel debugbar on JSON responses.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\JsonResponse;
class ProfileJsonResponse
{
/**
@pepeloper
pepeloper / CronSchedule.php
Created October 2, 2017 14:24 — forked from m4tthumphrey/CronSchedule.php
CronSchedule.php - Allows one to parse a cron expression into human readable text.
<?php
/*
* Plugin: StreamlineFoundation
*
* Class: Schedule
*
* Description: Provides scheduling mechanics including creating a schedule, testing if a specific moment is part of the schedule, moving back
* and forth between scheduled moments in time and translating the created schedule back to a human readable form.
*
* Usage: ::fromCronString() creates a new Schedule class and requires a string in the cron ('* * * * *', $language) format.
@pepeloper
pepeloper / drupal_trim_string.md
Created March 20, 2017 12:58
Trim string in Drupal way

Drupal Snippet

In this snippet we will know how to trim any string in Drupal way using the truncate_utf8 function

Code

truncate_utf8($string, $max_length, $wordsafe = FALSE, $add_ellipsis = FALSE, $min_wordsafe_length = 1)

So for example we can do something like this:

@pepeloper
pepeloper / field_formatter_settings.md
Last active March 27, 2017 10:41
Custom field formatter settings

Drupal Snippet

This snippet is a follow up from this one: Crear formato personalizado para un campo de tipo fecha

In order to implement a settings form to our custom field formatter we only need to use the 'settings' parameter in the field formatter declaration (in hook_field_formatter_info()) and a few hooks.

Through the hook_field_formatter_settings_summary() we can implement a summary showing the configuration used.

hook_field_formatter_settings_summary