text:
#ifndef GRAPHLAB_UNITY_SFRAME_SARRAY_READER_HPP
#define GRAPHLAB_UNITY_SFRAME_SARRAY_READER_HPP
#include <set>
#include <iterator>
#include <type_traits>
#include <functional>
#include <logger/assertions.hpp>
#include <serialization/iarchive.hpp>
#include <parallel/pthread_tools.hpp>
#include <sframe/siterable.hpp>
#include <flexible_type/flexible_type.hpp>
#include <sframe/sarray_file_format_v1.hpp>
#include <sframe/sarray_file_format_v2.hpp>
#include <sframe/sframe_constants.hpp>
#include <fileio/file_ownership_handle.hpp>
#include <sframe/sarray_reader_buffer.hpp>
namespace graphlab {

template <typename T>
class sarray;

/**
 * Implements a simple input iterator over an sarray.
 *
 * The sarray_iterator provides a simple input iterator (like forward iterator,
 * but one pass. i.e. increment of one, invalidates all other copies.) over a
 * segment of an sarray.
 */
template <typename T>
class sarray_iterator {
 public:
  // standard iterator stuff
  typedef T value_type;
  typedef int difference_type;
  typedef T* pointer;
  typedef T& reference;
  typedef std::input_iterator_tag iterator_category;

  /**
   * Default constructor. Makes an iterator which points nowhere.
   * Use of this iterator will produce undefined results.
   */
  sarray_iterator()
      :reader(NULL), segmentid(0),
       current_element(T()), current_element_counter(0) {}

  /// Default copy constructor
  sarray_iterator(const sarray_iterator& other) = default;

  /// Default assignment operator
  sarray_iterator& operator=(const sarray_iterator& other) = default;

  /**
   * Constructs an iterator from an input archive.
   * Creates a start iterator to the segment.
   *
   * \param reader The file format reader to use
   * \param segmentid The segment to read. Must be a valid segment
   * \param is_start_iterator If true, creates a start iterator to the segment.
   *                          If false, creates an end iterator to the segment.
   */
  sarray_iterator(sarray_reader_buffer<T>* reader,
                  size_t segmentid,
                  bool is_start_iterator)
      :reader(reader), segmentid(segmentid),
       current_element(T()), current_element_counter(0) {
    num_elements = reader->size();
    if (is_start_iterator) {
      if (num_elements > 0) {
        current_element = reader->next();
      }
      current_element_counter = 0;
    } else {
      // one past the end
      current_element_counter = num_elements;
    }
  }

  /**
   * Advances the iterator to the next element
   */
  sarray_iterator& operator++() {
    if (reader->has_next()) {
      current_element = reader->next();
      ++current_element_counter;
    } else {
      current_element_counter = num_elements;
      reader->clear();
    }
    return *this;
  }

  /**
   * Equivalent to other operator++ for input iterators
   */
  void operator++(int) {
    /// forward to the other operator++
    ++(*this);
  }

  /**
   * Returns true if the iterators are identical (points to the same
   * element in the same sarray).
   */
  bool operator==(const sarray_iterator& other) const {
    return (reader == other.reader) &&
        (segmentid == other.segmentid) &&
        (current_element_counter == other.current_element_counter);
  }

  /**
   * Returns true if the iterators are different (points to different
   * elements, or in different sarrays)
   */
  bool operator!=(const sarray_iterator& other) const {
    return !((*this) == other);
  }

  /**
   * Returns the current element. Value will be invalid if the iterator
   * is past the end of the sarray (points to end)
   */
  const value_type& operator*() const {
    return current_element;
  }

  /**
   * \overload
   */
  value_type& operator*() {
    return current_element;
  }

  /**
   * Returns the distance between two iterators. Both iterators must be
   * from the same segment of the same sarray, otherwise result is undefined.
   */
  int operator-(const sarray_iterator& other) const {
    return (int)(current_element_counter) - (int)(other.current_element_counter);
  }

 private:
  /// The reader we are reading from
  sarray_reader_buffer<T>* reader;
  /// The segment we are reading from
  size_t segmentid;
  /// The last element read (returned by the deref operator)
  T current_element;
  /// Number of elements successfully read so far.
  size_t current_element_counter;
  /// Total number of elements
  size_t num_elements;
};

/**
 * The SArray reader provides a reading interface to
 * an immutable, on disk, sequence of objects T.
 *
 * The SArray is an immutable sequence of objects of type T, and is internally
 * represented as a collection of files. The sequence is cut up into a
 * collection of segments (not necessarily of equal length), where each segment
 * covers a disjoint subset of the sequence. Each segment can then be read
 * in parallel.
 *
 * To read from an sarray<T> use \ref sarray::get_reader():
 * \code
 * auto reader = array.get_reader();
 * \endcode
 * reader will be of type sarray_reader<T>
 *
 * reader can then provide input iterators from segments via the begin()
 * and end() functions.
 */
template <typename T>
class sarray_reader: public siterable<sarray_iterator<T> > {
 public:
  /// The iterator type which \ref begin and \ref end returns
  typedef sarray_iterator<T> iterator;

  /// The value type the sarray stores
  typedef typename iterator::value_type value_type;

  /**
   * Default constructor. Does nothing. Use init()
   */
  sarray_reader() = default;

  /// Deleted Copy constructor
  sarray_reader(const sarray_reader& other) = delete;

  /// Assignment operator
  sarray_reader& operator=(const sarray_reader& other) = delete;

