text:
var myAPIKey = '';
var user_dir="0";
  var testint=0;
var routechoice=0;
var current=0;

function BusInfo (route,stop,eta) {
    this.route = route;
    this.stop =stop;
    this.eta = eta;
}

var West=[];

var East = [];

var North = [];

var South = [];

function iconFromTRANSITId(TRANSITId) {
  if (TRANSITId < 600) {
    return 2;
  } else if (TRANSITId < 700) {
    return 3;
  } else if (TRANSITId > 800) {
    return 1;
  } else {
    return 0;
  }
}

function fetchTRANSIT(latitude, longitude) {
  var req = new XMLHttpRequest();
  var req2 = new XMLHttpRequest();
  var req3 = new XMLHttpRequest();
  var req4 = new XMLHttpRequest();
  var req5 = new XMLHttpRequest();
  var Estop=" ";
    var Wstop=" ";
    var Sstop=" ";
    var Nstop=" ";

  var Ntime=" ";
  var Nroute=" ";
  var Ndirection=" ";
    var Wtime=" ";
  var Wroute=" ";
  var Wdirection=" ";
    var Stime=" ";
  var Sroute=" ";
  var Sdirection=" ";
    var Etime=" ";
  var Eroute=" ";
  var Edirection=" ";

  var default_dir="";

  console.log('lat2= ' + latitude + ' lon2= ' + longitude);
  //var lat= 49.248523;
  //var long = -123.101606;
  var lat=(''+latitude).substring(0,(""+latitude).indexOf(".")+7);
  var long=(''+longitude).substring(0,(""+longitude).indexOf(".")+7);
  console.log('lati= ' + lat + ' long= ' + long);
  lat= 49.273114;
  long = -123.100348;

  req.open('GET', 'http://api.translink.ca/rttiapi/v1/stops?apikey=M5uO4PdfDGgA0b7TIKjj&lat=' + lat + '&long=' + long + '&radius=500',true);
 // req.open('GET', 'http://api.translink.ca/rttiapi/v1/stops?apikey=M5uO4PdfDGgA0b7TIKjj&lat=49.248523&long=-123.108800&radius=10',true);

  function matchRuleShort(str, rule) {
  return new RegExp("^" + rule.split("*").join(".*") + "$").test(str);
}

  req.onload = function () {
    if (req.readyState === 4) {
      if (req.status === 200) {

      console.log(req.responseText);
        var count=0;
        var temp2="";
        //temp2=(req.responseText).substring((req.responseText).indexOf("<Name>")+6,(req.responseText).indexOf("<Name>")+8);
        temp2=req.responseText;
        console.log('Temp2'+temp2);
        //Maybe this should work for skytrains................
        while ((default_dir!=="EB"&&default_dir!=="WB"&&default_dir!=="SB"&&default_dir!=="NB")&&count<10) {

        default_dir=temp2.substring(temp2.indexOf("<Name>")+6,temp2.indexOf("<Name>")+8);
        temp2=temp2.substring(temp2.indexOf("<Name>")+8,temp2.length-1);
        count=count+1;
          console.log('Temp2'+temp2);
        console.log('Default'+default_dir);
        }
        if(user_dir==="0"){
        switch (default_dir){
          case "SB":
            user_dir="1";
            break;
          case "NB":
            user_dir="2";
            break;
          case "EB":
            user_dir="4";
            break;
          case "WB":
            user_dir="3";
            break;
        }
        }

          //Estop=(req.responseText).substring((req.responseText).indexOf("<StopNo>")+8,(req.responseText).indexOf("<StopNo>")+13);
        Estop=(req.responseText).substring((req.responseText).indexOf("<Name>EB")-14,(req.responseText).indexOf("<Name>EB")-9);
       console.log('Estop'+Estop+"!");
        Wstop=(req.responseText).substring((req.responseText).indexOf("<Name>WB")-14,(req.responseText).indexOf("<Name>WB")-9);
       console.log('Wstop'+Wstop);
        Sstop=(req.responseText).substring((req.responseText).indexOf("<Name>SB")-14,(req.responseText).indexOf("<Name>SB")-9);
       console.log('Sstop'+Sstop);
        Nstop=(req.responseText).substring((req.responseText).indexOf("<Name>NB")-14,(req.responseText).indexOf("<Name>NB")-9);
       console.log('Nstop'+Nstop);
            /*S=1
  N=2
  W=3
  E=4
  */
        console.log("Direction2:" +user_dir);
        testint=testint+1;
   /////////////EAST
        if(Estop!=="" && ((user_dir==="0" && default_dir==="EB") || user_dir==="4"))
          {
            console.log('Estop'+Estop+"1");
        req2.open('GET', 'http://api.translink.ca/rttiapi/v1/stops/'+Estop+'/estimates?apikey=M5uO4PdfDGgA0b7TIKjj&count=1',true);
        req2.onload = function () {
        if (req2.readyState === 4) {
      if (req2.status === 200) {
          //<ExpectedCountdown>2</ExpectedCountdown>
        //Etime=(req2.responseText).substring((req2.responseText).indexOf("<ExpectedCountdown>")+19,(req2.responseText).indexOf("</ExpectedCountdown>"));
        //Eroute=(req2.responseText).substring((req2.responseText).indexOf("<RouteNo>")+9,(req2.responseText).indexOf("</RouteNo>"));
        //Edirection=(req2.responseText).substring((req2.responseText).indexOf("<Direction>")+11,(req2.responseText).indexOf("<Direction>")+12);
        //<RouteNo>003<Direction></Direction>
          console.log(req2.responseText);
        console.log("Route"+Eroute);
        //console.log('lat3= ' + latitude + ' lon3= ' + longitude);

                var Stemp=req2.responseText;
        var check=0;
        while ((Stemp.indexOf("<Direction>")>0)&&check<10)
          {
            check=check+1;
            Etime=Stemp.substring(Stemp.indexOf("<ExpectedCountdown>")+19,Stemp.indexOf("</ExpectedCountdown>"));
            Eroute=Stemp.substring(Stemp.indexOf("<RouteNo>")+9,Stemp.indexOf("</RouteNo>"));
            Edirection=Stemp.substring(Stemp.indexOf("<Direction>")+11,Stemp.indexOf("<Direction>")+12);
            Stemp=Stemp.substring(Stemp.indexOf("<Direction>")+13,Stemp.length-1);
            South.push(new BusInfo("ROUTE: "+ Sroute +" "+Sdirection,"STOP: "+ Sstop,Stime));
          }

        East.push(new BusInfo("ROUTE: "+ Eroute +" "+Edirection,"STOP: "+ Estop,Etime));

                Pebble.sendAppMessage({
          'DIR_KEY': default_dir,
          'S_STOP_KEY': East[current].stop,
          'S_ETA_KEY': East[current].eta,
          'S_ROUTE_KEY': East[current].route,
        });
      }
   }
  };
        req2.send(null);
          }
  /////////////////WEST
                if(Wstop!=="" && ((user_dir==="0" && default_dir==="WB") ||user_dir==="3"))
          {
        console.log('Wstop'+Wstop+"2");
           req3.open('GET', 'http://api.translink.ca/rttiapi/v1/stops/'+Wstop+'/estimates?apikey=M5uO4PdfDGgA0b7TIKjj&count=1',true);
        req3.onload = function () {
        if (req3.readyState === 4) {
      if (req3.status === 200) {
          //<ExpectedCountdown>2</ExpectedCountdown>
        //Wtime=(req3.responseText).substring((req3.responseText).indexOf("<ExpectedCountdown>")+19,(req3.responseText).indexOf("</ExpectedCountdown>"));
        //Wroute=(req3.responseText).substring((req3.responseText).indexOf("<RouteNo>")+9,(req3.responseText).indexOf("</RouteNo>"));
        //Wdirection=(req3.responseText).substring((req3.responseText).indexOf("<Direction>")+11,(req3.responseText).indexOf("<Direction>")+12);
        //<RouteNo>003<Direction></Direction>
          console.log(req3.responseText);
        console.log("Route"+Wroute);
        //console.log('lat3= ' + latitude + ' lon3= ' + longitude);

        var Stemp=req3.responseText;
        var check=0;
                while ((Stemp.indexOf("<Direction>")>0)&&check<10)
          {
            check=check+1;
            Wtime=Stemp.substring(Stemp.indexOf("<ExpectedCountdown>")+19,Stemp.indexOf("</ExpectedCountdown>"));
            Wroute=Stemp.substring(Stemp.indexOf("<RouteNo>")+9,Stemp.indexOf("</RouteNo>"));
            Wdirection=Stemp.substring(Stemp.indexOf("<Direction>")+11,Stemp.indexOf("<Direction>")+12);
            Stemp=Stemp.substring(Stemp.indexOf("<Direction>")+13,Stemp.length-1);
            West.push(new BusInfo("ROUTE: "+ Wroute +" "+Wdirection,"STOP: "+ Wstop,Wtime));
          }

                Pebble.sendAppMessage({
          'DIR_KEY': default_dir,
          'S_STOP_KEY': West[current].stop,
          'S_ETA_KEY': West[current].eta,
          'S_ROUTE_KEY': West[current].route,
        });

      }
   }
  };
        req3.send(null);
          };
  ////////////////SOUTH
                if(Sstop!=="" && ((user_dir==="0" && default_dir==="SB") || user_dir==="1"))
          {
            console.log('Sstop'+Sstop+"3");
                req4.open('GET', 'http://api.translink.ca/rttiapi/v1/stops/'+Sstop+'/estimates?apikey=M5uO4PdfDGgA0b7TIKjj&count=1',true);
        req4.onload = function () {
        if (req4.readyState === 4) {
      if (req4.status === 200) {

        var Stemp=req4.responseText;
        var check=0;
        while ((Stemp.indexOf("<Direction>")>0)&&check<10)
          {
            check=check+1;
            Stime=Stemp.substring(Stemp.indexOf("<ExpectedCountdown>")+19,Stemp.indexOf("</ExpectedCountdown>"));
            Sroute=Stemp.substring(Stemp.indexOf("<RouteNo>")+9,Stemp.indexOf("</RouteNo>"));
            Sdirection=Stemp.substring(Stemp.indexOf("<Direction>")+11,Stemp.indexOf("<Direction>")+12);
            Stemp=Stemp.substring(Stemp.indexOf("<Direction>")+13,Stemp.length-1);
            South.push(new BusInfo("ROUTE: "+ Sroute +" "+Sdirection,"STOP: "+ Sstop,Stime));
          }
        //Stime=(req4.responseText).substring((req4.responseText).indexOf("<ExpectedCountdown>")+19,(req4.responseText).indexOf("</ExpectedCountdown>"));
        //Sroute=(req4.responseText).substring((req4.responseText).indexOf("<RouteNo>")+9,(req4.responseText).indexOf("</RouteNo>"));
        //Sdirection=(req4.responseText).substring((req4.responseText).indexOf("<Direction>")+11,(req4.responseText).indexOf("<Direction>")+12);

          Pebble.sendAppMessage({
          'DIR_KEY': default_dir,
          'S_STOP_KEY': South[current].stop,
          'S_ETA_KEY': South[current].eta,
          'S_ROUTE_KEY': South[current].route,
        });
      }
   }
  };
        req4.send(null);
          };
  //////////////////NORTH
                if(Nstop!=="" && ((user_dir==="0" && default_dir==="NB") ||user_dir==="2"))
          {
            console.log('Nstop'+Nstop+"4");
            req5.open('GET', 'http://api.translink.ca/rttiapi/v1/stops/'+Nstop+'/estimates?apikey=M5uO4PdfDGgA0b7TIKjj&count=1',true);
        req5.onload = function () {
        if (req5.readyState === 4) {
      if (req5.status === 200) {

        //Ntime=(req5.responseText).substring((req5.responseText).indexOf("<ExpectedCountdown>")+19,(req5.responseText).indexOf("</ExpectedCountdown>"));
        //Nroute=(req5.responseText).substring((req5.responseText).indexOf("<RouteNo>")+9,(req5.responseText).indexOf("</RouteNo>"));
        //Ndirection=(req5.responseText).substring((req5.responseText).indexOf("<Direction>")+11,(req5.responseText).indexOf("<Direction>")+12);

        var Stemp=req5.responseText;
        var check=0;
        while ((Stemp.indexOf("<Direction>")>0)&&check<10)
          {
            check=check+1;
            Ntime=Stemp.substring(Stemp.indexOf("<ExpectedCountdown>")+19,Stemp.indexOf("</ExpectedCountdown>"));
            Nroute=Stemp.substring(Stemp.indexOf("<RouteNo>")+9,Stemp.indexOf("</RouteNo>"));
            Ndirection=Stemp.substring(Stemp.indexOf("<Direction>")+11,Stemp.indexOf("<Direction>")+12);
            Stemp=Stemp.substring(Stemp.indexOf("<Direction>")+13,Stemp.length-1);
            North.push(new BusInfo("ROUTE: "+ Nroute +" "+Ndirection,"STOP: "+ Nstop,Ntime));
          }

                Pebble.sendAppMessage({
          'DIR_KEY': default_dir,
          'S_STOP_KEY': North[current].stop,
          'S_ETA_KEY': North[current].eta,
          'S_ROUTE_KEY': North[current].route,
        });
      }
   }
  };
        req5.send(null);
          };
  /////////////////////

      }
}
  };
    req.send(null);
}

function update(stop,eta,route){
  Pebble.sendAppMessage({
          'S_STOP_KEY': stop,
          'S_ETA_KEY': eta,
          'S_ROUTE_KEY': route,
            });
}

function locationSuccess(pos) {
  var coordinates = pos.coords;
  console.log('lat= ' + pos.coords.latitude + ' lon= ' + pos.coords.longitude);
  fetchTRANSIT(coordinates.latitude, coordinates.longitude);
}

function locationError(err) {
  console.warn('location error (' + err.code + '): ' + err.message);
  Pebble.sendAppMessage({
    'TRANSIT_ETA_KEY': 'Loc Unavailable',
    'TRANSIT_STOP_KEY': 'N/A'
  });
}

var locationOptions = {
  'timeout': 15000,
  'maximumAge': 60000
};

Pebble.addEventListener('ready', function (e) {
  console.log('connect!' + e.ready);
  window.navigator.geolocation.getCurrentPosition(locationSuccess, locationError,
    locationOptions);
  console.log(e.type);
});

Pebble.addEventListener('appmessage', function (e) {
    var dict = e.payload;
  var temp=JSON.stringify(dict).substring(JSON.stringify(dict).indexOf("{")+6,JSON.stringify(dict).indexOf("}"));
  if(temp!=='9')
    {
      current=0;

      user_dir=temp;
          switch (user_dir)
      {
        case '1':
South=[];
  break;
          case '2':
North=[];
  break;
          case '3':
West=[];
  break;
          case '4':
East=[];
  break;

      }
      window.navigator.geolocation.getCurrentPosition(locationSuccess, locationError,
    locationOptions);
    }
  else{
      console.log('MIDDLE BUTTON!');
    current=current+1;

  /*S=1
  N=2
  W=3
  E=4
  */

    switch (user_dir)
      {
        case '1':
    if(current>=South.length){
      current=0;
    }
  //update(South[current].stop,South[current].eta,South[current].route);
  break;
          case '2':
    if(current>=North.length){
      current=0;
    }
  //update(North[current].stop,North[current].eta,North[current].route);
  break;
          case '3':
    if(current>=West.length){
      current=0;
    }
  //update(West[current].stop,West[current].eta,West[current].route);
  break;
          case '4':
    if(current>=East.length){
      current=0;
    }
  //update(East[current].stop,East[current].eta,East[current].route);
  break;

      }
                    window.navigator.geolocation.getCurrentPosition(locationSuccess, locationError,
    locationOptions);
  }
  //testint=dict+"";
  console.log('Got message: ' + JSON.stringify(dict));
  //user_dir=dict;
  console.log(String(user_dir));
  console.log("Direction" +JSON.stringify(user_dir)+"END");
   //console.log(user_dir));
  console.log(e.payload.stop);
  console.log('message!');
    /*S=1
  N=2
  W=3
  E=4
  */

});

Pebble.addEventListener('webviewclosed', function (e) {
  console.log('webview closed');
  console.log(e.type);
  console.log(e.response);
});


text:
<?php
/**
 * @package rules
 * @author  Leigh MacDonald <leigh.macdonald@gmail.com>
 */

namespace RBAC\Exception;

class StorageError extends RBACException
{

}

redpajama_set_name: RedPajamaGithub


text:
#include <aws/securityhub/model/AwsEfsAccessPointRootDirectoryDetails.h>
#include <aws/core/utils/json/JsonSerializer.h>

#include <utility>

using namespace Aws::Utils::Json;
using namespace Aws::Utils;

namespace Aws
{
namespace SecurityHub
{
namespace Model
{

AwsEfsAccessPointRootDirectoryDetails::AwsEfsAccessPointRootDirectoryDetails() :
    m_creationInfoHasBeenSet(false),
    m_pathHasBeenSet(false)
{
}

AwsEfsAccessPointRootDirectoryDetails::AwsEfsAccessPointRootDirectoryDetails(JsonView jsonValue) :
    m_creationInfoHasBeenSet(false),
    m_pathHasBeenSet(false)
{
  *this = jsonValue;
}

AwsEfsAccessPointRootDirectoryDetails& AwsEfsAccessPointRootDirectoryDetails::operator =(JsonView jsonValue)
{
  if(jsonValue.ValueExists("CreationInfo"))
  {
    m_creationInfo = jsonValue.GetObject("CreationInfo");

    m_creationInfoHasBeenSet = true;
  }

  if(jsonValue.ValueExists("Path"))
  {
    m_path = jsonValue.GetString("Path");

    m_pathHasBeenSet = true;
  }

  return *this;
}

JsonValue AwsEfsAccessPointRootDirectoryDetails::Jsonize() const
{
  JsonValue payload;

  if(m_creationInfoHasBeenSet)
  {
   payload.WithObject("CreationInfo", m_creationInfo.Jsonize());

  }

  if(m_pathHasBeenSet)
  {
   payload.WithString("Path", m_path);

  }

  return payload;
}

} // namespace Model
} // namespace SecurityHub
} // namespace Aws


text:
define([
    'jquery',
    'underscore',
    'mage/template',
    'priceUtils',
    'priceBox',
    'jquery/ui'
], function ($, _, mageTemplate, utils) {
    'use strict';

    var globalOptions = {
        productId: null,
        priceHolderSelector: '.price-box', //data-role="priceBox"
        optionsSelector: '.product-custom-option',
        optionConfig: {},
        optionHandlers: {},
        optionTemplate: '<%- data.label %>' +
        '<% if (data.finalPrice.value) { %>' +
        ' +<%- data.finalPrice.formatted %>' +
        '<% } %>',
        controlContainer: 'dd'
    };

    $.widget('mage.priceOptions', {
        options: globalOptions,

        /**
         * Widget creating method.
         * Triggered once.
         * @private
         */
        _create: function createPriceOptions() {
            var form = this.element,
                options = $(this.options.optionsSelector, form),
                priceBox = $(this.options.priceHolderSelector, $(this.options.optionsSelector).element);

            if (priceBox.data('magePriceBox') && priceBox.priceBox('option') && priceBox.priceBox('option').priceConfig) {
                if (priceBox.priceBox('option').priceConfig.optionTemplate) {
                    this._setOption('optionTemplate', priceBox.priceBox('option').priceConfig.optionTemplate);
                }
                this._setOption('priceFormat', priceBox.priceBox('option').priceConfig.priceFormat);
            }

            this._applyOptionNodeFix(options);

            options.on('change', this._onOptionChanged.bind(this));
        },

        /**
         * Custom option change-event handler
         * @param {Event} event
         * @private
         */
        _onOptionChanged: function onOptionChanged(event) {
            var changes,
                option = $(event.target),
                handler = this.options.optionHandlers[option.data('role')];
            option.data('optionContainer', option.closest(this.options.controlContainer));

            if (handler && handler instanceof Function) {
                changes = handler(option, this.options.optionConfig, this);
            } else {
                changes = defaultGetOptionValue(option, this.options.optionConfig);
            }
            $(this.options.priceHolderSelector).trigger('updatePrice', changes);
        },

        /**
         * Helper to fix issue with option nodes:
         *  - you can't place any html in option ->
         *    so you can't style it via CSS
         * @param {jQuery} options
         * @private
         */
        _applyOptionNodeFix: function applyOptionNodeFix(options) {
            var config = this.options,
                format = config.priceFormat,
                template = config.optionTemplate;
            template = mageTemplate(template);
            options.filter('select').each(function (index, element) {
                var $element = $(element),
                    optionId = utils.findOptionId($element),
                    optionName = $element.prop('name'),
                    optionType = $element.prop('type');
                var  optionConfig = config.optionConfig && config.optionConfig[optionId];

                $element.find('option').each(function (idx, option) {
                    var $option,
                        optionValue,
                        toTemplate,
                        prices;

                    $option = $(option);
                    optionValue = $option.val();

                    if (!optionValue && optionValue !== 0) {
                        return;
                    }

                    toTemplate = {
                        data: {
                            label: optionConfig[optionValue] && optionConfig[optionValue].name
                        }
                    };
                    prices = optionConfig[optionValue] ? optionConfig[optionValue].prices : null;

                    if (prices) {
                        _.each(prices, function (price, type) {
                            var value = +(price.amount);
                            value += _.reduce(price.adjustments, function (sum, x) {
                                return sum + x;
                            }, 0);
                            toTemplate.data[type] = {
                                value: value,
                                formatted: utils.formatPrice(value, format)
                            };
                        });

                        $option.text(template(toTemplate));
                    }
                });
            });
        },

        /**
         * Custom behavior on getting options:
         * now widget able to deep merge accepted configuration with instance options.
         * @param  {Object}  options
         * @return {$.Widget}
         * @private
         */
        _setOptions: function setOptions(options) {
            $.extend(true, this.options, options);
            this._super(options);

            return this;
        }
    });

    return $.mage.priceOptions;

    /**
     * Custom option preprocessor
     * @param  {jQuery} element
     * @param  {Object} optionsConfig - part of config
     * @return {Object}
     */
    function defaultGetOptionValue(element, optionsConfig) {
        var changes = {},
            optionValue = element.val(),
            optionId = utils.findOptionId(element[0]),
            optionName = element.prop('name'),
            optionType = element.prop('type'),
            optionConfig = optionsConfig[optionId],
            optionHash = optionName;

        switch (optionType) {
            case 'text':

            case 'textarea':
                changes[optionHash] = optionValue ? optionConfig.prices : {};
                break;

            case 'radio':

            case 'select-one':
                changes[optionHash] = optionConfig[optionValue] && optionConfig[optionValue].prices || {};
                break;

            case 'select-multiple':
                _.each(optionConfig, function (row, optionValueCode) {
                    optionHash = optionName + '##' + optionValueCode;
                    changes[optionHash] = _.contains(optionValue, optionValueCode) ? row.prices : {};
                });
                break;

            case 'checkbox':
                optionHash = optionName + '##' + optionValue;
                changes[optionHash] = element.is(':checked') ? optionConfig[optionValue].prices : {};
                break;

            case 'file':
                // Checking for 'disable' property equal to checking DOMNode with id*="change-"
                changes[optionHash] = optionValue || element.prop('disabled') ? optionConfig.prices : {};
                break;
        }

        return changes;
    }
});


text:
package org.kuali.kfs.fp.document.web.struts;

/**
 * struts action class for YearEndBudgetAdjustmentAction the only functional difference between the YearEnd version
 * and the non-yearEnd version of a document is the glpe's generation.
 *
 * @see org.kuali.kfs.fp.document.web.struts.BudgetAdjustmentAction
 */

public class YearEndBudgetAdjustmentAction extends BudgetAdjustmentAction {
    // empty do not change. see above.
}


text:
using Sonosthesia;
using UnityEngine;

public class PathFollower : MonoBehaviour
{
    [SerializeField] private Path _path;
    [SerializeField] private float _speed = 5;
    [SerializeField] private bool _local;
    [SerializeField] private bool _normalized;

    public float Speed
    {
        get => _speed;
        set => _speed = value;
    }

    private float _distance;

    void Update()
    {
        _distance += _speed * Time.deltaTime;
        if (_local)
        {
            transform.localPosition = _path.Position(_distance, _normalized);
            transform.localRotation = _path.Rotation(_distance, _normalized);
        }
        else
        {
            transform.position = _path.Position(_distance, _normalized);
            transform.rotation = _path.Rotation(_distance, _normalized);
        }
    }
}


text:
title: Absurdy Pracy
author: Gutek
layout: post
permalink: /2010/01/14/absurdy-pracy/
categories:
  - priv
tags:
  - refleksje
---
Już od jakiegoś czasu zbieram się z tym postem. Ogólnie chciałbym by służył on jako *księga absurdów*, to znaczy śmiesznych, głupich a czasem tragicznych aspektów pracy programisty. Jeżeli komentarzy będzie sporo stworze osobą stronę poświęcę temu postowi :)

Wstępnie nie chcę być pierwszym rozpoczynającym ten ciąg (który mam nadzieję, że się pojawi), ale obiecuję jeżeli pojawią się komentarze to mam kilka naprawdę absurdalnych historii, którymi się z chęcią podzielę :)


text:
Router.configure({
    //standard layout all views use
    layoutTemplate: 'layout',
    //the page shown when some goes to a route we haven't defined
    notFoundTemplate: '404',
    //You can also set your iron-router-progress bar settings here
    progressSpinner: false
});

Router.route('/', {
    //name for a route which we can use in templates
    name: 'home',
    //which template we want to use for this route
    template: 'home',
    //meteorhacks:fast-render setting to let a user render the html for a page without there already being a ddp connection
    fastRender: true
});


text:
module Data.VCache.Seq
    ( Seq
    , empty
    , singleton
    , length
    , null
    , toList
    ) where

import Prelude hiding (length, null)
import qualified Data.Foldable as F
import Data.VCache.Seq.Type
import Database.VCache

-- | Model an empty sequence in a given VSpace
empty :: (VCacheable a) => VSpace -> Seq a
empty vc = Seq vc Empty

-- | Create a singleton sequence in a given VSpace
singleton :: (VCacheable a) => VSpace -> a -> Seq a
singleton vc = Seq vc . Single . Elem

-- | Test whether a sequence is empty.
null :: Seq a -> Bool
null = null' . q_data where
    null' Empty = True
    null' _ = False

-- | O(1) return the length of the sequence.
length :: Seq a -> Int
length = sizeOf . q_data

toList :: Seq a -> [a]
toList = F.toList


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Novon 12:327. 2002

#### Original name
Lesquerella pruinosa Greene

### Remarks
null


text:
<assembly>
	<id>package</id>
	<formats>
		<format>tar.gz</format>
	</formats>
	<includeBaseDirectory>true</includeBaseDirectory>
	<fileSets>
		<fileSet>
			<directory>src/main/resources/mp</directory>
			<outputDirectory>${file.separator}mp</outputDirectory>
		</fileSet>
		<fileSet>
			<directory>src/main/resources/bin</directory>
			<outputDirectory>${file.separator}bin</outputDirectory>
		</fileSet>
		<fileSet>
			<directory>src/main/resources/static</directory>
			<outputDirectory>${file.separator}static</outputDirectory>
		</fileSet>
		<fileSet>
			<directory>src/main/resources/templates</directory>
			<outputDirectory>${file.separator}templates</outputDirectory>
		</fileSet>
		<fileSet>
			<directory>src/main/resources</directory>
			<includes>
				<include>application.yml</include>
			</includes>
			<outputDirectory>${file.separator}config</outputDirectory>
		</fileSet>
	</fileSets>

	<files>
		<file>
			<source>src/main/resources/banner.txt</source>
			<outputDirectory>${file.separator}</outputDirectory>
		</file>
		<file>
			<source>${project.build.directory}${file.separator}${build.finalName}.jar
			</source>
			<outputDirectory>${file.separator}</outputDirectory>
			<destName>xgbbbs.jar</destName>
		</file>
	</files>

	<!--<dependencySets> <dependencySet> <outputDirectory>lib</outputDirectory>
		<scope>runtime</scope> <excludes> <exclude>${groupId}:${artifactId}</exclude>
		</excludes> </dependencySet> </dependencySets> -->
</assembly>


text:
import uuid

from oslo_db import exception as db_exception
from webob import exc

from murano.db.catalog import api
from murano.tests.unit import base
from murano.tests.unit import utils

