Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Doing some octopus work

M. Mert Yıldıran mertyildiran

:octocat:
Doing some octopus work
View GitHub Profile
@mertyildiran
mertyildiran / README.md
Last active Oct 9, 2021
HTTP dissector with TCPDUMP
View README.md

Reproducing malformed HTTP packets

This is a slightly edited version of reassemblydump example of GoPacket.

Setup Sock Shop and its load tests in Google Kubernetes Engine.

Add and enter into sniffer pod:

kubectl run tapper-test -n sock-shop --rm -i --tty --overrides='{"spec": {"hostNetwork": true}}' --image mertyildiran/tapper-test -- /bin/bash
@mertyildiran
mertyildiran / README.md
Last active Sep 15, 2021
Mizu Traffic Storage Solutions
View README.md

Mizu Traffic Storage Solutions

In this Gist, three solutions will be proposed for the traffic storage in Mizu:

  • Migrate to MongoDB, add a collection per protocol and an additional collection for TCP-level information. Indexes defined per protocol.
  • Migrate to a log oriented solution like Elasticsearch/KQL.
  • Develop a custom DBMS that's specialized in traffic storage, store dissected packets in binary files. (Let's say its name is Basenine)

Docker image size with SQLite: 85.5MB

View admin_client.py
from confluent_kafka.admin import AdminClient, NewTopic
a = AdminClient({'bootstrap.servers': 'kafka:9092'})
new_topics = [NewTopic(topic, num_partitions=3, replication_factor=1) for topic in ["topic1", "topic2"]]
# Note: In a multi-cluster production scenario, it is more typical to use a replication_factor of 3 for durability.
# Call create_topics to asynchronously create topics. A dict
# of <topic,future> is returned.
print("CreateTopic")
@mertyildiran
mertyildiran / consume.go
Last active Sep 3, 2021
Kafka Go demo code
View consume.go
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/segmentio/kafka-go"
)
@mertyildiran
mertyildiran / 29-mizutest-amqp-py-dep.yaml
Last active Sep 4, 2021
Mizu message queue capture on Kubrenetes
View 29-mizutest-amqp-py-dep.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mizutest-amqp-py
labels:
name: mizutest-amqp-py
namespace: sock-shop
spec:
replicas: 1
@mertyildiran
mertyildiran / README.md
Last active Dec 10, 2021
Mizu Development Workflow
View README.md

In this tutorial we'll explain two development workflows for Mizu:

  • Standard development workflow that you build a Docker image, publish into Docker Hub and pull it to Kubernetes. The workflow is only necessary if you're developing some Kubernetes specific feature.
  • Local machine development workflow that you run Mizu Agent on your machine with sudo privileges. Which is much faster than the standard development workflow and can be used if you're not developing a Kubernetes specific feature.

Standard Development Workflow

Whenever you make changes in the agent and tap packages or protocol extensions to test it; you first need to build a Docker image:

@mertyildiran
mertyildiran / README.md
Last active Jul 13, 2021
JIT compiled Chaos vs. Python, Ruby and PHP on recursive Fibonacci
View README.md

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 Jul 9, 2021
Catflix new `discover_movie.json.j2`
View 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 Jul 9, 2021
Catflix `discover_movie.json.j2`
View 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 Jul 9, 2021
Catflix `mock_config.yaml`
View mock_config.yaml
templatingEngine: "Jinja2"
management:
port: 8000
ssl: true
services:
- port: 8081
name: "Movie Database API"
endpoints:
- path: "/3/discover/movie"
response: