Welcome to my website. I am always posting links to photo albums, art, technology and other creations. Everything that you will see on my numerous personal sites is powered by the formVistaTM Website Management Engine.

icon.linkedin.jpgicon.twitter.jpg

  • Subscribe to this RSS Feed
  • Dynamically Instantiating Classes in Python
    08/11/2016 5:52PM
    A common design pattern is to define a class or list of classeses in configuration such that at runtime the classes can be dynamically instantiated.

    I've done this before in many other languages and had need to do so today in Python (2.7.11)

    It seems as though the clean way to do so is by using the Pyton importlib module.  By using it, it enables you to cleanly dynamically import sub modules

    Following is an example:

        import importlib

        klass_1_module = 'some.module.name'
        klass_1_classname = 'KlassNameOne'

        klass_2_module = 'klass2module'
        klass_2_classname = 'KlassNameOne'

        Klass1 = getattr(importlib.import_module(klass_1_module), klass_1_classname)
        klass1_instance = Klass1()

        Klass2 = getattr(importlib.import_module(klass_2_module), klass_2_classname)
        klass2_instance = Klass1('some_arg')
  • Java PowerMock Could not reconfigure JMX java.lang.LinkageError Solution
    08/09/2016 9:00AM

    If you are using Mockito and PowerMock to build mocks for your Java tests and you run into the following error:

    2016-05-05 17:31:20,204 main ERROR Could not reconfigure JMX java.lang.LinkageError: loader constraint violation: loader (instance of org/powermock/core/classloader/MockClassLoader) previously initiated loading for a different type with name "javax/management/MBeanServer"
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
            at org.powermock.core.classloader.MockClassLoader.loadUnmockedClass(MockClassLoader.java:238)
            at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:182)
            at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:70)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:357)


    Simply add the following as a class level annotation:

    @PowerMockIgnore( {"javax.management.*"})

  • Blacklisting Kernel Modules
    06/12/2016 12:14PM

    Following is a walkthrough on how to blacklist a kernel module.  The specific example is blacklisting the nouveau driver so that I can install the OEM Nvidia driver.

    1. First, blacklist the nouveau driver: Add a line to the textfile /etc/modprobe.d/nouveau-blacklist.conf that contains they keyword 'blacklist' and the name of the driver

    blacklist nouveau

    2. Rebuild the initramfs image file.  First, backup existing initramfs


    # mv initramfs-3.10.0-327.18.2.el7.x86_64.img initramfs-3.10.0-327.18.2.el7.x86_64.img_2016-06-09.bak

    Build new initramfs
    # dracut -v /boot/initramfs-$(uname -r).img $(uname -r)

    3. Reboot the system and confirm that the driver in question is not loaded.
    # lsmod | fgrep nouveau

  • How to Return Hive Query Results Similary to MySQL \G in One Vertical Column
    06/09/2016 4:03PM

    When trying to look at data in a database with really wide rows even just selecting 1 row to see the data is nearly impossible to understand when the single row wraps 7 or 8 times.

    MySQL offers the '\G' option to display the output in a single column.

    The corresponding method in Hive is to execute the following set command:

    !SET outputformat vertical;

  • How to Configure a User Account in Active Directory So that the Password Never Expires
    06/09/2016 3:54PM

    Using ADSI Edit, navigate to the user in question.  Right-click on the user and select Properties.

    Then, scroll down to the 'userAccountControl' property and click the Edit button.

    Enter 66048 into the field and then click 'OK' and then 'Apply'.

    After closing the edit window, scroll to the right to confirm that the value indicates the following: '0x10200 = (NORMAL_ACCOUNT|DONT_EXPIRE_PASSWORD)'

Advanced Search

Categories

Archives