class CatalogDBTestCase(base.MuranoWithDBTestCase):

    def setUp(self):
        super(CatalogDBTestCase, self).setUp()
        self.tenant_id = str(uuid.uuid4())
        self.tenant_id_2 = str(uuid.uuid4())
        self.context = utils.dummy_context(tenant_id=self.tenant_id)
        self.context_2 = utils.dummy_context(tenant_id=self.tenant_id_2)

        self.context_admin = utils.dummy_context(tenant_id=self.tenant_id)
        self.context_admin.is_admin = True

    def _create_categories(self):
        api.category_add('cat1')
        api.category_add('cat2')

    def _stub_package(self, **kwargs):
        base = {
            'archive': b"archive blob here",
            'fully_qualified_name': 'com.example.package',
            'type': 'class',
            'author': 'OpenStack',
            'name': 'package',
            'enabled': True,
            'description': 'some text',
            'is_public': False,
            'tags': ['tag1', 'tag2'],
            'logo': b"logo blob here",
            'ui_definition': '{}',
        }
        base.update(**kwargs)
        return base

    def get_change(self, op, path, value):
        return {
            'op': op,
            'path': path,
            'value': value
        }

    def test_order_by(self):
        pkgs = []
        for dummy in range(10):
            package = api.package_upload(self._stub_package(
                name=str(uuid.uuid4()),
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
            pkgs.append(package)

        pkg_created = [pkg.id for pkg in sorted(
            pkgs, key=lambda _pkg: _pkg.created)]
        pkg_name = [pkg.id for pkg in sorted(
            pkgs, key=lambda _pkg: _pkg.name)]
        pkg_fqn = [pkg.id for pkg in sorted(
            pkgs, key=lambda _pkg: _pkg.fully_qualified_name)]

        for order, pkg_ids in zip(['created', 'name', 'fqn'],
                                  [pkg_created, pkg_name, pkg_fqn]):
            res = api.package_search(
                {'order_by': [order]}, self.context, limit=10)
            self.assertEqual(10, len(res))
            self.assertEqual(pkg_ids, [r.id for r in res])

    def test_order_by_compound(self):
        pkgs_a, pkgs_z = [], []
        for _ in range(5):
            package = api.package_upload(self._stub_package(
                name='z',
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
            pkgs_z.append(package)
        for _ in range(5):
            package = api.package_upload(self._stub_package(
                name='a',
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
            pkgs_a.append(package)

        # sort pkg ids by pkg created
        pkg_a_id = [pkg.id for pkg in sorted(
            pkgs_a, key=lambda _pkg: _pkg.created)]
        pkg_z_id = [pkg.id for pkg in sorted(
            pkgs_z, key=lambda _pkg: _pkg.created)]

        res = api.package_search(
            {'order_by': ['name', 'created']}, self.context, limit=10)
        self.assertEqual(10, len(res))
        self.assertEqual(pkg_a_id + pkg_z_id, [r.id for r in res])

    def test_pagination_backwards(self):
        """Tests backwards pagination

        Creates 10 packages with unique names and iterates backwards,
        checking that package order is correct.
        """
        pkgs = []
        for dummy in range(10):
            package = api.package_upload(self._stub_package(
                name=str(uuid.uuid4()),
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
            pkgs.append(package)

        # sort pkg ids by pkg name
        pkg_ids = [pkg.id for pkg in sorted(pkgs, key=lambda _pkg: _pkg.name)]

        res = api.package_search({}, self.context, limit=10)
        self.assertEqual(10, len(res))
        self.assertEqual(pkg_ids, [r.id for r in res])
        marker = res[-1].id

        res = api.package_search(
            {'marker': marker,
             'sort_dir': 'desc'}, self.context, limit=5)
        self.assertEqual(5, len(res))
        self.assertEqual(list(reversed(pkg_ids[4:9])),
                         [r.id for r in res])
        marker = res[-1].id

        res = api.package_search(
            {'marker': marker,
             'sort_dir': 'desc'}, self.context, limit=5)
        self.assertEqual(4, len(res))
        self.assertEqual(list(reversed(pkg_ids[0:4])),
                         [r.id for r in res])
        marker = res[-1].id

        res = api.package_search(
            {'marker': marker,
             'sort_dir': 'desc'}, self.context, limit=5)
        self.assertEqual(0, len(res))

    def test_pagination(self):
        """Tests that package order is correct

        Creates 10 packages with unique names and iterates through them,
        checking that package order is correct.
        """

        pkgs = []
        for dummy in range(10):
            package = api.package_upload(self._stub_package(
                name=str(uuid.uuid4()),
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
            pkgs.append(package)

        # sort pkg ids by pkg name
        pkg_ids = [pkg.id for pkg in sorted(pkgs, key=lambda _pkg: _pkg.name)]

        res = api.package_search({}, self.context, limit=4)
        self.assertEqual(4, len(res))
        self.assertEqual(pkg_ids[0:4], [r.id for r in res])
        marker = res[-1].id

        res = api.package_search({'marker': marker}, self.context, limit=4)
        self.assertEqual(4, len(res))
        self.assertEqual(pkg_ids[4:8], [r.id for r in res])
        marker = res[-1].id

        res = api.package_search({'marker': marker}, self.context, limit=4)
        self.assertEqual(2, len(res))
        self.assertEqual(pkg_ids[8:10], [r.id for r in res])
        marker = res[-1].id

        res = api.package_search({'marker': marker}, self.context, limit=4)
        self.assertEqual(0, len(res))

    def test_pagination_loops_through_names(self):
        """Tests that packages with same display name are not skipped

        Creates 10 packages with the same display name and iterates
        through them, checking that package are not skipped.
        """

        for dummy in range(10):
            api.package_upload(
                self._stub_package(name='test',
                                   fully_qualified_name=str(uuid.uuid4())),
                self.tenant_id)
        res = api.package_search({}, self.context, limit=4)
        self.assertEqual(4, len(res))
        marker = res[-1].id

        res = api.package_search({'marker': marker}, self.context, limit=4)
        self.assertEqual(4, len(res))
        marker = res[-1].id

        res = api.package_search({'marker': marker}, self.context, limit=4)
        self.assertEqual(2, len(res))
        marker = res[-1].id

        res = api.package_search({'marker': marker}, self.context, limit=4)
        self.assertEqual(0, len(res))

    def test_package_search_search_order(self):
        pkg1 = api.package_upload(
            self._stub_package(
                fully_qualified_name=str(uuid.uuid4()),
                name='mysql',
                description='awcloud'),
            self.tenant_id)
        pkg2 = api.package_upload(
            self._stub_package(
                fully_qualified_name=str(uuid.uuid4()),
                name='awcloud',
                description='mysql'),
            self.tenant_id)
        api.package_upload(
            self._stub_package(
                tags=[],
                fully_qualified_name=str(uuid.uuid4())),
            self.tenant_id)

        res = api.package_search(
            {'search': 'mysql'}, self.context)
        self.assertEqual(2, len(res))
        self.assertEqual(pkg1.name, res[0].name)
        self.assertEqual(pkg2.description, res[1].description)

    def test_package_search_search(self):
        pkg1 = api.package_upload(
            self._stub_package(
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        pkg2 = api.package_upload(
            self._stub_package(
                tags=[],
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        res = api.package_search(
            {'search': 'tag1'}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search(
            {'search': pkg1.fully_qualified_name}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search(
            {'search': pkg2.fully_qualified_name}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search(
            {'search': 'not_a_valid_uuid'}, self.context)
        self.assertEqual(0, len(res))

        res = api.package_search(
            {'search': 'some text'}, self.context)
        self.assertEqual(2, len(res))

    def test_package_search_tags(self):
        api.package_upload(
            self._stub_package(
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(
            self._stub_package(
                tags=[],
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        res = api.package_search(
            {'tag': ['tag1']}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search(
            {'tag': ['tag2']}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search(
            {'tag': ['tag3']}, self.context)
        self.assertEqual(0, len(res))

    def test_package_search_type(self):
        api.package_upload(
            self._stub_package(
                type="Application",
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(
            self._stub_package(
                type="Library",
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        res = api.package_search(
            {'type': 'Library'}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search(
            {'type': 'Application'}, self.context)
        self.assertEqual(1, len(res))

    def test_package_search_disabled(self):
        api.package_upload(
            self._stub_package(
                is_public=True,
                enabled=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(
            self._stub_package(
                is_public=True,
                enabled=False,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        res = api.package_search(
            {'include_disabled': 'false'}, self.context)
        self.assertEqual(1, len(res))
        res = api.package_search(
            {'include_disabled': 'true'}, self.context)
        self.assertEqual(2, len(res))

    def test_package_search_owned(self):
        api.package_upload(
            self._stub_package(
                is_public=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(
            self._stub_package(
                is_public=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2)

        res = api.package_search({'owned': 'true'}, self.context_admin)
        self.assertEqual(1, len(res))
        res = api.package_search({'owned': 'false'}, self.context_admin)
        self.assertEqual(2, len(res))

    def test_package_search_no_filters_catalog(self):
        res = api.package_search({}, self.context, catalog=True)
        self.assertEqual(0, len(res))

        api.package_upload(
            self._stub_package(
                is_public=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(
            self._stub_package(
                is_public=False,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        api.package_upload(
            self._stub_package(
                is_public=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2)
        api.package_upload(
            self._stub_package(
                is_public=False,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2)

        # catalog=True should show public + mine
        res = api.package_search({}, self.context, catalog=True)
        self.assertEqual(3, len(res))

        res = api.package_search({}, self.context_admin, catalog=True)
        self.assertEqual(3, len(res))

    def test_package_search_no_filters(self):
        res = api.package_search({}, self.context)
        self.assertEqual(0, len(res))

        api.package_upload(
            self._stub_package(
                is_public=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
        api.package_upload(
            self._stub_package(
                is_public=False,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id)

        api.package_upload(
            self._stub_package(
                is_public=True,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2)
        api.package_upload(
            self._stub_package(
                is_public=False,
                fully_qualified_name=str(uuid.uuid4())), self.tenant_id_2)

        # I can only edit mine pkgs
        res = api.package_search({}, self.context)
        self.assertEqual(2, len(res))
        for pkg in res:
            self.assertEqual(self.tenant_id, pkg.owner_id)

        # Admin can see everything
        res = api.package_search({}, self.context_admin)
        self.assertEqual(4, len(res))

    def test_list_empty_categories(self):
        res = api.category_get_names()
        self.assertEqual(0, len(res))

    def test_add_list_categories(self):
        self._create_categories()

        res = api.categories_list()
        self.assertEqual(2, len(res))

        for cat in res:
            self.assertIsNotNone(cat.id)
            self.assertTrue(cat.name.startswith('cat'))

    def test_package_upload(self):
        self._create_categories()
        values = self._stub_package()

        package = api.package_upload(values, self.tenant_id)

        self.assertIsNotNone(package.id)
        for k in values.keys():
            self.assertEqual(values[k], package[k])

    def test_package_fqn_is_unique(self):
        self._create_categories()
        values = self._stub_package()

        api.package_upload(values, self.tenant_id)
        self.assertRaises(db_exception.DBDuplicateEntry,
                          api.package_upload, values, self.tenant_id)

    def test_package_delete(self):
        values = self._stub_package()
        package = api.package_upload(values, self.tenant_id)

        api.package_delete(package.id, self.context)

        self.assertRaises(exc.HTTPNotFound,
                          api.package_get, package.id, self.context)

    def test_package_upload_to_different_tenants_with_same_fqn(self):
        values = self._stub_package()

        api.package_upload(values, self.tenant_id)
        api.package_upload(values, self.tenant_id_2)

    def test_package_upload_public_public_fqn_violation(self):
        values = self._stub_package(is_public=True)
        api.package_upload(values, self.tenant_id)
        values = self._stub_package(is_public=True)
        self.assertRaises(exc.HTTPConflict, api.package_upload,
                          values, self.tenant_id_2)

    def test_package_upload_public_private_no_fqn_violation(self):
        values = self._stub_package(is_public=True)
        api.package_upload(values, self.tenant_id)
        values = self._stub_package(is_public=False)
        api.package_upload(values, self.tenant_id_2)

    def test_package_upload_private_public_no_fqn_violation(self):
        values = self._stub_package()
        api.package_upload(values, self.tenant_id)
        values = self._stub_package(is_public=True)
        api.package_upload(values, self.tenant_id_2)

    def test_class_name_is_unique(self):
        value = self._stub_package(class_definitions=('foo', 'bar'))
        api.package_upload(value, self.tenant_id)
        value = self._stub_package(class_definitions=('bar', 'baz'),
                                   fully_qualified_name='com.example.package2')
        self.assertRaises(exc.HTTPConflict, api.package_upload, value,
                          self.tenant_id)

    def test_class_name_uniqueness_not_enforced_in_different_tenants(self):
        value = self._stub_package(class_definitions=('foo', 'bar'))
        api.package_upload(value, self.tenant_id)
        value = self._stub_package(class_definitions=('foo', 'bar'),
                                   fully_qualified_name='com.example.package2')
        api.package_upload(value, self.tenant_id_2)

    def test_class_name_public_public_violation(self):
        value = self._stub_package(class_definitions=('foo', 'bar'),
                                   is_public=True)
        api.package_upload(value, self.tenant_id)
        value = self._stub_package(class_definitions=('foo', 'bar'),
                                   is_public=True,
                                   fully_qualified_name='com.example.package2')
        self.assertRaises(exc.HTTPConflict, api.package_upload,
                          value, self.tenant_id_2)

    def test_class_name_public_private_no_violation(self):
        value = self._stub_package(class_definitions=('foo', 'bar'),
                                   is_public=True)
        api.package_upload(value, self.tenant_id)
        value = self._stub_package(class_definitions=('foo', 'bar'),
                                   is_public=False,
                                   fully_qualified_name='com.example.package2')
        api.package_upload(value, self.tenant_id_2)

    def test_class_name_private_public_no_violation(self):
        value = self._stub_package(class_definitions=('foo', 'bar'),
                                   is_public=False)
        api.package_upload(value, self.tenant_id)
        value = self._stub_package(class_definitions=('foo', 'bar'),
                                   is_public=True,
                                   fully_qualified_name='com.example.package2')
        api.package_upload(value, self.tenant_id_2)

    def test_package_make_public(self):
        id = api.package_upload(self._stub_package(), self.tenant_id).id
        patch = self.get_change('replace', ['is_public'], True)
        api.package_update(id, [patch], self.context)
        package = api.package_get(id, self.context)
        self.assertTrue(package.is_public)

    def test_package_update_public_public_fqn_violation(self):
        id1 = api.package_upload(self._stub_package(), self.tenant_id).id
        id2 = api.package_upload(self._stub_package(), self.tenant_id_2).id
        patch = self.get_change('replace', ['is_public'], True)
        api.package_update(id1, [patch], self.context)
        self.assertRaises(exc.HTTPConflict, api.package_update,
                          id2, [patch], self.context_2)

    def test_package_update_public_public_class_name_violation(self):
        id1 = api.package_upload(self._stub_package(
            class_definitions=('foo', 'bar')), self.tenant_id).id
        id2 = api.package_upload(self._stub_package(
            class_definitions=('foo', 'bar'),
            fully_qualified_name='com.example.package2'), self.tenant_id_2).id
        patch = self.get_change('replace', ['is_public'], True)
        api.package_update(id1, [patch], self.context)
        self.assertRaises(exc.HTTPConflict, api.package_update,
                          id2, [patch], self.context_2)

    def test_category_paginate(self):
        """Paginate through a list of categories using limit and marker"""

        category_names = ['cat1', 'cat2', 'cat3', 'cat4', 'cat5']
        categories = []
        for name in category_names:
            categories.append(api.category_add(name))
        uuids = [c.id for c in categories]

        page = api.categories_list(limit=2)

        self.assertEqual(category_names[:2], [c.name for c in page])

        last = page[-1].id
        page = api.categories_list(limit=3, marker=last)
        self.assertEqual(category_names[2:5], [c.name for c in page])

        page = api.categories_list(marker=uuids[-1])
        self.assertEqual([], page)

        category_names.reverse()
        page = api.categories_list({'sort_dir': 'desc'})
        self.assertEqual(category_names, [c.name for c in page])

    def test_category_get_delete_error(self):
        category_id = 12
        self.assertRaises(exc.HTTPNotFound, api.category_get, category_id)
        self.assertRaises(exc.HTTPNotFound, api.category_delete, category_id)

    def test_get_categories_error(self):
        category_names = ['cat1', 'cat2', 'cat3', 'cat4', 'cat5']
        cat_session = None
        self.assertRaises(exc.HTTPBadRequest, api._get_categories,
                          category_names, cat_session)

    def test_authorize_package_delete_error(self):
        values = self._stub_package()
        package = api.package_upload(values, self.tenant_id)
        self.assertRaises(exc.HTTPForbidden, api._authorize_package, package,
                          self.context_2)
        self.assertRaises(exc.HTTPForbidden,
                          api.package_delete, package.id, self.context_2)
        id = package.id
        patch = self.get_change('replace', ['is_public'], False)
        api.package_update(id, [patch], self.context)
        self.assertRaises(exc.HTTPForbidden, api._authorize_package, package,
                          self.context_2, allow_public=True)


text:
paperclip-examples
==================

Rails app showing how to use paperclip


text:
package com.onplan.adviser;

import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;

import java.util.Collection;
import java.util.Map;

/**
 * Contains information about a strategy.
 */
public final class StrategyInfo extends TemplateInfo {
  private String id;
  private Map<String, String> executionParameters;
  private Collection<String> registeredInstruments;
  private StrategyStatisticsSnapshot strategyStatisticsSnapshot;

  public String getId() {
    return id;
  }

  public Map<String, String> getExecutionParameters() {
    return executionParameters;
  }

  public Collection<String> getRegisteredInstruments() {
    return registeredInstruments;
  }

  public void setId(String id) {
    this.id = id;
  }

  public void setExecutionParameters(Map<String, String> executionParameters) {
    this.executionParameters = executionParameters;
  }

  public void setRegisteredInstruments(Collection<String> registeredInstruments) {
    this.registeredInstruments = registeredInstruments;
  }

  public StrategyStatisticsSnapshot getStrategyStatisticsSnapshot() {
    return strategyStatisticsSnapshot;
  }

  public void setStrategyStatisticsSnapshot(StrategyStatisticsSnapshot strategyStatisticsSnapshot) {
    this.strategyStatisticsSnapshot = strategyStatisticsSnapshot;
  }

  public StrategyInfo() {
    // Intentionally empty.
  }

  public StrategyInfo(String displayName, String className, Iterable<String> availableParameters,
      String id, Map<String, String> executionParameters, Collection<String> registeredInstruments,
      StrategyStatisticsSnapshot strategyStatisticsSnapshot) {
    super(displayName, className, availableParameters);
    this.id = id;
    this.executionParameters = executionParameters;
    this.registeredInstruments = registeredInstruments;
    this.strategyStatisticsSnapshot = strategyStatisticsSnapshot;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    StrategyInfo strategyInfo = (StrategyInfo) o;
    return Objects.equal(this.id, strategyInfo.id) &&
        Objects.equal(this.displayName, strategyInfo.displayName) &&
        Objects.equal(this.className, strategyInfo.className) &&
        Objects.equal(this.availableParameters, strategyInfo.availableParameters) &&
        Objects.equal(this.executionParameters, strategyInfo.executionParameters) &&
        Objects.equal(this.registeredInstruments, strategyInfo.registeredInstruments) &&
        Objects.equal(this.strategyStatisticsSnapshot, strategyInfo.strategyStatisticsSnapshot);
  }

  @Override
  public int hashCode() {
    return Objects.hashCode(id, displayName, className, availableParameters, executionParameters,
        registeredInstruments, strategyStatisticsSnapshot);
  }

  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this)
        .add("id", id)
        .add("displayName", displayName)
        .add("className", className)
        .add("availableParameters", availableParameters)
        .add("executionParameters", executionParameters)
        .add("registeredInstruments", registeredInstruments)
        .add("strategyStatisticsSnapshot", strategyStatisticsSnapshot)
        .toString();
  }
}


text:
<?php

/**
 * see
 * WRONG URL -> http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Im.Field.html
 *
 */
class osapiIm extends osapiListField {
}


text:
namespace Solaire {

    typedef ArrayList<GenericValue> ArrayType;
    typedef ListMap<CString, GenericValue> ObjectType;

	// GenericValue

    GenericValue::GenericValue() throw() :
        mAllocator(&getDefaultAllocator()),
        mType(NULL_T)
    {}

    GenericValue::GenericValue(const ValueType aType) throw() :
        mAllocator(&getDefaultAllocator()),
        mType(aType)
    {
        switch(mType){
        case CHAR_T:
            mChar = ' ';
            break;
        case BOOL_T:
            mBool = false;
            break;
        case UNSIGNED_T:
            mUnsigned = 0;
            break;
        case SIGNED_T:
            mSigned = 0;
            break;
        case DOUBLE_T:
            mDouble = 0.0;
            break;
        case STRING_T:
            mString = new(mAllocator->allocate(sizeof(CString))) CString();
            break;
        case ARRAY_T:
            mArray = new(mAllocator->allocate(sizeof(ArrayType))) ArrayType();
            break;
        case OBJECT_T:
            mObject = new(mAllocator->allocate(sizeof(ObjectType))) ObjectType();
            break;
        default:
            break;
        }
    }

    GenericValue::GenericValue(const GenericValue& aOther) throw() :
        mAllocator(aOther.mAllocator),
        mType(aOther.mType)
    {
        switch(mType){
        case CHAR_T:
        case BOOL_T:
            mChar = aOther.mChar;
            break;
        case UNSIGNED_T:
        case SIGNED_T:
            mUnsigned = aOther.mUnsigned;
            break;
        case DOUBLE_T:
            mDouble = aOther.mDouble;
            break;
        case STRING_T:
            mString = new(mAllocator->allocate(sizeof(CString))) CString(*aOther.mString);
            break;
        case ARRAY_T:
            mArray = new(mAllocator->allocate(sizeof(ArrayType))) ArrayType(*aOther.mArray);
            break;
        case OBJECT_T:
            mObject = new(mAllocator->allocate(sizeof(ObjectType))) ObjectType(*aOther.mObject);
            break;
        default:
            break;
        }
    }

    GenericValue::GenericValue(GenericValue&& aOther) throw() :
        mAllocator(aOther.mAllocator),
        mType(aOther.mType)
    {
        switch(mType){
        case CHAR_T:
        case BOOL_T:
            mChar = aOther.mChar;
            break;
        case UNSIGNED_T:
        case SIGNED_T:
            mUnsigned = aOther.mUnsigned;
            break;
        case DOUBLE_T:
            mDouble = aOther.mDouble;
            break;
        case STRING_T:
        case ARRAY_T:
        case OBJECT_T:
            mString = aOther.mString;
            break;
        default:
            break;
        }

        aOther.mType = NULL_T;
    }

    GenericValue::GenericValue(const char aValue)throw() :
        mChar(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(CHAR_T)
    {}

    GenericValue::GenericValue(const bool aValue) throw() :
        mBool(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(BOOL_T)
    {}

    GenericValue::GenericValue(const uint8_t aValue) throw() :
        mUnsigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(UNSIGNED_T)
    {}

    GenericValue::GenericValue(const uint16_t aValue) throw() :
        mUnsigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(UNSIGNED_T)
    {}

    GenericValue::GenericValue(const uint32_t aValue) throw() :
        mUnsigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(UNSIGNED_T)
    {}

    GenericValue::GenericValue(const uint64_t aValue) throw() :
        mUnsigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(UNSIGNED_T)
    {}

    GenericValue::GenericValue(const int8_t aValue) throw() :
        mSigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(SIGNED_T)
    {}

    GenericValue::GenericValue(const int16_t aValue) throw() :
        mSigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(SIGNED_T)
    {}

    GenericValue::GenericValue(const int32_t aValue) throw() :
        mSigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(SIGNED_T)
    {}

    GenericValue::GenericValue(const int64_t aValue) throw() :
        mSigned(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(SIGNED_T)
    {}

    GenericValue::GenericValue(const double aValue) throw() :
        mDouble(aValue),
        mAllocator(&getDefaultAllocator()),
        mType(DOUBLE_T)
    {}

    GenericValue::GenericValue(const StringConstant<char>& aValue) throw() :
        mString(nullptr),
        mAllocator(&aValue.getAllocator()),
        mType(NULL_T)
    {
        setString() = aValue;
    }

        // C++ operators

    GenericValue& GenericValue::operator=(const GenericValue& aOther) throw() {
        setNull();
        mType = aOther.mType;
        mAllocator = aOther.mAllocator;
        switch(mType){
        case CHAR_T:
        case BOOL_T:
            mChar = aOther.mChar;
            break;
        case UNSIGNED_T:
        case SIGNED_T:
            mUnsigned = aOther.mUnsigned;
            break;
        case DOUBLE_T:
            mDouble = aOther.mDouble;
            break;
        case STRING_T:
            mString = new(mAllocator->allocate(sizeof(CString))) CString(*aOther.mString);
            break;
        case ARRAY_T:
            mArray = new(mAllocator->allocate(sizeof(ArrayType))) ArrayType(*aOther.mArray);
            break;
        case OBJECT_T:
            mObject = new(mAllocator->allocate(sizeof(ObjectType))) ObjectType(*aOther.mObject);
            break;
        default:
            break;
        }
        return *this;
    }

    GenericValue& GenericValue::operator=(GenericValue&& aOther) throw() {
        setNull();
        mType = aOther.mType;
        mAllocator = aOther.mAllocator;
        switch(mType){
        case CHAR_T:
        case BOOL_T:
            mChar = aOther.mChar;
            break;
        case UNSIGNED_T:
        case SIGNED_T:
            mUnsigned = aOther.mUnsigned;
            break;
        case DOUBLE_T:
            mDouble = aOther.mDouble;
            break;
        case STRING_T:
        case ARRAY_T:
        case OBJECT_T:
            mString = aOther.mString;
            break;
        default:
            break;
        }
        aOther.mType = NULL_T;
        return *this;
    }

    // get

    char GenericValue::getChar() const throw() {
        switch(mType){
        case CHAR_T:
            return mChar;
        case BOOL_T:
            return static_cast<char>(mBool);
        case UNSIGNED_T:
            return static_cast<char>(mUnsigned);
        case SIGNED_T:
            return static_cast<char>(mSigned);
        case DOUBLE_T:
            return static_cast<char>(mDouble);
        case STRING_T:
            return (*mString)[0];
        default:
            return 0;
        }
    }

    bool GenericValue::getBool() const throw() {
        switch(mType){
        case CHAR_T:
            return static_cast<bool>(mChar);
        case BOOL_T:
            return mBool;
        case UNSIGNED_T:
            return static_cast<bool>(mUnsigned);
        case SIGNED_T:
            return static_cast<bool>(mSigned);
        case DOUBLE_T:
            return static_cast<bool>(mDouble);
        case STRING_T:
            //! \todo Cast from string
        default:
            return false;
        }
    }

    uint64_t GenericValue::getUnsigned() const throw() {
        switch(mType){
        case CHAR_T:
            return static_cast<uint64_t>(mChar);
        case BOOL_T:
            return static_cast<uint64_t>(mBool);
        case UNSIGNED_T:
            return mUnsigned;
        case SIGNED_T:
            return static_cast<uint64_t>(mSigned);
        case DOUBLE_T:
            return static_cast<uint64_t>(mDouble);
        case STRING_T:
            return static_cast<uint64_t>(*mString);
        default:
            return 0;
        }
    }

    int64_t GenericValue::getSigned() const throw() {
        switch(mType){
        case CHAR_T:
            return static_cast<int64_t>(mChar);
        case BOOL_T:
            return static_cast<int64_t>(mBool);
        case UNSIGNED_T:
            return static_cast<int64_t>(mUnsigned);
        case SIGNED_T:
            return mSigned;
        case DOUBLE_T:
            return static_cast<int64_t>(mDouble);
        case STRING_T:
            return static_cast<int64_t>(*mString);
        default:
            return 0;
        }
    }

    double GenericValue::getDouble() const throw() {
        switch(mType){
        case CHAR_T:
            return static_cast<double>(mChar);
        case BOOL_T:
            return static_cast<double>(mBool);
        case UNSIGNED_T:
            return static_cast<double>(mUnsigned);
        case SIGNED_T:
            return static_cast<double>(mSigned);
        case DOUBLE_T:
            return mDouble;
        case STRING_T:
            //! \todo Cast from string
            return static_cast<int64_t>(*mString);
        default:
            return 0.0;
        }
    }

    const String<char>& GenericValue::getString() const throw() {
        return *mString;
    }

    String<char>& GenericValue::getString() throw() {
        return *mString;
    }

    const GenericArray& GenericValue::getArray() const throw() {
        return *mArray;
    }

    GenericArray& GenericValue::getArray() throw() {
        return *mArray;
    }

    const GenericObject& GenericValue::getObject() const throw() {
        return *mObject;
    }

    GenericObject& GenericValue::getObject() throw() {
        return *mObject;
    }

    void GenericValue::setNull() throw() {
        switch(mType){
        case STRING_T:
            mString->~String();
            mAllocator->deallocate(mString);
            break;
        case ARRAY_T:
            mArray->~GenericArray();
            mAllocator->deallocate(mArray);
            break;
        case OBJECT_T:
            mObject->~GenericObject();
            mAllocator->deallocate(mObject);
            break;
        }
        mType = NULL_T;
    }

    char& GenericValue::setChar(const char aValue) throw() {
        setNull();
        mType = CHAR_T;
        return mChar = aValue;
    }

    bool& GenericValue::setBool(const bool aValue) throw() {
        setNull();
        mType = BOOL_T;
        return mBool = aValue;
    }

    uint64_t& GenericValue::setUnsigned(const uint64_t aValue) throw() {
        setNull();
        mType = UNSIGNED_T;
        return mUnsigned = aValue;
    }

    int64_t& GenericValue::setSigned(const int64_t aValue) throw() {
        setNull();
        mType = UNSIGNED_T;
        return mSigned = aValue;
    }

    double& GenericValue::setDouble(const double aValue) throw() {
        setNull();
        mType = DOUBLE_T;
        return mDouble = aValue;
    }

    String<char>& GenericValue::setString() throw() {
        if(mType != STRING_T) {
            setNull();
            mString = new(mAllocator->allocate(sizeof(CString))) CString(*mAllocator);
            mType = STRING_T;
        }else {
            mString->clear();
        }
        return *mString;
    }

    GenericArray& GenericValue::setArray() throw() {
        if(mType != ARRAY_T) {
            setNull();
            mArray = new(mAllocator->allocate(sizeof(ArrayType))) ArrayType(*mAllocator);
            mType = ARRAY_T;
        }else {
            mArray->clear();
        }
        return *mArray;
    }

    GenericObject& GenericValue::setObject() throw() {
        if(mType != OBJECT_T) {
            setNull();
            mObject = new(mAllocator->allocate(sizeof(ObjectType))) ObjectType(*mAllocator);
            mType = OBJECT_T;
        }else {
            mObject->clear();
        }
        return *mObject;
    }
}


text:
.class Lu/aly/P;
.super Ljava/lang/Object;

# interfaces
.implements Lu/aly/dh;

# direct methods
.method private constructor <init>()V
    .locals 0

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method synthetic constructor <init>(Lu/aly/P;)V
    .locals 0

    invoke-direct {p0}, Lu/aly/P;-><init>()V

    return-void
.end method

# virtual methods
.method public a()Lu/aly/O;
    .locals 2

    new-instance v0, Lu/aly/O;

    const/4 v1, 0x0

    invoke-direct {v0, v1}, Lu/aly/O;-><init>(Lu/aly/O;)V

    return-object v0
.end method

.method public synthetic b()Lu/aly/dg;
    .locals 1

    invoke-virtual {p0}, Lu/aly/P;->a()Lu/aly/O;

    move-result-object v0

    return-object v0
.end method


text:
package io.crate.expression.scalar;

import io.crate.data.Input;
import io.crate.expression.symbol.Symbol;
import io.crate.metadata.NodeContext;
import io.crate.metadata.Scalar;
import io.crate.metadata.TransactionContext;
import io.crate.metadata.functions.BoundSignature;
import io.crate.metadata.functions.Signature;
import io.crate.types.DataTypes;
import io.crate.user.UserLookup;
import org.joda.time.Period;

import java.util.List;

public class DateBinFunction extends Scalar<Long, Object> {

    public static final String NAME = "date_bin";

    public static void register(ScalarFunctionModule module) {
        module.register(
            Signature.scalar(
                NAME,
                DataTypes.INTERVAL.getTypeSignature(),
                DataTypes.TIMESTAMPZ.getTypeSignature(), // source
                DataTypes.TIMESTAMPZ.getTypeSignature(), // origin
                DataTypes.TIMESTAMPZ.getTypeSignature()
            ).withFeatures(DETERMINISTIC_ONLY),
            DateBinFunction::new);

        module.register(
            Signature.scalar(
                NAME,
                DataTypes.INTERVAL.getTypeSignature(),
                DataTypes.TIMESTAMP.getTypeSignature(), // source
                DataTypes.TIMESTAMP.getTypeSignature(), // origin
                DataTypes.TIMESTAMP.getTypeSignature()
            ).withFeatures(DETERMINISTIC_ONLY),
            DateBinFunction::new);
    }

    private final Signature signature;
    private final BoundSignature boundSignature;

    private DateBinFunction(Signature signature, BoundSignature boundSignature) {
        this.signature = signature;
        this.boundSignature = boundSignature;
    }

    @Override
    public Signature signature() {
        return signature;
    }

    @Override
    public BoundSignature boundSignature() {
        return boundSignature;
    }

    @Override
    public Scalar<Long, Object> compile(List<Symbol> arguments, String currentUser, UserLookup userLookup) {
        assert arguments.size() == 3 : "Invalid number of arguments";

        if (arguments.get(0) instanceof Input<?> input) {
            var value = input.value();
            if (value != null) {
                long intervalInMs = ((Period) value).toStandardDuration().getMillis();
                if (intervalInMs == 0) {
                    throw new IllegalArgumentException("Interval cannot be zero");
                }
                return new CompiledDateBin(intervalInMs);
            }
        }
        return this;
    }

    @Override
    public final Long evaluate(TransactionContext txnCtx, NodeContext nodeCtx, Input[] args) {
        assert args.length == 3 : "Invalid number of arguments";

        var interval = args[0].value();
        var timestamp = args[1].value();
        var origin = args[2].value();

        if (interval == null || timestamp == null || origin == null) {
            return null;
        }

        return getBinnedTimestamp(((Period) interval).toStandardDuration().getMillis(), (long) timestamp, (long) origin);
    }

    private static long getBinnedTimestamp(long interval, long timestamp, long origin) {
        if (interval == 0) {
            throw new IllegalArgumentException("Interval cannot be zero");
        }

        /*
         in Java % operator returns negative result only if dividend is negative.
         https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.17.3

         We need to shift timestamp by the timeline to the "earlier" direction, to the left.
         If diff is negative, remainder will be also negative (see link above), we subtract negative
         to move to right side of the bin and then subtract abs(interval) to move to beginning of the bin.
        */

        long diff = timestamp - origin;
        if (diff >= 0) {
            // diff % interval >= 0 regardless of the interval sign.
            return timestamp - diff % interval;
        } else {
            // diff % interval < 0 regardless of the interval sign.
            if (interval > 0) {
                return timestamp - diff % interval - interval;
            } else {
                return timestamp - diff % interval + interval;
            }
        }
    }

    private class CompiledDateBin extends Scalar<Long, Object> {

        private final long intervalInMs;

        private CompiledDateBin(long intervalInMs) {
            this.intervalInMs = intervalInMs;
        }

        @Override
        public Signature signature() {
            return signature;
        }

        @Override
        public BoundSignature boundSignature() {
            return boundSignature;
        }

        @Override
        public Long evaluate(TransactionContext txnCtx, NodeContext nodeContext, Input<Object>... args) {
            // Validation for arguments amount is done in compile.

            var timestamp = args[1].value();
            var origin = args[2].value();

            if (timestamp == null || origin == null) {
                return null;
            }

            return getBinnedTimestamp(intervalInMs, (long) timestamp, (long) origin);
        }
    }
}


text:
import React from 'react';
import PropTypes from 'prop-types';

import DepthMatchingRender from '../DepthMatchingRender';
import FiveClauseRender from './FiveClauseRender';
import OperatorRender from './OperatorRender';
import SelectionBuilder from '../../../../Common/Misc/SelectionBuilder';

export default function render(props) {
  const vars = props.selection.range.variables;

  let maxDepth = 1;
  Object.keys(vars).forEach((key) => {
    if (vars[key].length > 1) maxDepth = 2;
  });

  const onChange = (changedPath, editing = false) => {
    // clone, so we don't step on whatever is current.
    const selection = JSON.parse(JSON.stringify(props.selection));
    const currentInterval =
      selection.range.variables[changedPath[0]][changedPath[1]];
    const changeItemIndex = changedPath[2];
    const newValue = changedPath[3];

    if (changeItemIndex === 0 || changeItemIndex === 4) {
      // change an input
      currentInterval.interval[changeItemIndex === 0 ? 0 : 1] = newValue;
    } else if (changeItemIndex === 1 || changeItemIndex === 3) {
      currentInterval.endpoints =
        changeItemIndex === 1
          ? `${newValue}${currentInterval.endpoints.slice(1, 2)}`
          : `${currentInterval.endpoints.slice(0, 1)}${newValue}`;
    }

    // Notify happens in parent
    props.onChange(
      editing ? selection : SelectionBuilder.markModified(selection),
      !editing
    );
  };

  const onDelete = (pathToDelete) => {
    // clone, so we don't step on whatever is current.
    const selection = JSON.parse(JSON.stringify(props.selection));
    const intervals = selection.range.variables[pathToDelete[0]];
    const deleteIntervalIndex = pathToDelete[1];

    // do we have more that 2 terms for this variable? If so, we can just remove one.
    if (intervals.length >= 2) {
      intervals.splice(deleteIntervalIndex, 1);
    } else {
      // Deleting the last interval - delete the variable.
      delete selection.range.variables[pathToDelete[0]];
    }

    // If we still have at least one variable, selection isn't empty.
    if (Object.keys(selection.range.variables).length !== 0) {
      props.onChange(SelectionBuilder.markModified(selection), true);
    } else {
      props.onChange(SelectionBuilder.empty(), true);
    }
  };

  return (
    <OperatorRender operator="and" depth={0} className={props.className}>
      {Object.keys(vars).map((fieldName, idx) => {
        if (vars[fieldName].length > 1) {
          return (
            <OperatorRender operator="or" depth={1} key={idx}>
              {vars[fieldName].map((clause, j) => (
                <FiveClauseRender
                  getLegend={props.getLegend}
                  onChange={onChange}
                  onDelete={onDelete}
                  intervalSpec={clause}
                  fieldName={fieldName}
                  path={[fieldName, j]}
                  key={j}
                />
              ))}
            </OperatorRender>
          );
        }
        return vars[fieldName].map((clause, j) => (
          <DepthMatchingRender depth={1} maxDepth={maxDepth}>
            <FiveClauseRender
              getLegend={props.getLegend}
              onChange={onChange}
              onDelete={onDelete}
              intervalSpec={clause}
              fieldName={fieldName}
              path={[fieldName, j]}
              key={j}
            />
          </DepthMatchingRender>
        ));
      })}
    </OperatorRender>
  );
}

render.propTypes = {
  selection: PropTypes.object,
  // ranges: PropTypes.object,
  onChange: PropTypes.func,
  getLegend: PropTypes.func,
  className: PropTypes.string,
};

render.defaultProps = {
  selection: undefined,
  className: undefined,
  onChange: undefined,
  getLegend: undefined,
};


text:
var App = require('app');
require('controllers/main/charts/heatmap_metrics/heatmap_metric');

describe('MainChartHeatmapMetric', function () {

  var mainChartHeatmapMetric = App.MainChartHeatmapMetric.create({});

  describe('#formatLegendNumber', function () {
    var tests = [
      {m:'undefined to undefined',i:undefined,e:undefined},
      {m:'0 to 0',i:0,e:0},
      {m:'1 to 1',i:1,e:1},
      {m:'1.23 to 1.2',i:1.23,e:1.2}
    ];
    tests.forEach(function(test) {
      it(test.m + ' ', function () {
        expect(mainChartHeatmapMetric.formatLegendNumber(test.i)).to.equal(test.e);
      });
    });
    it('NaN to NaN' + ' ', function () {
      expect(isNaN(mainChartHeatmapMetric.formatLegendNumber(NaN))).to.equal(true);
    });
  })

});


text:
namespace Custom.Algebra.QrCode.Encoding.Versions
{
	internal struct VersionControlStruct
	{
		internal VersionDetail VersionDetail { get; set; }
		internal bool isContainECI { get; set; }
		internal BitList ECIHeader { get; set; }
	}
}