This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## | |
# Synchronizes current branch with remote's master. | |
# | |
# `./git_sync.sh` – updates current branch with changes from remote/master | |
# `./git_sync.sh push` – updates remote/master with changes from current branch | |
## | |
count_stashes () { | |
# `wc` generates a value with whitespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setupRouting() { | |
registerRoute("/api/furnace", HTTP_GET, [&] (Request& request) { | |
furnaceController.apiGetAction(request); | |
}); | |
/* and many more like this one */ | |
} | |
// OPTION A: copy callback to function + move to lambda | |
void registerRoute( | |
const char* const uri, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Bar { | |
public: | |
Bar(int a, int b): a(a), b(b) {}; | |
// a is mutable property, b isn't – by the contract of object's public interface | |
void setA(int _a) { a = _a; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://www.wykop.pl/wpis/39614135/mirki-chce-przekierowanie-na-wp-jesli-httpacceptla/ | |
// 1. Zawsze porównuj z `===` - w bardzo wyjątkowych przypadkach `==` jest słuszne. Doczytaj sobie w dokumentacji dlaczego. | |
// 2. Spójność napisów - masz raz tak, raz inaczej, bez reguły. Najlepiej zawsze używaj apostrofów do napisów (`'`), chyba że faktycznie chcesz interpolować zmienne lub mieć znaki nowej linii, itp. (wtedy cudzysłowy `"`). | |
// 3. Jak kolega wyżej słusznie zauważył, `$_SERVER['HTTP_ACCEPT_LANGUAGE']` może nie istnieć. Powinieneś sprawdzać najpierw czy w ogóle jest wartość (np `isset`em) i uwzględnić ten przypadek. | |
// 4. Zmienne `$url` są Ci zbędne - wsadzaj wartość bezpośrednio do `wp_redirect`. | |
// 5. Jak już jesteś na głównej z PL, to przekierowanie zbędne. | |
// 6. Weź pod uwagę, że klient może przesłać język wielkimi literami. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// spoko, wiemy co należy przekazać | |
// ale kiepsko, bo dużo argumentów | |
function foo($bar1, $bar2, $bar3, $bar4, $bar5) { | |
} | |
// kiepsko, bo nie wiemy co dany parametr oznacza | |
foo('abc', 'def', 'ghj', 'klm', 'zxc'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Doctrine\ORM\EntityRepository; | |
class FooRepository extends EntityRepository | |
{ | |
public function save(Foo $foo) | |
{ | |
$em = $this->getEntityManager(); | |
$uof = $em->getUnitOfWork(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# what is the proper way to escape var in url path in html in twig? #} | |
{# method A #} | |
<a href="/foo/{{ bar }}">Link</a> | |
{# method B #} | |
<a href="/foo/{{ bar|e('url') }}">Link</a> | |
{# method C #} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Foo\Bar\Application\UseCase; | |
use Foo\Bar\Application\AuthorizationChecker; | |
use Foo\Bar\Domain\ItemRepository; | |
class ViewItemUseCase | |
{ | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Order | |
{ | |
public $user1; | |
public $user2; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\Security; | |
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler; | |
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; | |
use Symfony\Component\HttpFoundation\Request; | |
use Doctrine\Common\Persistence\ObjectManager; | |
use AppBundle\Entity\User; | |
use AppBundle\Entity\UserHasLoggedIn; |
NewerOlder