Skip to content

Instantly share code, notes, and snippets.

View gaborgsomogyi's full-sized avatar

Gabor Somogyi gaborgsomogyi

View GitHub Profile
from itertools import product

def generate_paintings():
    colors = ['A', 'B', 'C', 'D']
    hexagons = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7']  # 1 in the middle, 6 around
    
    # Generate all possible combinations of colors for the hexagons
    all_paintings = product(colors, repeat=7)
    

Dependency management in python

Python is not able to handle 2 different versions from the same package.

Dependency handling issue

When Pip <20.3 finds an unresolvable dependency (resolves a dependecy to 2+ versions) then would not halt the installation process. It’d successfully continue the process by installing the first matching dependency in the list of conflicts.

    @SuppressWarnings("unchecked")
    public static void setEnv(String key, String value) {
        try {
            Map<String, String> env = System.getenv();
            Class<?> cl = env.getClass();
            Field field = cl.getDeclaredField("m");
            field.setAccessible(true);
            Map<String, String> writableEnv = (Map<String, String>) field.get(env);
 writableEnv.put(key, value);

sun.net.www.protocol.http.NegotiateAuthentication caches per host (and no port information in the key) whether negotiation is supported or not (for instance SPNEGO). Worth to mention the cache is static (god knows why). This is so far so good but can lead to issues in unit tests. For example:

  • Developer writes a positive and negative test case for an SPNEGO protected server
  • Normally the order of test cases are not defined
  • Negative test case executes where SPNEGO turned off and expect 401
  • NegotiateAuthentication stores false in a map
  • Negative test case pass
  • Positive test case executes where SPNEGO turned on and expect 200
  • NegotiateAuthentication gives base isSupported=false from cache

Modify krb5.conf

$ cat /etc/krb5.conf
[libdefaults]
	udp_preference_limit=1
	default_realm = VPC.CLOUDERA.COM
	forwardable = true

[realms]
	VPC.CLOUDERA.COM = {