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 / readme.md
Last active November 18, 2022 18:35 — forked from StevenACoffman/ send_metric_to_statsd.sh
Send a metric to StatsD from bash

SENDING METRICS TO STATSD WITH A SHELL ONE-LINER

NOTE: From here

Etsy’s great post about tracking every release and has some good tips about tracking releases with statsd and graphite (including some essential graphite config tweaks). I was wondering how to do this from within a shell script, and I had to dig through lots of StatsD code and examples to find this snippet. I forget where I eventually found it, and thought it’d make it easier to find.

Deploy scripts are just one place where a concise and safe way to record a metric/event in important. From Etsy’s blog, using vertical lines to represent distinct events (code deployments) to give more context to the login trends:

Sending a metric from the command line, with netcat or curl, is just one bit of ‘glue’ that is essential for pulling t

@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