Skip to content

Instantly share code, notes, and snippets.

View VLogin's full-sized avatar

Viacheslav Login VLogin

  • Saint Petersburg, Russia
View GitHub Profile
@VLogin
VLogin / binary_operations_python.txt
Last active August 16, 2022 10:39
[Битовые операции в python] #python
Битовые операторы Python
Эти операторы работают над операндами бит за битом.
Бинарное И (&)
Проводит побитовую операцию and над двумя значением. Здесь бинарная 2 — это 10, а 3 — 11. Результатом побитового and является 10 — бинарная 2. Побитовое and над 011(3) и 100(4) выдает результат 000(0).
Пример:
>>> 2&3
2
>>> 3&4
@VLogin
VLogin / flatten_list.py
Created August 12, 2022 17:48
[flatten_list] flatten list
# flatten([1, [2, 3, [4]], 5]) -> [1,2,3,4,5]
# flatten([1, [2,3], [[2], 5], 6]) -> [1,2,3,2,5,6]
def flatten(s):
if not s:
return []
if isinstance(s[0], list):
return flatten(s[0]) + flatten(s[1:])
return s[:1] + flatten(s[1:])
@VLogin
VLogin / vcofrmnlib.py
Created July 3, 2022 11:36
[vcofrmnlib.py] #python #vro #vco
#!/bin/env python
"""
Python library for calling vCO workflows.
Author: AV
Date: 2018-07-11
Changed 2019-03-18
@VLogin
VLogin / vcofrmn.py
Created July 3, 2022 11:35
[vcofrmn.py] #python #vro #vco
#!/bin/env python
"""
Python wrapper for calling vCO workflows.
Author: AV
Date: 2018-06-14
Version: 0.6
History:
@VLogin
VLogin / k8s_snippets.txt
Created May 1, 2022 11:24
[curl k8s api from inside the pod] #k8s
CERT=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
curl --cacert $CERT -H "Authorization: Bearer $TOKEN" https://$KUBERNETES_SERVICE_HOST/api/v1/prelude/default/pods/
@VLogin
VLogin / CreateSession
Last active April 8, 2022 06:32
[CreateSession] scripting task #vRO #scripting_task
var spanSet = {}
for each (var vm in allVms) {
var vmOpts = allSessions.filter(function(x){ return x.vmName == vm.name })[0]
System.log(vmOpts)
System.log(vmOpts.parentName)
for each (var dev in vm.config.hardware.device) {
if (
!(dev instanceof VcVirtualVmxnet2) &&
!(dev instanceof VcVirtualVmxnet3) &&
!(dev instanceof VcVirtualE1000)
@VLogin
VLogin / esxcli.oneliners
Last active September 30, 2019 12:39
[esxcli] ESXi cli snippets #esxi #vsphere #esxcli
1. To find out the CIMC ip from within the ESXi cli:
[code]
enum_instances OMC_IPMIIPProtocolEndpoint root/cimv2 |grep ipv4
2. To change vmnic order (https://kb.vmware.com/s/article/2091560):
[code]
localcli --plugin-dir /usr/lib/vmware/esxcli/int/ deviceInternal alias list
localcli --plugin-dir /usr/lib/vmware/esxcli/int/ deviceInternal alias store --bus-type pci --alias vmnicN --bus-address B
For example, if you want to swap vmnic3 and vmnic4 use the following commands: