Skip to content

Instantly share code, notes, and snippets.

View zoka123's full-sized avatar

Zoran Antolović zoka123

View GitHub Profile
@zoka123
zoka123 / README.md
Last active November 28, 2022 12:41
Docker SSH agent forwarding for macOS

Add SSH key to your host agent and verify it's present with ssh-add -L.

If you're using a passphrase and you face issues, try adding your key with ssh-add -K {path}, docs:

-K      When adding identities, each passphrase will also be stored in
             the user's keychain.  When removing identities with -d, each
             passphrase will be removed from it.
@zoka123
zoka123 / 1-simple-api-model.md
Last active February 20, 2020 14:29
Simple API models
<?php

declare(strict_types=1);

namespace App\Infrastructure\UI\Http\Common;

abstract class ApiModel implements \JsonSerializable
{
@zoka123
zoka123 / 1-Simple-dto.md
Last active February 20, 2020 14:21
DTO usage example
<?php

declare(strict_types=1);

namespace App\Application\Query\Article\Cms;

use App\Application\Query\QueryInterface;

class ArticleQuery implements QueryInterface
@zoka123
zoka123 / description.md
Last active February 8, 2020 15:37
Issue with SF WebTestCase and similar API tests based on the simulated requests

Let's say we want to test that after we successfuly send POST request, we can GET the same data on another endpoint. Pretty common for a CRUD-like apps.

Let's further assume our entity after creation from the POST request payload will result with a primary entity (e.g. Book) and child entities (2 Authors). We're using the constructor to create the entity (no setters) and connect everything:

$tags = .. // result is Tag[]

$book = new Book($title, $something, $tags);
@zoka123
zoka123 / extract.js
Last active February 6, 2020 23:39
Extract Croatia cities and muncipalities from Wikipedia
// https://hr.wikipedia.org/wiki/Dodatak:Popis_gradova_i_op%C4%87ina_u_RH_po_%C5%BEupanijama
data = {};
$('.mw-headline').each(function(item){
let county = $(this).text();
let nodes = $(this).parent('h2').next('ul').children('li');
let cities = $(nodes[0]).find('li').get().map(node => $(node).text());
let muncipalities = $(nodes[1]).find('li').get().map(node => $(node).text());
data[county] = {cities: cities, muncipalities:muncipalities};
@zoka123
zoka123 / curl-timing-example.md
Created January 30, 2020 15:28
Measure HTTP request timings with curl

Measure HTTP request/response timings with Curl

1. Report template file

    time_namelookup:  %{time_namelookup}\n
       time_connect:  %{time_connect}\n
    time_appconnect:  %{time_appconnect}\n
   time_pretransfer:  %{time_pretransfer}\n
      time_redirect:  %{time_redirect}\n
 time_starttransfer: %{time_starttransfer}\n
@zoka123
zoka123 / Instructions
Created May 17, 2019 07:51
Docker-sync example
This is how I use docker-sync to get better performance with Symfony apps.
The performance increase is visible to me in both response time and test execution time.
1. Install docker-sync
2. Create docker-sync configuration in the project directory.
3. Map sync name as a volume in your docker-compose.yml
4. Start docker-sync with `docker-sync start -f` and check console for errors
5. Start docker-compose
6. Attach to the container and see your files there
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<title></title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<link rel="canonical" href="" />
<meta name="content-language" content="en" />
<meta http-equiv="Content-Language" content="en" />
@zoka123
zoka123 / gist:5acff1e71e010c96304a315be16ab6c6
Last active July 5, 2017 08:09
Start Xdebug for CLI and phpunit tests
export XDEBUG_CONFIG="remote_enable=1 remote_mode=req remote_port=9000 remote_host=127.0.0.1 remote_connect_back=0"
@zoka123
zoka123 / invite.js
Last active April 9, 2017 13:37
Invite
var matches = document.querySelectorAll("a[role=button]");
for(var i = 0; i < matches.length; i++){
var item = matches[i];
if(item.innerHTML == "Invite"){
item.click();
}
}
var matches = document.querySelectorAll("a.uiButton");
for(var i = 0; i < matches.length; i++){