text:
package com.teletalk.jserver.log;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.MDC;
import org.apache.log4j.spi.LoggingEvent;

import com.teletalk.jserver.JServerConstants;

/**
 * Base class for all classes requiring logging convinience methods.
 *
 * @author Tobias Löfstrand
 *
 * @since 2.0
 */
public abstract class LoggableObject
{
   protected final String fqcn;

   private boolean generateLocationInformation = false;

   private ComponentLogger defaultComponentLogger = null;

   /**
    * Creates a new LoggableObject.
    */
   protected LoggableObject()
   {
      this.fqcn = this.getClass().getName();
   }

   /**
    * Creates a new LoggableObject.
    *
    * @param fqcn fully qualified class name of the class.
    */
   protected LoggableObject(final String fqcn)
   {
      this.fqcn = fqcn;
   }

   /**
    * Gets the value of the flag indicating if location information is to be generated.
    */
   public boolean isGenerateLocationInformation()
   {
      return this.generateLocationInformation;
   }

   /**
    * Sets the value of the flag indicating if location information is to be generated.
    */
   public void setGenerateLocationInformation(boolean generateLocationInformation)
   {
      this.generateLocationInformation = generateLocationInformation;
   }

   /**
    * Gets the logger that will be used by this object to dispatch logging events. Subclasses may override this method to provide
    * an alternate way of getting the logger.
    */
   protected ComponentLogger getLogger()
   {
      synchronized(this)
      {
         if( this.defaultComponentLogger == null )
         {
            this.defaultComponentLogger = ComponentLogger.getTopSystemLogger();
         }

         return this.defaultComponentLogger;
      }
   }

   /**
    * Convenience method to check if log events with trace level can be logged.
    *
    * @return true if log events with trace level can be logged, otherwise false.
    *
    * @since 2.1.4 (20060512)
    *
    * @see #isLogLevelEnabled(Level)
    */
   public boolean isTraceEnabled()
   {
      return this.getLogger().isTraceEnabled();
   }

   /**
    * Convenience method to check if log events with debug level can be logged.
    *
    * @return true if log events with debug level can be logged, otherwise false.
    *
    * @since 2.1.4 (20060512)
    *
    *  @see #isLogLevelEnabled(Level)
    */
   public boolean isDebugEnabled()
   {
      return this.getLogger().isDebugEnabled();
   }

   /**
    * Convenience method to check if log events with info level can be logged.
    *
    * @return true if log events with info level can be logged, otherwise false.
    *
    * @since 2.1.4 (20060512)
    *
    * @see #isLogLevelEnabled(Level)
    */
   public boolean isInfoEnabled()
   {
      return this.getLogger().isInfoEnabled();
   }

   /**
    * Checks if log events with the specified level can be logged.
    *
    * @return true if log events with the specified level can be logged, otherwise false.
    *
    * @since 2.1.4 (20060512)
    */
   public boolean isLogLevelEnabled(final Level logLevel)
   {
      return this.getLogger().isEnabledFor(logLevel);
   }

   /**
    * Gets the current log level of the associated logger.
    *
    * @return the log level.
    *
    * @since 2.1.4 (20060512)
    */
   public Level getLevel()
   {
      return this.getLogger().getLevel();
   }

   /* ##### LOGGING METHODS BEGINS #####*/

   /**
    * Logs a message with the specified level.
    *
    * @param level the level of the logging event.
    * @param msg the message to log.
    *
    * @since 2.0
    */
   public void log(Level level, String msg)
   {
      this.log(fqcn, level, null, msg, null);
   }

   /**
    * Logs a message with the specified level.
    *
    * @param level the level of the logging event.
    * @param msg the message to log.
    * @param logMessageId the id associated with the log message. This id will be stored in the MDC as an java.lang.Integer object
    * under the key {@link JServerConstants#LOG_MESSAGE_ID_KEY}. The range 4095-65535 is reserved for JServer.
    *
    * @since 2.0
    */
   public void log(Level level, String msg, int logMessageId)
   {
      this.log(fqcn, level, null, msg, null, logMessageId);
   }

   /**
    * Logs a message with the specified level.
    *
    * @param level the level of the logging event.
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    *
    * @since 2.0
    */
   public void log(Level level, String origin, String msg)
   {
      this.log(fqcn, level, origin, msg, null);
   }

   /**
    * Logs a message with the specified level.
    *
    * @param level the level of the logging event.
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    * @param logMessageId the id associated with the log message. This id will be stored in the MDC as an java.lang.Integer object
    * under the key {@link JServerConstants#LOG_MESSAGE_ID_KEY}. The range 4095-65535 is reserved for JServer.
    *
    * @since 2.0
    */
   public void log(Level level, String origin, String msg, int logMessageId)
   {
      this.log(fqcn, level, origin, msg, null, logMessageId);
   }

   /**
    * Logs a message with the specified level.
    *
    * @param level the level of the logging event.
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    *
    * @since 2.0
    */
   public void log(Level level, String msg, Throwable throwable)
   {
      this.log(fqcn, level, null, msg, throwable);
   }

   /**
    * Logs a message with the specified level. This method supports messages of other types than String.
    *
    * @param level the level of the logging event.
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    * @param logMessageId the id associated with the log message. This id will be stored in the MDC as an java.lang.Integer object
    * under the key {@link JServerConstants#LOG_MESSAGE_ID_KEY}. The range 4095-65535 is reserved for JServer.
    *
    * @since 2.0
    */
   public void log(Level level, Object msg, Throwable throwable, int logMessageId)
   {
      this.log(fqcn, level, null, msg, throwable, logMessageId);
   }

   /**
    * Logs a message with the specified level. This method supports messages of other types than String.
    *
    * @param level the level of the logging event.
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    *
    * @since 2.0
    */
   public void log(Level level, String origin, Object msg, Throwable throwable)
   {
      this.log(fqcn, level, origin, msg, throwable);
   }

