Skip to content

Instantly share code, notes, and snippets.

View ivanmercedes's full-sized avatar
:octocat:

Ivan Mercedes ivanmercedes

:octocat:
View GitHub Profile
@ricardov03
ricardov03 / MonthsEnum.php
Created January 20, 2025 16:49
Example of a Enum definition that includes two methods to define Labels and Select Options.
<?php
namespace App\Enums;
use Exception;
enum MonthsEnum: int
{
case JANUARY = 1;
case FEBRUARY = 2;
@nathandaly
nathandaly / BaseResource.php
Last active August 12, 2025 21:28
Tenancy for Laravel & Filament V3 (Tenant per database)
<?php
/**
* Below is an the extended Filament resource your tenant panel resources
* will have to extend so that the queries are scoped properly.
*/
namespace App\Filament;
use Filament\Resources\Resource;
import { navigate } from "gatsby-link";
import { useMoralis } from "./useMoralis";
export function useAuth() {
const { Moralis } = useMoralis();
return {
login: async () => {
try {
const user = await Moralis?.Web3.authenticate();
navigate("/");
// This function converts the byte to the corresponding amount, be it kilo, mega, GB, etc.
const convertWeightByte = (byte) => {
let sizekiloByte = (byte / 1024);
let sizeMega = (sizekiloByte / 1024);
let sizeGigabyte = (sizeMega / 1024);
let sizeTerabyte = (sizeGigabyte / 1024);
let sizePetabyte = (sizeTerabyte / 1024);
let sizeExabyte = (sizePetabyte / 1024);
if(sizekiloByte > 0 && sizekiloByte <= 1024){
@ivanmercedes
ivanmercedes / masonry.css
Created August 11, 2020 23:03
Responsive Pure CSS Masonry Layout
/* Masonry grid */
.masonry {
transition: all .5s ease-in-out;
column-gap: 10px;
column-fill: initial;
}
/* Masonry item */
.masonry .brick {
vertical-align: top; /* Keep the item on the very top */
@codigoconjuan
codigoconjuan / index.js
Created February 20, 2020 22:49
Guía para instalar React Navigation 5
// Instalar react-navigation/native
npm install @react-navigation/native
// Instalar las dependencias
npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view
// Instalar navegación en Stack
npm i @react-navigation/stack
@codigoconjuan
codigoconjuan / db.json
Last active August 26, 2023 10:31
Materiales REDUX
{
"productos": [
{
"id": 1,
"nombre": "Jugo de Zanahoria",
"precio": "31111"
},
{
"id": 2,
"nombre": "Jugo de Naranja",
@NuarkNoir
NuarkNoir / fancyTimeFormat.js
Created March 31, 2019 12:05
Fancy time formater
let fancyTimeFormat = function (time) {
// Hours, minutes and seconds
var hrs = ~~(time / 3600);
var mins = ~~((time % 3600) / 60);
var secs = ~~time % 60;
// Output like "1:01" or "4:03:59" or "123:03:59"
var ret = "";
if (hrs > 0) {
@Klerith
Klerith / parse-jwt.js
Created March 15, 2018 15:07
Parse - JWT - Obtener Payload y fecha de creación y expiración
function parseJwt (token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace('-', '+').replace('_', '/');
return JSON.parse(window.atob(base64));
};
@fgilio
fgilio / axios-catch-error.js
Last active February 11, 2026 16:18
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