  ~sarray_reader() {
    if (reader) delete reader;
  }

  /**
   * Attempts to construct an sarray_iterator which reads from
   * an existing sarray.
   * If the index file cannot be opened, an exception is thrown.
   *
   * \param array The array to read
   * \param num_segments If num_segments == (size_t)(-1), the
   *                     original file segmentation is used. Otherwise,
   *                     the array is cut into num_segments number of
   *                     logical segments which distribute the rows uniformly.
   */
  void init(const sarray<T>& array, size_t num_segments = (size_t)(-1)) {
    ASSERT_MSG(!reader, "Reader already inited");
    open_format_reader(array);
    // row start and row end of each segment
    std::vector<std::pair<size_t, size_t> > segment_row_start_end;
    if (num_segments == (size_t)(-1)) {
      // we use the original sarray file layout
      auto index_info = array.get_index_info();
      // the cumulative sum across segment lengths
      size_t current_row_index = 0;
      // figure out the start and end position for each segment
      for (size_t i = 0;i < index_info.nsegments; ++i) {
        size_t row_start = current_row_index;
        size_t row_end = row_start + index_info.segment_sizes[i];
        segment_row_start_end.push_back({row_start, row_end});
        current_row_index = row_end;
      }
    } else {
      // we equally divide the data across the segments
      // compute the segment lengths
      ASSERT_GT(num_segments, 0);
      size_t totallength = size();
      // figure out the start and end position for each segment
      for (size_t i = 0;i < num_segments; ++i) {
        size_t row_start = ((i * totallength) / num_segments);
        size_t row_end = (((i + 1) * totallength) / num_segments);
        segment_row_start_end.push_back({row_start, row_end});
      }
    }
    create_segment_read_buffers(segment_row_start_end);
    files_managed = array.files_managed;
  }

  /**
   * Attempts to construct an sarray_iterator which reads from
   * an existing sarray and uses a segmentation defined by an argument.
   * If the index file cannot be opened, an exception is thrown.
   * If the sum of the lengths of all the segments do not add up to the
   * length of the sarray, an exception is thrown
   *
   * \param array The array to read
   * \param segment_lengths An array describing the lengths of each segment.
   *                        This must sum up to the length of the array.
   */
  void init(const sarray<T>& array, const std::vector<size_t>& segment_lengths) {
    ASSERT_MSG(!reader, "Reader already inited");
    open_format_reader(array);
    // check that lengths add up
    size_t sum = 0;
    for(size_t s: segment_lengths) sum += s;
    ASSERT_EQ(sum, size());

    // row start and row end of each segment
    std::vector<std::pair<size_t, size_t> > segment_row_start_end;

    // the cumulative sum across segment lengths
    size_t current_row_index = 0;
    // figure out the start and end position for each segment
    for (size_t i = 0;i < segment_lengths.size(); ++i) {
      size_t row_start = current_row_index;
      size_t row_end = row_start + segment_lengths[i];
      segment_row_start_end.push_back({row_start, row_end});
      current_row_index = row_end;
    }
    create_segment_read_buffers(segment_row_start_end);
  }

  /**
   * Return the number of segments in the collection.
   * Will throw an exception if the sarray is invalid (there is an error
   * reading files)
   */
  size_t num_segments() const {
    ASSERT_NE(reader, NULL);
    return m_num_segments;
  }

  /**
   * Return the number of rows in the segment.
   * Will throw an exception if the sarray is invalid (there is an error
   * reading files)
   */
  size_t segment_length(size_t segment) const {
    ASSERT_NE(reader, NULL);
    return m_segment_lengths[segment];
  }

  /**
   * Return the file prefix of the sarray (paramter on construction)
   */
  std::string get_index_file() const {
    ASSERT_NE(reader, NULL);
    return reader->get_index_file();
  }

  /**
   * Returns the collection of files storing the sarray.
   * For instance: [file_prefix].sidx, [file_prefix].0001, etc.
   */
  std::vector<std::string> get_file_names() const {
    ASSERT_NE(reader, NULL);
    return reader->get_index_info().segment_files;
  }

  /**
   * Reads the value of a key associated with the sarray.
   * Returns true on success, false on failure.
   */
  bool get_metadata(std::string key, std::string &val) const {
    ASSERT_NE(reader, NULL);
    if (reader == NULL) log_and_throw(std::string("Invalid sarray"));
    bool ret = false;
    std::tie(ret, val) = get_metadata(key);
    return ret;
  }

  /**
   * Reads the value of a key associated with the sarray.
   * Returns a pair of (true, value) on success, and (false, empty_string)
   * on failure.
   */
  std::pair<bool, std::string> get_metadata(std::string key) const {
    ASSERT_NE(reader, NULL);
    const index_file_information& index_info = reader->get_index_info();
    if (index_info.metadata.count(key)) {
      return std::pair<bool, std::string>(true,
                                          index_info.metadata.at(key));
    } else {
      return std::pair<bool, std::string>(false, "");
    }
  }

  /**
   * Returns the number of elements in the SArray
   */
  size_t size() const {
    ASSERT_NE(reader, NULL);
    size_t total = 0;
    const index_file_information& info = reader->get_index_info();
    for (size_t i = 0;i < info.segment_sizes.size(); ++i) {
      total += info.segment_sizes[i];
    }
    return total;
  }

  /**
   * Return the begin iterator of the segment.
   * The iterator (\ref sarray_iterator) is of the input iterator type and
   * has value_type T. See \ref end() to get the end iterator of the segment.
   *
   * The iterator is invalid once the originating sarray is destroyed.
   * Accessing the iterator after the sarray is destroyed is undefined behavior.
   *
   * \code
   * // example to print segment 1 to screen
   * auto iter = sarr.begin(1);
   * auto enditer =sarr.end(1);
   * while(iter != enditer) {
   *   std::cout << *iter << "\n";
   *   ++iter;
   * }
   * \endcode
   *
   * Will throw an exception if the sarray is invalid (there is an error
   * reading files) Also segmentid must be a valid segment ID. Will throw an
   * exception otherwise.
   */
  iterator begin(size_t segmentid) const {
    std::lock_guard<mutex> lck(lock);
    if (opened_segments.count(segmentid) == 0) {
      opened_segments.insert(segmentid);
    } else {
      log_and_throw(std::string("Must reset sarray iterators!"));
    }
    if (reader == NULL) log_and_throw(std::string("Invalid sarray"));
    if (segmentid >= num_segments()) log_and_throw(std::string("Invalid segment ID"));
    return iterator(&(m_read_buffers[segmentid]), segmentid, true);
  }

  /** Return the end iterator of the segment.
   * The iterator (\ref sarray_iterator) is of the input iterator type and
   * has value_type T. See \ref end() to get the end iterator of the segment.
   *
   * The iterator is invalid once the originating sarray is destroyed.
   * Accessing the iterator after the sarray is destroyed is undefined behavior.
   *
   * \code
   * // example to print segment 1 to screen
   * auto iter = sarr.begin(1);
   * auto enditer =sarr.end(1);
   * while(iter != enditer) {
   *   std::cout << *iter << "\n";
   *   ++iter;
   * }
   * \endcode
   *
   * Will throw an exception if the sarray is invalid (there is an error
   * reading files) Also segmentid must be a valid segment ID. Will throw an
   * exception otherwise.
   */
  iterator end(size_t segmentid) const {
    ASSERT_NE(reader, NULL);
    ASSERT_LT(segmentid, num_segments());
    return iterator(&(m_read_buffers[segmentid]), segmentid, false);
  }

  /**
   * Reads a collection of rows, storing the result in out_obj.
   * This function is independent of the open_segment/read_segment/close_segment
   * functions, and can be called anytime. This function is also fully
   * concurrent.
   * \param row_start First row to read
   * \param row_end one past the last row to read (i.e. EXCLUSIVE). row_end can
   *                be beyond the end of the array, in which case,
   *                fewer rows will be read.
   * \param out_obj The output array
   * \returns Actual number of rows read. Return (size_t)(-1) on failure.
   *
   * \note This function is not always efficient. Different file formats
   * implementations will have different characteristics.
   */
  size_t read_rows(size_t row_start,
                   size_t row_end,
                   std::vector<T>& out_obj) {
    DASSERT_NE(reader, NULL);
    return reader->read_rows(row_start, row_end, out_obj);
  }

  /**
   * Reads a collection of rows, storing the result in out_obj.
   * This function is independent of the open_segment/read_segment/close_segment
   * functions, and can be called anytime. This function is also fully
   * concurrent.
   * \param row_start First row to read
   * \param row_end one past the last row to read (i.e. EXCLUSIVE). row_end can
   *                be beyond the end of the array, in which case,
   *                fewer rows will be read.
   * \param out_obj The output array
   * \returns Actual number of rows read. Return (size_t)(-1) on failure.
   *
   * \note This function is not always efficient. Different file formats
   * implementations will have different characteristics.
   */
  size_t read_rows(size_t row_start,
                   size_t row_end,
                   sframe_rows& out_obj);

  /**
   * Resets all the file handles. All existing iterators are invalidated.
   */
  void reset_iterators() {
    std::lock_guard<mutex> lck(lock);
    opened_segments.clear();
    for (auto& buf: m_read_buffers) buf.clear();
  }

  /**
   * Returns the type of the SArray (as set by
   * \ref swriter<flexible_type>::set_type). If the type of the SArray was
   * not set, this returns \ref flex_type_enum::UNDEFINED, in which case
   * each row can be of arbitrary type.
   *
   * This function should only be used for sarray<flexible_type> and
   * will fail fatally otherwise.
   */
  flex_type_enum get_type() const {
    if (!std::is_same<T, flexible_type>::value) {
      ASSERT_MSG(false,
                  "Use of get_type() in SArray which "
                  "does not contain flexible_types");
    }
    ASSERT_NE(reader, NULL);
    const index_file_information& index_info = reader->get_index_info();
    if (index_info.metadata.count("__type__")) {
      return flex_type_enum::UNDEFINED;
    }
    return flex_type_enum(std::stoi(index_info.metadata.at("__type__")));
  }

 private:
  mutable sarray_format_reader<T>* reader = NULL;
  mutable mutex lock;
  size_t m_num_segments = 0;
  mutable std::set<size_t> opened_segments;
  std::vector<size_t> m_segment_lengths;
  // take a reference to all the handled files so that deletion of the sarray
  // does not cause the reader to become invalidated.
  std::vector<std::shared_ptr<fileio::file_ownership_handle>> files_managed;

  mutable std::vector<sarray_reader_buffer<T> > m_read_buffers;

