Skip to content

Instantly share code, notes, and snippets.

# List of errors with known causes
# * The file is treated as a YAML list, which means that every items start with a `-`.
# * Every item *must* have a `pattern` and `message` keys.
# * An item *can* have an optional `group_ids` key.
# * `pattern` - a valid regex pattern. To avoid having to escape characters,
# use the `>-` directive (literal scalar) on a new, indented, line.
# The pattern can have search groups (see `group_ids`).
# * `message` - a valid python string. If search groups are used, positional
# arguments can be added (in order to be expanded with str.format). The
# order is as provided in the optional `group_ids` list.
@mcouthon
mcouthon / rsync.sh
Last active April 5, 2017 07:25
A script to synchronize local code with code on a remote manager
if [ $# -eq 0 ]; then
echo "Need to provide an IP for the script to work"
exit 1
fi
IP=$1
USER=${2:-centos} # Set default user to centos
KEY=${3:-"~/.ssh/id_rsa"}
REPOS_DIR=/Users/pavel/dev/repos
MGMTWORKER_DIR=/opt/mgmtworker/env/lib/python2.7/site-packages
@mcouthon
mcouthon / dbus_docl_failure.txt
Created August 27, 2017 12:20
DBUS failure in docl image builder
Sending build context to Docker daemon 12.8 kB
Step 1 : FROM solita/centos-systemd-ssh:7
---> 93d5798b423e
Step 2 : RUN yum install -y -q which sudo initscripts libselinux-utils logrotate
---> Using cache
---> d1c8f8bb37d0
Successfully built d1c8f8bb37d0
Traceback (most recent call last):
File "/home/ubuntu/.virtualenvs/cloudify/bin/docl", line 11, in <module>
@mcouthon
mcouthon / dict_merge.py
Created September 7, 2017 07:47 — forked from angstwad/dict_merge.py
Recursive dictionary merge in Python
import collections
def dict_merge(dct, merge_dct):
""" Recursive dict merge. Inspired by :meth:``dict.update()``, instead of
updating only top-level keys, dict_merge recurses down into dicts nested
to an arbitrary depth, updating keys. The ``merge_dct`` is merged into
``dct``.
:param dct: dict onto which the merge is executed
:param merge_dct: dct merged into dct
@mcouthon
mcouthon / New_upgrade_mechanism.md
Last active October 19, 2017 07:31
New upgrade mechanism for Cloudify Manager

New upgrade mechanism

#cloudify

Abstract

This document is a proposal for completely reworking the Cloudify Manager upgrade mechanism. TL;DR - the current mechanism will be replaced by version-specific self-contained RPMs that will be installed in-place only.

Current problems

  • Massive downtime - teardown/bootstrap are necessary for an upgrade.
  • Fragmentation - the need to support many version combinations makes the upgrade code horrible to maintain (and look at).
@mcouthon
mcouthon / script.sh
Created March 4, 2018 09:43
Example of script that adds a file
#!/usr/bin/env bash
echo "Deploying SSH key"
cat > ssh_key << _EOF_
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEA6jl5GPIGLakcD7Xr+HWDS3NGwT0xmRcqFUnsYCpOsBeRBYcD
58Pq6JBEs2A3+kw+LIEawuFLM2//MZYxkRH0qmM/XosTaJbo1spLTSt67ILdtXmX
xGZqxArZWALekGDpeafcZraBCBY7is3Kn9Sm8ZQaM7uYzP5zYDMP8V+FajmFzMRb
0RV/DprvthC6HE5Z5k+lmZZ/F+vbWOL8PPZBO83A/Lg5h8BFwp9UKbMxHtV7eUKI
...
groups:
heal_group:
members: [{{ members }}]
policies:
host_failure_policy:
type: cloudify.policies.types.host_failure
properties:
service:
- .*host.*.cpu.total.system
interval_between_workflows: 600
@mcouthon
mcouthon / Profile.sh
Last active December 30, 2018 12:44
A convenience function to profile a python script
# This is the path to snakeviz executable in a dedicated venv
alias snake='/Users/pavel/dev/venvs/snakeviz/bin/snakeviz'
profile() {
tmp_file=$(mktemp)
python -m cProfile -o $tmp_file "$@"
snake $tmp_file
rm $tmp_file
}

JetBrains Shortcuts

Prerequisites: install jetbrains toolbox - use it to install IntelliJ (need ultimate edition for remote debugging; requires a license)

IntelliJ Community vs Ultimate

Full comparison. The main advantages of Ultimate:

  • Has all the functionality of DataGrip (SQL)
  • Has plugins for Ruby, Go, PHP, Node.js, Angular, React, and more
  • Supports Coffee/Type/Javascript
<scheme name="One Monokai (PB)" version="142" parent_scheme="Darcula">
<metaInfo>
<property name="created">2019-04-22T17:54:05</property>
<property name="ide">idea</property>
<property name="ideVersion">2019.1.1.0.0</property>
<property name="modified">2019-04-22T17:54:35</property>
<property name="originalScheme">One Monokai (PB)</property>
</metaInfo>
<colors>
<option name="CARET_COLOR" value="f8f8f0" />