Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Painful looking code

Name: Anonymous 2012-08-10 10:29

Code that makes you experience physical pain, nausea, and/or symptoms of high blood pressure.  Merely cringing is not enough.

I barely avoided vomiting while looking at this one http://codereview.stackexchange.com/questions/14528/python-script-very-slow-any-help-to-optimise

Just in case the author (who must be Satan) deletes his masterpiece, I made an unauthorized copy http://pastebin.com/zkuHK16n

Name: 2012-08-10 11:12

# Get Domain State

import sys,os
from weblogic.management.security.authentication import UserEditorMBean

from time import strftime, sleep
today = strftime('%Y%m%d %H:%M.%S')

#import wlstutility
#wlstutility.initialise(globals())
#from wlstutility import *
#from wlstutility.constructors import *
from java.io import FileInputStream

environment = []
component = []
adminURL = ""
adminServerName = ""
configFile = ""
userKeyFile = ""
userConfigFile = ""
keyFile = ""
adminServersFail = 0
adminServersErrorCapture = []
adminServerRunning = 0
adminServerLog = []
connectToAdminServerFail = 0
setEnvironmentPropertiesFail = 0
managedServersFail = 0
managedServersErrorCapture = []
managedServerRunning = 0
managedServerState = []
otherErrorCount = 0
otherErrorCapture = []
exitCode = 255

def setEnvironmentProperties(environment, component):
    try:
        global setEnvironmentPropertiesFail
        setEnvironmentPropertiesFail = 0
        print "Checking and connecting to " + component
        print strftime('%Y%m%d %H:%M.%S') + " INFO: environment: " + environment
        domainPFile = environment + "/" + component+ ".properties"
        print strftime('%Y%m%d %H:%M.%S') + " INFO: domainPFile: " + domainPFile
        print strftime('%Y%m%d %H:%M.%S') + " INFO: component: " + component
        loadProperties(domainPFile)
        dpInputStream = FileInputStream(domainPFile)
        domainProps = Properties()
        domainProps.load(dpInputStream)
        global configFile
        configFile = "./"+environment+"/"+component+"configFile"
        print strftime('%Y%m%d %H:%M.%S') + " INFO: configFile: " + configFile
        global userConfigFile
        userConfigFile=configFile
        global keyFile
        keyFile = "./"+environment+"/"+component+"keyFile"
        print strftime('%Y%m%d %H:%M.%S') + " INFO: keyFile: " + keyFile
        global userKeyFile
        userKeyFile=keyFile
        global adminUrl
        adminUrl="t3://" + adminListenAddress + ":" + adminListenPort
        print strftime('%Y%m%d %H:%M.%S') + " INFO: adminUrl: " + adminUrl
        global adminServerName
        adminServerName = adminServerName
        global clusterAddress
        clusterAddress = clusterName
        print strftime('%Y%m%d %H:%M.%S') + " INFO: clusterAddress: " + clusterAddress
    except:
        print " FATAL: Could NOT set properties for " + environment + " " + component
        global setEnvironmentPropertiesFail
        setEnvironmentPropertiesFail += 1
        global otherErrorCount
        otherErrorCount += 1
        global otherErrorCapture
        otherErrorCapture.append(" WARNING: Properties Could Not Be Set For " + environment + " " + component)
        global adminServerLog
        adminServerLog.append(environment + ";" + adminServerName + ";" + " " + ';' + " " + ';' + component + ';' + "PROPSNOTFOUND")   


