Skip to content

Instantly share code, notes, and snippets.

View xtrmstep's full-sized avatar
🏠
Working from home

Alexander Goida xtrmstep

🏠
Working from home
  • Sofia, Bulgaria
View GitHub Profile
@xtrmstep
xtrmstep / send-logs-to-gcp-logging.md
Last active August 14, 2022 12:40
How to send logs to GCP Cloud Logging

Custom Logs in GCP Logging

Logs can be sent to GCP logging very simple.

Basic Usage

You need to install the package google-cloud-logging.

Then the code will looks somehting like this:

@xtrmstep
xtrmstep / apache_airflow_readings.md
Created August 12, 2022 05:51
Apache Airflow Readings
@xtrmstep
xtrmstep / docker_image_build_notes.md
Created August 12, 2022 05:46
List of key notes about building and using Docker images

Here I gathered answers to small pitfalls which from time to time appears because you’re not doing some actions often. Such actions include using of .dockerignore, mounting files, SSL certificates for web servers in containers, etc.

Building of Docker images

  1. The file want be applied if it’s not located in the same directory where you run docker build command.
  2. Building of an image will fail if you use specific file names which you are ignoring. For example, if you write in Dockerfile COPY filetoignore.txt . and you are ignoring such file(s) in .dockerignore, you’ll get an error
  3. Paths inside Dockerfile are relative to the folder where you’re running command docker build and not to the one where your Dockerfile is located.
  4. Relative paths should use only current or child folders, since the parent one (or through it) is out of Docker context during building.

Docker-compose

@xtrmstep
xtrmstep / pandas_memory_consumptin.md
Created August 12, 2022 05:35
Memory consumption during adding a new column in Pandas DataFrame

A glance under the hood to what happens in memory when you do operations upon Pandas DataFrame and its columns. In monitoring I’ll use the library memory_profiler and use it in Jupyter Notebook as described here.

Since the module is using Python scripts its usage a little bit wired. The general approach is to create a method which I want to profile and execute it by means of magic code %mprun.

@xtrmstep
xtrmstep / sparse_checkout.txt
Last active August 12, 2022 05:30
How to partially download Git repo
Sparse checkout
From scratch (enable)
1) $ git init
2) $ git remote add -f origin URL
3) $ git config core.sparseCheckout true
4) create a file with exclusion rules: /.git/info/sparse-checkout
5) $ git pull origin master
On already cloned folder
@xtrmstep
xtrmstep / Branching-in-Airflow-workflows.py
Created October 16, 2021 21:49
Branching in Airflow workflows
import os
import sys
# it's required to work in Airflow with packages
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
from airflow import DAG
from airflow.utils.dates import days_ago
from airflow.utils.trigger_rule import TriggerRule
from airflow.operators.dummy import DummyOperator
@xtrmstep
xtrmstep / Feature_flags_with_Flagsmith-2.cs
Last active November 15, 2020 15:11
Using Feature Flags and Externalized configuration .NET Core app with Flagsmith - 2
public class BulletTrainRemoteConfiguration : IRemoteConfiguration
{
private readonly string _userIdentity;
private static readonly object LockObject = new object();
public BulletTrainRemoteConfiguration(RemoteConfigurationSettings settings)
{
if (BulletTrainClient.instance == null)
lock (LockObject)
if (BulletTrainClient.instance == null)
@xtrmstep
xtrmstep / Feature_flags_with_Flagsmith-1.cs
Last active November 15, 2020 15:08
Using Feature Flags and Externalized configuration .NET Core app with Flagsmith - 1
// main interface
public interface IRemoteConfiguration
{
Task<List<Feature>> GetFeatures();
Task<List<Setting>> GetSettings(List<string> keys = null);
Task<bool> IsFeatureEnabled(string key);
Task<string> GetSettingValue(string key);
}
// other classes
public abstract class RemoteConfigEntry
@xtrmstep
xtrmstep / compose-kafka-locally.yml
Created May 21, 2020 06:04
Docker-compose definition to run two Kafkas locally and configure MirrorMaker between them
version: '2'
services:
zookeeper1:
restart: always
image: wurstmeister/zookeeper:latest
container_name: zookeeper1
ports:
- "2181:2181"
kafka1: