text:
"""
Deuce Valere - Client - Valere
"""
import datetime
import logging

from deuceclient.api import Block
from deuceclient.common import errors as deuce_errors
from stoplight import validate

from deucevalere.common.validation import *
from deucevalere.common.validation_instance import *

class ValereClient(object):

    @validate(deuce_client=ClientRule,
              vault=VaultInstanceRule,
              manager=ValereManagerRule)
    def __init__(self, deuce_client, vault, manager):
        self.deuceclient = deuce_client
        self.vault = vault
        self.manager = manager
        self.log = logging.getLogger(__name__)

    def get_block_list(self):
        """Fill the Manager's list of current blocks
        """
        self.manager.metadata.current = []

        marker = self.manager.start_block

        self.log.info('Project ID: {0}, Vault {1} - '
                 'Searching for Blocks [{2}, {3})'
                 .format(self.vault.project_id,
                         self.vault.vault_id,
                         marker,
                         self.manager.end_block))

        while True:
            for block_id in self.deuceclient.GetBlockList(self.vault,
                                                          marker=marker):
                if self.manager.end_block is not None:
                    if block_id < self.manager.end_block:
                        self.manager.metadata.current.append(block_id)
                    else:
                        break
                else:
                    self.manager.metadata.current.append(block_id)

            marker = self.vault.blocks.marker
            self.log.debug('Next Marker: {0}'.format(marker))

            if marker is None:
                break

    @staticmethod
    @validate(metadata_id=MetadataBlockIdRuleNoneOkay)
    def _convert_metadata_id_to_storage_id(metadata_id):
        """Return a 'valid' storage id that is the lowest possible value

        Note: This will need to be updated when the format of the
              storage id changes.

        Note: It is impossible to create a UUID that is guarateed to be the
              lowest possible value using a UUID generator. However, UUIDs
              are alphanumeric values; thus '0' is always the lowest value
              and filling out a formatstring that looks like a UUID string
              but uses all zeros (0) will giveus a string that will compare
              as the lowest possible UUID value.
        """
        if metadata_id is not None:
            return '{0:}_{1:}-{2:}-{2:}-{2:}-{3:}'.format(metadata_id,
                                                          '{:08X}'.format(0),
                                                          '{:04X}'.format(0),
                                                          '{:012X}'.format(0))
        else:
            return None

    def get_storage_list(self):
        """Fill the manager's list of current storage blocks
        """
        self.manager.storage.current = []

        start_marker = ValereClient._convert_metadata_id_to_storage_id(
            self.manager.start_block)
        end_marker = ValereClient._convert_metadata_id_to_storage_id(
            self.manager.end_block) if self.manager.end_block else None

        self.log.info('Project ID: {0}, Vault {1} - '
                 'Searching for Storage Blocks [{2}, {3})'
                 .format(self.vault.project_id,
                         self.vault.vault_id,
                         start_marker,
                         end_marker))

        while True:
            for block_id in self.deuceclient.GetBlockStorageList(
                    self.vault, marker=start_marker):

                if end_marker is not None:
                    if block_id < end_marker:
                        self.manager.storage.current.append(block_id)
                    else:
                        break
                else:
                    self.manager.storage.current.append(block_id)

            start_marker = self.vault.storageblocks.marker
            self.log.debug('Next Marker: {0}'.format(start_marker))

            if start_marker is None:
                break

    def validate_metadata(self):
        """Validate a block

        Access each block through a HEAD operation
        Checks if the reference count is zero
        For blocks with zero reference counts mark them as expired if they
        pass the age specified by the manager
        """
        # Note: THis function is a little more verbose since it is detecting
        #       which blocks to delete.
        if self.manager.metadata.current is None:
            self.get_block_list()

        if len(self.manager.metadata.current) == 0:
            self.get_block_list()

        if self.manager.metadata.expired is None:
            self.manager.metadata.expired = []

        # Loop over any known blocks and validate them
        for block_id in self.manager.metadata.current:
            self.log.debug('Project ID {0}, Vault {1} - '
                           'Validating Block: {2}'
                           .format(self.vault.project_id,
                                   self.vault.vault_id,
                                   block_id))

            try:
                # Access the block so that Deuce validates it all internally
                block = self.deuceclient.HeadBlock(self.vault,
                                                   self.vault.blocks[block_id])

            except deuce_errors.MissingBlockError as missing_ex:
                self.log.warn('Project ID {0}, Vault {1} - '
                              'Block {2} error missing storage block '
                              .format(self.vault.project_id,
                                      self.vault.vault_id,
                                      block_id))
                self.manager.missing_counter.add(1, 0)
                block = None

            except Exception as ex:
                # if there was a problem just mark the block as None so it
                # get ignored for this iteration of the loop
                self.log.warn('Project ID {0}, Vault {1} - '
                         'Block {2} error heading block ({3}): {4}'
                         .format(self.vault.project_id,
                                 self.vault.vault_id,
                                 block_id,
                                 type(ex),
                                 str(ex)))
                block = None

            # if there was a problem then go to the next block_id
            if block is None:
                self.log.warn('Project ID {0}, Vault {1} - '
                         'Block {2} no block data to analyze'
                         .format(self.vault.project_id,
                                 self.vault.vault_id,
                                 block_id))
                continue

            # Now check if the block has any references
            if int(block.ref_count) == 0:
                self.log.warn('Project ID {0}, Vault {1} - '
                         'Block {2} has no references'
                         .format(self.vault.project_id,
                                 self.vault.vault_id,
                                 block_id))
                # Try to calculate the age of the block since it was
                # last modified

                block_age = datetime.datetime.utcnow() - \
                    datetime.datetime.utcfromtimestamp(block.ref_modified)
                self.log.warn('Project ID {0}, Vault {1} - '
                         'Block {2} has age {3}'
                         .format(self.vault.project_id,
                                 self.vault.vault_id,
                                 block_id,
                                 block_age))

                # If the block age is beyond the threshold then mark it
                # for deletion
                if block_age > self.manager.expire_age:
                    self.log.info('Project ID {0}, Vault {1} - '
                             'Found Expired Block: {2}'
                             .format(self.vault.project_id,
                                     self.vault.vault_id,
                                     block_id))

                    # If we have already marked it for deletion then
                    # do not add it a second time; try to keep the list
                    # to a minimum
                    if block_id not in self.manager.metadata.expired:
                        self.manager.expired_counter.add(1, len(block))
                        self.manager.metadata.expired.append(block_id)

            else:
                self.log.warn('Project ID {0}, Vault {1} - '
                         'Block {2} has {3} references'
                         .format(self.vault.project_id,
                                 self.vault.vault_id,
                                 block_id,
                                 block.ref_count))

        for block_id in self.manager.metadata.expired:
            # there _should_ only be one instance of a block_id in the
            # current list; but loop over it just in case since remove()
            # only removes the first instance it finds
            while block_id in self.manager.metadata.current:
                self.manager.metadata.current.remove(block_id)

    def cleanup_expired_blocks(self):
        """Delete expired blocks

        Attempt to delete each expired block
        On success, adds the block to a list of deleted blocks and removes
        the block id from the list of expired blocks

        Note: A block deletion may fail for numerous reasons including that
              the block received a change in its reference count to being
              non-zero between when it was detected as being expired and
              when the deletion operation occurred. This is a designed
              feature of Deuce so that blocks are not accidentally or
              improperly removed.
        """
        # Note: This function must be very verbose in its logging since it
        #       it removing user data that will not be recoverable from
        #       within Deuce

        # Check if there is a list to operate on; if not throw an error
        if self.manager.metadata.expired is not None:

            # Keep track of any block we successfully deleted
            if self.manager.metadata.deleted is None:
                self.manager.metadata.deleted = []

            # Attempt to delete all expired blocks
            for expired_block_id in self.manager.metadata.expired:

                # Check to see if we have already deleted the block
                if expired_block_id not in self.manager.metadata.deleted:

                    # Log that we are going to delete the block
                    self.log.info('Project ID {0}, Vault {1} - '
                                  'Deleting Expired Block: {2}'
                                  .format(self.vault.project_id,
                                          self.vault.vault_id,
                                          expired_block_id))

                    # Attempt to delete the block
                    # Note: This may fail for numerous reasons, including
                    #       that the block received a reference count between
                    #       when it was deteremined not to have any and when
                    #       the cleanup tried to remove it.
                    try:
                        self.deuceclient.DeleteBlock(self.vault,
                                                     self.vault.blocks[
                                                         expired_block_id])

                        # The block was deleted, save it as being so
                        # This serves two purposes:
                        #   1. Do not attempt to delete the same block twice
                        #   2. Do not mutate the expired block list while it
                        #      is being traversed; it'll get cleaned up later
                        self.manager.metadata.deleted.append(expired_block_id)

                        block_size = len(self.vault.blocks[
                            expired_block_id])
                        self.manager.delete_expired_counter.add(1,
                                                         block_size)
                        self.log.info('Project ID {0}, Vault {1} - '
                                      'Successfully Deleted Expired Block: {2}'
                                      .format(self.vault.project_id,
                                              self.vault.vault_id,
                                              expired_block_id))
                    except Exception as ex:
                        self.log.info('Project ID {0}, Vault {1} - '
                                      'FAILED to Deleted Expired Block '
                                      '({2}): {3}'
                                      .format(self.vault.project_id,
                                              self.vault.vault_id,
                                              expired_block_id,
                                              str(ex)))
                else:
                    self.log.info('Project ID {0}, Vault {1} - '
                                  'Already Deleted Expired Block: {2}'
                                  .format(self.vault.project_id,
                                          self.vault.vault_id,
                                          expired_block_id))

            # Now cleanup the expired list to remove the blocks that were
            # Actually deleted
            for deleted_block_id in self.manager.metadata.deleted:
                while deleted_block_id in self.manager.metadata.expired:
                    self.manager.metadata.expired.remove(deleted_block_id)
        else:
            raise RuntimeError('No expired blocks to remove.'
                               'Please run validate_metadata() first.')

    def build_cross_references(self, skip_expired=False):
        """Build a cross reference look-up for the metadata and storage ids

        Primary purpose is to have a quick way to do a reverse lookup of
        storage ids to determine validity based on the information we
        already have.

        :param skip_expired: boolean value for whether or not to include the
                             expired metadata blocks in the cross reference
                             data. Default is False which removes them from
                             the cross reference data.
        """

        check_expired = self.manager.metadata.expired is not None
        check_deleted = self.manager.metadata.deleted is not None

        if skip_expired:
            check_expired = False

        for block_id, block in self.vault.blocks.items():
            storage_id = block.storage_id
            self.log.debug('Project ID {0}, Vault {1} - '
                           'Checking status of Storage ID {2} '
                           'with Block ID {3}'
                           .format(self.vault.project_id,
                                   self.vault.vault_id,
                                   storage_id,
                                   block_id))

            # Skip the block if it was expired
            if check_expired:
                if block_id in self.manager.metadata.expired:
                    self.log.debug('Project ID {0}, Vault {1} - '
                                   'block {2} expired, not '
                                   'cross-referencing'
                                   .format(self.vault.project_id,
                                           self.vault.vault_id,
                                           block_id))
                    continue

            # Skip the block if it was deleted
            if check_deleted:
                if block_id in self.manager.metadata.deleted:
                    self.log.debug('Project ID {0}, Vault {1} - '
                                   'block {2} deleted, not '
                                   'cross-referencing'
                                   .format(self.vault.project_id,
                                           self.vault.vault_id,
                                           block_id))
                    continue

            # lookup the storage id
            self.log.debug('Project ID {0}, Vault {1} - '
                           'Mapping Storage ID {2} to Block ID {3}'
                           .format(self.vault.project_id,
                                   self.vault.vault_id,
                                   storage_id,
                                   block_id))

            # Add it to the cross-reference dict
            self.manager.cross_reference[storage_id] = block_id

    def validate_storage(self, skip_expired=False):
        """Check storage for orphaned blocks

        This implements the short version where we only operate on the
        listing of the storage blocks.

        :param skip_expired: Parameter to call to build_cross_references().
                             See build_cross_references() for details.

        Note: In some cases it may be advantageous to include the expired
              metadata blocks in the cross-reference data in order to keep
              their associated storage blocks from incorrectly being
              detected as orphaned blocks. This is primarily due to an
              order of operations issue when validating both metadata and
              storage prior to performing the actual block deletions. In
              these instances, set skip_expired to True to avoid improper
              detection of orphaned blocks that are not really orphaned.
        """

        if self.manager.storage.current is None:
            self.get_storage_list()

        if len(self.manager.storage.current) == 0:
            self.get_storage_list()

        if self.manager.storage.orphaned is None:
            self.manager.storage.orphaned = []

        # This builds a quick lookup which provides the following benefits:
        #   1. We do not have to look at self.vault.blocks every time
        #   2. We do not need to rely on the format of the storage block id to
        #      determine the metadata block id
        self.build_cross_references(skip_expired)

        if len(self.manager.cross_reference) == 0:
            self.log.warn('Project ID {0}, Vault {1} - no cross-references '
                          'between metadata and storage. All blocks will be'
                          'marked as orphaned for metadata block range '
                          '[{2}, {3})'
                          .format(
                              self.vault.project_id,
                              self.vault.vault_id,
                              self.manager.start_block,
                              self.manager.end_block))

        # Note: Marking a block orphaned here does not necessarily mean it is
        #       actually orphaned as there could have been activity on the
        #       Vault since we got the listings that could change the state of
        #       any block.This cuts both ways in that some blocks we determine
        #       are orphaned may not be orphaned, while other blocks we think
        #       are not orphaned are actually orphaned. This is okay as Deuce
        #       is designed to prevent deletion of non-ophaned blocks, and
        #       blocks that are not identified as orphaned but really are will
        #       be picked up on the next run.
        for storage_id in self.manager.storage.current:
            if storage_id not in self.manager.cross_reference:
                self.log.info('Project ID {0}, Vault {1} - '
                              'Found Orphaned Storage Block {2}'
                              .format(
                                  self.vault.project_id,
                                  self.vault.vault_id,
                                  storage_id))
                self.manager.storage.orphaned.append(storage_id)

                block_size = len(self.vault.storageblocks[storage_id])

                if block_size == 0:
                    mid, sid = storage_id.split('_')

                    if mid in self.vault.blocks:
                        self.log.info('Project ID {0}, Vault {1} - '
                                      'Located block {2} matching '
                                      'orphaned block {3}. Using for '
                                      'block size'.format(
                                          self.vault.project_id,
                                          self.vault.vault_id,
                                          mid,
                                          storage_id))
                        block_size = len(self.vault.blocks[mid])
                self.manager.orphaned_counter.add(1, block_size)

    def validate_storage_with_head(self):
        """Check storage for orphaned blocks

        This implements the long version where we operate on the listing
        of the storage blocks and also HEAD each block in storage
        """
        if self.manager.storage.current is None:
            self.get_storage_list()

        if len(self.manager.storage.current) == 0:
            self.get_storage_list()

        if self.manager.storage.orphaned is None:
            self.manager.storage.orphaned = []

        # Note: This version relies on Deuce to tell us that a block is
        #       orphaned so it is the most accurate at the time this
        #       function is called. However, there is still the chance that
        #       a block has a change of state between when we access it here
        #       and when it actually gets cleaned up
        for storage_id in self.manager.storage.current:

            self.log.debug('Project ID {0}, Vault {1} - '
                           'Validating Storage Block: {2}'
                           .format(self.vault.project_id,
                                   self.vault.vault_id,
                                   storage_id))
            try:
                block = self.deuceclient.HeadBlockStorage(self.vault,
                                                          self.vault.
                                                          storageblocks[
                                                              storage_id])
            except Exception as ex:
                # if there was a problem just mark the block as None so it
                # get ignored for this iteration of the loop
                self.log.warn('Project ID {0}, Vault {1} - '
                         'Storage Block {2} error heading block ({3}): {4}'
                         .format(self.vault.project_id,
                                 self.vault.vault_id,
                                 storage_id,
                                 type(ex),
                                 str(ex)))
                block = None

            # if there was a problem then go to the next block_id
            if block is None:
                self.log.warn('Project ID {0}, Vault {1} - '
                         'Storage Block {2} no block data to analyze'
                         .format(self.vault.project_id,
                                 self.vault.vault_id,
                                 storage_id))
                continue

            if block.block_orphaned:
                self.log.info('Project ID {0}, Vault {1} - '
                              'Found Orphaned Storage Block {2}'
                              .format(
                                  self.vault.project_id,
                                  self.vault.vault_id,
                                  storage_id))
                self.manager.storage.orphaned.append(storage_id)

                block_size = len(block)

                self.log.info('Storage Block ID {0} - block size {1}'
                              .format(storage_id, block_size))

                if block_size == 0:
                    mid, sid = storage_id.split('_')

                    self.log.info('\tBlock ID: {0}'.format(mid))
                    self.log.info('\tStorage UUID: {0}'.format(sid))

                    if mid in self.vault.blocks:
                        self.log.info('\tBlock ID {0} in Vault'.format(mid))

                        self.log.info('Project ID {0}, Vault {1} - '
                                      'Located block {2} matching '
                                      'orphaned block {3}. Using for '
                                      'block size'.format(
                                          self.vault.project_id,
                                          self.vault.vault_id,
                                          mid,
                                          storage_id))
                        self.log.info('\tUpdating Block Size from {0} to {1}'
                                      .format(block_size,
                                              len(self.vault.blocks[mid])))
                        block_size = len(self.vault.blocks[mid])
                self.manager.orphaned_counter.add(1, block_size)

    def calculate_current(self):
        """Calculate the amount of data that is still current
        """

        if self.manager.metadata.current is not None:
            for block_id in self.manager.metadata.current:
                block_size = len(self.vault.blocks[block_id])
                self.manager.current_counter.add(1, block_size)

    def cleanup_storage(self):
        """Delete orphaned blocks from storage

        Attempt to delete each orphaned block
        On success, adds the block to the list deleted blocks and removes
        the storage id from the orphaned blocks

        Note: A block deletion may fail for numerous reasons including that
              the block received a change in its state so it is no longer
              orphaned between when it was detected as orphaned and when
              the deletion operation occurred. This is a designed feature
              of Deuce so that blocks that blocks are not accidentally or
              improperly removed.
        """
        # Note: This function must be very verbose in its logging since it
        #       it removing user data that will not be recoverable from
        #       within Deuce

        # Check if there is a list to operate on; if not throw an error
        if self.manager.storage.orphaned is not None:

            # Keep track of any block we successfully deleted
            if self.manager.storage.deleted is None:
                self.manager.storage.deleted = []

            # Attempt to delete all expired blocks
            for orphaned_storage_block_id in self.manager.storage.orphaned:

                # Check to see if we have already deleted the block
                if orphaned_storage_block_id not in \
                        self.manager.storage.deleted:

                    # Log that we are going to delete the block
                    self.log.info('Project ID {0}, Vault {1} - '
                                  'Deleting Orphaned Block: {2}'
                                  .format(self.vault.project_id,
                                          self.vault.vault_id,
                                          orphaned_storage_block_id))

                    # Attempt to delete the block
                    # Note: This may fail for numerous reasons, including
                    #       that the block received a reference count between
                    #       when it was deteremined not to have any and when
                    #       the cleanup tried to remove it.
                    try:
                        osbid = orphaned_storage_block_id
                        orphaned_block = Block(self.vault.project_id,
                                               self.vault.vault_id,
                                               block_id=None,
                                               storage_id=osbid,
                                               block_type='storage')
                        self.deuceclient.DeleteBlockStorage(self.vault,
                                                            orphaned_block)

                        # The block was deleted, save it as being so
                        # This serves two purposes:
                        #   1. Do not attempt to delete the same block twice
                        #   2. Do not mutate the orphaned block list while it
                        #      is being traversed; it'll get cleaned up later
                        self.manager.storage.deleted.append(
                            orphaned_storage_block_id)

                        # By default this will be zero and this should be
                        # valid since the oprhaned_storage_block_id comes
                        # from listing the storage blocks to start with
                        block_size = len(self.vault.storageblocks[
                            orphaned_storage_block_id])

                        if block_size == 0:
                            mid, sid = orphaned_storage_block_id.split('_')

                            if mid in self.vault.blocks:
                                self.log.info('Project ID {0}, Vault {1} - '
                                              'Located block {2} matching '
                                              'orphaned block {3}. Using for '
                                              'block size'.format(
                                                  self.vault.project_id,
                                                  self.vault.vault_id,
                                                  mid,
                                                  orphaned_storage_block_id))
                                block_size = len(self.vault.blocks[mid])

                        self.manager.delete_orphaned_counter.add(1, block_size)

                        self.log.info('Project ID {0}, Vault {1} - '
                                      'Successfully Deleted Orphaned Block: '
                                      '{2}'
                                      .format(self.vault.project_id,
                                              self.vault.vault_id,
                                              orphaned_storage_block_id))
                    except Exception as ex:
                        self.log.info('Project ID {0}, Vault {1} - '
                                      'FAILED to Deleted Orphaned Block '
                                      '({2}): {3}'
                                      .format(self.vault.project_id,
                                              self.vault.vault_id,
                                              orphaned_storage_block_id,
                                              str(ex)))
                else:
                    self.log.info('Project ID {0}, Vault {1} - '
                                  'Already Deleted Orphaned Block: {2}'
                                  .format(self.vault.project_id,
                                          self.vault.vault_id,
                                          orphaned_storage_block_id))

            # Now cleanup the orphaned list to remove the blocks that were
            # Actually deleted
            for deleted_block_id in self.manager.storage.deleted:
                while deleted_block_id in self.manager.storage.orphaned:
                    self.manager.storage.orphaned.remove(deleted_block_id)
        else:
            raise RuntimeError('No orphaned blocks to remove.'
                               'Please run validate_storage() '
                               'or validate_storage_with_head() first.')


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_main">

    <com.alucine.zinio.marvelpoc.helpers.EmptyRecyclerView
        android:id="@+id/cardList"
        android:scrollbars="vertical"
        android:scrollbarStyle="outsideInset"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <TextView android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textSize="17dp"
        android:gravity="center"
        android:visibility="gone"
        android:textColor="@android:color/black"
        android:textStyle="bold"
        android:id="@+id/emptyCharacters"
        android:text="@string/downloading_characters" />

</RelativeLayout>

redpajama_set_name: RedPajamaGithub


text:
package CivPackage.Models;

import CivPackage.GameProject;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
import java.util.HashMap;

/**
 * Created by james on 6/29/2014.
 */
public class Hex extends Actor{
    //the tiles in pixel coordinates,
    private Vector2 pixelPos;

    //the tiles in map x and y coordinates, stored in the array
    private Vector2 pos;
    private boolean even;   //if this tile is even or odd
    private boolean selected;

    private String id;         //what this tile is
    private int resource;   //id of the resource
    private int SRCount;    //amount of strategic resource, iron, horses, etc
    private float cost;       //how much it costs to move across this tile
    private boolean walkable = true;//
    private Entity unit;    //the unit that is currently on this hex

    private Texture texture;

    public String landType = "";    //Ocean, Shore, Desert, Plains, Grassland, Tundra, Snow
    public int elevation;           //1 = normal, 2 = hill, 3 = mountain, 0 = water
    public static final String[] elevationName = {"", "", "Hills", "Mountain"};
    public boolean freshWater;
    public String river = "000000";
    public String feature = "";     //Atoll, Ice, Oasis, Jungle, Forest, Marsh
    private float[] terrainGains;   //the growth from this tile;    0 = food, 1 = production, 2 = gold, 3 = science, 4 = culture
    private String wonder = "";     //private because then it has to call a function, which allows me to update this hex' data

