Skip to content

Instantly share code, notes, and snippets.

@AndrewBelt
AndrewBelt / panel2source.py
Created November 1, 2017 08:30
for exporting SVG panels to VCV plugin source files
# panel2source.py
# for exporting SVG panels to VCV plugin source files
# Version: 1
# Support contact email: /dev/null
# License: CC0
import sys
import os
import re
@toke
toke / Vagrantfile
Last active October 27, 2017 13:15
Ansible Issue 30753 (https://github.com/ansible/ansible/issues/30753) Testcase using Vagrant against Debian Wheezy
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "debian/wheezy64"
config.vm.provision :ansible do |ansible|
ansible.playbook = "playbook.yml"
end
end
@abadger
abadger / basic.rst
Last active October 17, 2018 17:13
categorization of basic.rst

For the glossary:

distribution
In some operating systems, the kernel of the OS is produced by one organization but this is combined with other necessary tools by a second organization. This second organization is called a distribution.
native string
Python2 and Python3 have different types for unadorned string literals and many strings operations. In Python2, these are byte strings. In Python3,
from __future__ import print_function
import automat
import os, sys, logging, json, time
from flask import Flask, request
from Queue import Queue
from threading import Thread
class BaseMachine(object):
_machine = automat.MethodicalMachine()
# See https://github.com/ansible/ansible/compare/devel...alikins:var_man_changed_show_change
#
TASK VARS:
{
"a": {
"final": 1,
"scopes": [
{
"info": null,
@kingspp
kingspp / logging.py
Created April 22, 2017 07:14
Python Comprehensive Logging using YAML Configuration
import os
import yaml
import logging.config
import logging
import coloredlogs
def setup_logging(default_path='logging.yaml', default_level=logging.INFO, env_key='LOG_CFG'):
"""
| **@author:** Prathyush SP
| Logging Setup
@SegFaultAX
SegFaultAX / transitive.py
Created March 10, 2017 22:12
Simple Dependency graph / Transitive closure [python]
def dependencies(partials):
shallow_dep_list = { m.name: m.inherits for m in partials }
def transitive1(otl):
deps = []
rest = list(shallow_dep_list[otl])
while rest:
e = rest.pop()
deps.append(e)
rest += [d for d in shallow_dep_list[e] if d not in deps]
return deps

When the manifest file of my project/the root project, call it A, contains a dep/constraint statement for another project, say X, that doesn't appear in A's import statements, there are three modes in which tools can interpret that:

  1. X must be present in the result (A's lock+vendor), and it must meet the version constraint.
    • (There's a variant where it works like this when it’s the root manifest giving the dep on X, but if it’s a non-root manifest, things work like 2)
  2. X needn't be present in the result, and even if it is, it needn't meet the constraint. (Basically, the constraint is cruft and we ignore it)
  3. X needn't necessarily be present in the result, but if it is (because some other dep actually does import X), then it must meet A's stated constraint.
    • (Again, there's a variant where it works like this for the root manifest, but like 2 for a non-root manifest.)

The first mode's biggest benefit is up-front intuitiveness for users. As we've discussed, it corresponds nicely to a get or add-

@TomWhitwell
TomWhitwell / compose.py
Created November 20, 2016 17:51
Python script to generate random scores for modular synth
import random
import string
# -*- coding: utf-8 -*-
def randomname(length = 6):
vowels = ['a','e','i','o','u','']
consonants = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z']
a = random.sample(consonants,length/2)
x = 1
- hosts: all
vars:
repo_file: '/etc/apt/sources.list.d/ppa_jal233_proot_trusty.list'
tasks:
- name: 'Remove repo file'
file:
path: '{{ repo_file }}'
state: 'absent'