   /**
    * Logs a message with the specified level. This method supports messages of other types than String.
    *
    * @param level the level of the logging event.
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    * @param logMessageId the id associated with the log message. This id will be stored in the MDC as an java.lang.Integer object
    * under the key {@link JServerConstants#LOG_MESSAGE_ID_KEY}. The range 4095-65535 is reserved for JServer.
    *
    * @since 2.0
    */
   public void log(Level level, String origin, Object msg, Throwable throwable, int logMessageId)
   {
      this.log(fqcn, level, origin, msg, throwable, logMessageId);
   }

   /**
    * Logs a message with the specified level. This method supports messages of other types than String.
    *
    * @param callerFQN the fully qualified name of the calling class. This is only used for generating org.apache.log4j.spi.LocationInfo.
    * @param level the level of the logging event.
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    *
    * @since 2.0
    */
   public void log(String callerFQN, Level level, Object msg, Throwable throwable)
   {
      this.log(callerFQN, level, null, msg, throwable);
   }

   /**
    * Logs a message with the specified level. This method supports messages of other types than String.
    *
    * @param callerFQN the fully qualified name of the calling class. This is only used for generating org.apache.log4j.spi.LocationInfo.
    * @param level the level of the logging event.
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    * @param logMessageId the id associated with the log message. This id will be stored in the MDC as an java.lang.Integer object
    * under the key {@link JServerConstants#LOG_MESSAGE_ID_KEY}. The range 4095-65535 is reserved for JServer.
    *
    * @since 2.0
    */
   public void log(String callerFQN, Level level, Object msg, Throwable throwable, int logMessageId)
   {
      this.log(callerFQN, level, null, msg, throwable, logMessageId);
   }

   /**
    * Logs a message with the specified level. This method supports messages of other types than String.
    *
    * @param callerFQN the fully qualified name of the calling class. This is only used for generating org.apache.log4j.spi.LocationInfo.
    * @param level the level of the logging event.
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    *
    * @since 2.0
    */
   public void log(final String callerFQN, final Level level, final String origin, final Object msg, final Throwable throwable)
   {
      this.doLog(callerFQN, level, origin, msg, throwable, false, -1);
   }

   /**
    * Logs a message with the specified level. This method supports messages of other types than String.
    *
    * @param callerFQN the fully qualified name of the calling class. This is only used for generating org.apache.log4j.spi.LocationInfo.
    * @param level the level of the logging event.
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    * @param logMessageId the id associated with the log message. This id will be stored in the MDC as an java.lang.Integer object
    * under the key {@link JServerConstants#LOG_MESSAGE_ID_KEY}. The range 4095-65535 is reserved for JServer.
    *
    * @since 2.0
    */
   public void log(final String callerFQN, final Level level, final String origin, final Object msg, final Throwable throwable, final int logMessageId)
   {
      this.doLog(callerFQN, level, origin, msg, throwable, true, logMessageId);
   }

   /**
    * Creates a logging event. All logging methods in this class calls this method
    * to create a logging event, which means this method can be overridden by subclasses to intercept (and possibly modify) log calls.
    *
    * @param callerFQN the fully qualified name of the calling class. This is only used for generating org.apache.log4j.spi.LocationInfo.
    * @param level the level of the logging event.
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    * @param useLogMessageId flag indicating id the logMessageId parameter should be included in the context of the log message.
    * @param logMessageId the id associated with the log message. This id will be stored in the MDC as an java.lang.Integer object
    * under the key {@link JServerConstants#LOG_MESSAGE_ID_KEY}. The range 4095-65535 is reserved for JServer.
    *
    * @since 2.1.1 (20060118)
    */
   protected void doLog(final String callerFQN, final Level level, String origin, final Object msg, final Throwable throwable, final boolean useLogMessageId, final int logMessageId)
   {
      final ComponentLogger logger = this.getLogger();

      synchronized(logger)
      {
         if( useLogMessageId ) MDC.put(JServerConstants.LOG_MESSAGE_ID_KEY, new Integer(logMessageId));

         // Get the logger that will be used to generate the category name field (origin) of the logging event
         Logger originLogger = null;
         if( origin != null )
         {
            if( !origin.startsWith(JServerConstants.JSERVER_TOP_SYSTEM_ALIAS + ".") ) origin = JServerConstants.JSERVER_TOP_SYSTEM_ALIAS + "." + origin;
            originLogger = Logger.getLogger(origin);
         }
         else originLogger = logger;

         LoggingEvent loggingEvent = new LoggingEvent(callerFQN, originLogger, level, msg, throwable);
         if( this.generateLocationInformation ) loggingEvent.getLocationInformation();
         logger.log(loggingEvent);

         // We assume that the log messsage id has been copied when the above call is completed...
         if( useLogMessageId ) MDC.remove(JServerConstants.LOG_MESSAGE_ID_KEY);
      }
   }

   /**
    * Convenience method to log a trace (finer-grained than debug) message (org.apache.log4j.Level.TRACE).
    *
    * @param msg the message to log.
    *
    * @since 2.1.4 (20060511)
    */
   public void logTrace(String msg)
   {
      this.log(Level.TRACE, msg);
   }

   /**
    * Convenience method to log a trace (finer-grained than debug) message (org.apache.log4j.Level.TRACE).
    *
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    *
    * @since 2.1.4 (20060511)
    */
   public void logTrace(String origin, String msg)
   {
      this.log(Level.TRACE, origin, msg);
   }

   /**
    * Convenience method to log a debug message (org.apache.log4j.Level.DEBUG).
    *
    * @param msg the message to log.
    */
   public void logDebug(String msg)
   {
      this.log(Level.DEBUG, msg);
   }

   /**
    * Convenience method to log a debug message (org.apache.log4j.Level.DEBUG).
    *
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    */
   public void logDebug(String origin, String msg)
   {
      this.log(Level.DEBUG, origin, msg);
   }

   /**
    * Convenience method to log an information message (org.apache.log4j.Level.INFO).
    *
    * @param msg the message to log.
    */
   public void logInfo(String msg)
   {
      this.log(Level.INFO, msg);
   }

   /**
    * Convenience method to log an information message (org.apache.log4j.Level.INFO).
    *
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    */
   public void logInfo(String origin, String msg)
   {
      this.log(Level.INFO, origin, msg);
   }

   /**
    * Convenience method to log a warning message (org.apache.log4j.Level.WARNING).
    *
    * @param msg the message to log.
    */
   public void logWarning(String msg)
   {
      this.log(Level.WARN, msg);
   }

   /**
    * Convenience method to log a warning message (org.apache.log4j.Level.WARNING).
    *
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    */
   public void logWarning(String origin, String msg)
   {
      this.log(Level.WARN, origin, msg);
   }

   /**
    * Convenience method to log a warning message (org.apache.log4j.Level.WARNING).
    *
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    */
   public void logWarning(String msg, Throwable throwable)
   {
      this.log(Level.WARN, msg, (Throwable)throwable);
   }

   /**
    * Convenience method to log a warning message (org.apache.log4j.Level.WARNING).
    *
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    */
   public void logWarning(String origin, String msg, Throwable throwable)
   {
      this.log(Level.WARN, origin, msg, throwable);
   }

   /**
    * Convenience method to log an error message (org.apache.log4j.Level.ERROR).
    *
    * @param msg a description of the error.
    *
    * @see com.teletalk.jserver.log.LogManager
    */
   public void logError(String msg)
   {
      this.log(Level.ERROR, msg);
   }

   /**
    * Convenience method to log an error message (org.apache.log4j.Level.ERROR).
    *
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg a description of the error.
    *
    * @see com.teletalk.jserver.log.LogManager
    */
   public void logError(String origin, String msg)
   {
      this.log(Level.ERROR, origin, msg);
   }

   /**
    * Convenience method to log an error message (org.apache.log4j.Level.ERROR).
    *
    * @param msg a msg of the error.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    *
    * @see com.teletalk.jserver.log.LogManager
    */
   public void logError(String msg, Throwable throwable)
   {
      this.log(Level.ERROR, msg, throwable);
   }

   /**
    * Convenience method to log an error message (org.apache.log4j.Level.ERROR).
    *
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg a description of the error.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    *
    * @see com.teletalk.jserver.log.LogManager
    */
   public void logError(String origin, String msg, Throwable throwable)
   {
      this.log(Level.ERROR, origin, msg, throwable);
   }

   /**
    * Convenience method to log a critical error message (org.apache.log4j.Level.FATAL).
    *
    * @param msg the message to log.
    *
    * @deprecated replaced by {@link #logCriticalError(String, int)}
    */
   public void logCriticalError(String msg)
   {
      this.log(Level.FATAL, msg);
   }

   /**
    * Convenience method to log a critical error message (org.apache.log4j.Level.FATAL).
    *
    * @param msg the message to log.
    * @param logMessageId the id associated with the log message. This id will be stored in the MDC as an java.lang.Integer object
    * under the key {@link JServerConstants#LOG_MESSAGE_ID_KEY}. The range 4095-65535 is reserved for JServer.
    */
   public void logCriticalError(String msg, int logMessageId)
   {
      this.log(Level.FATAL, msg, logMessageId);
   }

   /**
    * Convenience method to log a critical error message (org.apache.log4j.Level.FATAL).
    *
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    *
    * @deprecated replaced by {@link #logCriticalError(String, String, int)}
    */
   public void logCriticalError(String origin, String msg)
   {
      this.log(Level.FATAL, origin, msg);
   }

   /**
    * Convenience method to log a critical error message (org.apache.log4j.Level.FATAL).
    *
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    * @param logMessageId the id associated with the log message. This id will be stored in the MDC as an java.lang.Integer object
    * under the key {@link JServerConstants#LOG_MESSAGE_ID_KEY}. The range 4095-65535 is reserved for JServer.
    */
   public void logCriticalError(String origin, String msg, int logMessageId)
   {
      this.log(Level.FATAL, origin, msg, logMessageId);
   }

   /**
    * Convenience method to log a critical error message (org.apache.log4j.Level.FATAL).
    *
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    *
    * @deprecated replaced by {@link #logCriticalError(String, Throwable, int)}
    */
   public void logCriticalError(String msg, Throwable throwable)
   {
      this.log(Level.FATAL, msg, throwable);
   }

   /**
    * Convenience method to log a critical error message (org.apache.log4j.Level.FATAL).
    *
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    * @param logMessageId the id associated with the log message. This id will be stored in the MDC as an java.lang.Integer object
    * under the key {@link JServerConstants#LOG_MESSAGE_ID_KEY}. The range 4095-65535 is reserved for JServer.
    */
   public void logCriticalError(String msg, Throwable throwable, int logMessageId)
   {
      this.log(Level.FATAL, msg, throwable, logMessageId);
   }

   /**
    * Convenience method to log a critical error message (org.apache.log4j.Level.FATAL).
    *
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    *
    * @deprecated replaced by {@link #logCriticalError(String, String, Throwable, int)}
    */
   public void logCriticalError(String origin, String msg, Throwable throwable)
   {
      this.log(Level.FATAL, origin, msg, throwable);
   }

   /**
    * Convenience method to log a critical error message (org.apache.log4j.Level.FATAL).
    *
    * @param origin the origin of the logging event. The thread name will be set to this parameter when creating the logging event.
    * @param msg the message to log.
    * @param throwable a throwable to be associated with the logging event. This parameter may be null.
    * @param logMessageId the id associated with the log message. This id will be stored in the MDC as an java.lang.Integer object
    * under the key {@link JServerConstants#LOG_MESSAGE_ID_KEY}. The range 4095-65535 is reserved for JServer.
    */
   public void logCriticalError(String origin, String msg, Throwable throwable, int logMessageId)
   {
      this.log(Level.FATAL, origin, msg, throwable, logMessageId);
   }

   /* ##### LOGGING METHODS ENDS #####*/
}


text:
@implementation UITextField (TCAdditions)

- (void)tc_setLeftAndRightPadding:(CGFloat)paddingWidth
{
    if (paddingWidth < 0) {
        [TCInvalidArgument raiseWithReason:@"paddingWidth can not be a negative number"];
    }

    UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, paddingWidth, self.frame.size.height)];

    self.leftView = paddingView;
    self.leftViewMode = UITextFieldViewModeAlways;
    self.rightView = paddingView;
    self.rightViewMode = UITextFieldViewModeUnlessEditing;
}

- (void)tc_addNextButtonToolbarWithColor:(UIColor * __tc_nonnull)toolbarColor
                               nextField:(UITextField * __tc_nonnull)nextTextField

{
    [self tc_addToolbarWithButton:@"Next" toolbarColor:toolbarColor target:nextTextField action:@selector(becomeFirstResponder)];
}

- (void)tc_addToolbarWithButton:(NSString * __tc_nonnull)buttonTitle
                   toolbarColor:(UIColor * __tc_nonnull)toolbarColor
                         target:(id)target action:(SEL)selector
{
    UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:buttonTitle style:UIBarButtonItemStylePlain target:target action:selector];
    [self addToolBarWithButton:button toolbarColor:toolbarColor];
}

- (void)addToolBarWithButton:(UIBarButtonItem * __tc_nonnull)buttonItem
                toolbarColor:(UIColor * __tc_nonnull)toolbarColor
{
    UIToolbar *toolbar = [[UIToolbar alloc] init];
    toolbar.tintColor = toolbarColor;
    [toolbar sizeToFit];

    toolbar.items = @[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil], buttonItem];

    self.inputAccessoryView = toolbar;
}

@end

redpajama_set_name: RedPajamaGithub


text:
package com.mapswithme.maps;

/**
 * Interface to re-use some important variables from C++.
 */
public class PrivateVariables
{
  public static native String alohalyticsUrl();
  public static native String flurryKey();
  public static native String myTrackerKey();
  public static native int myTargetSlot();
  public static native int myTargetRbSlot();
  public static native String myTargetCheckUrl();
  /**
   * @return interval in seconds
   */
  public static native long myTargetCheckInterval();
}


text:
namespace MTC2016.ArtificialInteligence
{
    public class UserSaysData
    {
        public string Text { get; set; }
    }
}


text:
@(pack: Pack, item: Item)

@helper.form(action = routes.PacksController.removeItem(pack.id.get, item.id.get)) {
  <button class="btn btn-danger remove-item">
    <i class="glyphicon glyphicon-remove"></i>
  </button>
}


text:
Writing tests interactively with a browser
==========================================

Since your website is going to be used interactively, it can be helpful to write
your tests in a similar way to how a user views the website, rather than doing
it "blind". This page outlines a method for doing that.

You can also view the content of this page `as a video <https://www.youtube.com/watch?v=nEr6T2pL8Es>`_:

.. raw:: html

A complete example project for the setup can be found in the `examples folder
<https://github.com/django-functest/django-functest/tree/master/examples/example_project>`_.

We are going to use pytest and pytest-django, and use all the :doc:`pytest`
tips, including the ``--show-browser`` option.

The essential technique is:

* use `REPL programming with IPython
  <https://lukeplant.me.uk/blog/posts/repl-python-programming-and-debugging-with-ipython/>`_.
* ensure the browser window is visible.

Using the example from the project, we've got a custom user class, and we're
going to test that the admin interface has been registered and still works.

We start with a test that looks like this:

.. code-block:: python

   from django_functest import FuncBaseMixin, ShortcutLoginMixin

   from .base import SeleniumTestBase, WebTestBase
   from .factories import create_user

   class UserAdminBase(FuncBaseMixin, ShortcutLoginMixin):
       def test_change_details(self):
           pass

   class UserAdminWT(UserAdminBase, WebTestBase):
       pass

   class UserAdminSL(UserAdminBase, SeleniumTestBase):
       pass

The code here is just following the pattern from the guide, plus two things:

* Adding the ``ShortcutLoginMixin``
* Importing a little custom utility function for creating users.

We now add our IPython prompt code into the base class method, so it looks like this:

.. code-block:: python

   def test_change_details(self):
        import IPython; IPython.embed()

Next, we are going to run the Selenium version of this test, with the browser
window visible. Since I've only got one test so far, we can select it like this,
using the ``selenium`` marker:

.. code-block:: shell

   pytest accounts/tests/test_admin.py -m selenium --show-browser -s

Notice the use of ``-s`` to ensure that pytest doesn't capture our input, which
would break IPython.

This will run the test, and we'll find ourselves at an IPython prompt with a
browser window open.

We can then interactively write the test into IPython a line at a time, and
watch our commands being executed. We'll probably start something like this:

.. code-block:: python

   user = create_user(is_superuser=True)
   self.shortcut_login(user)
   self.get_url("admin:accounts_user_changelist")

We can then use "Inspect" and web browser dev tools to work out what elements to
refer to and interact with. We might continue like this:

.. code-block:: python

   self.follow_link("#result_list tbody a")
   self.fill({"#id_first_name": "Joe", "#id_last_name": "Bloggs"})
   self.submit('input[value="Save"]')

We can also do our asserts:

.. code-block:: python

   user.refresh_from_db()
   assert user.first_name == "Joe"

If we found that some of our setup code was actually wrong, or we missed
something, there is no need to restart — just fix it by executing commands
interactively and carry on.

Finally, we can copy back code from the terminal into our editor. You can use
the history functionality in IPython (PageUp and PageDown) to look back through
everything you typed. Use ``Ctrl-D`` to exit from IPython and allow pytest to
finish.

In our editor, we'll probably want to clean it up, and once done, we can run the
tests again. This time, we'll want to run both the WebTest and Selenium
versions:

.. code-block:: shell

   pytest accounts/tests/test_admin.py -v

.. raw:: html

   ============================= test session starts ==============================
   platform linux -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0 -- /home/luke/.virtualenvs/django-functest-example/bin/python
   cachedir: .pytest_cache
   django: settings: example_project.settings (from ini)
   rootdir: /home/luke/devel/django-functest/examples/example_project, configfile: pytest.ini
   plugins: django-4.5.2, django-webtest-1.9.10
   collecting ... collected 2 items

   accounts/tests/test_admin.py::UserAdminWT::test_change_own_details  PASSED [ 50%]
   accounts/tests/test_admin.py::UserAdminSL::test_change_own_details  PASSED [100%]

   =============================== 2 passed in 1.87s ===============================

If we get any failures, we can also use the IPython prompt technique to debug
easily, by insert the "embed" line just before the failing line of code.

Hopefully you'll enjoy this method of writing tests! If you've got any more
tips for improving this method, do let us know.


text:
command -v ./primesum >/dev/null 2>/dev/null
if [ $? -ne 0 ]
then
    echo "Error: no primesum binary in current directory."
    exit 1
fi

# check if primesum supports --log option
log_flag=$(./primesum --help | grep Log > /dev/null && echo --log)

while read first_line < worktodo.txt
do
    # Skip empty lines and comments
    if [ "$first_line" != "" ] && [ ${first_line:0:1} != "#" ]
    then
        ./primesum $first_line $log_flag

        # Check if primesum exited successfully
        if [ $? -ne 0 ]
        then
            echo ""
            echo "Error in primesum_from_file.sh:"
            echo "The following command failed: ./primesum $first_line"
            exit 1
        fi
    fi

    # delete first line from worktodo.txt
    tail -n +2 worktodo.txt > .tmp_worktodo.txt
    mv -f .tmp_worktodo.txt worktodo.txt
done


text:
import * as amqp from "amqplib";
import * as amqpConMgr from 'amqp-connection-manager';

// from README.md
const connection = amqpConMgr.connect(['amqp://localhost']);
const channelWrapper: amqpConMgr.ChannelWrapper = connection.createChannel({
    json: true,
    setup: async (channel: amqp.ConfirmChannel): Promise<void> => {
        // `channel` here is a regular amqplib `ConfirmChannel`. Unfortunately its typings make it return a bluebird-specific promise
        // tslint:disable-next-line:await-promise
        await channel.assertQueue('rxQueueName', {durable: true});
    }
});

connection.on("connect", (_arg: { connection: amqp.Connection, url: string }): void => undefined);
connection.on("disconnect", (_arg: { err: Error }): void => undefined);

channelWrapper.on("close", () => undefined);
channelWrapper.on("connect", () => undefined);
channelWrapper.on("error", (_error: Error) => undefined);

channelWrapper.sendToQueue("foo", Buffer.from("bar"))
    .catch((error: Error): void => {
        // nothing
    });

// Test that plain objects are implicitly serialized.
channelWrapper.sendToQueue("foo", {a: 'bar'}).catch(_ => {});

// Checking connection options
amqpConMgr.connect(["foo", "bar"], {
    findServers(callback) {
        callback("x");
    }
});

amqpConMgr.connect(["foo", "bar"], {
    findServers(callback) {
        callback(["x", "y"]);
    }
});

amqpConMgr.connect(["foo", "bar"], {
    findServers() {
        return Promise.resolve("x");
    }
});

amqpConMgr.connect(["foo", "bar"], {
    findServers() {
        return Promise.resolve(["x", "y"]);
    }
});

amqpConMgr.connect(["foo", "bar"], {
    reconnectTimeInSeconds: 123
});

amqpConMgr.connect(["foo", "bar"], {
    heartbeatIntervalInSeconds: 123
});

amqpConMgr.connect(["foo", "bar"], {
    connectionOptions: {
        ca: "some CA",
        servername: "foo.example.com"
    }
});


text:
<?php

require_once 'intro.php';
require_once 'GSB_Client.php';

$client  = new GSB_Client($storage, $network, $logger);

$len = count($argv);
for ($i = 1; $i < $len; $i++) {
    $url = $argv[$i];
    $matches = $client->doLookup($url);
    print "$url: " . count($matches) . "\n";
}

//$client->doLookup('http://malware.testing.google.test/testing/malware/');
//$client->doLookup('http://www.iospace.com/');
//$client->doLookup('http://the-zen.co.kr/');
//$client->doLookup('http://adingurj.com/');
//$client->doLookup('http://matzines.com/');
// http://online-xp-antivir.com


text:
 This command takes a URL as input and downloads and opens a data file.  It can be used to download and save files of other typ  es, but these will not be opened.

---
Requirements
----
- IBM SPSS Statistics 18 or later and the corresponding IBM SPSS Statistics-Integration Plug-in for Python.

Note: For users with IBM SPSS Statistics version 23 or higher, the SPSSINC GETURI DATA extension is installed as part of IBM SPSS Statistics-Essentials for Python.

---
Installation intructions
----
1. Open IBM SPSS Statistics
2. Navigate to Utilities -> Extension Bundles -> Download and Install Extension Bundles
3. Search for the name of the extension and click Ok. Your extension will be available.

---
Tutorial
----
SPSSINC GETURI DATA URI="*uri including filename*"^* "..."
FILETYPE=SPSS^** or XLS or SAS or STATA or OTHER
DATASET = *dataset*
SAVE="directory"

/OPTIONS
-- options for Excel --
ASSUMEDSTRWIDTH = *number*
SHEETNAME ="*sheet name*"
SHEETNUMBER = *number*
CELLRANGE = "*Excel range specification*"
READNAMES=YES^** or NO
-- options for SAS --
DSET = "*dataset*"

/HELP

^* Required
^** Default

/HELP displays this help and does nothing else.

Example:
```
SPSSINC GETURI DATA
URI="http://www2.census.gov/prod2/statcomp/usac/excel/Source.xls"
FILETYPE=XLS
/OPTIONS SHEETNUMBER=1 READNAMES=YES ASSUMEDSTRWIDTH=100.
```

**URI** specifies the full web address including the protocol such as http:// or ftp://
If the name is too long for an SPSS literal, write it as multiple quoted
strings that are NOT joined with "+".  For example,
```URI="http://abc" "defghi/somefile.xls"```

**FILETYPE** specifies the type of file to read.

You can optionally use **DATASET** to assign a dataset name to the opened file.

If the filetype is OTHER, the **SAVE** keyword is required and specifies the directory
for the download.  The file is not opened.  If a file with the same name exists in the download
location, it may or may not be overwritten depending on the operating system.

Options are specific to the file type and are ignored if they do not apply.
For Excel, you can specify
* ASSUMEDSTRWIDTH - the width to use for string variables
* SHEETNAME - the name of the sheet to read
* SHEETNUMBER - the number of the sheet to read.
You cannot specify both the name and the number.  The default is SHEETNUMBER=1
* CELLRANGE - the range to read within the sheet.  The default is to read the entire sheet.
* READNAMES - whether to read variable names from the first row of the range.  The default is YES.

For SAS you can specify the dataset name within the uri with **DSET**.

There are no options for SPSS or Stata files.

---
License
----

- Apache 2.0

Contributors
----

  - JKP, IBM SPSS


text: load File.expand_path("../../tasks/secrets.rake", __FILE__)


text:
package com.bugua.culweather.gson;

import com.google.gson.annotations.SerializedName;

/**
 * Created by Administrator on 2017-10-14.
 */

public class Now {

    @SerializedName("tmp")
    public String temperature;

    @SerializedName("cond")
    public Condition condition;

    @SerializedName("wind")
    public Wind wind;

    public class Condition {

        @SerializedName("txt")
        public String info;

    }

    public class Wind {
        @SerializedName("dir")
        public String direction;
        @SerializedName("sc")
        public String intension;
    }
}


text:
package com.impetus.client.cassandra.pelops;

import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.scale7.cassandra.pelops.Cluster;
import org.scale7.cassandra.pelops.Cluster.Node;
import org.scale7.cassandra.pelops.IConnection;
import org.scale7.cassandra.pelops.Mutator;
import org.scale7.cassandra.pelops.Pelops;
import org.scale7.cassandra.pelops.RowDeletor;
import org.scale7.cassandra.pelops.Selector;
import org.scale7.cassandra.pelops.exceptions.TransportException;
import org.scale7.cassandra.pelops.pool.CommonsBackedPool;
import org.scale7.cassandra.pelops.pool.CommonsBackedPool.Policy;
import org.scale7.cassandra.pelops.pool.IThriftPool;
import org.scale7.cassandra.pelops.pool.IThriftPool.IPooledConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Lists;
import com.impetus.client.cassandra.common.CassandraClientFactory;
import com.impetus.client.cassandra.common.CassandraUtilities;
import com.impetus.client.cassandra.config.CassandraPropertyReader;
import com.impetus.client.cassandra.query.CassandraEntityReader;
import com.impetus.client.cassandra.schemamanager.CassandraSchemaManager;
import com.impetus.client.cassandra.service.CassandraHost;
import com.impetus.client.cassandra.service.CassandraHostConfiguration;
import com.impetus.client.cassandra.service.CassandraRetryService;
import com.impetus.kundera.Constants;
import com.impetus.kundera.KunderaException;
import com.impetus.kundera.PersistenceProperties;
import com.impetus.kundera.client.Client;
import com.impetus.kundera.configure.schema.api.SchemaManager;
import com.impetus.kundera.metadata.KunderaMetadataManager;
import com.impetus.kundera.metadata.model.PersistenceUnitMetadata;
import com.impetus.kundera.service.Host;
import com.impetus.kundera.service.HostConfiguration;
import com.impetus.kundera.service.policy.LeastActiveBalancingPolicy;
import com.impetus.kundera.service.policy.RoundRobinBalancingPolicy;

/**
 * A factory for creating PelopsCliobjects.
 */
public class PelopsClientFactory extends CassandraClientFactory
{
    /** The logger. */
    private static Logger logger = LoggerFactory.getLogger(PelopsClientFactory.class);

    private HostConfiguration configuration;

    @Override
    public void initialize(Map<String, Object> externalProperty)
    {
        reader = new CassandraEntityReader(kunderaMetadata);
        initializePropertyReader();
        // setExternalProperties(externalProperty);
        String loadBalancingPolicyName = CassandraPropertyReader.csmd != null ? CassandraPropertyReader.csmd
                .getConnectionProperties().getProperty(Constants.LOADBALANCING_POLICY) : null;
        initializeLoadBalancer(loadBalancingPolicyName);
        configuration = new CassandraHostConfiguration(externalProperties, CassandraPropertyReader.csmd,
                getPersistenceUnit(), kunderaMetadata);
        hostRetryService = new CassandraRetryService(configuration, this);

        // initialize timestamp generator.
        initializeTimestampGenerator(externalProperty);
    }

    @Override
    protected Object createPoolOrConnection()
    {
        logger.info("Creating pool");
        PersistenceUnitMetadata persistenceUnitMetadata = kunderaMetadata.getApplicationMetadata()
                .getPersistenceUnitMetadata(getPersistenceUnit());

        Properties props = persistenceUnitMetadata.getProperties();
        String keyspace = null;
        if (externalProperties != null)
        {
            keyspace = (String) externalProperties.get(PersistenceProperties.KUNDERA_KEYSPACE);
        }
        if (keyspace == null)
        {
            keyspace = (String) props.get(PersistenceProperties.KUNDERA_KEYSPACE);
        }

        for (Host host : ((CassandraHostConfiguration) configuration).getCassandraHosts())
        {
            CassandraHost cassandraHost = (CassandraHost) host;
            String poolName = PelopsUtils.generatePoolName(cassandraHost.getHost(), cassandraHost.getPort(), keyspace);
            if (CassandraUtilities.verifyConnection(cassandraHost.getHost(), cassandraHost.getPort()))
            {
                Cluster cluster = new Cluster(cassandraHost.getHost(), new IConnection.Config(cassandraHost.getPort(),
                        true, -1, PelopsUtils.getAuthenticationRequest(cassandraHost.getUser(),
                                cassandraHost.getPassword())), false);

                if (logger.isInfoEnabled())
                {
                    logger.info("Initializing connection pool for keyspace {}, host {},port {}.", keyspace,
                            cassandraHost.getHost(), cassandraHost.getPort());
                }

                Policy policy = PelopsUtils.getPoolConfigPolicy(cassandraHost);

                // Add pool with specified policy. null means default operand
                // policy.
                Pelops.addPool(poolName, cluster, keyspace, policy, null);
                hostPools.put(cassandraHost, Pelops.getDbConnPool(poolName));
            }
            else
            {
                logger.warn("Node " + host.getHost() + " are down");
                if (host.isRetryHost())
                {
                    logger.info("Scheduling node for future retry");
                    ((CassandraRetryService) hostRetryService).add((CassandraHost) host);
                }
            }
        }
        // TODO return a thrift pool
        return null;
    }

