Skip to content

Instantly share code, notes, and snippets.

View carlitorweb's full-sized avatar
🏁
With a important goal ahead

Carlos Rodriguez carlitorweb

🏁
With a important goal ahead
View GitHub Profile
@carlitorweb
carlitorweb / readmedia.php
Created April 25, 2024 21:31 — forked from SniperSister/readmedia.php
readmedia.php for Joomla 4 and 5
<?php
/**
* @version 1.0.0
* @package Readmedia
* @copyright Copyright (C) 2018 David Jardin - djumla GmbH
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
* @link http://www.djumla.de
*/
/* Initialize Joomla framework */
@carlitorweb
carlitorweb / workflow.sql
Last active April 20, 2024 10:59
Your site has been upgraded from joomla 3 unsuccessfuly or that you have copied articles directly from another site using the database
-- A upgrade from 3 to 4 (or copy manually the content table) was not completed successfuly
-- as it should have created a record for each article in the #_workflow_associations table. (even if you are not using workflows it needs a record in that table).
-- Newly created articles in j4 or higher have that record created automatically.
-- The sql query below should create the missing records for you.
--
-- replace #_ with your own db prefix
INSERT INTO #__workflow_associations (item_id, stage_id, extension)
SELECT c.id as item_id, '1', 'com_content.article' FROM #__content AS c
WHERE NOT EXISTS (SELECT wa.item_id FROM #__workflow_associations AS wa WHERE wa.item_id = c.id);
@carlitorweb
carlitorweb / getEvenOddCounts.js
Created December 12, 2022 14:21
Group and count "Even - Odd" values
function getEvenOddCounts (acc, val) {
const key = val % 2 === 0 ? "even" : "odd";
acc[key] = (acc[key] ?? 0) + 1;
return acc;
}
const result = [1, 2, 3, 4, 5].reduce(getEvenOddCounts, {});
console.log(result); // { even: 2, odd: 3 }
@carlitorweb
carlitorweb / enumASobjectkey.js
Last active March 27, 2021 16:31
Use Enum as restricted key type - Typescript / React
// type.ts
enum Ingredient {
salad = "salad",
bacon = "bacon",
cheese = "cheese",
meat = "meat",
breadBottom = "bread-bottom",
breadTop = "bread-top",
}
@carlitorweb
carlitorweb / aux-statelesscomponent.js
Last active March 25, 2021 21:18
In the file "Layout", <Aux> still complaining with Typescript: This JSX tag's 'children' prop expects a single child of type 'Element', but multiple children were provided.
// AUX FILE
import React from "react";
interface AuxProps {
children: React.ReactNode;
}
const aux = (props: AuxProps) => <>{props.children}</>;
export default aux;
@carlitorweb
carlitorweb / jsplitText.php
Last active March 3, 2016 22:20
[Joomla] Search for the {readmore} tag and split the text up accordingly
$pattern = '#<hr\s+id=("|\')system-readmore("|\')\s*\/*>#i';
$tagPos = preg_match($pattern, $someText);
if ($tagPos == 0)
{
$introText = $someText;
$fullText = '';
}
else
{