  /**
   * Construct the format reader object from the sarray.
   * Only called by the init() functions.
   */
  void open_format_reader(const sarray<T>& array) {
    // redirect to the appropriate file reader
    // for now, we only have version 0
    size_t file_version = array.get_index_info().version;

    switch(file_version) {
     case 0:
       log_and_throw("Format version 0 deprecated");
       break;
     case 1:
       reader = new sarray_format_reader_v1<T>();
       reader->open(array.get_index_info());
       break;
     case 2:
       reader = new sarray_format_reader_v2<T>();
       reader->open(array.get_index_info());
       break;
     default:
       reader = NULL;
       log_and_throw("Invalid file format version");
       break;
    }
  }

  /**
   * Construct the format reader object from the sarray.
   * Only called by the init() functions. Also sets up the m_segment_lengths
   * and m_num_segments variables.
   */
  void create_segment_read_buffers(
      const std::vector<std::pair<size_t, size_t> >& segment_row_start_end) {
    // set up the read buffers
    m_num_segments = segment_row_start_end.size();
    m_segment_lengths.resize(m_num_segments);
    m_read_buffers.resize(m_num_segments);

    for (size_t i = 0;i < m_segment_lengths.size(); ++i) {
      m_segment_lengths[i] =
          segment_row_start_end[i].second - segment_row_start_end[i].first;
      /*
       * We would like to reuse the sarray_reader_buffer here.
       * However, we have a singularly annoying problem. Which is that
       * the sarray_reader_buffer takes a shared_ptr to the sarray_reader.
       * There are 5 possible solutions:
       *  - change sarray.get_reader() to return a shared_ptr and have sarray
       *    inherit from std::enable_shared_from_this. This will allow me to
       *    hand off a shared_ptr to the sarray_reader_buffer and be reference
       *    counted correctly. However, this is bad since it introduces a
       *    circular reference meaning sarray_reader will never be deleted.
       *  - change sarray.get_reader() to return a shared_ptr and have sarray
       *    inherit from std::enable_shared_from_this. And modify
       *    sarray_reader_buffer to take a weak_ptr to break the circular
       *    reference. Problematic and liable to break things. For instance
       *    if sarray_reader_buffer is constructed from a get_reader() and
       *    the reader is thrown away.
       *  - change sarray_reader_buffer to a regular pointer. Problematic.
       *    like the above.
       *  - Re-implement the sarray_reader_buffer here. Code duplication is ugly.
       *  - keep the shared_ptr in the sarray_reader_buffer, but give it a
       *    shared_ptr that doesn't actually delete the pointer. Not pretty,
       *    but works.
       */
      std::shared_ptr<sarray_reader<T>> bad_ptr_to_this(this, [](void*){});
      m_read_buffers[i].init(bad_ptr_to_this,
                             segment_row_start_end[i].first,
                             segment_row_start_end[i].second);
    }
  }
};

template <typename T>
inline size_t sarray_reader<T>::read_rows(size_t row_start,
                                          size_t row_end,
                                          sframe_rows& out_obj) {
  ASSERT_MSG(false, "read_rows() to sframe_rows not implemented for "
                    "non-flexible_type templatizations of sarray");
  return 0;
}

template <>
inline size_t sarray_reader<flexible_type>::read_rows(size_t row_start,
                                                      size_t row_end,
                                                      sframe_rows& out_obj) {
  DASSERT_NE(reader, NULL);
  return reader->read_rows(row_start, row_end, out_obj);
}

} // namespace graphlab

namespace std {

// specialization of std::distance
template <typename T>
inline int distance(const graphlab::sarray_iterator<T>& begin,
                    const graphlab::sarray_iterator<T>& end) {
  return end - begin;
}

} // namespace std

#endif