def connectToAdmin():
    try:
        global connectToAdminServerFail
        connectToAdminServerFail = 0
        print strftime('%Y%m%d %H:%M.%S') + " INFO: Connecting to running AdminServer"
        connect(userConfigFile=configFile, userKeyFile=keyFile, url=adminUrl)
        print strftime('%Y%m%d %H:%M.%S') + " INFO: Getting " + adminServerName + " Server Status"
        domainRuntime()
        cd('/ServerRuntimes/' + adminServerName)
        ss = cmo.getState()
        hs = cmo.getHealthState()
        x = hs.toString().split(',')[1].split(':')[1]
        print strftime('%Y%m%d %H:%M.%S') + " INFO: " + adminServerName + ': ' + ss + ': ' + x
        cd('../..')
        global adminServerLog
        adminServerLog.append(environment + ";" + adminServerName + ";" + ss + ';' + x + ';' + component + ';')


    except:
        global connectToAdminServerFail
        connectToAdminServerFail += 1
        print strftime('%Y%m%d %H:%M.%S') + " FATAL: Cannot connect to " + adminUrl + " ensure property files are correct"
        global adminServersErrorCapture
        adminServersErrorCapture.append(environment + ";" + adminUrl + ";" + component)
        global adminServerLog
        adminServerLog.append(environment + ';' + adminServerName + ';' + "" + ';' + " " + ';' + component + ';' + 'FAILEDCONNECTADMIN')


def findManagedServers():
    print strftime('%Y%m%d %H:%M.%S') + " INFO: Finding Managed Servers"
    try:
        global findManagedServerFail
        findManagedServerFail = 0
        domainConfig()
        print "CD to cluster" + clusterAddress
        cd('Clusters/' +clusterAddress)
        global managedServers
        managedServers=cmo.getServers()
        global numberofManagedServers
        numberofManagedServers=`len(managedServers)`
        print strftime('%Y%m%d %H:%M.%S') + " INFO: Found " + numberofManagedServers + " Managed Servers"

    except:
        global findManagedServerFail
        findManagedServerFail += 1
        print strftime('%Y%m%d %H:%M.%S') + " FATAL: Error navigating DomainConfig MBean tree for managed servers"     
        global managedServerState
        managedServerState.append(environment + ';' + "Managed Server Name NOT Found" + ';' + " " + ';' + " " + ';' + component + ';' + "FAILEDMSMBEAN")

Name: 2012-08-10 11:13

def getManagedServerState():
    domainRuntime()
    for servers in managedServers:
        managedServerName=servers.getName()
        print "Checking MS State of " + managedServerName
        try:
            print strftime('%Y%m%d %H:%M.%S') + " INFO: Getting " + managedServerName + " Server Status"
            cd('/ServerRuntimes/' + managedServerName)
            ss = cmo.getState()
            hs = cmo.getHealthState()
            x = hs.toString().split(',')[1].split(':')[1]
            print strftime('%Y%m%d %H:%M.%S') + " INFO: " + managedServerName + ': ' + ss + ': ' + x
            cd('../..')
            global managedServerState
            managedServerState.append(environment + ';' + managedServerName + ';' + ss + ';' + x + ';' + component + ';')


        except:
            print strftime('%Y%m%d %H:%M.%S') + " WARNING: " + managedServerName + " could NOT be contacted please investigate!"
            global managedServersFail
            managedServersFail =+ 1
            global managedServersErrorCapture
            managedServersErrorCapture.append(environment + ';' + managedServerName + ';' + " " + ';' + " " + ';' + component)
            global managedServerState
            managedServerState.append(environment + ';' + managedServerName + ';' + " " + ';' + " " + ';' + component + ';' + "FAILEDCONNECTMANAGED")
    if managedServersFail == numberofManagedServers:
        print strftime('%Y%m%d %H:%M.%S') + " FATAL: No Managed Servers Can Be Contacted in Cluster " + clusterAddress
        exitCode = -1

def internalServiceBus(component):
    if component == INTSB:
        try:
            domainRuntime()
            for server in serverNames:
                cd ('ServerRuntimes/intsb_ms1/JMSRuntime/intsb_ms1.jms/JMSServers/idecideserver_1/Destinations/idecideresources!idecideserver_1@idecide.commonerror')
        except:
            print strftime('%Y%m%d %H:%M.%S') + " Warning: Unable to connect to " + managedServerName
            managedServersFail += 1
            managedServersErrorCapture.append(server + " Unable to navigate domainRuntime MBean tree, please investigate")
            exitCode = -1

