Skip to content

Instantly share code, notes, and snippets.

View mertyildiran's full-sized avatar
:octocat:
Doing some octopus work

M. Mert Yildiran mertyildiran

:octocat:
Doing some octopus work
View GitHub Profile
@mertyildiran
mertyildiran / README.md
Last active July 13, 2021 17:42
JIT compiled Chaos vs. Python, Ruby and PHP on recursive Fibonacci

fib(40) results:

$ hyperfine --warmup 3 \
	'chaos dev.kaos' \
	'python3 dev.py' \
	'ruby dev.rb' \
	'php dev.php'
Benchmark #1: chaos dev.kaos
  Time (mean ± σ):     954.4 ms ±   4.1 ms    [User: 953.6 ms, System: 0.5 ms]
@mertyildiran
mertyildiran / discover_movie.json.j2
Created July 9, 2021 16:45
Catflix new `discover_movie.json.j2`
{
"page": 1,
"results": [{% for n in range(range(100) | random) %}
{
"adult": {{ fake.boolean(chance_of_getting_true=25) | lower }},
"backdrop_path": "/500/281/cat?random={{ fake.random_int(min=0, max=1000, step=1) }}",
"genre_ids": {{ ([request.queryString.with_genres | int] + fake.random_choices(elements=[12, 28, 53, 135, 956, 2786, 10752])) | unique | list | tojson }},
"id": {{ fake.random_int(min=10000, max=50000, step=1) }},
"original_language": "{{ fake.language_code() }}",
"original_title": "{{ fake.text(max_nb_chars=20)[:-1] | title }}",
@mertyildiran
mertyildiran / discover_movie.json.j2
Created July 9, 2021 09:29
Catflix `discover_movie.json.j2`
{
"page": 1,
"results": [{% for n in range(range(100) | random) %}
{
"adult": {{ fake.boolean(chance_of_getting_true=25) | lower }},
"backdrop_path": "/500/281/cat?random={{ fake.random_int(min=0, max=1000, step=1) }}",
"genre_ids": {{ ([request.queryString.with_genres | int] + fake.random_choices(elements=[12, 28, 53, 135, 956, 2786, 10752])) | unique | list | tojson }},
"id": {{ fake.random_int(min=10000, max=50000, step=1) }},
"original_language": "{{ fake.language_code() }}",
"original_title": "{{ fake.text(max_nb_chars=20)[:-1] | title }}",
@mertyildiran
mertyildiran / mock_config.yaml
Created July 9, 2021 09:27
Catflix `mock_config.yaml`
templatingEngine: "Jinja2"
management:
port: 8000
ssl: true
services:
- port: 8081
name: "Movie Database API"
endpoints:
- path: "/3/discover/movie"
response:
@mertyildiran
mertyildiran / 01.yaml
Created May 25, 2021 00:04
Mockintosh: mocks for microservice environments - Part 7: Asynchronous Kafka Actors
services:
- name: Kafka Mocks
type: kafka
address: "{{ env 'KAFKA_ADDR' 'localhost:9092' }}"
actors: []
@mertyildiran
mertyildiran / 01.companies.json.j2
Created May 23, 2021 22:49
Mockintosh: mocks for microservice environments - Part 6: Management UI
{
"id": {{ random.int(100000, 999999) }},
"name": "{{ jsonPath(request.json, '$.name') }}",
"address": "{{ jsonPath(request.json, '$.address') }}",
"phone": "{{ jsonPath(request.json, '$.phone') }}"
}
@mertyildiran
mertyildiran / 01.yaml
Created May 22, 2021 23:30
Mockintosh: mocks for microservice environments - Part 5: Chaos and Resilience Testing
performanceProfiles:
profile1:
ratio: 1
delay: 1.5
faults:
'200': 0.3
'201': 0.1
'400': 0.1
'500': 0.2
'503': 0.1
@mertyildiran
mertyildiran / 01.yaml
Created May 22, 2021 23:28
Mockintosh: mocks for microservice environments - Part 4: Multiple Responses and Datasets
services:
- port: 8081
endpoints:
- path: "/example"
response:
- "response 1"
- "response 2"
- "response 3"
@mertyildiran
mertyildiran / 01.yaml
Last active May 20, 2021 13:35
Mockintosh: mocks for microservice environments - Part 3: HTTP Response Templating (Handlebars & Jinja2)
services:
- port: 8081
endpoints:
- path: /api-call
response:
status: "{{ request.queryString.rc }}"
headers:
content-type: '{{ request.headers.accept }}'
x-custom-id: '{{ random.int 0 1000 }}'
body: '{"result": "created", "name": "{{fake.lastname}}" }'
@mertyildiran
mertyildiran / 01.yaml
Last active May 17, 2021 22:22
Mockintosh: mocks for microservice environments - Part 2: HTTP Request Matching
services:
- port: 8081
endpoints:
- path: "/example/path/{{my_variable}}/lastsegment"
response: "my_variable is captured: {{my_variable}}"