Skip to content

Instantly share code, notes, and snippets.

View programarivm's full-sized avatar

Jordi Bassagana programarivm

View GitHub Profile
<?php
namespace App\DataFixtures;
use App\Entity\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Faker\Factory;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
<?php
namespace App\DataFixtures;
use App\Entity\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
class UserFixtures extends Fixture
{
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
class User
<?php
namespace App\DataFixtures;
use App\Entity\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
class UserFixtures extends Fixture
{
@programarivm
programarivm / example.js
Last active May 2, 2023 08:33
Sharing state variables between React components
// src/features/dialog/PlayComputerDialog.js
import * as React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import CloseIcon from '@mui/icons-material/Close';
import {
Button,
Dialog,
DialogContent,
DialogTitle,
@programarivm
programarivm / example.js
Created May 2, 2023 08:26
Sharing state variables between React components
// src/features/dialog/SelectColorButtons.js
import * as React from 'react';
import { Avatar, ButtonGroup, IconButton } from '@mui/material';
import { makeStyles } from '@mui/styles';
import wKing from '../../assets/img/pieces/png/150/wKing.png';
import wbKing from '../../assets/img/pieces/png/150/wbKing.png';
import bKing from '../../assets/img/pieces/png/150/bKing.png';
import Pgn from '../../common/Pgn';
@programarivm
programarivm / example.js
Created May 1, 2023 22:19
Selecting multiple elements
import React, { useRef } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import Ascii from '../common/Ascii';
import Pgn from '../common/Pgn';
import Piece from '../common/Piece';
// ...
const Board = ({props}) => {
const state = useSelector(state => state);
@programarivm
programarivm / example.js
Created May 1, 2023 22:08
Select an element
function TextInputWithFocusButton() {
const inputEl = useRef(null);
const onButtonClick = () => {
// `current` points to the mounted text input element
inputEl.current.focus();
};
return (
<>
<input ref={inputEl} type="text" />
<button onClick={onButtonClick}>Focus the input</button>
@programarivm
programarivm / StartedButtonsPlayMode.js
Created July 31, 2022 14:11
src/features/playMode/StartedButtonsPlayMode.js
import React from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { Button, ButtonGroup } from '@mui/material/';
import { makeStyles } from '@mui/styles';
import { openDrawOfferDialog } from '../../features/dialog/offerDrawDialogSlice';
import { openResignAcceptDialog } from '../../features/dialog/acceptResignDialogSlice';
import { openTakebackOfferDialog } from '../../features/dialog/offerTakebackDialogSlice';
import { MODE_PLAY } from '../../features/modeConstants';
const useStyles = makeStyles({
@programarivm
programarivm / TwoBishopsRandomizerTest.php
Created July 29, 2022 16:23
Chess\Tests\Unit\Randomizer\Checkmate\TwoBishopsRandomizerTest
<?php
namespace Chess\Tests\Unit\Randomizer\Checkmate;
use Chess\Randomizer\Checkmate\TwoBishopsRandomizer;
use Chess\FEN\BoardToStr;
use Chess\PGN\AN\Color;
use Chess\Tests\AbstractUnitTestCase;
class TwoBishopsRandomizerTest extends AbstractUnitTestCase