    //File names of the hex tiles
    private static String[] hexNames = {"Hex0",             //0
            "Ocean",    "OceanAtoll",       "OceanIce",     //3
            "Shore",    "ShoreAtoll",       "ShoreIce",     //6
            "Desert",   "DesertHills",      "DesertMountain",   "DesertFallout",    "DesertOasis",      "DesertFloodplains",    //12
            "Grassland","GrasslandHills",   "GrasslandMountain","GrasslandFallout", "GrasslandForest",  "GrasslandHillForest","GrasslandHillJungle","GrasslandJungle", "GrasslandMarsh",  //21
            "Plains",   "PlainsHills",      "PlainsMountain",   "PlainsFallout",    "PlainsForest",     "PlainsHillForest",     //27
            "Snow",     "SnowHills",        "SnowMountain", //30
            "Tundra",   "TundraHills",      "TundraMountain",   "TundraFallout",    "TundraForest",     "TundraHillForest",     //36
            "Special1"
    };
    //Array of textures preloaded from the file names above
    private static Texture[] textures;

    private static final String[] hexNames2 = {"Ocean", "Shore", "Desert", "Grassland", "Plains", "Snow", "Tundra", "Lake"};
    private static final String[] features = {"Atoll", "Ice", "Oasis", "Jungle", "Forest", "Marsh"};
    private static HashMap generatedHexes = new HashMap();  //key is string of the entire hex, value is the hex pixmap

    static {
        //assembles the file name into the full file name
        for (int i = 0; i < hexNames.length; i++){
            hexNames[i] = GameProject.fileName + "Hex/256/Tiles/" + hexNames[i] + ".png";
        }
        textures = new Texture[hexNames.length];
        for (int i = 0; i < hexNames.length; i++){
            textures[i] = new Texture(hexNames[i]);
        }
        //System.out.print("H");

        /*
        //v2
        Pixmap p, p2;
        Texture t;
        for (int i = 0; i < hexNames2.length; i++){
            for (int n = 0; n < features.length; n++){
                //System.out.println(hexNames2[i] + features[n]);
                p = new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/Tiles/"+hexNames2[i]+".png"));
                generatedHexes.put(hexNames2[i], new Texture(p));
                p2 = new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/Tiles/"+features[n]+".png"));
                generatedHexes.put(features[n], new Texture(p2));
                p = new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/Tiles/"+hexNames2[i]+".png"));
                p.drawPixmap(p2, 0, 0);
                t = new Texture(p);
                generatedHexes.put(hexNames2[i] + features[n], t);
            }
        }*/
    }

    public static final Texture[] ICONS = { //http://civilization.wikia.com/wiki/Category:Civilization_V_icon_templates
            new Texture(GameProject.fileName + "Hex/256/Icons/Food32.png"),
            new Texture(GameProject.fileName + "Hex/256/Icons/Two2.png"),
            new Texture(GameProject.fileName + "Hex/256/Icons/Three.png")
    };

    private static final Pixmap[] rivers = {new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/River1.png"))
            ,new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/River2.png"))
            ,new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/River3.png"))
            ,new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/River4.png"))
            ,new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/River5.png"))
            ,new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/River6.png"))
    };

    public static final Texture BC = new Texture(GameProject.fileName + "Hex/256/Wonders/BC.png");

    public static final Texture SELECTED = new Texture(GameProject.fileName + "Hex/256/Selected1.png");
    public static final Texture SELECTED2 = new Texture(GameProject.fileName + "Hex/256/Selected2.png");
    public static final Pixmap PATH = new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/Path.png"));

    //http://www.gamedev.net/page/resources/_/technical/game-programming/coordinates-in-hexagon-based-tile-maps-r1800
    public static final int HexS = 127;
    public static final int HexH = (int)Math.round(HexS * Math.sin(3.14156/6));  //S * sin(30) (height)
    public static final int HexR = (int)Math.round(HexS * Math.cos(3.14156/6));  //S * cos(30) (radius)
    public static final int HexD = HexR * 2; //2 * HexR    (diameter)
    public static final int HexHS= HexH + HexS; //HexH + HexS

    /*
    Id directory:       NO LONGER BEING USED
        abcdefghijklmn

        |letter and name|------------------|a,          b,          c,              d,          e,      f,      g,      h
        0  a: terrain type;                 flat land,  hill,       mountain
        1  b: terrain;                      ocean,      coast/lake, desert,         grassland,  plains, snow,   tundra
        2  d: rivers/fresh water;           River,      lake
        3  c: terrain features;             atoll,      fallout,    flood plains,   forest,     ice,    jungle, marsh,  oasis
        4  e: wonders;                      17 of them
        5  f: food resource;                bananas,    wheat,      cattle,         sheep,      deer,   fish,   stone
        6  g: luxury resource;              25 of them
        7  h: strategic resource;           horses,     iron,       coal,           aluminum,   oil,    uranium
        8  i: pillaged improvement;         yes,        no
        9  j: great people improvements;    8 of them
        10 k: regular improvements;         21 of them
        11 l: roads;                        road,       railroad
        12 m: exploration;                  explored,   unexplored
        13 n: land ownership;               free land,  your land

        Wonders:
        Luxury resource:
        GP improvements:                    academy, ancient ruins, citadel, city ruins, customs house, encampment, holy site, manufactory
        Regular improvements:               archaeological dig, brazilwood camp, camp, chateau, farm, feitoria, fishing boats, fort, kasbah,
                                            landmark, lumber mill, mine, moai, offshore platform, oil well, pasture, plantation, polder, quarry, terrance farm, trading post
     */

    /*
            Banana - Jungle
            Wheat  - flood plains, plains
            Cattle - plains, hills, grassland
            Sheep  - plains, hills
            Bison  - grassland, plains
            Deer   - forest, tundra
            Fish   - coast
            Stone  - desert, plains, tundra, hills, snow
     */

    public Hex(int x, int y){
        pixelPos = new Vector2();
        pos = new Vector2(x,y);
        if (pos.y%2 == 0){
            even = true;
        }else{
            even = false;
        }
        cost = 1;
        terrainGains = new float[5];
        for (int i = 0; i < terrainGains.length; i++)
            terrainGains[0] = 0;

        pixelPos.x = pos.x * HexD + (pos.y %2)*HexR;
        pixelPos.y = pos.y * HexHS;
    }