    @Override
    protected Client instantiateClient(String persistenceUnit)
    {
        if (logger.isInfoEnabled())
        {
            // logger.info("Initializing pelops client for persistence unit {}",
            // persistenceUnit);
        }
        IThriftPool pool = getPoolUsingPolicy();
        return new PelopsClient(indexManager, reader, this, persistenceUnit, externalProperties, pool, kunderaMetadata,
                timestampGenerator);
    }

    @Override
    public boolean isThreadSafe()
    {
        return false;
    }

    @Override
    public void destroy()
    {
        if (indexManager != null)
        {
            indexManager.close();
        }
        if (schemaManager != null)
        {
            schemaManager.dropSchema();
        }
        schemaManager = null;
        // Pelops.shutdown();
        // Pelops.removePool(PelopsUtils.generatePoolName(getPersistenceUnit(),
        // externalProperties));
        externalProperties = null;
    }

    @Override
    public SchemaManager getSchemaManager(Map<String, Object> externalProperty)
    {
        if (schemaManager == null)
        {
            initializePropertyReader();
            setExternalProperties(externalProperty);
            schemaManager = new CassandraSchemaManager(PelopsClientFactory.class.getName(), externalProperty,
                    kunderaMetadata);
        }

        return schemaManager;
    }

    /**
     *
     */
    private void initializePropertyReader()
    {
        if (propertyReader == null)
        {
            propertyReader = new CassandraPropertyReader(externalProperties, kunderaMetadata.getApplicationMetadata()
                    .getPersistenceUnitMetadata(getPersistenceUnit()));
            propertyReader.read(getPersistenceUnit());
        }
    }

    @Override
    protected void initializeLoadBalancer(String loadBalancingPolicyName)
    {
        switch (LoadBalancer.getValue(loadBalancingPolicyName))
        {
        case ROUNDROBIN:
            loadBalancingPolicy = new RoundRobinBalancingPolicy();
            break;
        case LEASTACTIVE:
            loadBalancingPolicy = new PelopsLeastActiveBalancingPolcy();
            break;
        default:
            loadBalancingPolicy = new RoundRobinBalancingPolicy();
            break;
        }
    }

    /**
     *
     * @return pool an the basis of LoadBalancing policy.
     */
    private IThriftPool getPoolUsingPolicy()
    {
        if (!hostPools.isEmpty())
        {
            logger.info("Returning pool using {} .", loadBalancingPolicy.getClass().getSimpleName());
            return (IThriftPool) loadBalancingPolicy.getPool(hostPools.values());
        }
        throw new KunderaException("All hosts are down. please check servers manully.");
    }

    IPooledConnection getConnection(IThriftPool pool)
    {
        IThriftPool iThriftPool = pool;
        boolean success = false;
        while (!success)
        {
            success = true;
            if (iThriftPool != null)
            {
                Node[] nodes = ((CommonsBackedPool) iThriftPool).getCluster().getNodes();
                String host = nodes[0].getAddress();
                int thriftPort = ((CommonsBackedPool) iThriftPool).getCluster().getConnectionConfig().getThriftPort();
                CassandraHost cassandraHost = ((CassandraHostConfiguration) configuration).getCassandraHost(
                        nodes[0].getAddress(), ((CommonsBackedPool) pool).getCluster().getConnectionConfig()
                                .getThriftPort());
                if (cassandraHost.isTestOnBorrow())
                {
                    if (cassandraHost.isTestOnBorrow() && CassandraUtilities.verifyConnection(host, thriftPort))
                    {
                        // logger.info("Returning connection of {} :{} .",
                        // nodes[0].getAddress(), thriftPort);
                        return iThriftPool.getConnection();
                    }
                    removePool(iThriftPool);
                }
                else
                {
                    // logger.info("Returning connection of {} :{} .",
                    // nodes[0].getAddress(), thriftPort);
                    return iThriftPool.getConnection();
                }
                removePool(iThriftPool);
            }
            success = false;
            iThriftPool = getPoolUsingPolicy();
        }
        throw new KunderaException("All hosts are down. please check servers manully.");
    }

    Mutator getMutator(IThriftPool pool)
    {
        IThriftPool iThriftPool = pool;
        boolean success = false;
        while (!success)
        {
            success = true;
            if (iThriftPool != null)
            {
                Node[] nodes = ((CommonsBackedPool) iThriftPool).getCluster().getNodes();
                String host = nodes[0].getAddress();
                int thriftPort = ((CommonsBackedPool) iThriftPool).getCluster().getConnectionConfig().getThriftPort();
                CassandraHost cassandraHost = ((CassandraHostConfiguration) configuration).getCassandraHost(
                        nodes[0].getAddress(), ((CommonsBackedPool) pool).getCluster().getConnectionConfig()
                                .getThriftPort());
                if (cassandraHost.isTestOnBorrow())
                {
                    if (cassandraHost.isTestOnBorrow() && CassandraUtilities.verifyConnection(host, thriftPort))
                    {
                        // logger.info("Returning mutator of {} :{} .",
                        // nodes[0].getAddress(), thriftPort);
                        return Pelops.createMutator(PelopsUtils.getPoolName(iThriftPool));
                    }
                    removePool(iThriftPool);
                }
                else
                {
                    return iThriftPool.createMutator();
                }
            }
            success = false;
            iThriftPool = getPoolUsingPolicy();
        }
        throw new KunderaException("All hosts are down. please check servers manully.");
    }

    Selector getSelector(IThriftPool pool)
    {
        IThriftPool iThriftPool = pool;
        boolean success = false;
        while (!success)
        {
            if (iThriftPool != null)
            {
                Node[] nodes = ((CommonsBackedPool) iThriftPool).getCluster().getNodes();
                String host = nodes[0].getAddress();
                int thriftPort = ((CommonsBackedPool) iThriftPool).getCluster().getConnectionConfig().getThriftPort();
                CassandraHost cassandraHost = ((CassandraHostConfiguration) configuration).getCassandraHost(
                        nodes[0].getAddress(), ((CommonsBackedPool) pool).getCluster().getConnectionConfig()
                                .getThriftPort());
                if (cassandraHost.isTestOnBorrow())
                {
                    if (cassandraHost.isTestOnBorrow() && CassandraUtilities.verifyConnection(host, thriftPort))
                    {
                        // logger.info("Returning selector of {} :{} .",
                        // nodes[0].getAddress(), thriftPort);
                        return Pelops.createSelector(PelopsUtils.getPoolName(iThriftPool));
                    }
                    removePool(iThriftPool);
                }
                else
                {
                    // logger.info("Returning selector of {} :{} .",
                    // nodes[0].getAddress(), thriftPort);
                    return Pelops.createSelector(PelopsUtils.getPoolName(iThriftPool));
                }
            }
            success = false;
            iThriftPool = getPoolUsingPolicy();
        }
        throw new KunderaException("All hosts are down. please check servers manully.");
    }