def exitDomainState():
    print ""
    print "---------------------------------------------------"
    print " Domain State Checks Complete"
    print "---------------------------------------------------"
    print ""
    print ""
    print "The Following Services are Running Without Issue:"
    print ""
    for smallsEnv in environments:

        print smallsEnv

        for smallsComponents in components:
            for keys in adminServerLog:
                key=keys.split(";")
                if key[0] == smallsEnv:
                    if key[4] == smallsComponents:
                        if key[5] != "FAILEDCONNECTADMIN" and key[5] != "PROPSNOTFOUND":
                            printcount = 0
                            while printcount < 1:
                                print "-" + smallsComponents
                                print "--Administration Server"
                                printcount += 1
                        if key[2] == "RUNNING":
                            print "    INFO: Weblogic Server " + key[1] + " is currently " + key[2] + " " + key[3]

            global msprintcount
            msprintcount = 0
            for keys in managedServerState:
                key=keys.split(";")
                if key[0] == smallsEnv:
                    if key[4] == smallsComponents:
                        if key[5] != "FAILEDCONNECTMANAGED":
                            while msprintcount < 1:
                                print "--Managed Servers"
                                global msprintcount
                                msprintcount += 1
                        if key[2] == "RUNNING":
                            print "    INFO: Weblogic Server " + key[1] + " is currently " + key[2] + " " + key[3]

        print "---------------------------------------------------"
    print ""
    print ""
    print "---------------------------------------------------"
    print "The Following Services have issues :"
    print "---------------------------------------------------"
    print ""   

    for smallsEnv in environments:
        global smallscount
        smallscount = 0
        for smallsComponents in components:
            for keys in adminServerLog:
                key=keys.split(";")
                if key[0] == smallsEnv:
                    if key[4] == smallsComponents:
                        if key[5] == "FAILEDCONNECTADMIN" or key[5] == "PROPSNOTFOUND" or key[2] != "RUNNING" or key[3] != "HEALTH_OK":
                            printcount = 0
                            while printcount < 1:
                                while smallscount < 1:
                                    print smallsEnv
                                    smallscount += 1
                                print "-" + smallsComponents
                                print "--Administration Server"
                                printcount += 1
                        if key[5] == "FAILEDCONNECTADMIN":
                            print "    FATAL: Could NOT Connect to " + key[1] + " Administration Server - Check Properties and/or server logs"
                        if key[5] == "PROPSNOTFOUND":
                            print "    FATAL: Properties NOT found for " + smallsComponents + " Please Check Files"
                        if (key[2] != "RUNNING") and `len(key[2])` < 1:
                            print "    WARNING: Weblogic Server " + key[1] + " is communicating but has a state of " + key[2] + " check log files"
                        if (key[3] != "HEALTH_OK") and `len(key[2])` < 1:
                            print "    WARNING: Weblogic Server " + key[1] + " is " + key[2] + " but has a bad health status"

            global msprintcount
            msprintcount = 0
            for keys in managedServerState:
                key=keys.split(";")
                if key[0] == smallsEnv:
                    if key[4] == smallsComponents:
                        if key[5] == "FAILEDMSMBEAN" or key[5] == "FAILEDCONNECTMANAGED" or key[2] != "RUNNING" or key[3] != "HEALTH_OK":
                            while msprintcount < 1:
                                while smallscount < 1:
                                    print smallsEnv
                                    print "-" + smallsComponents
                                    smallscount += 1
                                print "--Managed Servers"
                                global msprintcount
                                msprintcount += 1
                        if key[5] == "FAILEDCONNECTMANAGED":
                            print "    FATAL: Could NOT Connect to Managed Server: " + key[1] + " - server state " + key[2] + " check console and logfiles"
                        if key[5] == "FAILEDMSMBEAN":
                            print "    ERROR: Failed to traverse Managed Server MBEAN Tree in domainConfig() - Check Admin server health and properties, this error can also be generated if the domain has NO managed servers"
                        if (key[2] != "RUNNING") and `len(key[2])` < 1:
                            print "    WARNING: Weblogic Server " + key[1] + " is communicating but has a state of " + key[2] + " check log files"
                        if (key[3] != "HEALTH_OK") and `len(key[2])` < 1:
                            print "    WARNING: Weblogic Server " + key[1] + " is " + key[2] + "but has a bad health status"
        global smallscount
        smallscount = 0
    disconnect()
    exit()