text:
 Către Galateea

 Poezia  Către Galateea  de Nichita Stănescu este o artă poetică aparținând neomodernismului. Face parte din volumul  Dreptul la timp  (1965), care marchează trecerea spre un lirism interiorizat, reflexiv, specific celei de-a doua etape de creație.

			Click aici pentru a citi opera.

 De ce e o artă poetică?

 Este o artă poetică deoarece, prin mijloace artistice, este redată concepția autorului despre poezie (atributele ei specificate) și despre rolul poetului (raportul acestuia cu lumea și creația).

 Este o artă poetică aparținând neomodernismului, în care se realizează răsturnarea relației creator-operă, inversarea rolurilor: artistul este cel "născut" de operă.

		Relația dintre viziunea autorului asupra poeziei și

			<input type = "radio" name = "Neomodernism" ng-model = "Neomodernism" class = "big-dot" value = "neomodernism" /> neomodernism

			<input type = "radio" name = "Neomodernism" ng-model = "Neomodernism" class = "big-dot" value = "modernism" /> modernism

		se concentrează în jurul unor aspecte relevante în textul poeziei: ruptura tragică a sinelui, conștiința scizionată, perceperea dureroasă a timpului, dialogul poetului cu miturile.

 Care este tema poeziei?

 Poezia prezintă relația inversată dintre artist și operă, dar și relația timp-operă, în cadrul unui cuplu inedit: Creatorul/Timpul și femeia, Galateea/Opera,  Tema  este aceea a cunoașterii-naștere revelată în procesul de creație.

 Ce semnifică titlul?

  Titlul  este sugestiv pentru o artă poetică în care se înfățișează relația dintre artist și operă, prin aluzia la vechiul mit al lui Pygmalion.

 Sculptorul din Cipru, îndrăgostit de una dintre statuile sale de fildeș, se roagă zeiței Afrodita s-o însuflețească pentru el. Din căsătoria cu Galateea, opera-femeie plăsmuită de artist, se naște un fiu numit Pathos (în greacă,  suferință,  patimă). Sensul mitului este acela că patosul artistului însuflețește opera.

 Nichita Stănescu reinterpretează mitul în sensul unei răsturnări de roluri. Atribuind eului liric ipostaza creatorului "nenăscut", poezia se constituie ca o fierbinte rugă adresată operei, de a-l crea ca ființa vie. Prezența prepoziției  către  în titlu este pusă în relație cu caracterul adresat al discursului liric, care realizează că o invocație către Galateea, simbol al ființei iubite și al misterului vieții.

 Cum se realizează lirismul subiectiv

		Lirismul subiectiv se realizează prin atitudinea poetică transmisă în mod
		<input type = "text" class = "form-control short-input-box" ng-model = "Lirism" value = "{Lirism}" />

		, iar, la nivelul expresiei, prin mărcile
		<input type = "text" class = "form-control short-input-box" ng-model = "Subjective" value = "{Subjective}" />

		:

 alternarea formelor de persoana I și a II-a singular

 alternarea formelor adjectivului posesiv "meu"-"tău"

 alternarea formelor verbului la prezent

 Cum este structurată opera?

		Compozițional, poezia are
		<input type = "range" class = "short-input-box" min = "1" max = "5" ng-model = "Verses" style = "display: inline-block;" />  {{Verses}}

		secvențe poetice marcate prin organizarea strofică. Cele ..{{Verses}}.. strofe încep cu verbul  "știu"  și se încheie cu imperativul  "naște-mă" , ceea ce conferă simetria compozițională. Simbolul rugăciunii,  "genunchiul", constituie un element de recurență, iar gestul adorației se repetă gradat în fiecare strofă.

 Discursul liric se organizează gradat în jurul celor două simboluri:

 Artistul - sub semnul lui "știu"

 Opera - cu puterea ei de a-l "naște" (de a-i da  dreptul la timp), adică al celor două noțiuni:  a ști  și  a fi născut.

 Ce prezintă cele trei secvențe?

 Prima secvență redă, în enumerație, atributele operei "știute" numai de artist și reprezentate în forma concretă a însușirilor femeii iubire: umbra, tăcerile, sânul, mersul, melancolia, inelul.

 Patima bărbatului, cunoașterea elementelor operei, exprimate patetic în adresarea directă de mai jos motivează dorința de a deveni artist:

				"Îți știu toate timpurile, toate mișcările, toate parfumurile"

				"și nu mai am răbdare și genunchiul mi-l pun în pietre

				 și mă rog de tine,

				 naște-mă."

				A doua secvență depășește cadrul atributelor concrete. Artistul cunoaște și inefabilul operei, ceea ce nu este legat de planul existenței, orizontul cunoașterii poetice, exprimat metaforic prin indicii temporali și
				<input type = "text" class = "form-control short-input-box" ng-model = "Space" value = "{Space}" />

				: "după-amiaza, după-orizontul, dincolo-de-marea...".

 Jocul cuvintelor în rostirea poetică antrenează categoriile aproapelui și departelui (rezonanța eminesciană).

				"Știu tot [...]

				 și tot ce e dincolo de ele,

				 și atât de departe, încât nu mai are nici nume."

 Metafora "genunchiul pietrelor" sugerează o altă relație a artistului-poet cu lumea decât în strofa anterioară: trecerea de la perceperea exterioară, de la contemplație, la comunicarea intimă, iar lumea se organizează prin cântec după chipul și aseănarea lui.

 Verbul "îngână" poate avea ca sens conotativ atât verbul "cântă", cât și verbul "imită". Prin cântec/poezie, lumea reală devine o copie (mimesis) a lumii plăsmuite de artist.

 Elementele lumii înseși (copacii, râurile, pietrele) sunt doar "umbre" ale artei. Materia se naște din operă, dobândește sens din ea, iar artistul este o punte de legătură între operă și materie. Ultima secvență poetică îl înfățișează pe creator ca suflet al operei:

				"Bătaia inimii care urmează bătăii ce-o auzi."

 Viața miraculoasă a operei nu ține doar de conștiința artistului, ci de întreaga existență. Opera  naște  propriul univers prin intermediul artistului care are harul cunoașterii și se oferă ca model al lumii, umanizând-o.

 Reprezentarea abstracțiilor în forma concretă are ca efect plăsmuirea unui univers poetic original, cu un imaginar propriu, inedit. Treptele cunoașterii poetice sunt ierarhizate în cele trei strofe, de la perceptibil/fenomen la imperceptibil/esență.

 I - "Îțî știu toate timpurile, toate mișcările, toate parfumurile"

 II - "Știu tot ce e mai departe de tine"

 III - "Știu tot ceea ce tu nu știi niciodată, din tine.."

redpajama_set_name: RedPajamaGithub


text:
permissions
===========

Permissions is an attribute-based access control (ABAC) in Python.


text:
package com.badlogic.gdx.physics.box2d.joints;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Joint;
import com.badlogic.gdx.physics.box2d.World;

/**
 * The pulley joint is connected to two bodies and two fixed ground points. The
 * pulley supports a ratio such that: length1 + ratio * length2 <= constant Yes,
 * the force transmitted is scaled by the ratio. The pulley also enforces a
 * maximum length limit on both sides. This is useful to prevent one side of the
 * pulley hitting the top.
 */
public class PulleyJoint extends Joint {
    /*
     * JNI #include <Box2D/Box2D.h>
     */

    public PulleyJoint(World world, long addr) {
        super(world, addr);
    }

    /** Get the first ground anchor. */
    private final float[] tmp = new float[2];
    private final Vector2 groundAnchorA = new Vector2();

    public Vector2 getGroundAnchorA() {
        jniGetGroundAnchorA(addr, tmp);
        groundAnchorA.set(tmp[0], tmp[1]);
        return groundAnchorA;
    }

    private native void jniGetGroundAnchorA(long addr, float[] anchor); /*
                                                                         * b2PulleyJoint
                                                                         * *
                                                                         * joint
                                                                         * = (
                                                                         * b2PulleyJoint
                                                                         * *
                                                                         * )addr
                                                                         * ;
                                                                         * anchor
                                                                         * [0] =
                                                                         * joint
                                                                         * ->
                                                                         * GetGroundAnchorA
                                                                         * ().x;
                                                                         * anchor
                                                                         * [1] =
                                                                         * joint
                                                                         * ->
                                                                         * GetGroundAnchorA
                                                                         * ().y;
                                                                         */

    /** Get the second ground anchor. */
    private final Vector2 groundAnchorB = new Vector2();

    public Vector2 getGroundAnchorB() {
        jniGetGroundAnchorB(addr, tmp);
        groundAnchorB.set(tmp[0], tmp[1]);
        return groundAnchorB;
    }

    private native void jniGetGroundAnchorB(long addr, float[] anchor); /*
                                                                         * b2PulleyJoint
                                                                         * *
                                                                         * joint
                                                                         * = (
                                                                         * b2PulleyJoint
                                                                         * *
                                                                         * )addr
                                                                         * ;
                                                                         * anchor
                                                                         * [0] =
                                                                         * joint
                                                                         * ->
                                                                         * GetGroundAnchorB
                                                                         * ().x;
                                                                         * anchor
                                                                         * [1] =
                                                                         * joint
                                                                         * ->
                                                                         * GetGroundAnchorB
                                                                         * ().y;
                                                                         */

    /** Get the current length of the segment attached to body1. */
    public float getLength1() {
        return jniGetLength1(addr);
    }

    private native float jniGetLength1(long addr); /*
                                                    * b2PulleyJoint* joint =
                                                    * (b2PulleyJoint*)addr;
                                                    * return
                                                    * joint->GetLengthA();
                                                    */

    /** Get the current length of the segment attached to body2. */
    public float getLength2() {
        return jniGetLength2(addr);
    }

    private native float jniGetLength2(long addr); /*
                                                    * b2PulleyJoint* joint =
                                                    * (b2PulleyJoint*)addr;
                                                    * return
                                                    * joint->GetLengthB();
                                                    */

    /** Get the pulley ratio. */
    public float getRatio() {
        return jniGetRatio(addr);
    }

    private native float jniGetRatio(long addr); /*
                                                  * b2PulleyJoint* joint =
                                                  * (b2PulleyJoint*)addr; return
                                                  * joint->GetRatio();
                                                  */
}


text:
function alpha = VoidFraction_RefLub(q, rho_v, rho_l, param)

switch param.type_void_fraction
    case 'Homogenous'
        alpha = VoidFraction_homogenous(q, rho_v,  rho_l);

    case 'Zivi'
        alpha = VoidFraction_Zivi(q, rho_v,  rho_l);

    case 'SlipRatio'
        alpha = VoidFraction_SlipRatio(q, rho_v,  rho_l, param.S_ratio);

    case 'LockMart'
        alpha = VoidFraction_Lockhart_Martinelli(q, rho_v,  rho_l, param.mu_v, param.mu_l);

    case 'GrahamCondensation'
        alpha = VoidFraction_GrahamCondensation(q, rho_v, param.G, param.D);

    case 'Hughmark'
        alpha = VoidFraction_Hughmark(q, rho_v, rho_l, param.mu_v, param.mu_l, param.D, param.G);

    case 'Premoli'
        alpha = VoidFraction_Premoli(q, rho_v, rho_l, param.mu_l, param.sig, param.D, param.G);

    case 'AnnularFlow'
        if q > 0.9
            fit_ratiobis = param.fit_ratio_rho;
            AF = AnnularFlow_VPipe(param.G, param.P_Pa, param.T_K, param.C_oil, param.D, param.fluid_ref, param.fluid_lub, fit_ratiobis, param.fit_DTP_zeta);
            if AF.flag>0
                alpha = AF.alpha;
            else
                alpha = VoidFraction_Premoli(q, rho_v, rho_l, param.mu_l, param.sig, param.D, param.G);
                disp('Prob Annular flow')
            end
        else
            alpha = VoidFraction_Premoli(q, rho_v, rho_l, param.mu_l, param.sig, param.D, param.G);
        end
end
end


text:
package org.jolokia.restrictor;

import java.io.InputStream;

import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

import org.jolokia.util.HttpMethod;
import org.jolokia.util.RequestType;
import org.testng.annotations.Test;

import static org.testng.Assert.*;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;

/**
 * @author roland
 * @since Jul 29, 2009
 */
public class PolicyBasedRestrictorTest {