    RowDeletor getRowDeletor(IThriftPool pool)
    {
        IThriftPool iThriftPool = pool;
        boolean success = false;
        while (!success)
        {
            if (iThriftPool != null)
            {
                Node[] nodes = ((CommonsBackedPool) iThriftPool).getCluster().getNodes();
                String host = nodes[0].getAddress();
                int thriftPort = ((CommonsBackedPool) iThriftPool).getCluster().getConnectionConfig().getThriftPort();
                CassandraHost cassandraHost = ((CassandraHostConfiguration) configuration).getCassandraHost(
                        nodes[0].getAddress(), ((CommonsBackedPool) pool).getCluster().getConnectionConfig()
                                .getThriftPort());
                if (cassandraHost.isTestOnBorrow())
                {
                    if (cassandraHost.isTestOnBorrow() && CassandraUtilities.verifyConnection(host, thriftPort))
                    {
                        logger.info("Returning row deletor of {} :{} .", nodes[0].getAddress(), thriftPort);
                        return Pelops.createRowDeletor(PelopsUtils.getPoolName(iThriftPool));
                    }
                    removePool(iThriftPool);
                }
                else
                {
                    logger.info("Returning row deletor of {} :{} .", nodes[0].getAddress(), thriftPort);
                    return Pelops.createRowDeletor(PelopsUtils.getPoolName(iThriftPool));
                }
            }
            success = false;
            iThriftPool = getPoolUsingPolicy();
        }
        throw new KunderaException("All hosts are down. please check servers manully.");

    }

    void releaseConnection(IPooledConnection conn)
    {
        if (conn != null)
        {
            conn.release();
        }
    }

    /**
     * Adds a pool in hostPools map for given host.
     *
     * @param cassandraHost
     * @return true id added successfully.
     */
    public boolean addCassandraHost(CassandraHost cassandraHost)
    {
        Properties props = KunderaMetadataManager.getPersistenceUnitMetadata(kunderaMetadata, getPersistenceUnit())
                .getProperties();
        String keyspace = null;
        if (externalProperties != null)
        {
            keyspace = (String) externalProperties.get(PersistenceProperties.KUNDERA_KEYSPACE);
        }
        if (keyspace == null)
        {
            keyspace = (String) props.get(PersistenceProperties.KUNDERA_KEYSPACE);
        }
        String poolName = PelopsUtils.generatePoolName(cassandraHost.getHost(), cassandraHost.getPort(), keyspace);
        Cluster cluster = new Cluster(cassandraHost.getHost(), new IConnection.Config(cassandraHost.getPort(), true,
                -1, PelopsUtils.getAuthenticationRequest(cassandraHost.getUser(), cassandraHost.getPassword())), false);
        Policy policy = PelopsUtils.getPoolConfigPolicy(cassandraHost);
        try
        {
            Pelops.addPool(poolName, cluster, keyspace, policy, null);
            hostPools.put(cassandraHost, Pelops.getDbConnPool(poolName));
            return true;
        }
        catch (TransportException e)
        {
            logger.warn("Node {} are still down ", cassandraHost.getHost());
            return false;
        }
    }

    /**
     * Removes downed host pool from pool map.
     *
     * @param pool
     */
    private void removePool(IThriftPool pool)
    {
        Pelops.removePool(PelopsUtils.getPoolName(pool));
        Node[] nodes = ((CommonsBackedPool) pool).getCluster().getNodes();
        logger.warn("{} :{}  host appears to be down, trying for next ", nodes, ((CommonsBackedPool) pool).getCluster()
                .getConnectionConfig().getThriftPort());
        CassandraHost cassandraHost = ((CassandraHostConfiguration) configuration).getCassandraHost(
                nodes[0].getAddress(), ((CommonsBackedPool) pool).getCluster().getConnectionConfig().getThriftPort());
        hostPools.remove(cassandraHost);
    }

    /**
     * Extends LeastActiveBalancingPolicy class and provide own implementation
     * in order to support least active balancing policy.
     *
     * @author Kuldeep.Mishra
     *
     */
    private class PelopsLeastActiveBalancingPolcy extends LeastActiveBalancingPolicy
    {

        /**
         *
         * @return pool object for host which has least active connections
         *         determined by maxActive connection.
         *
         */
        public Object getPool(Collection<Object> pools)
        {
            List<Object> vals = Lists.newArrayList(pools);
            Collections.shuffle(vals);
            Collections.sort(vals, new ShufflingCompare());
            Collections.reverse(vals);
            Iterator<Object> iterator = vals.iterator();
            Object concurrentConnectionPool = iterator.next();
            return concurrentConnectionPool;
        }

        /**
         * Compares two pool object on the basis of their maxActive connection
         * per node.
         *
         * @author Kuldeep Mishra
         *
         */
        private final class ShufflingCompare implements Comparator<Object>
        {
            public int compare(Object o1, Object o2)
            {
                Policy policy1 = ((CommonsBackedPool) ((IThriftPool) o1)).getPolicy();
                Policy policy2 = ((CommonsBackedPool) ((IThriftPool) o2)).getPolicy();

                int activeConnections1 = ((CommonsBackedPool) ((IThriftPool) o1)).getConnectionsActive();
                int activeConnections2 = ((CommonsBackedPool) ((IThriftPool) o2)).getConnectionsActive();

                return (policy1.getMaxActivePerNode() - activeConnections1)
                        - (policy2.getMaxActivePerNode() - activeConnections2);
            }
        }
    }
}