Name: 2012-08-10 11:14

try:
    environment=sys.argv[1]
    component=sys.argv[2]
    print "Environment " +  environment
    if environment == "App1":
        global environments
        environments = []
        environments.extend(["SM1","SM2","SM3",])
        global components
        components = []
        components.extend(["IL2CMS","IL2FORMS","IL2PORTAL","IL3FORMS","IL3COMMS",])
    if environment == "App2":
        global environments
        environments = []
        environments.extend(["SM1","SM2","SM3","SM4",])
        global components
        components = []
        components.extend(["BPM","INTSB","EXTSB","OPA","VRD","BULKINTSB","BULKEXTSB",])
    if environment == "App3":
        global environments
        environments = []
        environments.extend(["SM1","SM2","SM3",])
        global components
        components = []
        components.extend(["ETL","PORTAL","SB","SP",]) 
    if environment == "ALL":
        global environments
        environments = []
        environments.extend(["SM1","SM2","SM3","SM4"])
        global components
        components = []
        components.extend(["IL2CMS","IL2FORMS","IL2PORTAL","IL3FORMS","IL3COMMS","BPM","INTSB","EXTSB","OPA","VRD","BULKINTSB","BULKEXTSB","ETL","PORTAL","SB","SP",]) 
    for environmentState in environments:
        print "Checking and connecting to " + environmentState
        for componentState in components:
            environment = environmentState
            component = componentState
            setEnvironmentProperties(environment, component)
            if setEnvironmentPropertiesFail == 0:
                connectToAdmin()
                if connectToAdminServerFail == 0:
                    findManagedServers()
                    if findManagedServerFail == 0:
                        getManagedServerState()
            disconnect()
#               if setEnvironmentPropertiesFail > 0:
#                   global managedServerState
#                   managedServerState.append(environment + ';' + managedServerName + ';;;' + component + ';' + "FAILED")

    exitDomainState()

#   environments = [environment]
#   components = [component]
#   setEnvironmentProperties(environment, component)
#   connectToAdmin()
#   findManagedServers()
#   getManagedServerState()
#   exitDomainState()
#   exit()

finally:
    exit()

Name: Anonymous 2012-08-10 11:14

Name: Anonymous 2012-08-10 11:49

>>2-4
FUCK

Name: Anonymous 2012-08-10 11:54

i cringe if it isn't javascript

everybody insists on using these slow, bloated, inelegant, unreadable languages! fuck that

Name: Anonymous 2012-08-10 11:56

>>7
But JavaScript isn't fast, small, elegant and readable.

Name: Anonymous 2012-08-10 11:59

http://patriciopalladino.com/blog/2012/08/09/non-alphanumeric-javascript.html


0 +[]
1 +!![]
2 !+[]+!![]
3 !+[]+!![]+!![]
4 !+[]+!![]+!![]+!![]
5 !+[]+!![]+!![]+!![]+!![]
6 !+[]+!![]+!![]+!![]+!![]+!![]
7 !+[]+!![]+!![]+!![]+!![]+!![]+!![]
8 !+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]
9 !+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![]

Name: Anonymous 2012-08-10 12:31

>>9
Not painful, I actually enjoyed reading the article.

Name: Anonymous 2012-08-10 13:55

>>7
C++ is better than Javascript

Name: Anonymous 2012-08-10 14:09

>>9
wow

Name: Anonymous 2012-08-10 14:35

>>9
But is it Touring-complete?

Name: Anonymous 2012-08-10 14:44

Name: Anonymous 2012-08-10 14:51

>>9
this really shows the immense power of js, for all the ``faggots'' that think their language is any good

it makes macros look like a joke

Name: Anonymous 2012-08-10 15:03

I know C in and out, and I've grasped on to some of the core C++/STL stuff.
Recently, I've been wanting to learn Fortran - anyone have any experience with it?

Name: Anonymous 2012-08-10 15:03

>>16 whoops, wrong thread

Name: Anonymous 2012-08-11 0:11

>>15
Except that's nothing more than a poor man's Church numerals, just like javashit is nothing more than a poor man's LISP.

Name: Anonymous 2012-08-11 1:53

>>18
You have been trolled. Sorry. It should be known that Javascript is a terrible language.

Name: Anonymous 2012-08-11 2:17

>>19
back to /g/

Name: Anonymous 2012-08-11 17:42

>>20
/polecat kebabs/

Name: Anonymous 2012-08-11 18:08

CHECK EM

Name: Anonymous 2012-08-11 18:12

>>21'
>using a regex to match a constant string
>ISHYGDDT

Name: Anonymous 2012-08-11 18:14

>>23                            `
>javascript
>any year

ISHYGDDT

Name: Anonymous 2012-08-11 18:29

>>18
Not so much Church numerals as Peano numbers. Church numerals are the same thnig constructed out of only lambdas. On the topic of which, a favourite of mine is
(display
  ((lambda (d)
     ((lambda (n)
        ((lambda (s)
           ((lambda (f) (((f f) n) 0))
            (lambda (f)
              (lambda (n)
                (lambda (w) (if (= n 0) ""
                              ((lambda (c) (string-append (((f f) (d n)) (max w (string-length c))) (if (= w 0) "" (make-string (floor (/ (- w (string-length c)) 2)) #\ )) c)) (s n))))))))
         (lambda (n)
           ((lambda (b)
              ((lambda (f) (((f f) (d n)) 0))
               (lambda (f)
                 (lambda (n)
                   (lambda (k) (string-append (number->string ((b n) k)) (if (= n k) "\n" (string-append " " (((f f) n) (1+ k))))))))))
            (lambda (n)
              (lambda (k)
                ((lambda (f) (((f f) n) k))
                 (lambda (f)
                   (lambda (n)
                     (lambda (k) (if (= k 0) 1 (/ (* n (((f f) (d n)) (d k))) k)))))))))))) 30))
   (lambda (n) (- n 1))))

Name: Anonymous 2012-08-11 18:40

>>25
DO NOT RUN THAT CODE ITS A PASCAL TRIANGLE!!!!!!!

Name: Anonymous 2012-08-11 18:46

>>25
that has more throwaway anonymous functions than a javascript for loop

Name: Anonymous 2012-08-11 18:55

>>27
That's what I was going for. I suppose I could've eliminated all but display and = (numerical equality), in addition to needing string literals, and implemented all other built in functions myself, but that would just make it unreadable. Not to mention, likely to exhaust the stack if I done naively. Please note that I took special care not to use perverted, multiple-argument lambdas.

Name: Anonymous 2012-08-12 1:16

JavaScript is a ``functional'' language. It just has dysfunctional scoping and coercion rules.

Name: Anonymous 2012-08-13 8:05

Halp.. PLZ..... I put a lot of time into a theme, and end of with this stupid arror and I don't know how to fix it.

Also, I'm not super great with PHP, so If there's an obvious fix, I'll kick my self in the nuts for all to see.


<?php get_header(); ?>

    <?php
    if(is_page(array('services','computer-repair','web-design','support','pricing'))) {
      wp_nav_menu(array( 'theme_location' => 'menu-2'));
    }
    elseif(is_page(array('about','staff'))) {
      wp_nav_menu(array('theme_location' => 'menu-3'));
    }
    elseif(is_page(array('contact','location'))) {
      wp_nav_menu(array( 'theme_location' => 'menu-4' ));
    }
    else {
      if(! is_page(array('home','front-page'))) {
        wp_nav_menu(array('theme_location' => 'menu-5'));
    }
    ?>
   
  <section id="primary">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       
      <article class="page" id="post-<?php the_ID(); ?>">

        <div class="entry">

          <?php the_content(); ?>

          <?php wp_link_pages(array('before' => 'Pages: ', 'next_or_number' => 'number')); ?>

        </div>

      </article>

      <?php endwhile; endif; ?>
  </section>

<?php get_footer(); ?>

Name: 2012-08-13 8:15

stupid arror

Name: Anonymous 2012-08-13 11:27

>>31
That's a nice portmanteau for Arrow Error

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List