Skip to content

Instantly share code, notes, and snippets.

View gibizer's full-sized avatar

Balazs Gibizer gibizer

View GitHub Profile
# This will succeed if applied as an update over https://gist.github.com/gibizer/a0c4e5dc4a59ed3217f64c04a8f207a4
# if there are still free resource on the compute as neutron allows replacing a qos policy on a bound port and does
# the necessary allocation update in placement.
heat_template_version: wallaby
resources:
net0:
type: OS::Neutron::ProviderNet
properties:
name: net0
# This will fail is used as an update over https://gist.github.com/gibizer/a0c4e5dc4a59ed3217f64c04a8f207a4 as
# neutron does not support changing a qos rule if that is used by a bound port
heat_template_version: wallaby
resources:
net0:
type: OS::Neutron::ProviderNet
properties:
name: net0
network_type: vlan
heat_template_version: wallaby
resources:
net0:
type: OS::Neutron::ProviderNet
properties:
name: net0
network_type: vlan
physical_network: physnet0
segmentation_id: 100
import openstack
def main():
cloud = openstack.connect()
projects = cloud.list_projects()
for project in projects:
print('project_id:', project['id'])
floating_ips = cloud.list_floating_ips(
filters={"project_id": project["id"]},
// ==UserScript==
// @name opendev gerrit CI table
// @namespace http://tampermonkey.net/
// @version 0.3
// @description
// @author gibi
// @match https://review.opendev.org/c/*
// @grant none
// ==/UserScript==
import unittest
from unittest import mock
class System:
def __init__(self):
self.counter1 = 0
self.counter2 = 0
def foo(self):
import dataclasses
@dataclasses.dataclass
class Animal:
name: str
likeable: bool = True
class Cat(Animal):
color: str
//! # A generic threaded pipeline
use std::fmt::Display;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use log::{error, info};
use log_panics;
//! # Counting word frequncy in text
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
fn get_word_freq<R: Read>(input: &mut R) -> HashMap<String, u32> {
let mut text = String::new();
// TODO: avoid reading the whole input into memory here
// TODO: would be nicer to return a Result<HashMap..., Err> instead of
// panic on non utf-8 input
import collections
counter = collections.Counter()
word = ""
with open('sherlock.txt') as f:
while True:
c = f.read(1)
if not c:
break
if c.isalnum():