Skip to content

Instantly share code, notes, and snippets.

View gallettilance's full-sized avatar

Lance Galletti gallettilance

View GitHub Profile
@gallettilance
gallettilance / Stream_of_all_Points_in_3D.js
Last active November 14, 2017 21:42
Functional Reactive Programming
// // // // // // // // // // // // // // // //
// set up:
// you have a counter with id="theCounts_triples"
// and buttons for the prev points, next points
// and a reset button. We order the points by
// the sum of their coordinates (i.e. along the
// diagonally cutting plane
// // // // // // // // // // // // // // // //
var tripleNext = $('#triplesNext').asEventStream('click');
@gallettilance
gallettilance / sieve.clj
Last active November 14, 2017 21:43
Sieve Of Eratosthenes - Stream of Primes
(defn theNats [init]
(lazy-seq (cons (+ init 1) (theNats (+ init 1))))
)
(defn sieve [nats]
(lazy-seq (cons (first nats) (filter (fn [x] (> (mod x (first nats)) 0)) (rest nats)))
))
(def thePrimes (sieve (theNats 2)))
@gallettilance
gallettilance / subsets.clj
Created November 16, 2017 01:44
Get all subsets of a set
(defn combine [xs ys res]
(if (empty? ys) res (concat (combine (cons (first ys) xs) (rest ys) '())
(combine xs (rest ys) (cons (cons (first ys) xs) res)) )))
(defn getsubsets [xs]
(cons '() (combine '() xs '())))
(count (getsubsets '(1 2 3))) ;; 2^3 = 8
(count (getsubsets '(1 2 3 4))) ;; 2^4 = 16
(count (getsubsets '(1 2 3 4 5))) ;; 2^5 = 32
@gallettilance
gallettilance / permutations.clj
Created November 16, 2017 02:10
Lazy get next permutation
(defn list_reverse [xs]
(letfn [(helper [xs res] (if (empty? xs) res (helper (rest xs) (conj res (first xs)))))]
(helper xs nil)
))
(defn list_length [xs]
(letfn [(helper [xs res] (if (empty? xs) res (helper (rest xs) (+ res 1))))]
(helper xs 0)
))
@gallettilance
gallettilance / opm-cli.md
Created October 3, 2019 16:57
Operator Registry's OPM CLI

opm

Here are a list of commands and flags for the new opm cli of operator-registry that cover the existing functionality of all other binaries.

  1. appregistry-server equivalent

opm serve appregistry ...

  1. confimap-server equivalent

Testing operator registry

In the current state of 4.3, creating a catalogsource will create an operator registry pod using the old format. The new format is available through the use of the opm binary / command line utility that is not currently referenced when building an operator registry pod on an OCP cluster. Hence, we cannot test the new fields and formats that were added to the registry database on an OCP cluster. In order to test that the operator registry has been populated with the correct content, we need to do this testing locally.

Operator-Registry communicates usinng grpc. To test that the content is properly set we need to create a new operator registry service by using the opm command line tool locally and query the registry server using grpcurl.

├── 3scale-operator
│   ├── 3scale-operator.package.yaml
│   ├── 3scale-operator.v0.3.0.clusterserviceversion.yaml
│   ├── 3scale-operator.v0.4.0.clusterserviceversion.yaml
│   ├── 3scale-operator.v0.4.1.clusterserviceversion.yaml
│   ├── 3scale-operator.v0.4.2.clusterserviceversion.yaml
│   ├── APIManager-v1alpha1.crd.yaml
│   ├── API-v1alpha1.crd.yaml
│   ├── Binding-v1alpha1.crd.yaml
@gallettilance
gallettilance / add_properties.py
Last active July 28, 2021 13:51
Add maxOpenShiftVersion Property of "4.8" to all bundles that use deprecated v1beta1 APIs
# Requires
# OPM, operator-sdk v1.8.0 or higher
# grpcurl, podman or docker, skopeo, manifest-tool
import os
import re
import time
import json
import socket
import sqlite3
# Requires
# OPM, operator-sdk v1.8.0 or higher
# grpcurl, podman or docker, skopeo, manifest-tool
import os
import re
import time
import json
import socket
import sqlite3

How to Run the Script

    python3 add_properties.py

Change INDEX_IMAGE (image that needs the properties added) and TARGET_INDEX (output image that will contain all the properties) to add the property to different indexes.

INDEX_IMAGE should be: