Skip to content

Instantly share code, notes, and snippets.

View kotfic's full-sized avatar

Christopher Kotfila kotfic

  • Kitware
  • Washington DC
View GitHub Profile
@kotfic
kotfic / 99-usb-radio.rules
Created August 27, 2022 18:20
Steps to get FT-891 and rigctld working with udev and systemd
# /etc/udev/rules.d/99-usb-radio.rules
# Adds the /dev/ft891 device, note that ID_USB_INTERFACE_NUM is required because of the weird use of the USB to Dual serial adapter driver
SUBSYSTEM=="tty" ENV{ID_USB_INTERFACE_NUM}=="00" ATTRS{idVendor}=="10c4" ATTRS{idProduct}=="ea70" SYMLINK+="ft891" ENV{SYSTEMD_WANTS}="rigctld.service"
import sys
import click
from piplicenses import get_packages, create_parser
from pipdeptree import build_dist_index, construct_tree
try:
from pip._internal.utils.misc import get_installed_distributions
from pip._internal.operations.freeze import FrozenRequirement
except ImportError:
from pip import get_installed_distributions, FrozenRequirement

Problem

Lets say you have Gitlab CI defined that generates docker images on merge request. This is great because it lets people review your work in a consistent environment. The problem is all those image tags from branches hang around in the registry and clutter things up. Wouldn't it be great if you could remove those tags as apart of the CI when you merge to master?

Solution

When merging a branch to gitlab it automatically provides a merge title "Merge branch 'branch-name' into 'master'." During the master CI pipeline we can parse out the branch name from the commit and use that to remove any tagged images in the form gitlab.kitware.com:4567/group/project/container:branch-name.

There are a few sticking points we have to negotiate. In order to use a reasonable tag name when generating the merge request image tag we use the $CI_COMMIT_REF_SLUG which is a url friendly conversion of the branch name (e.g. "dev/feature/branch-name" becomes "def-feature-branch-name"). The script parses out 'dev/feature

def _walk_obj(obj, func, leaf_condition=None):
"""Walk through a nested object applying func to each leaf element.
This function recursively builds a nested structure from a simple
object (e.g. dict, list, tuple) by applying func to each element
leaf element. By default a leaf node is considered to be any
object that is not a dict, list or tuple unless leaf_condition is
defined. leaf_condition should be a callable function that
returns True or False when passed the object. This allows
_walk_obj to consider simple objects that meet certain conditions
==> amazon-ebs: Provisioning with Ansible...
==> amazon-ebs: Executing Ansible: ansible-playbook --extra-vars packer_build_name=amazon-ebs packer_builder_type=amazon-ebs -i /tmp/packer-provisioner-ansible415170920 /home/kotfic/src/deployments/girder-load-testing/girder/site.yml --private-key /tmp/ansible-key145955565
amazon-ebs: [DEPRECATION WARNING]: docker is kept for backwards compatibility but usage is
amazon-ebs: discouraged. The module documentation details page may explain more about this
amazon-ebs: rationale..
amazon-ebs: This feature will be removed in a future release. Deprecation
amazon-ebs: warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
amazon-ebs:
amazon-ebs: PLAY [all] *********************************************************************
amazon-ebs:
#!/bin/sh
#
#
# this is a fork of schnouki's script, see original blog post
# https://schnouki.net/posts/2014/12/12/openvpn-for-a-single-application-on-linux/
#
# original script can be found here
# https://gist.github.com/Schnouki/fd171bcb2d8c556e8fdf
NS_NAME=kitware
[Unit]
Description=Gentle Rain via mpv and youtube-dl
[Service]
Type=simple
ExecStart=/usr/bin/mpv --no-video "https://www.youtube.com/watch?v=lasWefVUCsI&t=100s"
ExecStop=/usr/bin/pkill -f "lasWefVUCsI"
Restart=always
[Install]
L57.Globe.annual.2011.hh04vv13.h5v1.doy014to270.NBAR.v3.0
L57.Globe.annual.2011.hh25vv02.h2v2.doy100to260.NBAR.v3.0
L57.Globe.annual.2011.hh25vv02.h5v4.doy066to292.NBAR.v3.0
L57.Globe.annual.2011.hh26vv02.h4v5.doy111to239.NBAR.v3.0
L57.Globe.annual.2011.hh04vv13.h5v1.doy014to270.NBAR.v3.0
L57.Globe.annual.2011.hh25vv02.h2v2.doy100to260.NBAR.v3.0
L57.Globe.annual.2011.hh25vv02.h5v4.doy066to292.NBAR.v3.0
L57.Globe.annual.2011.hh26vv02.h4v5.doy111to239.NBAR.v3.0
# [Celery best practice]
from myapp import foo
foo.delay(args, kwargs)
# [Correct way to do in Celery what GW tries to do now]
from myapp import app
app.send_task(“myapp.foo”, args, kwargs)
# [Current Girder]