Skip to content

Instantly share code, notes, and snippets.

View pinkeen's full-sized avatar
☢️
Feeling radiant 😎

Filip Sobalski pinkeen

☢️
Feeling radiant 😎
View GitHub Profile
#!/usr/bin/env bash
NAME="$1"
CONCURRENCY="$2"
MAX_MESSAGES="$3"
LOGFILE="var/log/worker-${NAME}.log"
PIDFILE="var/run/worker-${NAME}.pid"
@pinkeen
pinkeen / .0-MAGENTO-CLOUD-HELPER-SCRIPTS.md
Last active July 16, 2021 13:13
Helper scripts for Magento Commerce Cloud prod/stage envs

Magento Cloud helper scripts

I drop them into the root project's dir and push them to the repo. Mostly they should use whatever env you've got checked out with magento-cloud command.

Tested only on Mac with Pro/Stage envs, use at your own risk YMMV.

Tip: You can adjust .gitignore like this for convenience:

#include <stdio.h>
#include <stdint.h>
/**
* Simple string hash with minimal memory requirements.
*
* This is meant for uCs with 128-512 byte SRAM -
* the purpose is to avoid having to store string
* identifier in RAM when parsing some incoming data.
*
@pinkeen
pinkeen / anecdotes.md
Last active August 21, 2019 11:57
DevOps/SysOps Fuckup Anecdotes

Elasticsuite thesaurus fuckup / huge es logfiles

Elasticsuite synonimization feature (thesaurus) works like this:

  • For each synonimized keyword in user's search query and each synonym configured for this keyword add a match condition to the elasticsearch query that has the keyword string replaced with synonym.
  • For multiple synonymized keywords appearing in user's search query this will produce a separate match condition for each combination of each synonym of each keyword.
  • This means that the resulting elasticsearch query will basically grow geometrically with the number of synonymized keywords present in user's query as the number of conditions is roughly (keyword count)^(average number of synonyms).

What client did is they've configured a bunch of keywords with 40-80 synonyms each one. When somebody entered a search query that had 3 of them elasticsuite would produce an elasticsearch query (the raw JSON) that weighed ~1GB (sic!). Of course elasticsearch would fail to parse such query

@pinkeen
pinkeen / 01-README.md
Last active July 29, 2019 12:27
Patch Magento AMQP framework to prevent RabbitMQ blowing up with consumer jobs that require long processing

Patch Magento AMQP framework to prevent RabbitMQ blowing up with consumer jobs that require long processing

Rationale

The default AMQP settings have unlimited prefetch count - this means that the server will continue sending messages to the consumer as quickly as it can regardless of whether the client is actually reading the messages.

When consumer worker is processing a long running job it's not reading the socket, while RMQ is still sending - this causes the TCP buffer to be overflown and the connection dropped before the original job even had the chance of finishing, this has major stability implications:

@pinkeen
pinkeen / Jenkinsfile
Last active September 8, 2019 19:19
Docker Hub Build Jenkins Pipeline
/**
* This pipeline kind of simulates the Docker Hub's execution environment
* hence the build hook is used and the same env vars are provided.
*/
pipeline {
agent any
environment {
DOCKER_REPO="${params.DOCKER_REPO}"
DOCKER_TAG="${params.DOCKER_TAG}"
@pinkeen
pinkeen / 001-STUFF.md
Last active June 24, 2020 20:30
Useful scripts, patterns and stuff
@pinkeen
pinkeen / HOWTO.md
Last active June 10, 2019 15:55
Add Elasticsearch plugins to Magento Cloud docker container when running locally

How to add Elasticsearch plugins to Magento Cloud local docker setup

Please see the Official Magento Cloud docs first.

This guide has been created because the environment service configuration setting for this does not work with local docker container setup.

  1. Install the project's composer dependencies

    This is needed so the docker directory is created and ece-tools installed.

@pinkeen
pinkeen / ViolationErrorNameTest.php
Last active November 12, 2016 11:19
Test for getting a violation error name from symfony validator's ConstraintViolation
<?php
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Constraints as Assert;
@pinkeen
pinkeen / PKGBUILD
Created April 12, 2015 13:13
osmc installer pkgbuild for ver 1.1.1
# Maintainer: Sam G Nazarko <email@samnazarko.co.uk>
# Contributor: Luigi Ranghetti <ggranga@gmail.com>
pkgname=osmc-installer-bin
pkgver=1.1.1
pkgrel=1
pkgdesc="OSMC Installer allows you to install OSMC on a variety of devices."
url=http://osmc.tv
arch=(i686 x86_64)
license=(GPL)