    @Test
    public void basics() throws MalformedObjectNameException {
        InputStream is = getClass().getResourceAsStream("/access-sample1.xml");
        PolicyRestrictor restrictor = new PolicyRestrictor(is);
        assertTrue(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"),"Verbose"));
        assertFalse(restrictor.isAttributeWriteAllowed(new ObjectName("java.lang:type=Memory"),"Verbose"));
        assertFalse(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"),"NonHeapMemoryUsage"));
        assertTrue(restrictor.isOperationAllowed(new ObjectName("java.lang:type=Memory"),"gc"));
        assertFalse(restrictor.isOperationAllowed(new ObjectName("java.lang:type=Threading"),"gc"));
        assertTrue(restrictor.isHttpMethodAllowed(HttpMethod.POST));
        assertFalse(restrictor.isHttpMethodAllowed(HttpMethod.GET));
    }

    @Test
    public void restrictIp() {
        InputStream is = getClass().getResourceAsStream("/access-sample1.xml");
        PolicyRestrictor restrictor = new PolicyRestrictor(is);

        String ips[][] = {
                { "11.0.18.32", "true" },
                { "planck", "true" },
                { "heisenberg", "false" },
                { "10.0.11.125", "true" },
                { "10.0.11.126", "false" },
                { "11.1.18.32", "false" },
                { "192.168.15.3", "true" },
                { "192.168.15.8", "true" },
                { "192.168.16.3", "false" }
        };

        for (String check[] : ips) {
            String res = restrictor.isRemoteAccessAllowed(check[0]) ? "true" : "false";
            assertEquals("Ip " + check[0] + " is " +
                         (check[1].equals("false") ? "not " : "") +
                         "allowed",check[1],res);
        }
    }

    @Test
    public void patterns() throws MalformedObjectNameException {
        InputStream is = getClass().getResourceAsStream("/access-sample2.xml");
        PolicyRestrictor restrictor = new PolicyRestrictor(is);
        assertTrue(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"),"HeapMemoryUsage"));
        assertFalse(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"),"NonHeapMemoryUsage"));
        assertTrue(restrictor.isAttributeReadAllowed(new ObjectName("jolokia:type=Config,name=Bla"),"Debug"));
        assertFalse(restrictor.isOperationAllowed(new ObjectName("jolokia:type=Threading"),"gc"));

        // No hosts set.
        assertTrue(restrictor.isRemoteAccessAllowed("10.0.1.125"));

    }

    @Test
    public void noRestrictions() throws MalformedObjectNameException {
        InputStream is = getClass().getResourceAsStream("/access-sample3.xml");
        PolicyRestrictor restrictor = new PolicyRestrictor(is);
        assertTrue(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"),"HeapMemoryUsage"));
        assertTrue(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"),"NonHeapMemoryUsage"));
        assertTrue(restrictor.isAttributeReadAllowed(new ObjectName("jolokia:type=Config,name=Bla"),"Debug"));
        assertTrue(restrictor.isOperationAllowed(new ObjectName("jolokia:type=Threading"),"gc"));
        assertTrue(restrictor.isTypeAllowed(RequestType.READ));
        assertTrue(restrictor.isHttpMethodAllowed(HttpMethod.GET));
        assertTrue(restrictor.isHttpMethodAllowed(HttpMethod.POST));
    }

    @Test
    public void deny() throws MalformedObjectNameException {
        InputStream is = getClass().getResourceAsStream("/access-sample4.xml");
        PolicyRestrictor restrictor = new PolicyRestrictor(is);
        assertFalse(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"),"HeapMemoryUsage"));
        assertFalse(restrictor.isAttributeWriteAllowed(new ObjectName("java.lang:type=Memory"),"HeapMemoryUsage"));
        assertFalse(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"),"NonHeapMemoryUsage"));
        assertTrue(restrictor.isAttributeWriteAllowed(new ObjectName("java.lang:type=Memory"),"NonHeapMemoryUsage"));
        assertTrue(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"),"BlaUsage"));

        assertFalse(restrictor.isAttributeReadAllowed(new ObjectName("jolokia:type=Config"),"Debug"));

        assertFalse(restrictor.isOperationAllowed(new ObjectName("java.lang:type=Blubber,name=x"),"gc"));
        assertTrue(restrictor.isOperationAllowed(new ObjectName("java.lang:type=Blubber,name=x"),"xavier"));
    }

    @Test
    public void allow() throws MalformedObjectNameException {
        InputStream is = getClass().getResourceAsStream("/access-sample5.xml");
        PolicyRestrictor restrictor = new PolicyRestrictor(is);
        assertTrue(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"), "HeapMemoryUsage"));
        assertTrue(restrictor.isAttributeWriteAllowed(new ObjectName("java.lang:type=Memory"), "HeapMemoryUsage"));
        assertTrue(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"), "NonHeapMemoryUsage"));
        assertFalse(restrictor.isAttributeWriteAllowed(new ObjectName("java.lang:type=Memory"), "NonHeapMemoryUsage"));
        assertFalse(restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"), "BlaUsage"));

        assertTrue(restrictor.isAttributeReadAllowed(new ObjectName("jolokia:type=Config"), "Debug"));

        assertTrue(restrictor.isOperationAllowed(new ObjectName("java.lang:type=Blubber,name=x"), "gc"));
        assertFalse(restrictor.isOperationAllowed(new ObjectName("java.lang:type=Blubber,name=x"), "xavier"));
    }

    @Test
    public void illegalXml() {
        InputStream is = getClass().getResourceAsStream("/illegal1.xml");
        try {
            PolicyRestrictor restrictor = new PolicyRestrictor(is);
            fail("Could parse illegal file");
        } catch (SecurityException exp) {
            //ok
        }

        try {
            new PolicyRestrictor(null);
            fail("No file given");
        } catch (SecurityException exp) {
            // ok
        }
    }

    @Test
    public void noName() {
        InputStream is = getClass().getResourceAsStream("/illegal2.xml");
        try {
            PolicyRestrictor restrictor = new PolicyRestrictor(is);
            fail("Could parse illegal file");
        } catch (SecurityException exp) {
            assertTrue(exp.getMessage().contains("name"));
        }
    }

    @Test
    public void invalidTag() {
        InputStream is = getClass().getResourceAsStream("/illegal3.xml");
        try {
            PolicyRestrictor restrictor = new PolicyRestrictor(is);
            fail("Could parse illegal file");
        } catch (SecurityException exp) {
            assertTrue(exp.getMessage().contains("name"));
            assertTrue(exp.getMessage().contains("attribute"));
            assertTrue(exp.getMessage().contains("operation"));
            assertTrue(exp.getMessage().contains("bla"));
        }
    }

    @Test
    public void doubleName() {
        InputStream is = getClass().getResourceAsStream("/illegal4.xml");
        try {
            PolicyRestrictor restrictor = new PolicyRestrictor(is);
            fail("Could parse illegal file");
        } catch (SecurityException exp) {
            assertTrue(exp.getMessage().contains("name"));
        }

    }

    @Test
    public void httpMethod() {
        InputStream is = getClass().getResourceAsStream("/method.xml");
        PolicyRestrictor res = new PolicyRestrictor(is);
        assertTrue(res.isHttpMethodAllowed(HttpMethod.GET));
        assertTrue(res.isHttpMethodAllowed(HttpMethod.POST));
    }

    @Test
    public void illegalHttpMethod() {
        InputStream is = getClass().getResourceAsStream("/illegal5.xml");
        try {
            new PolicyRestrictor(is);
            fail();
        } catch (SecurityException exp) {
            assertTrue(exp.getMessage().contains("BLA"));
        }
    }

    @Test
    public void illegalHttpMethodTag() {
        InputStream is = getClass().getResourceAsStream("/illegal6.xml");
        try {
            new PolicyRestrictor(is);
            fail();
        } catch (SecurityException exp) {
            assertTrue(exp.getMessage().contains("method"));
            assertTrue(exp.getMessage().contains("blubber"));
        }
    }

    @Test
    public void cors() {
        InputStream is = getClass().getResourceAsStream("/allow-origin1.xml");
        PolicyRestrictor restrictor = new PolicyRestrictor(is);

        assertTrue(restrictor.isCorsAccessAllowed("http://bla.com"));
        assertFalse(restrictor.isCorsAccessAllowed("http://www.jolokia.org"));
        assertTrue(restrictor.isCorsAccessAllowed("https://www.consol.de"));
    }

    @Test
    public void corsWildCard() {
        InputStream is = getClass().getResourceAsStream("/allow-origin2.xml");
        PolicyRestrictor restrictor = new PolicyRestrictor(is);

        assertTrue(restrictor.isCorsAccessAllowed("http://bla.com"));
        assertTrue(restrictor.isCorsAccessAllowed("http://www.jolokia.org"));
        assertTrue(restrictor.isCorsAccessAllowed("http://www.consol.de"));
    }

    @Test
    public void corsEmpty() {
        InputStream is = getClass().getResourceAsStream("/allow-origin3.xml");
        PolicyRestrictor restrictor = new PolicyRestrictor(is);

        assertTrue(restrictor.isCorsAccessAllowed("http://bla.com"));
        assertTrue(restrictor.isCorsAccessAllowed("http://www.jolokia.org"));
        assertTrue(restrictor.isCorsAccessAllowed("http://www.consol.de"));
    }

    @Test
    public void corsNoTags() {
        InputStream is = getClass().getResourceAsStream("/access-sample1.xml");
        PolicyRestrictor restrictor = new PolicyRestrictor(is);

        assertTrue(restrictor.isCorsAccessAllowed("http://bla.com"));
        assertTrue(restrictor.isCorsAccessAllowed("http://www.jolokia.org"));
        assertTrue(restrictor.isCorsAccessAllowed("https://www.consol.de"));
    }

}


text:
using UnityEngine;
using UnityEditor;

namespace Com.LuisPedroFonseca.ProCamera2D
{
    [CustomEditor(typeof(ConstantShakePreset))]
    public class ConstantShakePresetEditor : Editor
    {
        GUIContent _tooltip;

        ConstantShakePreset _preset;

        void OnEnable()
        {
            _preset = (ConstantShakePreset)target;
        }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // Intensity
            _tooltip = new GUIContent("Intensity", "How fast the camera moves towards the amplitude");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("Intensity"), _tooltip);

            // Layers
            _tooltip = new GUIContent("Layers", "");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("Layers"), _tooltip, true);

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            // Shake test buttons
            GUI.enabled = Application.isPlaying && ProCamera2DShake.Exists;
            if (GUILayout.Button("Constant Shake!"))
            {
                ProCamera2DShake.Instance.ConstantShake(_preset);
            }

            if (GUILayout.Button("Stop!"))
            {
                ProCamera2DShake.Instance.StopConstantShaking();
            }
            GUI.enabled = true;

            if (GUILayout.Button("Go to ProCamera2D"))
            {
                if (ProCamera2D.Instance != null)
                {
                    Selection.activeGameObject = ProCamera2D.Instance.gameObject;
                }
            }

            if (_preset.Intensity < .01f)
                _preset.Intensity = .01f;

            serializedObject.ApplyModifiedProperties();
        }
    }
}