Skip to content

Instantly share code, notes, and snippets.

View adrianpietka's full-sized avatar

Adrian Piętka adrianpietka

View GitHub Profile

Change origin URL

git remote set-url origin new.git.url/here

Verify new remote URL

g`it remote -v
#!/usr/bin/env bash
USERNAME=$1
AWS_ACCESS_KEY_ID=$2
AWS_SECRET_KEY=$3
if [[ -z ${USERNAME} ]] && [[ -z ${AWS_ACCESS_KEY_ID} ]] && [[ -z ${AWS_SECRET_KEY} ]]; then
echo "
Usage: $(basename "$0") [USER NAME] [AWS ACCESS KEY ID] [AWS SECRET KEY]"
exit 1
<?php
class CreateUserUseCase {
public function __construct(Repository $repository) {
}
public function execute(string $username, string $password) {
}
@adrianpietka
adrianpietka / angular-bing-maps-v8.js
Last active November 1, 2017 11:28
AngularJS 1.x & Bing Maps V8 Web Control
(function () {
var mapTimer = setInterval(mapSupervisor, 10);
function mapModule(angular, Microsoft) {
angular
.module('app')
.factory('mapProxyService', mapProxyService);
console.log('Has all modules. Initialize.');
@adrianpietka
adrianpietka / silex-cors.md
Last active October 24, 2017 21:35
Silex + CORS

Allow:

  • access from every host (1)
  • use HTTP headers Authorization-Key and Origin (2)
  • use HTTP methods GET, POST, PUT, DELETE, OPTIONS (3)
<?php

$app->after(function (Request $request, Response $response) {
 $response-&gt;headers-&gt;set('Access-Control-Allow-Origin', '*'); // (1)
@adrianpietka
adrianpietka / silex-doctrine-dbal.php
Last active October 24, 2017 21:50
Silex + Doctrine DBAL
<?php
// ..
$app->register(new Silex\Provider\DoctrineServiceProvider(), [
'db.options' => [
'driver' => 'pdo_mysql',
'host' => 'localhost',
'port' => 3306,
'dbname' => 'database_name',
@adrianpietka
adrianpietka / composition.js
Last active April 13, 2017 21:39
best-practice-js
// composition
const killer = state => {
kill: () => console.log("Heu hue, I kill you!")
}
const barker = state => ({
bark: () => console.log("Wooof, I am " + state.name)
})
@adrianpietka
adrianpietka / symfony-doctrine.sh
Last active March 12, 2017 20:30
Symfony 3.x Doctrine Commands
# database managment
$: php bin/console doctrine:database:drop --force
$: php bin/console doctrine:database:create
# generate entities
$: php bin/console doctrine:generate:entity
$: php bin/console doctrine:generate:entities AppBundle
$: php bin/console doctrine:generate:entities AppBundle/Entity/Product
# schema update
@adrianpietka
adrianpietka / emailtemplates.php
Created November 28, 2016 11:25
Separate accepted email template for each national center
<?php
class EmailNotificationSubscriber
{
public function handleAcceptedForm(AcceptedFormEvent $event)
{
$this->sendEmailToReferrer(EmailTemplateCode::REFERRAL_FORM_ACCEPTED, $event->getFormId());
$this->sendAcceptedEmailToNationalCenter($event->getFormId());
}
@adrianpietka
adrianpietka / solid-solution-1.php
Last active November 16, 2016 13:59
SOLID - Technical Meeting
<?php
class Document
{
public $id;
public $title;
public $created;
public $author;
public $content;
}