Skip to content

Instantly share code, notes, and snippets.

Nadav Goldin nvgoldin

Block or report user

Report or block nvgoldin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nvgoldin
nvgoldin / __del__.py
Created Jan 2, 2020
__del__ order of clearing globals not promised
View __del__.py
In [2]: # %load risk_of__del__globals_cleanup.py
...: import gc
...:
...: class GlobalCounter:
...: value = 0
...:
...:
...: class SomeKlass:
...: def __del__(self):
...: print('in SomeKlass __del__')
@nvgoldin
nvgoldin / Dockerfile-python:2.7.14-alpine-h5py
Last active Jan 13, 2020
Installing tables, h5py in Alpine Docker(python:2.7.14-alpine)
View Dockerfile-python:2.7.14-alpine-h5py
FROM python:2.7.14-alpine
RUN apk add --no-cache \
--allow-untrusted \
--repository \
http://dl-3.alpinelinux.org/alpine/edge/testing \
hdf5 \
hdf5-dev && \
apk add --no-cache \
build-base
RUN pip install --no-cache-dir --no-binary :all: tables h5py
View lago_sdk_example.py
import pytest
import textwrap
import tempfile
from lago import sdk
def generate_config():
conf = """
domains:
@nvgoldin
nvgoldin / transient.py
Created Apr 23, 2017
Running 'transient' systemd unit files with dbus
View transient.py
from __future__ import print_function
import uuid
import functools
import hashlib
# TO-DO: switch to pydbus, currently same code
# with pydbus gives errors.
from dbus import SessionBus, SystemBus, Interface
def rand_name():
@nvgoldin
nvgoldin / inspect_local.sh
Created Apr 23, 2017
inspect whether a variable declared with 'local' is local
View inspect_local.sh
#!/bin/bash -ex
a="global"
b="global"
c="global"
d="global"
function koko() {
local a b c d
a="xxx"
b="zzz"
c="ddd"
@nvgoldin
nvgoldin / local_vars.sh
Created Apr 18, 2017
bash local variables and assignment in the same line masking the return code [SC2155]
View local_vars.sh
> cat local.sh
#!/bin/bash -x
function test1() {
echo "test1"
local kk=$(wtf)
echo $?
}
function test2() {
@nvgoldin
nvgoldin / ost_lago_runtest.sh
Created Apr 2, 2017
Re-run 'lago ovirt run-test' individual test
View ost_lago_runtest.sh
./run_suite.sh -o /dev/shm/ost basic-suite-master
# failure/stop
export LAGO_INITFILE_PATH="/home/ngoldin/src/gerrit.ovirt.org/ovirt-system-tests/basic-suite-master/"
export LAGO_WORKDIR_PATH="/dev/shm/ost"
export SUITE="basic-suite-master"
cd /dev/shm/ost
PYTHONPATH=$PYTHONPATH:/home/ngoldin/src/gerrit.ovirt.org/ovirt-system-tests/basic-suite-master/ lago ovirt runtest /home/ngoldin/src/gerrit.ovirt.org/ovirt-system-tests/basic-suite-master/test-scenarios/002_bootstrap.py
@nvgoldin
nvgoldin / sdk4_types.py
Last active Mar 20, 2017
sdk4 types init
View sdk4_types.py
In [1]: import ovirtsdk4 as sdk4
In [2]: sdk4.types
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-3ecb0c730dda> in <module>()
----> 1 sdk4.types
AttributeError: 'module' object has no attribute 'types'
@nvgoldin
nvgoldin / vms.py
Created Mar 19, 2017
getting nets
View vms.py
In [1]: class vm(object):
...: def __init__(self, nets):
...: self.nets = nets
...:
In [2]: vms = [ vm(nets=['1', '2']), vm(nets=['2', '9']), vm(nets=['3', '2']) ]
In [3]: set((net for vm in vms for net in vm.nets))
Out[3]: {'1', '2', '3', '9'}
@nvgoldin
nvgoldin / jenkins_perf.py
Created Feb 22, 2017
Compare jenkins job average execution time relative to a build
View jenkins_perf.py
import numpy as np
import jenkins
import getpass
import time
"""
compare a jenkins job average execution time relative to a build
advisable to have: https://wiki.jenkins-ci.org/display/JENKINS/Metrics+Plugin
"""
You can’t perform that action at this time.