    /**
     *  Creates a new hex
     * @param id    refer to the chart on top for what the id means
     * @param x
     * @param y
     */
    public Hex(String id, int x, int y){
        pixelPos = new Vector2();
        pos = new Vector2(x,y);
        if (pos.y%2 == 0){
            even = true;
        }else{
            even = false;
        }
        id = id.toLowerCase();
        this.id = id;

        //assign the texture
        /*if (id.charAt(4) != 0){     //checks if this is a wonder, if it is, just assign it the wonder texture
            texture = textures[0];
        }else {
            texture = textures[getImageId(id.substring(0, 3))];
        }*/
        //texture = textures[getImageId(id.substring(0, 4))];
        cost = 1;

        pixelPos.x = pos.x * HexD + (pos.y %2)*HexR;
        pixelPos.y = pos.y * HexHS;
    }

    public void makeWonder(String s){
        wonder = s;
        switch (s){
            case "BC":              //becomes mountain
            case "Mesa":
            case "OF":
            case "CdP":
            case "SP":
            case "MSin":
            case "Kail":
            case "Ulu":
            case "Kili":
                elevation = 3;
                break;
            case "Fuji":
            case "Krak":            //becomes grassland mountain
                landType = "Grassland";
                elevation = 3;
                break;
            case "ED":              //flatland plains
            case "FoY":
            case "Vic":
            case "Mos":
                landType = "Plains";
                elevation = 1;
                break;
        }
        update();
    }

    /**
     * Call this method to update the tile after changes
     */
    public void update(){
        //============================= update the output values ==================
        //0 = food, 1 = production, 2 = gold, 3 = science, 4 = culture
        for (int i = 0; i < terrainGains.length; i++)
            terrainGains[i] = 0;        //reset all values

        if (elevation == 0) {
            terrainGains[0] = 1;                    //all water values are just +1 food
            if (landType.equals("Lake"))
                terrainGains[0] = 2;                //except lakes
            if (feature.equals("Ice")){             //ice has no gains
                terrainGains[0] = 0;
                terrainGains[1] = 0;
            }

        }else if (elevation == 1){
            if (feature == "") {                    //if there is no terrain feature,
                switch (landType) {                 //update landtype values
                    case "Tundra":
                        terrainGains[0] = 1;
                        break;
                    case "Grassland":
                        terrainGains[0] = 2;
                        break;
                    case "Plains":
                        terrainGains[0] = 1;
                        terrainGains[1] = 1;
                        break;
                    //desert and snow have no output values, so dont need to include
                }
            }else{                                  //if there is terrain feature, update according to the feature
                switch (feature){
                    case "Forest":
                    case "Atoll":
                        terrainGains[0] = 1;
                        terrainGains[1] = 1;
                        break;
                    case "Jungle":
                        terrainGains[0] = 1;
                        terrainGains[1] = -1;
                        break;
                    case "Marsh":
                        terrainGains[0] = -1;
                        break;
                    case "FloodPlains":
                        terrainGains[0] = 2;
                        break;
                    case "Oasis":
                        terrainGains[0] = 3;
                        terrainGains[2] = 1;
                        break;
                }
            }
        }else if (elevation == 2){
            terrainGains[1] = 2;        //hills are always +2 production
        }                               //mountains are +0, so not included

        //============================= update the image ==========================
        boolean test = true;
        if (elevation == 3) {
            walkable = false;
        }else{
            walkable = true;
        }

        if (test) {
            //v2
            String[] l = {landType, elevationName[elevation], feature};
            texture = makePixMap(l);
        }else {

            if (wonder.equals("")) {
                texture = textures[getImageId()];
            } else {
                texture = BC;
            }
        }
    }

