Skip to content

Instantly share code, notes, and snippets.

View blopa's full-sized avatar
🏴‍☠️

Pablo Benmaman blopa

🏴‍☠️
View GitHub Profile
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-17.sh
Created March 22, 2026 18:39
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
bin/magento module:enable Werules_GameShop
bin/magento setup:upgrade
bin/magento cache:flush
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-16.php
Created March 22, 2026 18:39
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<?php
$mediaUrl = $block->getViewFileUrl('Werules_GameShop::images/shopkeeper.png');
$baseUrl = $block->getBaseUrl();
$pageTitle = __('GameShop - Buy & Sell Games');
$pageDescription = __('Find the best gaming deals, buy and sell games easily!');
?>
<!-- Open Graph Meta Tags -->
<meta property="og:image" content="<?= $mediaUrl ?>"/>
<meta property="og:image:alt" content="GameShop Shopkeeper Avatar"/>
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-15.xml
Created March 22, 2026 18:39
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<referenceBlock name="head.additional">
<block class="Magento\Framework\View\Element\Template"
name="werules.gameshop.head"
template="Werules_GameShop::seo/head.phtml"/>
</referenceBlock>
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-14.js
Created March 22, 2026 18:39
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
methods: {
onMenuItemClick(selection) {
if (selection === 'Talk') {
const randomIndex = Math.floor(Math.random() * this.talkLines.length);
this.currentTalkLine = this.talkLines[randomIndex];
}
}
}
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-13.html
Created March 22, 2026 18:39
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<div v-else-if="menuSelection === 'Talk'" class="flex items-center justify-center h-64 border-2 border-orange-500 p-6">
<p class="text-3xl text-orange-400 text-center">
{{ currentTalkLine }}
</p>
</div>
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-12.html
Created March 22, 2026 18:39
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<div v-if="activeView === 'detail' && currentProduct" class="space-y-4">
<p class="italic text-lg mb-2">
<?= sprintf(__('Ah, the %s! This item might do something special...'), '<strong>{{ currentProduct.name }}</strong>'); ?>
</p>
<div class="flex flex-col md:flex-row space-y-4 items-start border border-orange-500 p-4">
<img :src="currentProduct.image_url"
class="w-72 h-72 object-cover border border-orange-500 bg-black">
<div class="flex-1">
<h3 class="text-2xl font-bold">{{ currentProduct.name }}</h3>
@blopa
blopa / musclo:-redesign-do-acompanhamento-nutricional-e-por-que-a-assinatura-do-seu-app-de-fitness-é-uma-enganação-script-5.ts
Created March 22, 2026 18:39
Code for post "Musclo: Redesign do acompanhamento nutricional e por que a assinatura do seu app de fitness é uma enganação"
// utils/usdaMapper.ts
export function mapUSDAFoodToUnified(food: USDAFood): UnifiedFoodResult {
const nutrients = food.foodNutrients;
// USDA usa códigos numéricos de nutrientes — 1008/208 é energia, 1003/203 é proteína, etc.
const calories = mapUSDANutritient(nutrients, '1008') ?? mapUSDANutritient(nutrients, '208');
const protein = mapUSDANutritient(nutrients, '1003') ?? mapUSDANutritient(nutrients, '203');
const carbs = mapUSDANutritient(nutrients, '1005') ?? mapUSDANutritient(nutrients, '205');
const fat = mapUSDANutritient(nutrients, '1004') ?? mapUSDANutritient(nutrients, '204');
const fiber = mapUSDANutritient(nutrients, '1079') ?? mapUSDANutritient(nutrients, '291');
@blopa
blopa / musclo:-redesign-do-acompanhamento-nutricional-e-por-que-a-assinatura-do-seu-app-de-fitness-é-uma-enganação-script-4.ts
Created March 22, 2026 18:39
Code for post "Musclo: Redesign do acompanhamento nutricional e por que a assinatura do seu app de fitness é uma enganação"
// utils/workoutCalculator.ts
export function calculateAverage1RM(weight: number, reps: number, rir: number = 0): number {
const formulas: FormulaType[] = [
'Epley', 'Brzycki', 'Lander', 'Lombardi', 'Mayhew', 'OConner', 'Wathan',
];
let total1RM = 0;
let validFormulas = 0;
formulas.forEach((formula) => {
const oneRM = calculate1RM(weight, reps, formula, rir);
@blopa
blopa / musclo:-redesign-do-acompanhamento-nutricional-e-por-que-a-assinatura-do-seu-app-de-fitness-é-uma-enganação-script-3.ts
Created March 22, 2026 18:39
Code for post "Musclo: Redesign do acompanhamento nutricional e por que a assinatura do seu app de fitness é uma enganação"
// components/charts/LineChart.tsx — native (Skia)
import { Area, CartesianChart, Line, Scatter } from 'victory-native';
import Animated, { useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
// components/charts/LineChart.web.tsx — web (SVG)
import { VictoryArea, VictoryAxis, VictoryChart, VictoryLine, VictoryScatter } from 'victory';
@blopa
blopa / musclo:-redesign-do-acompanhamento-nutricional-e-por-que-a-assinatura-do-seu-app-de-fitness-é-uma-enganação-script-2.ts
Created March 22, 2026 18:39
Code for post "Musclo: Redesign do acompanhamento nutricional e por que a assinatura do seu app de fitness é uma enganação"
// database/encryptionHelpers.ts
export async function encryptNutritionLogSnapshot(plain: {
loggedFoodName?: string;
loggedCalories: number;
loggedProtein: number;
loggedCarbs: number;
loggedFat: number;
loggedFiber: number;
loggedMicros?: Record<string, number | undefined>;
}) {