Skip to content

Instantly share code, notes, and snippets.

View kubk's full-sized avatar

Egor Gorbachev kubk

View GitHub Profile
import PropTypes from 'prop-types';
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type Defined<T> = T extends undefined ? never : T;
/**
* Get the type that represents the props with the defaultProps included.
*
* Alternatively, we could have done something like this:
@adamsafr
adamsafr / CountryRepository.php
Last active September 5, 2023 09:17
Doctrine: Union with JOIN example
<?php
namespace AppBundle\Repository;
use AppBundle\Entity\Country;
use AppBundle\Entity\CountryTranslation;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\QueryBuilder;
@chadrien
chadrien / README.md
Last active September 1, 2023 12:43
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&amp;&amp; echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" &gt; /usr/local/etc/php/conf.d/xdebug.ini \
<?php
namespace Acme\Serializer\Normalizer;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer;
@Burgov
Burgov / CSRFListener.php
Last active August 12, 2023 03:32
CSRF protection for AJAX requests
<?php
namespace myApp\APIBundle\Http;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@danielkcz
danielkcz / formik-mobx.js
Last active July 26, 2023 21:51
Formik with MobX
function useFormik(props) {
// useState to keep the same observable around without recreating it on each render
const [formik] = React.useState(() =>
mobx.observable({
values: props.initialValues || {},
touched: {}
})
)
// just mutate state, this function itself can be considered an action+reducer
@mcjim
mcjim / .bashrc
Last active July 21, 2023 22:16 — forked from henrik/.bashrc
Git branch, dirty and stash state in Bash prompt.
# Quick fork by @mcjim to add stash status and tweak to suit his style.
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# host dir master $ # clean working directory
# host dir master* $ # dirty working directory
# host dir master*^ $ # dirty working directory with stash
# host dir master^ $ # clean working directory with stash
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
@calebporzio
calebporzio / composer_versions_cheatsheet.md
Last active June 6, 2023 17:40
Composer version symbol cheatsheet
...
"require": {
    "vendor/package": "1.3.2", // exactly 1.3.2 (exact)

    // >, <, >=, <= | specify upper / lower bounds
    "vendor/package": ">=1.3.2", // anything above or equal to 1.3.2
    "vendor/package": "<1.3.2", // anything below 1.3.2

 // * | wildcard
@nixjobin
nixjobin / bitbucket-backup-all-repos.sh
Last active February 15, 2023 16:33
bitbucket-backup-all-repos.sh
#!/bin/bash
#Author Jobin Joseph
#Blog : nixhive.com
#Bio : JobinJoseph.com
#Bitbucket credentials
bbuser='Username_here'
bbpass='password_here'
fname=`date +%F_%H_%M`
@codedokode
codedokode / задача-сайт-testhub.md
Last active January 24, 2023 14:44
Сайт для тестирования TestHub

Задача

Примечание: раньше тут были другие условия задачи. Их можно найти в предыдущих ревизиях этого задания по ссылке https://gist.github.com/codedokode/8733007/e8e73b0255b3d899cb4e17dc9446fe694a8f5f7c

Cделать сайт TestHub, который позволяет создавать и проходить тесты (с вопросами и ответами). Их могут использовать например, преподаватели для проверки знаний студентов, работодатели для отсеивания кандидатов на вакансию, маркетологи для проведения опросов. Далее мы будем называть того, кто создает тесты, экзаменатором, а того, кто сдает, студентом, это лишь условные названия.

  • Предлагаемые технологии: фреймворк (Symfony 3-4 (сложнее, но интереснее), Yii2, Laravel), MySQL или Postgres, шаблонизатор Twig, ORM Doctrine
  • Время выполнения: все зависит от тебя, но я бы смотрел на 4-6 недель
  • Уровень: очень продвинутый новичок
  • Требуемые знания: PHP, MVC, ООП, HTML/CSS, SQL, основы JS