    private Texture makePixMap(String[] list){
        String s = "";
        for (String str: list){
            s += str;
        }
        if (s.equals("")){
            return BC;
        }

        if (!wonder.equals("")){
            Pixmap p = new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/Tiles/"+landType+".png"));
            Pixmap wdr = new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/Wonders/" + wonder + ".png"));
            p.drawPixmap(wdr, 0, 0);
            return new Texture(p);
        }

        if (generatedHexes.containsKey(s)){
            return (Texture)generatedHexes.get(s);
        }

        Pixmap p = new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/Tiles/"+landType+".png"));
        if (!feature.equals(""))
            p.drawPixmap(new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/Tiles/"+feature+".png")), 0, 0);
        if (elevation > 1)
            p.drawPixmap(new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/Tiles/"+elevationName[elevation]+".png")), 0, 0);
        Texture t = new Texture(p);
        generatedHexes.put(s, t);

        return t;
    }

    /**
     * Returns the image id of the hex using a bunch of switches
     * @return  integer of the location in the array which the image is stored in
     */
    private int getImageId(){
        switch (landType){
            case "Ocean":{                                  //ocean
                if (feature.equals("Ice"))    //ice
                    return 3;
                else
                    return 1;               //ocean
            }case "Shore":{                                 //shore/lake
                switch (feature){
                    case "":
                        return 4;           //shore/lake
                    case "Atoll":
                        return 5;           //atoll
                    case "Ice":
                        return 6;           //ice
                    default:
                        return 4;
                }
            }case "Lake":{
                return 1;
            }case "Desert":{                                 //desert
                switch (elevation){
                    case 3:   //mountain
                        return 9;          //desert mountain
                    case 1:{  //flat land
                        switch (feature){
                            case "":
                                return 7;    //desert
                            case "FloodPlains"://'c':
                                return 12;   //flood plains
                            case "Oasis":
                                return 11;   //oasis
                            default:
                                return 7;
                        }
                    }
                    case 2:{  //hill
                        return 8;          //desert hills
                    }
                }
            }case "Grassland":{                                 //grassland
                switch (elevation){
                    case 3:   //mountain
                        return 15;           //grassland mountain
                    case 1:{  //flat land
                        switch (feature){
                            case "":
                                return 13;   //grassland
                            case "Forest":
                                return 19;   //forest
                            case "Jungle":
                                return 20;   //jungle
                            case "Marsh":
                                return 21;   //marsh
                            default:
                                return 13;
                        }
                    }
                    case 2:{  //hill
                        switch (feature){
                            case "":
                                return 14;   //grassland hill
                            case "Forest":
                                return 18;   //forest
                            case "Jungle":
                                return 19;   //jungle
                            default:
                                return 14;
                        }
                    }
                }
            }case "Plains":{                                 //plains
                switch (elevation){
                    case 3:   //mountain
                        return 24;           //plains mountain
                    case 1:{  //flat land
                        switch (feature){
                            case "":
                                return 22;   //plains
                            case "Forest":
                                return 26;   //forest
                            default:
                                return 22;
                        }
                    }
                    case 2:{  //hill
                        switch (feature){
                            case "":
                                return 23;   //plains hill
                            case "Forest":
                                return 27;   //forest
                            default:
                                return 23;
                        }
                    }
                }
            }case "Snow":{                                 //snow
                switch (elevation){
                    case 1:{  //flat land
                        return 28;
                    }case 2:{ //hill
                        return 29;
                    }case 3:{ //mountain
                        return 30;
                    }
                }
            }case "Tundra":{                                 //tundra
                switch (elevation){
                    case 1:{  //flat land
                        if (feature.equals("Forest"))
                            return 35;      //forest
                        else
                            return 31;      //tundra
                    }case 2:{ //hill
                        if (feature.equals("Forest"))
                            return 36;      //forest
                        else
                            return 32;      //tundra hill
                    }case 3:  //mountain
                        return 33;          //tundra mountain
                }
            }case "Special":{
                return 37;
            }
            default: {
                System.out.println(pos.x + " " + pos.y + " " + id);
                return 0;
            }
        }
    }

    public void addRiver(String where){
        Pixmap p;
        if (wonder.equals(""))
            p = new Pixmap(Gdx.files.internal(hexNames[getImageId()]));
        else
            p = new Pixmap(Gdx.files.internal(GameProject.fileName + "Hex/256/Wonders/" + wonder + ".png"));
        river = where;
        for (int i = 0; i < where.length(); i++){
            if (where.charAt(i) == '1'){
                p.drawPixmap(rivers[i], 0, 0);
            }
        }
        texture = new Texture(p);
    }

    public float[] getTerrainGains(){return terrainGains;}
    public String getWonder(){return wonder;}
    public Texture getTexture(){
        return texture;
    }
    public Vector2 getPixelPos(){return pixelPos;}
    public Vector2 getPos(){return pos;}
    public int getMapX(){return (int)pos.x;}
    public int getMapY(){return (int)pos.y;}
    public boolean getEven(){return even;}
    public Entity getUnit() {return unit;}
    public void addUnit(Entity unit){this.unit = unit;}
    public float getCost(){return cost;}
    public boolean getWalkable(){return walkable;}
}


text:
class TesseractPagesController < ApplicationController
  skip_before_filter :verify_authenticity_token
  def run

  	puts "In Run Controller"

    jpg = Base64.decode64(params[:image]);

    puts "Creating directory"
    %x(mkdir tessdir)

    puts "Saving image"
    file = File.open("tessdir/sample.jpg",'wb')
  	file.write jpg

    puts "Starting tesseract"
    %x(tesseract tessdir/sample.jpg tessdir/out -l #{params[:language]})

    puts "Reading result"
    file = File.open("tessdir/out.txt", "rb")
    contents = file.read

    puts "removing tessdir"
    %x(rm -Rf tessdir)

    render text: contents
  end
end


text:
#pragma mark Named Structures

struct CGPoint {
    double _field1;
    double _field2;
};

struct CGRect {
    struct CGPoint _field1;
    struct CGSize _field2;
};

struct CGSize {
    double width;
    double height;
};

struct _NSRange {
    unsigned long long _field1;
    unsigned long long _field2;
};

#pragma mark Typedef'd Structures

typedef struct {
    double _field1;
    double _field2;
    double _field3;
    double _field4;
} CDStruct_d2b197d1;


text:
import unittest
import sys
import random
import jellyfish

class TestStringMers(unittest.TestCase):
    def setUp(self):
        bases = "ACGTacgt"
        self.str = ''.join(random.choice(bases) for _ in range(1000))
        self.k = random.randint(10, 110)
        jellyfish.MerDNA.k(self.k)

    def test_all_mers(self):
        count = 0
        good = True
        mers = jellyfish.string_mers(self.str)
        for m in mers:
            m2 = jellyfish.MerDNA(self.str[count:count+self.k])
            good = good and m == m2
            count += 1
        self.assertTrue(good)
        self.assertEqual(len(self.str) - self.k + 1, count)

    def test_canonical_mers(self):
        good = True
        mers = jellyfish.string_canonicals(self.str)
        for count, m in enumerate(mers):
            m2 = jellyfish.MerDNA(self.str[count:count+self.k])
            rm2 = m2.get_reverse_complement()
            good = good and (m == m2 or m == rm2)
            good = good and (not (m > m2)) and (not (m > rm2))
            # count += 1
        self.assertTrue(good)
        self.assertEqual(len(self.str) - self.k + 0, count)

if __name__ == '__main__':
    data = sys.argv.pop(1)
    unittest.main()


text:
namespace glm
{
	/// @addtogroup gtx_color_space
	/// @{

	/// Converts a color from HSV color space to its color in RGB color space.
	/// @see gtx_color_space
	template <typename T, precision P>
	GLM_FUNC_DECL tvec3<T, P> rgbColor(
		tvec3<T, P> const & hsvValue);

	/// Converts a color from RGB color space to its color in HSV color space.
	/// @see gtx_color_space
	template <typename T, precision P>
	GLM_FUNC_DECL tvec3<T, P> hsvColor(
		tvec3<T, P> const & rgbValue);

	/// Build a saturation matrix.
	/// @see gtx_color_space
	template <typename T>
	GLM_FUNC_DECL tmat4x4<T, defaultp> saturation(
		T const s);

	/// Modify the saturation of a color.
	/// @see gtx_color_space
	template <typename T, precision P>
	GLM_FUNC_DECL tvec3<T, P> saturation(
		T const s,
		tvec3<T, P> const & color);

	/// Modify the saturation of a color.
	/// @see gtx_color_space
	template <typename T, precision P>
	GLM_FUNC_DECL tvec4<T, P> saturation(
		T const s,
		tvec4<T, P> const & color);

	/// Compute color luminosity associating ratios (0.33, 0.59, 0.11) to RGB canals.
	/// @see gtx_color_space
	template <typename T, precision P>
	GLM_FUNC_DECL T luminosity(
		tvec3<T, P> const & color);

	/// @}
}//namespace glm

#include "color_space.inl"


text:
import calendar
import datetime

from django.conf import settings
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy

from corehq.apps.app_manager.dbaccessors import get_brief_apps_in_domain
from corehq.apps.commtrack.const import USER_LOCATION_OWNER_MAP_TYPE
from corehq.apps.export.models.incremental import IncrementalExport
from corehq.apps.groups.models import Group
from corehq.apps.reports.analytics.esaccessors import (
    get_case_types_for_domain,
)
from corehq.apps.reports.filters.base import (
    BaseMultipleOptionFilter,
    BaseSingleOptionFilter,
)
from corehq.motech.repeaters.const import (
    RECORD_CANCELLED_STATE,
    RECORD_FAILURE_STATE,
    RECORD_PENDING_STATE,
    RECORD_SUCCESS_STATE,
)
from corehq.motech.repeaters.dbaccessors import get_repeaters_by_domain

class GroupFilterMixin(object):
    slug = "group"
    label = gettext_lazy("Group")
    default_text = gettext_lazy("Everybody")

    @property
    def options(self):
        return [(group.get_id, group.name) for group in Group.get_reporting_groups(self.domain)]

class GroupFilter(GroupFilterMixin, BaseSingleOptionFilter):
    placeholder = gettext_lazy('Click to select a group')

class MultiGroupFilter(GroupFilterMixin, BaseMultipleOptionFilter):
    placeholder = gettext_lazy('Click to select groups')

class YearFilter(BaseSingleOptionFilter):
    slug = "year"
    label = gettext_lazy("Year")
    default_text = None

    @property
    def options(self):
        start_year = getattr(settings, 'START_YEAR', 2008)
        years = [(str(y), y) for y in range(start_year, datetime.datetime.utcnow().year + 1)]
        years.reverse()
        return years

class MonthFilter(BaseSingleOptionFilter):
    slug = "month"
    label = gettext_lazy("Month")
    default_text = None

    @property
    def options(self):
        return [("%02d" % m, calendar.month_name[m]) for m in range(1, 13)]

class CaseTypeMixin(object):
    slug = "case_type"
    label = gettext_lazy("Case Type")
    default_text = gettext_lazy("All Case Types")

    @property
    def options(self):
        case_types = sorted(get_case_types_for_domain(self.domain))
        return [(case, "%s" % case) for case in case_types
                if case != USER_LOCATION_OWNER_MAP_TYPE]

class CaseTypeFilter(CaseTypeMixin, BaseSingleOptionFilter):
    placeholder = gettext_lazy('Click to select a case type')

class MultiCaseTypeFilter(CaseTypeMixin, BaseMultipleOptionFilter):
    placeholder = gettext_lazy('Click to select case types')

class SelectOpenCloseFilter(BaseSingleOptionFilter):
    slug = "is_open"
    label = gettext_lazy("Open / Closed")
    default_text = gettext_lazy("Show All")

    @property
    def options(self):
        return [
            ('open', _("Only Open")),
            ('closed', _("Only Closed")),
        ]

class SelectApplicationFilter(BaseSingleOptionFilter):
    slug = "app"
    label = gettext_lazy("Application")

    if settings.SERVER_ENVIRONMENT in settings.ICDS_ENVS:
        default_text = gettext_lazy("Select Application")
    else:
        default_text = gettext_lazy("Select Application [Latest Build Version]")

    @property
    def options(self):
        apps_for_domain = get_brief_apps_in_domain(self.domain)
        if settings.SERVER_ENVIRONMENT in settings.ICDS_ENVS:
            return [(app.get_id, _("{name}".format(
                name=app.name))) for app in apps_for_domain
            ]
        else:
            return [(app.get_id, _("{name} [up to build {version}]".format(
                name=app.name,
                version=app.version))) for app in apps_for_domain
            ]

class RepeaterFilter(BaseSingleOptionFilter):
    slug = 'repeater'
    label = gettext_lazy('Repeater')
    default_text = gettext_lazy("All Repeaters")
    placeholder = gettext_lazy('Click to select repeaters')

    @property
    def options(self):
        return [(r.get_id, str(r)) for r in self._get_repeaters()]

    def _get_repeaters(self):
        return get_repeaters_by_domain(self.domain)

class RepeatRecordStateFilter(BaseSingleOptionFilter):
    slug = "record_state"
    label = gettext_lazy("Record Status")
    default_text = gettext_lazy("Show All")

    @property
    def options(self):
        return [
            (RECORD_SUCCESS_STATE, _("Successful")),
            (RECORD_PENDING_STATE, _("Pending")),
            (RECORD_CANCELLED_STATE, _("Cancelled")),
            (RECORD_FAILURE_STATE, _("Failed")),
        ]

class IncrementalExportFilter(BaseSingleOptionFilter):
    slug = 'incremental_export_id'
    label = gettext_lazy('Incremental Export')
    default_text = gettext_lazy("All Incremental Exports")

    @property
    def options(self):
        return [(str(i[0]), i[1]) for i in IncrementalExport.objects.filter(
            domain=self.domain
        ).values_list('id', 'name').all()]


text:
package javaguide.application.root;

// #root
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import javax.inject.Singleton;
import play.http.HttpErrorHandler;
import play.mvc.*;
import play.mvc.Http.*;

@Singleton
public class ErrorHandler implements HttpErrorHandler {
  public CompletionStage<Result> onClientError(
      RequestHeader request, int statusCode, String message) {
    return CompletableFuture.completedFuture(
        Results.status(statusCode, "A client error occurred: " + message));
  }

  public CompletionStage<Result> onServerError(RequestHeader request, Throwable exception) {
    return CompletableFuture.completedFuture(
        Results.internalServerError("A server error occurred: " + exception.getMessage()));
  }
}
// #root