text:
//! Streams
//!
//! This module contains a number of functions for working with `Stream`s,
//! including the `StreamExt` trait which adds methods to `Stream` types.

use crate::future::Either;
#[cfg(feature = "alloc")]
use alloc::boxed::Box;
use core::pin::Pin;
#[cfg(feature = "sink")]
use futures_core::stream::TryStream;
#[cfg(feature = "alloc")]
use futures_core::stream::{BoxStream, LocalBoxStream};
use futures_core::{
    future::Future,
    stream::{FusedStream, Stream},
    task::{Context, Poll},
};
#[cfg(feature = "sink")]
use futures_sink::Sink;

mod chain;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::chain::Chain;

mod collect;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::collect::Collect;

mod concat;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::concat::Concat;

mod enumerate;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::enumerate::Enumerate;

mod filter;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::filter::Filter;

mod filter_map;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::filter_map::FilterMap;

mod flatten;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::flatten::Flatten;

mod fold;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::fold::Fold;

#[cfg(feature = "sink")]
mod forward;
#[cfg(feature = "sink")]
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::forward::Forward;

mod for_each;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::for_each::ForEach;

mod fuse;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::fuse::Fuse;

mod into_future;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::into_future::StreamFuture;

mod inspect;
pub(crate) use self::inspect::inspect; // used by `TryStreamExt::{inspect_ok, inspect_err}`
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::inspect::Inspect;

mod map;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::map::Map;

mod next;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::next::Next;

mod select_next_some;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::select_next_some::SelectNextSome;

mod peek;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::peek::Peekable;

mod skip;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::skip::Skip;

mod skip_while;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::skip_while::SkipWhile;

mod take;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::take::Take;

mod take_while;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::take_while::TakeWhile;

mod then;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::then::Then;

mod zip;
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::zip::Zip;

#[cfg(feature = "alloc")]
mod chunks;
#[cfg(feature = "alloc")]
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::chunks::Chunks;

cfg_target_has_atomic! {
    #[cfg(feature = "alloc")]
    mod buffer_unordered;
    #[cfg(feature = "alloc")]
    #[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
    pub use self::buffer_unordered::BufferUnordered;

    #[cfg(feature = "alloc")]
    mod buffered;
    #[cfg(feature = "alloc")]
    #[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
    pub use self::buffered::Buffered;

    #[cfg(feature = "alloc")]
    mod for_each_concurrent;
    #[cfg(feature = "alloc")]
    #[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
    pub use self::for_each_concurrent::ForEachConcurrent;

    #[cfg(feature = "sink")]
    #[cfg(feature = "alloc")]
    mod split;
    #[cfg(feature = "sink")]
    #[cfg(feature = "alloc")]
    #[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
    pub use self::split::{SplitStream, SplitSink, ReuniteError};
}

#[cfg(feature = "std")]
mod catch_unwind;
#[cfg(feature = "std")]
#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
pub use self::catch_unwind::CatchUnwind;

impl<T: ?Sized> StreamExt for T where T: Stream {}

/// An extension trait for `Stream`s that provides a variety of convenient
/// combinator functions.
pub trait StreamExt: Stream {
    /// Creates a future that resolves to the next item in the stream.
    ///
    /// Note that because `next` doesn't take ownership over the stream,
    /// the [`Stream`] type must be [`Unpin`]. If you want to use `next` with a
    /// [`!Unpin`](Unpin) stream, you'll first have to pin the stream. This can
    /// be done by boxing the stream using [`Box::pin`] or
    /// pinning it to the stack using the `pin_mut!` macro from the `pin_utils`
    /// crate.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let mut stream = stream::iter(1..=3);
    ///
    /// assert_eq!(stream.next().await, Some(1));
    /// assert_eq!(stream.next().await, Some(2));
    /// assert_eq!(stream.next().await, Some(3));
    /// assert_eq!(stream.next().await, None);
    /// # });
    /// ```
    fn next(&mut self) -> Next<'_, Self>
    where
        Self: Unpin,
    {
        Next::new(self)
    }

    /// Converts this stream into a future of `(next_item, tail_of_stream)`.
    /// If the stream terminates, then the next item is [`None`].
    ///
    /// The returned future can be used to compose streams and futures together
    /// by placing everything into the "world of futures".
    ///
    /// Note that because `into_future` moves the stream, the [`Stream`] type
    /// must be [`Unpin`]. If you want to use `into_future` with a
    /// [`!Unpin`](Unpin) stream, you'll first have to pin the stream. This can
    /// be done by boxing the stream using [`Box::pin`] or
    /// pinning it to the stack using the `pin_mut!` macro from the `pin_utils`
    /// crate.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream = stream::iter(1..=3);
    ///
    /// let (item, stream) = stream.into_future().await;
    /// assert_eq!(Some(1), item);
    ///
    /// let (item, stream) = stream.into_future().await;
    /// assert_eq!(Some(2), item);
    /// # });
    /// ```
    fn into_future(self) -> StreamFuture<Self>
    where
        Self: Sized + Unpin,
    {
        StreamFuture::new(self)
    }

    /// Maps this stream's items to a different type, returning a new stream of
    /// the resulting type.
    ///
    /// The provided closure is executed over all elements of this stream as
    /// they are made available. It is executed inline with calls to
    /// [`poll_next`](Stream::poll_next).
    ///
    /// Note that this function consumes the stream passed into it and returns a
    /// wrapped version of it, similar to the existing `map` methods in the
    /// standard library.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream = stream::iter(1..=3);
    /// let stream = stream.map(|x| x + 3);
    ///
    /// assert_eq!(vec![4, 5, 6], stream.collect::<Vec<_>>().await);
    /// # });
    /// ```
    fn map<T, F>(self, f: F) -> Map<Self, F>
    where
        F: FnMut(Self::Item) -> T,
        Self: Sized,
    {
        Map::new(self, f)
    }

    /// Creates a stream which gives the current iteration count as well as
    /// the next value.
    ///
    /// The stream returned yields pairs `(i, val)`, where `i` is the
    /// current index of iteration and `val` is the value returned by the
    /// stream.
    ///
    /// `enumerate()` keeps its count as a [`usize`]. If you want to count by a
    /// different sized integer, the [`zip`](StreamExt::zip) function provides similar
    /// functionality.
    ///
    /// # Overflow Behavior
    ///
    /// The method does no guarding against overflows, so enumerating more than
    /// [`usize::max_value()`] elements either produces the wrong result or panics. If
    /// debug assertions are enabled, a panic is guaranteed.
    ///
    /// # Panics
    ///
    /// The returned stream might panic if the to-be-returned index would
    /// overflow a [`usize`].
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream = stream::iter(vec!['a', 'b', 'c']);
    ///
    /// let mut stream = stream.enumerate();
    ///
    /// assert_eq!(stream.next().await, Some((0, 'a')));
    /// assert_eq!(stream.next().await, Some((1, 'b')));
    /// assert_eq!(stream.next().await, Some((2, 'c')));
    /// assert_eq!(stream.next().await, None);
    /// # });
    /// ```
    fn enumerate(self) -> Enumerate<Self>
    where
        Self: Sized,
    {
        Enumerate::new(self)
    }

    /// Filters the values produced by this stream according to the provided
    /// asynchronous predicate.
    ///
    /// As values of this stream are made available, the provided predicate `f`
    /// will be run against them. If the predicate returns a `Future` which
    /// resolves to `true`, then the stream will yield the value, but if the
    /// predicate returns a `Future` which resolves to `false`, then the value
    /// will be discarded and the next value will be produced.
    ///
    /// Note that this function consumes the stream passed into it and returns a
    /// wrapped version of it, similar to the existing `filter` methods in the
    /// standard library.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::future;
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream = stream::iter(1..=10);
    /// let evens = stream.filter(|x| future::ready(x % 2 == 0));
    ///
    /// assert_eq!(vec![2, 4, 6, 8, 10], evens.collect::<Vec<_>>().await);
    /// # });
    /// ```
    fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>
    where
        F: FnMut(&Self::Item) -> Fut,
        Fut: Future<Output = bool>,
        Self: Sized,
    {
        Filter::new(self, f)
    }

    /// Filters the values produced by this stream while simultaneously mapping
    /// them to a different type according to the provided asynchronous closure.
    ///
    /// As values of this stream are made available, the provided function will
    /// be run on them. If the future returned by the predicate `f` resolves to
    /// [`Some(item)`](Some) then the stream will yield the value `item`, but if
    /// it resolves to [`None`] then the next value will be produced.
    ///
    /// Note that this function consumes the stream passed into it and returns a
    /// wrapped version of it, similar to the existing `filter_map` methods in
    /// the standard library.
    ///
    /// # Examples
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream = stream::iter(1..=10);
    /// let evens = stream.filter_map(|x| async move {
    ///     if x % 2 == 0 { Some(x + 1) } else { None }
    /// });
    ///
    /// assert_eq!(vec![3, 5, 7, 9, 11], evens.collect::<Vec<_>>().await);
    /// # });
    /// ```
    fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>
    where
        F: FnMut(Self::Item) -> Fut,
        Fut: Future<Output = Option<T>>,
        Self: Sized,
    {
        FilterMap::new(self, f)
    }

    /// Computes from this stream's items new items of a different type using
    /// an asynchronous closure.
    ///
    /// The provided closure `f` will be called with an `Item` once a value is
    /// ready, it returns a future which will then be run to completion
    /// to produce the next value on this stream.
    ///
    /// Note that this function consumes the stream passed into it and returns a
    /// wrapped version of it.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream = stream::iter(1..=3);
    /// let stream = stream.then(|x| async move { x + 3 });
    ///
    /// assert_eq!(vec![4, 5, 6], stream.collect::<Vec<_>>().await);
    /// # });
    /// ```
    fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
    where
        F: FnMut(Self::Item) -> Fut,
        Fut: Future,
        Self: Sized,
    {
        Then::new(self, f)
    }

    /// Transforms a stream into a collection, returning a
    /// future representing the result of that computation.
    ///
    /// The returned future will be resolved when the stream terminates.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::channel::mpsc;
    /// use futures::stream::StreamExt;
    /// use std::thread;
    ///
    /// let (tx, rx) = mpsc::unbounded();
    ///
    /// thread::spawn(move || {
    ///     for i in 1..=5 {
    ///         tx.unbounded_send(i).unwrap();
    ///     }
    /// });
    ///
    /// let output = rx.collect::<Vec<i32>>().await;
    /// assert_eq!(output, vec![1, 2, 3, 4, 5]);
    /// # });
    /// ```
    fn collect<C: Default + Extend<Self::Item>>(self) -> Collect<Self, C>
    where
        Self: Sized,
    {
        Collect::new(self)
    }

    /// Concatenate all items of a stream into a single extendable
    /// destination, returning a future representing the end result.
    ///
    /// This combinator will extend the first item with the contents
    /// of all the subsequent results of the stream. If the stream is
    /// empty, the default value will be returned.
    ///
    /// Works with all collections that implement the
    /// [`Extend`](std::iter::Extend) trait.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::channel::mpsc;
    /// use futures::stream::StreamExt;
    /// use std::thread;
    ///
    /// let (tx, rx) = mpsc::unbounded();
    ///
    /// thread::spawn(move || {
    ///     for i in (0..3).rev() {
    ///         let n = i * 3;
    ///         tx.unbounded_send(vec![n + 1, n + 2, n + 3]).unwrap();
    ///     }
    /// });
    ///
    /// let result = rx.concat().await;
    ///
    /// assert_eq!(result, vec![7, 8, 9, 4, 5, 6, 1, 2, 3]);
    /// # });
    /// ```
    fn concat(self) -> Concat<Self>
    where
        Self: Sized,
        Self::Item: Extend<<<Self as Stream>::Item as IntoIterator>::Item> + IntoIterator + Default,
    {
        Concat::new(self)
    }

    /// Execute an accumulating asynchronous computation over a stream,
    /// collecting all the values into one final result.
    ///
    /// This combinator will accumulate all values returned by this stream
    /// according to the closure provided. The initial state is also provided to
    /// this method and then is returned again by each execution of the closure.
    /// Once the entire stream has been exhausted the returned future will
    /// resolve to this value.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let number_stream = stream::iter(0..6);
    /// let sum = number_stream.fold(0, |acc, x| async move { acc + x });
    /// assert_eq!(sum.await, 15);
    /// # });
    /// ```
    fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>
    where
        F: FnMut(T, Self::Item) -> Fut,
        Fut: Future<Output = T>,
        Self: Sized,
    {
        Fold::new(self, f, init)
    }

    /// Flattens a stream of streams into just one continuous stream.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::channel::mpsc;
    /// use futures::stream::StreamExt;
    /// use std::thread;
    ///
    /// let (tx1, rx1) = mpsc::unbounded();
    /// let (tx2, rx2) = mpsc::unbounded();
    /// let (tx3, rx3) = mpsc::unbounded();
    ///
    /// thread::spawn(move || {
    ///     tx1.unbounded_send(1).unwrap();
    ///     tx1.unbounded_send(2).unwrap();
    /// });
    /// thread::spawn(move || {
    ///     tx2.unbounded_send(3).unwrap();
    ///     tx2.unbounded_send(4).unwrap();
    /// });
    /// thread::spawn(move || {
    ///     tx3.unbounded_send(rx1).unwrap();
    ///     tx3.unbounded_send(rx2).unwrap();
    /// });
    ///
    /// let output = rx3.flatten().collect::<Vec<i32>>().await;
    /// assert_eq!(output, vec![1, 2, 3, 4]);
    /// # });
    /// ```
    fn flatten(self) -> Flatten<Self>
    where
        Self::Item: Stream,
        Self: Sized,
    {
        Flatten::new(self)
    }

    /// Skip elements on this stream while the provided asynchronous predicate
    /// resolves to `true`.
    ///
    /// This function, like `Iterator::skip_while`, will skip elements on the
    /// stream until the predicate `f` resolves to `false`. Once one element
    /// returns false all future elements will be returned from the underlying
    /// stream.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::future;
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream = stream::iter(1..=10);
    ///
    /// let stream = stream.skip_while(|x| future::ready(*x <= 5));
    ///
    /// assert_eq!(vec![6, 7, 8, 9, 10], stream.collect::<Vec<_>>().await);
    /// # });
    /// ```
    fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>
    where
        F: FnMut(&Self::Item) -> Fut,
        Fut: Future<Output = bool>,
        Self: Sized,
    {
        SkipWhile::new(self, f)
    }

    /// Take elements from this stream while the provided asynchronous predicate
    /// resolves to `true`.
    ///
    /// This function, like `Iterator::take_while`, will take elements from the
    /// stream until the predicate `f` resolves to `false`. Once one element
    /// returns false it will always return that the stream is done.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::future;
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream = stream::iter(1..=10);
    ///
    /// let stream = stream.take_while(|x| future::ready(*x <= 5));
    ///
    /// assert_eq!(vec![1, 2, 3, 4, 5], stream.collect::<Vec<_>>().await);
    /// # });
    /// ```
    fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>
    where
        F: FnMut(&Self::Item) -> Fut,
        Fut: Future<Output = bool>,
        Self: Sized,
    {
        TakeWhile::new(self, f)
    }

    /// Runs this stream to completion, executing the provided asynchronous
    /// closure for each element on the stream.
    ///
    /// The closure provided will be called for each item this stream produces,
    /// yielding a future. That future will then be executed to completion
    /// before moving on to the next item.
    ///
    /// The returned value is a `Future` where the `Output` type is `()`; it is
    /// executed entirely for its side effects.
    ///
    /// To process each item in the stream and produce another stream instead
    /// of a single future, use `then` instead.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::future;
    /// use futures::stream::{self, StreamExt};
    ///
    /// let mut x = 0;
    ///
    /// {
    ///     let fut = stream::repeat(1).take(3).for_each(|item| {
    ///         x += item;
    ///         future::ready(())
    ///     });
    ///     fut.await;
    /// }
    ///
    /// assert_eq!(x, 3);
    /// # });
    /// ```
    fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>
    where
        F: FnMut(Self::Item) -> Fut,
        Fut: Future<Output = ()>,
        Self: Sized,
    {
        ForEach::new(self, f)
    }

    /// Runs this stream to completion, executing the provided asynchronous
    /// closure for each element on the stream concurrently as elements become
    /// available.
    ///
    /// This is similar to [`StreamExt::for_each`], but the futures
    /// produced by the closure are run concurrently (but not in parallel--
    /// this combinator does not introduce any threads).
    ///
    /// The closure provided will be called for each item this stream produces,
    /// yielding a future. That future will then be executed to completion
    /// concurrently with the other futures produced by the closure.
    ///
    /// The first argument is an optional limit on the number of concurrent
    /// futures. If this limit is not `None`, no more than `limit` futures
    /// will be run concurrently. The `limit` argument is of type
    /// `Into<Option<usize>>`, and so can be provided as either `None`,
    /// `Some(10)`, or just `10`. Note: a limit of zero is interpreted as
    /// no limit at all, and will have the same result as passing in `None`.
    ///
    /// This method is only available when the `std` or `alloc` feature of this
    /// library is activated, and it is activated by default.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::channel::oneshot;
    /// use futures::stream::{self, StreamExt};
    ///
    /// let (tx1, rx1) = oneshot::channel();
    /// let (tx2, rx2) = oneshot::channel();
    /// let (tx3, rx3) = oneshot::channel();
    ///
    /// let fut = stream::iter(vec![rx1, rx2, rx3]).for_each_concurrent(
    ///     /* limit */ 2,
    ///     |rx| async move {
    ///         rx.await.unwrap();
    ///     }
    /// );
    /// tx1.send(()).unwrap();
    /// tx2.send(()).unwrap();
    /// tx3.send(()).unwrap();
    /// fut.await;
    /// # })
    /// ```
    #[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))]
    #[cfg(feature = "alloc")]
    fn for_each_concurrent<Fut, F>(
        self,
        limit: impl Into<Option<usize>>,
        f: F,
    ) -> ForEachConcurrent<Self, Fut, F>
    where
        F: FnMut(Self::Item) -> Fut,
        Fut: Future<Output = ()>,
        Self: Sized,
    {
        ForEachConcurrent::new(self, limit.into(), f)
    }

    /// Creates a new stream of at most `n` items of the underlying stream.
    ///
    /// Once `n` items have been yielded from this stream then it will always
    /// return that the stream is done.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream = stream::iter(1..=10).take(3);
    ///
    /// assert_eq!(vec![1, 2, 3], stream.collect::<Vec<_>>().await);
    /// # });
    /// ```
    fn take(self, n: usize) -> Take<Self>
    where
        Self: Sized,
    {
        Take::new(self, n)
    }

    /// Creates a new stream which skips `n` items of the underlying stream.
    ///
    /// Once `n` items have been skipped from this stream then it will always
    /// return the remaining items on this stream.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream = stream::iter(1..=10).skip(5);
    ///
    /// assert_eq!(vec![6, 7, 8, 9, 10], stream.collect::<Vec<_>>().await);
    /// # });
    /// ```
    fn skip(self, n: usize) -> Skip<Self>
    where
        Self: Sized,
    {
        Skip::new(self, n)
    }

    /// Fuse a stream such that [`poll_next`](Stream::poll_next) will never
    /// again be called once it has finished. This method can be used to turn
    /// any `Stream` into a `FusedStream`.
    ///
    /// Normally, once a stream has returned [`None`] from
    /// [`poll_next`](Stream::poll_next) any further calls could exhibit bad
    /// behavior such as block forever, panic, never return, etc. If it is known
    /// that [`poll_next`](Stream::poll_next) may be called after stream
    /// has already finished, then this method can be used to ensure that it has
    /// defined semantics.
    ///
    /// The [`poll_next`](Stream::poll_next) method of a `fuse`d stream
    /// is guaranteed to return [`None`] after the underlying stream has
    /// finished.
    ///
    /// # Examples
    ///
    /// ```
    /// use futures::executor::block_on_stream;
    /// use futures::stream::{self, StreamExt};
    /// use futures::task::Poll;
    ///
    /// let mut x = 0;
    /// let stream = stream::poll_fn(|_| {
    ///     x += 1;
    ///     match x {
    ///         0..=2 => Poll::Ready(Some(x)),
    ///         3 => Poll::Ready(None),
    ///         _ => panic!("should not happen")
    ///     }
    /// }).fuse();
    ///
    /// let mut iter = block_on_stream(stream);
    /// assert_eq!(Some(1), iter.next());
    /// assert_eq!(Some(2), iter.next());
    /// assert_eq!(None, iter.next());
    /// assert_eq!(None, iter.next());
    /// // ...
    /// ```
    fn fuse(self) -> Fuse<Self>
    where
        Self: Sized,
    {
        Fuse::new(self)
    }

    /// Borrows a stream, rather than consuming it.
    ///
    /// This is useful to allow applying stream adaptors while still retaining
    /// ownership of the original stream.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let mut stream = stream::iter(1..5);
    ///
    /// let sum = stream.by_ref()
    ///                 .take(2)
    ///                 .fold(0, |a, b| async move { a + b })
    ///                 .await;
    /// assert_eq!(sum, 3);
    ///
    /// // You can use the stream again
    /// let sum = stream.take(2)
    ///                 .fold(0, |a, b| async move { a + b })
    ///                 .await;
    /// assert_eq!(sum, 7);
    /// # });
    /// ```
    fn by_ref(&mut self) -> &mut Self {
        self
    }

    /// Catches unwinding panics while polling the stream.
    ///
    /// Caught panic (if any) will be the last element of the resulting stream.
    ///
    /// In general, panics within a stream can propagate all the way out to the
    /// task level. This combinator makes it possible to halt unwinding within
    /// the stream itself. It's most commonly used within task executors. This
    /// method should not be used for error handling.
    ///
    /// Note that this method requires the `UnwindSafe` bound from the standard
    /// library. This isn't always applied automatically, and the standard
    /// library provides an `AssertUnwindSafe` wrapper type to apply it
    /// after-the fact. To assist using this method, the [`Stream`] trait is
    /// also implemented for `AssertUnwindSafe<St>` where `St` implements
    /// [`Stream`].
    ///
    /// This method is only available when the `std` feature of this
    /// library is activated, and it is activated by default.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream = stream::iter(vec![Some(10), None, Some(11)]);
    /// // Panic on second element
    /// let stream_panicking = stream.map(|o| o.unwrap());
    /// // Collect all the results
    /// let stream = stream_panicking.catch_unwind();
    ///
    /// let results: Vec<Result<i32, _>> = stream.collect().await;
    /// match results[0] {
    ///     Ok(10) => {}
    ///     _ => panic!("unexpected result!"),
    /// }
    /// assert!(results[1].is_err());
    /// assert_eq!(results.len(), 2);
    /// # });
    /// ```
    #[cfg(feature = "std")]
    fn catch_unwind(self) -> CatchUnwind<Self>
    where
        Self: Sized + std::panic::UnwindSafe,
    {
        CatchUnwind::new(self)
    }

    /// Wrap the stream in a Box, pinning it.
    ///
    /// This method is only available when the `std` or `alloc` feature of this
    /// library is activated, and it is activated by default.
    #[cfg(feature = "alloc")]
    fn boxed<'a>(self) -> BoxStream<'a, Self::Item>
    where
        Self: Sized + Send + 'a,
    {
        Box::pin(self)
    }

    /// Wrap the stream in a Box, pinning it.
    ///
    /// Similar to `boxed`, but without the `Send` requirement.
    ///
    /// This method is only available when the `std` or `alloc` feature of this
    /// library is activated, and it is activated by default.
    #[cfg(feature = "alloc")]
    fn boxed_local<'a>(self) -> LocalBoxStream<'a, Self::Item>
    where
        Self: Sized + 'a,
    {
        Box::pin(self)
    }

    /// An adaptor for creating a buffered list of pending futures.
    ///
    /// If this stream's item can be converted into a future, then this adaptor
    /// will buffer up to at most `n` futures and then return the outputs in the
    /// same order as the underlying stream. No more than `n` futures will be
    /// buffered at any point in time, and less than `n` may also be buffered
    /// depending on the state of each future.
    ///
    /// The returned stream will be a stream of each future's output.
    ///
    /// This method is only available when the `std` or `alloc` feature of this
    /// library is activated, and it is activated by default.
    #[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))]
    #[cfg(feature = "alloc")]
    fn buffered(self, n: usize) -> Buffered<Self>
    where
        Self::Item: Future,
        Self: Sized,
    {
        Buffered::new(self, n)
    }

    /// An adaptor for creating a buffered list of pending futures (unordered).
    ///
    /// If this stream's item can be converted into a future, then this adaptor
    /// will buffer up to `n` futures and then return the outputs in the order
    /// in which they complete. No more than `n` futures will be buffered at
    /// any point in time, and less than `n` may also be buffered depending on
    /// the state of each future.
    ///
    /// The returned stream will be a stream of each future's output.
    ///
    /// This method is only available when the `std` or `alloc` feature of this
    /// library is activated, and it is activated by default.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::channel::oneshot;
    /// use futures::stream::{self, StreamExt};
    ///
    /// let (send_one, recv_one) = oneshot::channel();
    /// let (send_two, recv_two) = oneshot::channel();
    ///
    /// let stream_of_futures = stream::iter(vec![recv_one, recv_two]);
    /// let mut buffered = stream_of_futures.buffer_unordered(10);
    ///
    /// send_two.send(2i32)?;
    /// assert_eq!(buffered.next().await, Some(Ok(2i32)));
    ///
    /// send_one.send(1i32)?;
    /// assert_eq!(buffered.next().await, Some(Ok(1i32)));
    ///
    /// assert_eq!(buffered.next().await, None);
    /// # Ok::<(), i32>(()) }).unwrap();
    /// ```
    #[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))]
    #[cfg(feature = "alloc")]
    fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
    where
        Self::Item: Future,
        Self: Sized,
    {
        BufferUnordered::new(self, n)
    }

    /// An adapter for zipping two streams together.
    ///
    /// The zipped stream waits for both streams to produce an item, and then
    /// returns that pair. If either stream ends then the zipped stream will
    /// also end.
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream1 = stream::iter(1..=3);
    /// let stream2 = stream::iter(5..=10);
    ///
    /// let vec = stream1.zip(stream2)
    ///                  .collect::<Vec<_>>()
    ///                  .await;
    /// assert_eq!(vec![(1, 5), (2, 6), (3, 7)], vec);
    /// # });
    /// ```
    ///
    fn zip<St>(self, other: St) -> Zip<Self, St>
    where
        St: Stream,
        Self: Sized,
    {
        Zip::new(self, other)
    }

    /// Adapter for chaining two streams.
    ///
    /// The resulting stream emits elements from the first stream, and when
    /// first stream reaches the end, emits the elements from the second stream.
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::stream::{self, StreamExt};
    ///
    /// let stream1 = stream::iter(vec![Ok(10), Err(false)]);
    /// let stream2 = stream::iter(vec![Err(true), Ok(20)]);
    ///
    /// let stream = stream1.chain(stream2);
    ///
    /// let result: Vec<_> = stream.collect().await;
    /// assert_eq!(result, vec![
    ///     Ok(10),
    ///     Err(false),
    ///     Err(true),
    ///     Ok(20),
    /// ]);
    /// # });
    /// ```
    fn chain<St>(self, other: St) -> Chain<Self, St>
    where
        St: Stream<Item = Self::Item>,
        Self: Sized,
    {
        Chain::new(self, other)
    }

    /// Creates a new stream which exposes a `peek` method.
    ///
    /// Calling `peek` returns a reference to the next item in the stream.
    fn peekable(self) -> Peekable<Self>
    where
        Self: Sized,
    {
        Peekable::new(self)
    }

    /// An adaptor for chunking up items of the stream inside a vector.
    ///
    /// This combinator will attempt to pull items from this stream and buffer
    /// them into a local vector. At most `capacity` items will get buffered
    /// before they're yielded from the returned stream.
    ///
    /// Note that the vectors returned from this iterator may not always have
    /// `capacity` elements. If the underlying stream ended and only a partial
    /// vector was created, it'll be returned. Additionally if an error happens
    /// from the underlying stream then the currently buffered items will be
    /// yielded.
    ///
    /// This method is only available when the `std` or `alloc` feature of this
    /// library is activated, and it is activated by default.
    ///
    /// # Panics
    ///
    /// This method will panic if `capacity` is zero.
    #[cfg(feature = "alloc")]
    fn chunks(self, capacity: usize) -> Chunks<Self>
    where
        Self: Sized,
    {
        Chunks::new(self, capacity)
    }

    /// A future that completes after the given stream has been fully processed
    /// into the sink and the sink has been flushed and closed.
    ///
    /// This future will drive the stream to keep producing items until it is
    /// exhausted, sending each item to the sink. It will complete once the
    /// stream is exhausted, the sink has received and flushed all items, and
    /// the sink is closed. Note that neither the original stream nor provided
    /// sink will be output by this future. Pass the sink by `Pin<&mut S>`
    /// (for example, via `forward(&mut sink)` inside an `async` fn/block) in
    /// order to preserve access to the `Sink`.
    #[cfg(feature = "sink")]
    fn forward<S>(self, sink: S) -> Forward<Self, S>
    where
        S: Sink<<Self as TryStream>::Ok>,
        Self: TryStream<Error = S::Error> + Sized,
    {
        Forward::new(self, sink)
    }

    /// Splits this `Stream + Sink` object into separate `Stream` and `Sink`
    /// objects.
    ///
    /// This can be useful when you want to split ownership between tasks, or
    /// allow direct interaction between the two objects (e.g. via
    /// `Sink::send_all`).
    ///
    /// This method is only available when the `std` or `alloc` feature of this
    /// library is activated, and it is activated by default.
    #[cfg(feature = "sink")]
    #[cfg_attr(feature = "cfg-target-has-atomic", cfg(target_has_atomic = "ptr"))]
    #[cfg(feature = "alloc")]
    fn split<Item>(self) -> (SplitSink<Self, Item>, SplitStream<Self>)
    where
        Self: Sink<Item> + Sized,
    {
        split::split(self)
    }

    /// Do something with each item of this stream, afterwards passing it on.
    ///
    /// This is similar to the `Iterator::inspect` method in the standard
    /// library where it allows easily inspecting each value as it passes
    /// through the stream, for example to debug what's going on.
    fn inspect<F>(self, f: F) -> Inspect<Self, F>
    where
        F: FnMut(&Self::Item),
        Self: Sized,
    {
        Inspect::new(self, f)
    }

    /// Wrap this stream in an `Either` stream, making it the left-hand variant
    /// of that `Either`.
    ///
    /// This can be used in combination with the `right_stream` method to write `if`
    /// statements that evaluate to different streams in different branches.
    fn left_stream<B>(self) -> Either<Self, B>
    where
        B: Stream<Item = Self::Item>,
        Self: Sized,
    {
        Either::Left(self)
    }

    /// Wrap this stream in an `Either` stream, making it the right-hand variant
    /// of that `Either`.
    ///
    /// This can be used in combination with the `left_stream` method to write `if`
    /// statements that evaluate to different streams in different branches.
    fn right_stream<B>(self) -> Either<B, Self>
    where
        B: Stream<Item = Self::Item>,
        Self: Sized,
    {
        Either::Right(self)
    }

    /// A convenience method for calling [`Stream::poll_next`] on [`Unpin`]
    /// stream types.
    fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>
    where
        Self: Unpin,
    {
        Pin::new(self).poll_next(cx)
    }

    /// Returns a [`Future`] that resolves when the next item in this stream is
    /// ready.
    ///
    /// This is similar to the [`next`][StreamExt::next] method, but it won't
    /// resolve to [`None`] if used on an empty [`Stream`]. Instead, the
    /// returned future type will return `true` from
    /// [`FusedFuture::is_terminated`][] when the [`Stream`] is empty, allowing
    /// [`select_next_some`][StreamExt::select_next_some] to be easily used with
    /// the [`select!`] macro.
    ///
    /// If the future is polled after this [`Stream`] is empty it will panic.
    /// Using the future with a [`FusedFuture`][]-aware primitive like the
    /// [`select!`] macro will prevent this.
    ///
    /// [`FusedFuture`]: futures_core::future::FusedFuture
    /// [`FusedFuture::is_terminated`]: futures_core::future::FusedFuture::is_terminated
    ///
    /// # Examples
    ///
    /// ```
    /// # futures::executor::block_on(async {
    /// use futures::{future, select};
    /// use futures::stream::{StreamExt, FuturesUnordered};
    ///
    /// let mut fut = future::ready(1);
    /// let mut async_tasks = FuturesUnordered::new();
    /// let mut total = 0;
    /// loop {
    ///     select! {
    ///         num = fut => {
    ///             // First, the `ready` future completes.
    ///             total += num;
    ///             // Then we spawn a new task onto `async_tasks`,
    ///             async_tasks.push(async { 5 });
    ///         },
    ///         // On the next iteration of the loop, the task we spawned
    ///         // completes.
    ///         num = async_tasks.select_next_some() => {
    ///             total += num;
    ///         }
    ///         // Finally, both the `ready` future and `async_tasks` have
    ///         // finished, so we enter the `complete` branch.
    ///         complete => break,
    ///     }
    /// }
    /// assert_eq!(total, 6);
    /// # });
    /// ```
    fn select_next_some(&mut self) -> SelectNextSome<'_, Self>
    where
        Self: Unpin + FusedStream,
    {
        SelectNextSome::new(self)
    }
}


text:
<?php
namespace hotelja\iugu\services;

class Accounts extends \hotelja\iugu\Form
{
    public $data;
    public $files;
    public $automatic_validation=true;
    public function rules()
    {
        return [
            [['data','files'],'required','on'=>'request_verification'],
            [['automatic_validation'],'boolean'],
            [['automatic_validation'],'default','value'=>true],
        ];
    }

    public function requestVerification($id)
    {
        return $this->post($id.'/request_verification');
    }

    public static function getById($id)
    {
        return $this->get($id);
    }
}

redpajama_set_name: RedPajamaGithub


text:
default[:openvpn][:configs] = {}
default[:openvpn][:client_configs] = {}


text:
html, body {
	min-width: 100vw;
	min-height: 100vh;

	margin: 0;
	padding: 0;
}
body {
	background: rgba(0, 0, 256, .75) url('http://res2.windows.microsoft.com/resbox/en/windows/main/ebf9f807-1f54-4b82-a3fe-862380833f9c_6.jpg') no-repeat;
	font-family: 'Droid Serif', serif;
	font-size: 12px;
	overflow: hidden;
}
li {
	color: rgb(255, 255, 255);
	white-space: nowrap;
}
ul {
	list-style-type: none;
	padding-left: 16px;
}
input:focus, select:focus, textarea:focus, button:focus {
    outline: none;
}
.busy {
	cursor: wait !important;
}

/********** CONTAINER **********/
.container {
	z-index: 100;
}
.container > .workspace-container > .logout {
	position: absolute;
	right: 0;
	top: 0;
	z-index: 500;

	color: rgb(255, 255, 0);
	cursor: pointer;
	padding: 4px;
}
.container > .workspace-container > .logout:hover {
	color: rgb(255, 0, 0);
}
.container > .workspace-container > .menuIndicator {
	color: rgb(255, 255, 0);
	cursor: pointer;
}
.container > .workspace-container > .tip-search {
	left: 0;
	position: absolute;
	top: 29px;
	z-index: 201;

	background-color: rgba(0, 0, 0, 0.95);
	border-radius: 10px;
	color: rgb(255, 255, 0);
	padding: 8px;
}

/********** FILE CONTAINER **********/
.file-container {
	position: absolute;
	top: 10px;
	left: 350px;

	height: auto !important;
	width: auto !important;

	background: rgba(0, 0, 0, 0.5);
	border: 1px solid rgb(0, 0, 0);
	border-top-left-radius: 12px;
	border-top-right-radius: 12px;
	display: inline-block;
}
.file-container > .content-container > .content {
	min-height: 476px;
	min-width: 800px;

	background-color: rgba(0, 0, 0, 0.75);
	border-color: rgba(0, 0, 0, 0.25);
	color: rgb(0, 255, 0);
	font-size: 12px;
	font-family: 'Droid Sans Mono', monospace;
	tab-size: 4;
	-moz-tab-size: 4;
}
.file-container > .content-container > .content.nowrap {
	white-space: pre;
}
.file-container > .control-container {
	min-height: 24px;

	background-color: rgb(80, 80, 80);
	border-top-left-radius: 12px;
	border-top-right-radius: 12px;
	cursor: move;
}
.file-container > .control-container > .close {
	position: absolute;
	right: 6px;
	top: 6px;

	color: rgb(255, 0, 0);
	cursor: pointer;
	font-size: 12px;
}
.file-container > .control-container > .file-path {
	color: rgb(255, 255, 255);
	display: inline-block;
	font-weight: bold;
	margin-left: 6px;
	margin-top: 4px;
}
.file-container > .control-container > .save {
	cursor: pointer;
	font-size: 12px;
	margin-left: 8px;
	margin-top: 4px;
}
.file-container > .control-container > .save.modified {
	color: rgb(255, 255, 0);
}
.file-container > .control-container > .save.unmodified {
	color: rgb(0, 255, 0);
	padding-left: 1px;
	padding-right: 1px;
}
.file-container > .control-container > .word-wrap {
	position: absolute;
	right: 20px;
	top: 6px;

	color: rgb(255, 255, 255);
	cursor: pointer;
	font-size: 12px;
}

/********** MENU **********/
.menu {
	left: 0;
	position: absolute;
	top: 0;
	z-index: 200;

	height: 99.7vh;
	max-height: 99.7vh;
	min-height: 600px;
	min-width: 300px;

	background: rgba(16, 16, 16, 0.8);
	border: 1px solid #000;
	color: rgb(255, 255, 255);
	font-family: 'Droid Sans Mono', monospace;
}
.menu > .content-container {
	height: auto;

	overflow: auto;
	padding-right: 6px;
}
.menu > .content-container > .content {
	margin: 4px;
	margin-left: -12px;

	font-size: 0;
}
.menu > .content-container > .content .menu-item {
	line-height: 14px;
}
.menu > .content-container > .content .menu-item .delete {
	left: 0px;
	position: relative;

	color: rgb(255, 0, 0);
	cursor: pointer;
	font-size: 12px;
	margin-left: 4px;
}
.menu > .content-container > .content .menu-item .delete.delete-directory {
	left: -11px;
	position: relative;
}
.menu > .content-container > .content .menu-item .edit {
	cursor: pointer;
	font-size: 12px;
	margin-left: 4px;
}
.menu > .content-container > .content .menu-item .file,
.menu > .content-container > .content .menu-item .folder {
	cursor: default;
	font-size: 12px;
	margin-left: 4px;
}
.menu > .content-container > .content .menu-item > .file-name {
	font-size: 12px;
	margin-left: 4px;
}
.menu > .content-container > .content .menu-item > .move-down-directory {
	left: -11px;
	position: relative;

	cursor: pointer;
	font-size: 12px;
	margin-left: 4px;
}
.menu > .content-container > .content .menu-item > .move-down-file {
	cursor: pointer;
	font-size: 12px;
	margin-left: 4px;
}
.menu > .content-container > .content .menu-item > .move-up-directory {
	left: -11px;
	position: relative;

	cursor: pointer;
	font-size: 12px;
	margin-left: 4px;
}
.menu > .content-container > .content .menu-item > .move-up-file {
	cursor: pointer;
	font-size: 12px;
	margin-left: 4px;
}
.menu > .content-container > .content .menu-item > .new-directory {
	cursor: pointer;
}
.menu > .content-container > .content .menu-item > .new-directory > .plus {
	left: -9px;
	position: relative;
	top: -1px;

	color: rgb(0, 0, 0);
	font-size: 8px;
}
.menu > .content-container > .content .menu-item > .new-file {
	left: -5px;
	position: relative;

	cursor: pointer;
}
.menu > .content-container > .content .menu-item > .new-file > .plus {
	left: -9px;
	position: relative;
	top: -1px;

	color: rgb(0, 0, 0);
	font-size: 8px;
}
.menu > .content-container > .content .menu-item .rename {
	cursor: pointer;
	font-size: 12px;
	margin-left: 4px;
}
.menu > .content-container > .content .menu-item > .upload {
	left: -11px;
	position: relative;

	cursor: pointer;
	font-size: 12px;
	margin-left: 4px;
}
.menu > .control-container {
	min-height: 25px;

	background-color: rgba(128, 128, 128, 0.5);
	color: black;
	cursor: pointer;
	font-size: 24px;
	font-weight: bold;
	padding-top: 3px;
	padding-bottom: 3px;
	text-align: center;
}
.menu > .control-container > .close {
	cursor: pointer;
}
.menu > .search-container {
	position: relative;

	display: inline-block;
	min-height: 26px;

	background-color: rgb(0, 0, 0);
}
.menu > .search-container > .pattern {
	position: absolute;

	left: 18px;
	min-height: 17px;
	min-width: 262px;
	top: 3px;
	z-index: 202;

	background-color: rgba(0, 0, 0, 0.25);
	border-radius: 10px;
	border-width: 0;
	color: rgb(231, 231, 231);
	padding-left: 12px;
	padding-right: 6px;
}
.menu > .search-container > .pattern-container {
	position: absolute;

	display: inline-block;
	left: 12px;
	min-height: 21px;
	min-width: 287px;
	top: 2px;
	z-index: 201;

	background-color: rgba(128, 128, 128, 0.5);
	border-radius: 10px;
}
.menu > .search-container > .search {
	position: absolute;

	display: inline-block;
	height: 21px;
	left: 2px;
	top: 2px;
	width: 26px;
	z-index: 203;

	background-color: rgb(32, 32, 32);
	border-radius: 10px;
	cursor: default;
}
.menu > .search-container > .search > .icon {
	width: 100%;

	color: rgb(255, 255, 0);
	font-size: 12px;
	line-height: 21px;
	text-align: center;
}

/********** MESSAGES **********/
.message {
	min-width: 250px;
	overflow: hidden;
	transition: top 2s, right 2s;

	position: absolute;
	top: 35%;
	right: 50%;
	margin-top: -7px;
	margin-right: -125px;
	z-index: 400;

	padding: 6px;
	border-radius: 6px;
}
.message.error {
	background-color: rgba(255, 0, 0, 0.5);
}
.message.info {
	background-color: rgba(255, 255, 0, 0.5);
}
.message.success {
	background-color: rgba(0, 128, 0, 0.5);
}

/********** PROMPT CONTAINER **********/
.prompt-container {
	position: absolute;
	top: 0;
	left: 0;

	max-height: 100vh;
	min-height: 600px;
	max-width: 100vw;
	min-width: 800px;
	height: 100vh;
	width: 100vw;
	z-index: 300;

	cursor: default;
}
.prompt-container.overlay {
	background-color: rgba(0, 0, 0, 0.35);
}
.prompt-container .prompt {
	min-width: 320px;

	background: rgba(16, 16, 16, 0.65);
	border: 1px solid #000;
	border-radius: 12px;
	padding: 6px;
}
.prompt-container .prompt .close {
	position: absolute;
	right: 0;
	top: 0;

	color: rgb(255, 0, 0);
	cursor: pointer;
	font-size: 12px;
}
.prompt-container .prompt > .content {
	margin-bottom: 36px;
}
.prompt-container .prompt > .content.delete-directory,
.prompt-container .prompt > .content.delete-file,
.prompt-container .prompt > .content.move-down-directory,
.prompt-container .prompt > .content.move-down-file,
.prompt-container .prompt > .content.move-up-directory,
.prompt-container .prompt > .content.move-up-file,
.prompt-container .prompt > .content.new-directory,
.prompt-container .prompt > .content.new-file,
.prompt-container .prompt > .content.upload-file,
.prompt-container .prompt > .content .input.login,
.prompt-container .prompt > .title {
	text-align: center;
}
.prompt-container .prompt > .content > .confirmation {
	color: rgb(255, 255, 0);
	font-weight: bold;
}
.prompt-container .prompt > .content .input input {
	background: rgba(0, 0, 0, 0.5);
	border-width: 0;
	border-radius: 6px;
	color: rgb(128, 128, 128);
	font-family: monospace;
	font-weight: bold;
	margin: 1px;
	padding: 8px;
}
.prompt-container .prompt > .content .input select {
	background: rgba(0, 0, 0, 0.5);
	border-width: 0;
	border-radius: 6px;
	color: rgb(128, 128, 128);
	font-family: monospace;
	font-weight: bold;
	margin: 1px;
	margin-bottom: 12px;
	padding: 8px;
}
.prompt-container .prompt > .content .file-path {
	color: rgb(192, 192, 192);
	font-family: monospace;
	font-weight: bold;
	margin-left: 4px;
}
.prompt-container .prompt > .content .old-name {
	color: rgb(192, 192, 192);
	font-family: monospace;
	font-weight: bold;
	margin-left: 4px;
}
.prompt-container .prompt > .content .prompt-no {
	color: #000;
	cursor: pointer;
	background: rgba(0, 128, 0, 0.5);
	border: 1px solid #000;
	border-radius: 8px;
	font-weight: bold;
	padding: 8px;
}
.prompt-container .prompt > .content .prompt-yes {
	color: #000;
	cursor: pointer;
	background: rgba(255, 0, 0, 0.5);
	border: 1px solid #000;
	border-radius: 8px;
	font-weight: bold;
	padding: 8px;
}
.prompt-container .prompt > .content.upload-file > .input {
	margin: 8px 0;
}
.prompt-container .prompt > .content.upload-file > .input input[type=file] {
	display: none;
}
.prompt-container .prompt > .content.upload-file > .input .newfile {
	background: rgba(0, 0, 0, 0.5);
	border-width: 0;
	border-radius: 6px;
	color: rgb(128, 128, 128);
	display: inline-block;
	font-family: monospace;
	font-weight: bold;
	margin: 1px;
	max-height: 15px;
	min-height: 15px;
	min-width: 160px;
	padding: 8px;
	text-align: left;
}
.prompt-container .prompt > .content.upload-file > .input label {
	color: #000;
	cursor: pointer;
	background: rgba(255, 255, 0, 0.75);
	border: 1px solid #000;
	border-radius: 8px;
	font-weight: bold;
	padding: 8px;
}
.prompt-container .prompt > .title {
	position: relative;

	color: rgb(255, 255, 255);
	font-size: 30px;
	margin-bottom: 12px;
}


text:
public interface InterfaceOverloadingObjectMethods {

    String toString();

    InterfaceOverloadingObjectMethods clone();
}


text:
<?php

namespace Lunr\L10n\Tests;

use Lunr\L10n\L10nHTMLView;

/**
 * Base tests for the localized view class.
 *
 * @covers Lunr\L10n\L10nHTMLView
 */
class L10nHTMLViewBaseTest extends L10nHTMLViewTest
{

    /**
     * Test that the request class is set correctly.
     */
    public function testRequestSetCorrectly(): void
    {
        $this->assertPropertySame('request', $this->request);
    }

    /**
     * Test that the response class is set correctly.
     */
    public function testResponseSetCorrectly(): void
    {
        $this->assertPropertySame('response', $this->response);
    }

    /**
     * Test that the configuration class is set correctly.
     */
    public function testConfigurationSetCorrectly(): void
    {
        $this->assertPropertySame('configuration', $this->configuration);
    }

    /**
     * Test that the l10nprovider class is set correctly.
     */
    public function testL10nProviderSetCorrectly()
    {
        $this->assertPropertySame('l10n', $this->l10nprovider);
    }

}

?>


text:
@class NSArray, NSString;

@protocol IDEGroupCore <IDEContainerItemCore>
@property(copy) NSArray *subitems;
@property(copy) NSString *name;
@property(retain) id  parentContainer;
@end


text:
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!-- ### [Unreleased] -->

### 1.1.2

#### Added
- Added the `setDieOnFatal` function to give users the ability log a fatal error without the runtime calling `die()`
- Throws exception unless run on 64 bit PHP platform

### 1.1.1

#### Changed
- Logs `error_flag` as string values `'true'` or `'false'`

### 1.1.0

#### Changed
- Connects to collector over secure port by default


text:
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.4.RELEASE</version>
	</parent>

	<groupId>br.com.cas10.oraman</groupId>
	<artifactId>oraman</artifactId>
	<version>0.8.0</version>
	<packaging>war</packaging>

	<name>oraman</name>

	<repositories>
		<repository>
			<id>ojdbc-repo</id>
			<url>file://${basedir}/ojdbc-repo</url>
		</repository>
	</repositories>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-security</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>com.google.guava</groupId>
			<artifactId>guava</artifactId>
			<version>18.0</version>
		</dependency>
		<dependency>
			<groupId>com.oracle.jdbc</groupId>
			<artifactId>ojdbc</artifactId>
			<version>any</version>
			<scope>runtime</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<artifactId>maven-checkstyle-plugin</artifactId>
				<version>3.0.0</version>
				<dependencies>
					<dependency>
						<groupId>com.puppycrawl.tools</groupId>
						<artifactId>checkstyle</artifactId>
						<version>8.12</version>
					</dependency>
				</dependencies>
				<executions>
					<execution>
						<id>checkstyle-verify</id>
						<phase>validate</phase>
						<goals>
							<goal>check</goal>
						</goals>
						<configuration>
							<configLocation>${project.basedir}/checkstyle.xml</configLocation>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>src/main/assembly/oraman.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-install-plugin</artifactId>
				<configuration>
					<skip>true</skip>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<properties>
		<checkstyle.violationSeverity>warning</checkstyle.violationSeverity>
	</properties>
</project>


text:
void UIImage::Init()
{
	UIWidget::Init();

	// Init material
	// Color texture
	{
		auto uiMaterialTemplate = MaterialTemplate::Get("UIMaterial_ColorTexture");
		if (!uiMaterialTemplate)
		{
			// Init ui material template
			uiMaterialTemplate = MaterialTemplate::Create("UIMaterial_ColorTexture");
			ASSERT(uiMaterialTemplate);

			auto colorVar = uiMaterialTemplate->NewVariable("color", MATERIAL_VAR_TYPE_SCALAR, 4);
			auto textureVar = uiMaterialTemplate->NewVariable("texture", MATERIAL_VAR_TYPE_TEXTURE, 3);

			auto colorVarOP = uiMaterialTemplate->CreateOperator<MaterialTemplateOpScalarVariable>();
			colorVarOP->varID = colorVar->ID();

			auto textureVarOP = uiMaterialTemplate->CreateOperator<MaterialTemplateOpTextureVariable>();
			textureVarOP->varID = textureVar->ID();

			auto selectRBG = uiMaterialTemplate->CreateOperator<MaterialTemplateOpSelector>();
			selectRBG->channelsCount = 3;
			selectRBG->SetConnector(colorVarOP, RHI_COLOR_CHANNEL_INDEX_R, RHI_COLOR_CHANNEL_INDEX_R);
			selectRBG->SetConnector(colorVarOP, RHI_COLOR_CHANNEL_INDEX_G, RHI_COLOR_CHANNEL_INDEX_G);
			selectRBG->SetConnector(colorVarOP, RHI_COLOR_CHANNEL_INDEX_B, RHI_COLOR_CHANNEL_INDEX_B);

			auto multiply = uiMaterialTemplate->CreateOperator<MaterialTemplateOpMultiply>();
			multiply->src = selectRBG;
			multiply->dst = textureVarOP;

			// color.rbg * texture.rgb
			uiMaterialTemplate->BaseColorSlot().op = multiply;

			// color.a
			auto selectA = uiMaterialTemplate->CreateOperator<MaterialTemplateOpSelector>();
			selectA->SetConnector(colorVarOP, RHI_COLOR_CHANNEL_INDEX_A, RHI_COLOR_CHANNEL_INDEX_R);
			uiMaterialTemplate->OpacitySlot().op = selectA;
		}

		ASSERT(uiMaterialTemplate);
		_textureMaterial = uiMaterialTemplate->CreateInstance();
	}
}

void UIImage::PrepareRendering()
{
	auto showTexture = GetTexture();

	// Switch material
	if (showTexture)
	{
		GetComponent<RenderingComponent>()->SetMaterial(_textureMaterial);

	}
	else
	{
		GetComponent<RenderingComponent>()->SetMaterial(_colorMaterial);
	}

	// Set texture variable
	auto var = _textureMaterial->GetVariable("texture");
	if (var)
		var->AsTexture()->texture = showTexture;

	UIWidget::PrepareRendering();
}

float UIImage::GetPreferredSizeRatio() const
{
	auto showTexture = GetTexture();

	if (ratioRestriction
		&& showTexture
		&& (float)showTexture->Desc().size.y() != 0.0f)
	{
		return (float)showTexture->Desc().size.x() / (float)showTexture->Desc().size.y();
	}
	else
	{
		return 0.0f;
	}
}


text:
package com.linkedin.paldb.impl;

import com.linkedin.paldb.utils.DataInputOutput;
import java.util.Iterator;
import java.util.Map;

/**
 * Store iterable that return store iterator.
 */
public final class ReaderIterable<K, V> implements Iterable<Map.Entry<K, V>> {

  // Iterable
  private Iterable<Map.Entry<byte[], byte[]>> byteIterable;

  // Serialization
  private StorageSerialization serialization;

  /**
   * Constructor.
   *
   * @param byteIterable byte iterator
   * @param serialization serialization
   */
  ReaderIterable(Iterable<Map.Entry<byte[], byte[]>> byteIterable, StorageSerialization serialization) {
    this.byteIterable = byteIterable;
    this.serialization = serialization;
  }

  @Override
  public Iterator<Map.Entry<K, V>> iterator() {
    return new ReaderIterator<K, V>(byteIterable.iterator(), serialization);
  }

  /**
   * Store iterator that streams deserialized key/value entries.
   *

   * Note that entry objects are reused.
   */
  private static final class ReaderIterator<K, V> implements Iterator<Map.Entry<K, V>> {

    // Reusable entry
    private final FastEntry<K, V> entry = new FastEntry<K, V>();
    // Iterator
    private final Iterator<Map.Entry<byte[], byte[]>> byteIterator;
    // Buffer
    private final DataInputOutput dataInputOutput = new DataInputOutput();
    // Serialization
    private StorageSerialization serialization;

    /**
     * Constructor.
     *
     * @param byteIterator byte iterator
     * @param serialization serialization
     */
    ReaderIterator(Iterator<Map.Entry<byte[], byte[]>> byteIterator, StorageSerialization serialization) {
      this.byteIterator = byteIterator;
      this.serialization = serialization;
    }

    @Override
    public boolean hasNext() {
      return byteIterator.hasNext();
    }

    @Override
    public Map.Entry<K, V> next() {
      Map.Entry<byte[], byte[]> byteEntry = byteIterator.next();
      try {
        K key = (K) serialization.deserialize(dataInputOutput.reset(byteEntry.getKey()));
        V value = (V) serialization.deserialize(dataInputOutput.reset(byteEntry.getValue()));
        entry.set(key, value);
      } catch (Exception ex) {
        throw new RuntimeException(ex);
      }
      return entry;
    }

    @Override
    public void remove() {
      throw new UnsupportedOperationException("Not supported.");
    }

    /**
     * Reusable Map.Entry.
     */
    private static class FastEntry<K, V> implements Map.Entry<K, V> {

      private K key;
      private V val;

      /**
       * Sets the key/value
       * @param k key
       * @param v value
       */
      protected void set(K k, V v) {
        this.key = k;
        this.val = v;
      }

      @Override
      public K getKey() {
        return key;
      }

      @Override
      public V getValue() {
        return val;
      }

      @Override
      public Object setValue(Object value) {
        throw new UnsupportedOperationException("Not supported.");
      }
    }
  }
}


text:
(function ($) {
    var options = {
        series: { stack: null } // or number/string
    };

    function init(plot) {
        function findMatchingSeries(s, allseries) {
            var res = null;
            for (var i = 0; i < allseries.length; ++i) {
                if (s === allseries[i]) break;

                if (allseries[i].stack === s.stack) {
                    res = allseries[i];
                }
            }

            return res;
        }

        function addBottomPoints (s, datapoints) {
            var formattedPoints = [];
            for (var i = 0; i < datapoints.points.length; i += 2) {
                formattedPoints.push(datapoints.points[i]);
                formattedPoints.push(datapoints.points[i + 1]);
                formattedPoints.push(0);
            }

            datapoints.format.push({
                x: false,
                y: true,
                number: true,
                required: false,
                computeRange: s.yaxis.options.autoScale !== 'none',
                defaultValue: 0
            });
            datapoints.points = formattedPoints;
            datapoints.pointsize = 3;
        }

        function stackData(plot, s, datapoints) {
            if (s.stack == null || s.stack === false) return;

            var needsBottom = s.bars.show || (s.lines.show && s.lines.fill);
            var hasBottom = datapoints.pointsize > 2 && (horizontal ? datapoints.format[2].x : datapoints.format[2].y);
            // Series data is missing bottom points - need to format
            if (needsBottom && !hasBottom) {
                addBottomPoints(s, datapoints);
            }

            var other = findMatchingSeries(s, plot.getData());
            if (!other) return;

            var ps = datapoints.pointsize,
                points = datapoints.points,
                otherps = other.datapoints.pointsize,
                otherpoints = other.datapoints.points,
                newpoints = [],
                px, py, intery, qx, qy, bottom,
                withlines = s.lines.show,
                horizontal = s.bars.horizontal,
                withsteps = withlines && s.lines.steps,
                fromgap = true,
                keyOffset = horizontal ? 1 : 0,
                accumulateOffset = horizontal ? 0 : 1,
                i = 0, j = 0, l, m;

            while (true) {
                if (i >= points.length) break;

                l = newpoints.length;

                if (points[i] == null) {
                    // copy gaps
                    for (m = 0; m < ps; ++m) {
                        newpoints.push(points[i + m]);
                    }

                    i += ps;
                } else if (j >= otherpoints.length) {
                    // for lines, we can't use the rest of the points
                    if (!withlines) {
                        for (m = 0; m < ps; ++m) {
                            newpoints.push(points[i + m]);
                        }
                    }

                    i += ps;
                } else if (otherpoints[j] == null) {
                    // oops, got a gap
                    for (m = 0; m < ps; ++m) {
                        newpoints.push(null);
                    }

                    fromgap = true;
                    j += otherps;
                } else {
                    // cases where we actually got two points
                    px = points[i + keyOffset];
                    py = points[i + accumulateOffset];
                    qx = otherpoints[j + keyOffset];
                    qy = otherpoints[j + accumulateOffset];
                    bottom = 0;

                    if (px === qx) {
                        for (m = 0; m < ps; ++m) {
                            newpoints.push(points[i + m]);
                        }

                        newpoints[l + accumulateOffset] += qy;
                        bottom = qy;

                        i += ps;
                        j += otherps;
                    } else if (px > qx) {
                        // we got past point below, might need to
                        // insert interpolated extra point
                        if (withlines && i > 0 && points[i - ps] != null) {
                            intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
                            newpoints.push(qx);
                            newpoints.push(intery + qy);
                            for (m = 2; m < ps; ++m) {
                                newpoints.push(points[i + m]);
                            }

                            bottom = qy;
                        }

                        j += otherps;
                    } else { // px < qx
                        if (fromgap && withlines) {
                            // if we come from a gap, we just skip this point
                            i += ps;
                            continue;
                        }

                        for (m = 0; m < ps; ++m) {
                            newpoints.push(points[i + m]);
                        }

                        // we might be able to interpolate a point below,
                        // this can give us a better y
                        if (withlines && j > 0 && otherpoints[j - otherps] != null) {
                            bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx);
                        }

                        newpoints[l + accumulateOffset] += bottom;

                        i += ps;
                    }

                    fromgap = false;

                    if (l !== newpoints.length && needsBottom) {
                        newpoints[l + 2] += bottom;
                    }
                }

                // maintain the line steps invariant
                if (withsteps && l !== newpoints.length && l > 0 &&
                    newpoints[l] !== null &&
                    newpoints[l] !== newpoints[l - ps] &&
                    newpoints[l + 1] !== newpoints[l - ps + 1]) {
                    for (m = 0; m < ps; ++m) {
                        newpoints[l + ps + m] = newpoints[l + m];
                    }

                    newpoints[l + 1] = newpoints[l - ps + 1];
                }
            }

            datapoints.points = newpoints;
        }

        plot.hooks.processDatapoints.push(stackData);
    }

    $.plot.plugins.push({
        init: init,
        options: options,
        name: 'stack',
        version: '1.2'
    });
})(jQuery);


text:
namespace Rosetta.Configuration
{
	public enum ColumnAlignment
	{
		Left,
		Right
	}
}


text:
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using MS.Internal;

namespace System.Windows.Media.Media3D
{
    /// <summary>
    ///     EmissiveMaterial allows a 2d brush to be used on a 3d model that has been lit
    ///     as if it were emitting light equal to the color of the brush
    /// </summary>
    public sealed partial class EmissiveMaterial : Material
    {
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        /// <summary>
        ///     Constructs a EmissiveMaterial
        /// </summary>
        public EmissiveMaterial()
        {

        }

        /// <summary>
        ///     Constructor that sets the Brush property to "brush"
        /// </summary>
        /// <param name="brush">The new material's brush</param>
        public EmissiveMaterial(Brush brush)
        {
            Brush = brush;
        }

        #endregion Constructors

    }
}


text:
var LiveUI = require('../index');
var lui = new LiveUI("2AB3D033-10F8-48E8-9A1E-50A952CB0831");

var http = require('http');
var dispatcher = require('httpdispatcher');

//Lets define a port we want to listen to
const PORT = 8080;

dispatcher.setStatic('resources');

//A sample GET request
dispatcher.onGet("/", function(req, res) {
	var string = '
Page One!! Path Hit: ' + req.url + '
';
	string = string + '
LUITranslate: ' + lui.translation('KEY') + '
';
	string = string + '
LUIImage: ' + lui.image('KEY') + '
';
	string = string + '
LUIColor: ' + lui.color('KEY') + '
';
	string = string + '
LUIColorAlpha: ' + lui.colorAlpha('KEY') + '%
';

    res.writeHead(200, {'Content-Type': 'text/html'});
    res.end(string);
});

//We need a function which handles requests and send response
function handleRequest(request, response) {
    try {
        //log the request on console
        console.log(request.url);
        //Disptach
        dispatcher.dispatch(request, response);
    } catch(err) {
        console.log(err);
    }
}

//Create a server
var server = http.createServer(handleRequest);

//Lets start our server
server.listen(PORT, function(){
    //Callback triggered when server is successfully listening. Hurray!
    console.log("Server listening on: http://localhost:%s", PORT);
});


text:
package ua.com.fielden.platform.example.dnd.classes;

/**
 * Enumeration describing widget orientation.
 *
 * @author 01es
 */
public enum WidgetOrientation {
    VERTICAL, HORIZONTAL;
}


text:
function salient_input_to_target(tensor, semsup)
    local toReturn = {}

    if semsup then
        local categorical = tensor:narrow(2, 1, 10)
        local _, max_indices = categorical:max(2)
        toReturn = max_indices:typeAs(tensor):clone()
    else
        for i = 2, #n_classes_per_lc do
            local cat = tensor:narrow(2, c_offset[i], n_classes_per_lc[i])
            local _, max_idx = cat:max(2)
            max_idx = max_idx:typeAs(tensor):clone()

            toReturn[#toReturn+1] = max_idx
        end

        if n_cont_vars > 0 then
            toReturn[#toReturn+1] = tensor:narrow(2, c_offset[#c_offset], n_cont_vars):clone()
        end
    end

    return toReturn
end

-- Populates `res` such that each row contains a random one-hot vector.
-- That is, each row will be almost full of 0s, except for a 1 in a random
-- position.
function random_one_hot(res)
    local batch_size = res:size(1)
    local n_categories = res:size(2)

    local probabilities = res.new(n_categories):fill(1 / n_categories)
    local indices = torch.multinomial(probabilities, batch_size, true):view(-1, 1)

    res:zero():scatter(2, indices, 1)
end

-- Test input for G to test quality of its samples with respect to C
local G_test_input = {}
local n_classes = n_classes_per_lc[1]
-- Construct the input so that batch_size samples of each class is created
for i = 1, n_classes do
    G_test_input[i] = torch.CudaTensor(batch_size, n_gen_inputs):zero()
    G_test_input[i]:narrow(2, n_salient_vars + 1, n_noise_vars):normal(0, 1)
    G_test_input[i][{{}, {i}}] = torch.ones(batch_size)

    for j=2, #n_classes_per_lc do
        random_one_hot(G_test_input[i]:narrow(2, c_offset[j], n_classes_per_lc[j]))
    end
    if n_cont_vars > 0 then
        G_test_input[i]:narrow(2, n_cat_vars + 1, n_cont_vars):uniform(-1, 1)
    end
end

function test_signal(G, C)
    -- Create the synthetic samples
    G:evaluate()
    C1:evaluate()
    local synthSamples
    local predictions = torch.CudaTensor(n_classes * batch_size, n_classes_per_lc[1])
    for i = 1, n_classes do
        local range1 = (i - 1) * batch_size + 1
        local range2 = i * batch_size
        synthSamples = G:forward(G_test_input[i])
        predictions[{{range1, range2}, {}}] = C1:forward(synthSamples)
    end

    local meanPred = torch.Tensor(n_classes, n_classes):zero()

    for i = 1, n_classes do
        range1 = (i-1)*batch_size + 1
        range2 = i*batch_size
        -- Get the probabilities in [0,1] range
        meanPred[{{i}, {}}] = predictions[{{range1, range2}, {}}]:mean(1):squeeze():float()
    end

    -- Get a greedy bijective mapping from salient class to proper class.
    -- mapping(salient_class) = proper_class
    local mapping = torch.Tensor(n_classes):zero()
    for i = 1, n_classes do
        -- Find maximum probability value
        local r_max_val, r_max_idx = meanPred:max(2)
        local c_max_val, c_max_idx = r_max_val:max(1)
        local row_idx = c_max_idx[1][1]
        local col_idx = r_max_idx[row_idx][1]
        local max_val = meanPred[row_idx][col_idx]
        mapping[row_idx] = col_idx
        -- Assign the salient class mapped to -1 so it does not get mapped again.
        meanPred[{{row_idx}, {}}] = -1
        -- Assign the proper class mapped to -1 so it does not get mapped to again.
        meanPred[{{}, {col_idx}}] = -1
    end

    local loss = torch.Tensor(n_classes):zero()
    for i = 1, n_classes do
        range1 = (i-1)*batch_size + 1
        range2 = i*batch_size

        -- Compute the mean 0-1 loss for each salient class i.
        local _, predClass = predictions[{{range1, range2}, {}}]:max(2)
        loss[i] = predClass:ne(mapping[i]):float():mean()
    end

    return loss:mean()
end

function evaluate_infoHead_real(D)
    local predictions = D:forward(dataset.test_inputs)[2]
    local meanPred = torch.Tensor(n_classes, n_classes):zero()

    for i = 1, n_classes do
        range1 = (i-1)*batch_size + 1
        range2 = i*batch_size
        -- Get the probabilities in [0,1] range
        meanPred[{{i}, {}}] = predictions[{{range1, range2}, {}}]:mean(1):squeeze():float()
    end

    -- Get a greedy bijective mapping from salient class to proper class.
    -- mapping(proper_class) = salient_class
    local mapping = torch.CudaTensor(n_classes):zero()
    for i = 1, n_classes do
        -- Find maximum probability value
        local r_max_val, r_max_idx = meanPred:max(2)
        local c_max_val, c_max_idx = r_max_val:max(1)
        local row_idx = c_max_idx[1][1]
        local col_idx = r_max_idx[row_idx][1]
        local max_val = meanPred[row_idx][col_idx]
        mapping[row_idx] = col_idx
        -- Assign the salient class mapped to -1 so it does not get mapped again.
        meanPred[{{row_idx}, {}}] = -1
        -- Assign the proper class mapped to -1 so it does not get mapped to again.
        meanPred[{{}, {col_idx}}] = -1
    end

    local loss = torch.Tensor(n_classes):zero()
    for i = 1, n_classes do
        range1 = (i-1)*batch_size + 1
        range2 = i*batch_size

        local _, predClass = predictions[{{range1, range2}, {}}]:max(2)
        loss[i] = predClass:ne(mapping[i]):float():mean()
    end

    return loss:mean()
end

function evaluate_infoHead_fake(G, D)
    G:evaluate()

    -- Create the synthetic samples
    local synthSamples = torch.CudaTensor(n_classes * batch_size, samples_dim[1], samples_dim[2], samples_dim[3])
    for i = 1, n_classes do
      local range1 = (i - 1) * batch_size + 1
      local range2 = i * batch_size
      synthSamples[{{range1, range2}, {}}] = G:forward(G_test_input[i])
    end

    -- Evaluate the synthetic samples on the classifier
    local predictions = D:forward(synthSamples)
    local pred_semsup = predictions[2]
    local pred_unsup = predictions[3]
    local loss_semsup = torch.Tensor(n_classes):zero()
    local loss_unsup = torch.Tensor(n_classes):zero()

    for i = 1, n_classes do
        range1 = (i-1)*batch_size + 1
        range2 = i*batch_size

        -- -- Compute the mean 0-1 loss for each salient class i.
        local true_c = salient_input_to_target(G_test_input[i], true)

        -- Compute the mean 0-1 loss for each salient class i.
        local _, predClass = pred_semsup[{{range1, range2}, {}}]:max(2)
        loss_semsup[i] = predClass:long():ne(true_c:long()):float():mean()

        true_c = salient_input_to_target(G_test_input[i], false)

        -- Construct the output
        if n_unsup_vars > 0 then
            local tmp_output = {}
            for j = 1, #pred_unsup do
                tmp_output[j] = pred_unsup[j][{{range1, range2}, {}}]
            end

            loss_unsup[i] = info_head_unsup_crit:forward(tmp_output, true_c)
        end
    end

    return loss_semsup:mean(), loss_unsup:mean()
end


text:
namespace ActivateAssemblyBindingErrorLog
{
    partial class MainFrm
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
            this.logTextBox = new System.Windows.Forms.RichTextBox();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.directoryTextBox = new System.Windows.Forms.TextBox();
            this.browseButton = new System.Windows.Forms.Button();
            this.activeButton = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.checkButton = new System.Windows.Forms.Button();
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.statusStrip1 = new System.Windows.Forms.StatusStrip();
            this.파일FToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.도구TToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.showConsoleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.messageToolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
            this.imageList = new System.Windows.Forms.ImageList(this.components);
            this.statusLabel = new System.Windows.Forms.Label();
            this.openLogDirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.pictureBox = new System.Windows.Forms.PictureBox();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            this.groupBox1.SuspendLayout();
            this.menuStrip1.SuspendLayout();
            this.statusStrip1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
            this.SuspendLayout();
            //
            // splitContainer1
            //
            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
            this.splitContainer1.Location = new System.Drawing.Point(0, 24);
            this.splitContainer1.Name = "splitContainer1";
            this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
            //
            // splitContainer1.Panel1
            //
            this.splitContainer1.Panel1.Controls.Add(this.groupBox1);
            this.splitContainer1.Panel1.Padding = new System.Windows.Forms.Padding(12);
            this.splitContainer1.Panel1MinSize = 190;
            //
            // splitContainer1.Panel2
            //
            this.splitContainer1.Panel2.Controls.Add(this.logTextBox);
            this.splitContainer1.Size = new System.Drawing.Size(444, 282);
            this.splitContainer1.SplitterDistance = 190;
            this.splitContainer1.TabIndex = 0;
            //
            // logTextBox
            //
            this.logTextBox.BackColor = System.Drawing.Color.Black;
            this.logTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.logTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
            this.logTextBox.ForeColor = System.Drawing.Color.White;
            this.logTextBox.Location = new System.Drawing.Point(0, 0);
            this.logTextBox.Name = "logTextBox";
            this.logTextBox.ReadOnly = true;
            this.logTextBox.Size = new System.Drawing.Size(444, 88);
            this.logTextBox.TabIndex = 0;
            this.logTextBox.Text = "";
            //
            // groupBox1
            //
            this.groupBox1.Controls.Add(this.statusLabel);
            this.groupBox1.Controls.Add(this.pictureBox);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Controls.Add(this.checkButton);
            this.groupBox1.Controls.Add(this.activeButton);
            this.groupBox1.Controls.Add(this.browseButton);
            this.groupBox1.Controls.Add(this.directoryTextBox);
            this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.groupBox1.Location = new System.Drawing.Point(12, 12);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Padding = new System.Windows.Forms.Padding(6, 12, 6, 12);
            this.groupBox1.Size = new System.Drawing.Size(420, 166);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Fusion Log";
            //
            // directoryTextBox
            //
            this.directoryTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
            | System.Windows.Forms.AnchorStyles.Right)));
            this.directoryTextBox.Location = new System.Drawing.Point(155, 24);
            this.directoryTextBox.Name = "directoryTextBox";
            this.directoryTextBox.ReadOnly = true;
            this.directoryTextBox.Size = new System.Drawing.Size(175, 22);
            this.directoryTextBox.TabIndex = 0;
            //
            // browseButton
            //
            this.browseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.browseButton.Location = new System.Drawing.Point(336, 24);
            this.browseButton.Name = "browseButton";
            this.browseButton.Size = new System.Drawing.Size(75, 23);
            this.browseButton.TabIndex = 1;
            this.browseButton.Text = "Browse";
            this.browseButton.UseVisualStyleBackColor = true;
            //
            // activeButton
            //
            this.activeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.activeButton.Location = new System.Drawing.Point(321, 128);
            this.activeButton.Name = "activeButton";
            this.activeButton.Size = new System.Drawing.Size(90, 23);
            this.activeButton.TabIndex = 2;
            this.activeButton.Text = "Deactivate";
            this.activeButton.UseVisualStyleBackColor = true;
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(9, 27);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(140, 13);
            this.label1.TabIndex = 3;
            this.label1.Text = "Log file directory:";
            //
            // checkButton
            //
            this.checkButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.checkButton.Location = new System.Drawing.Point(9, 128);
            this.checkButton.Name = "checkButton";
            this.checkButton.Size = new System.Drawing.Size(75, 23);
            this.checkButton.TabIndex = 2;
            this.checkButton.Text = "Check";
            this.checkButton.UseVisualStyleBackColor = true;
            //
            // menuStrip1
            //
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.파일FToolStripMenuItem,
            this.도구TToolStripMenuItem,
            this.aboutToolStripMenuItem});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(444, 24);
            this.menuStrip1.TabIndex = 1;
            this.menuStrip1.Text = "menuStrip1";
            //
            // statusStrip1
            //
            this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.messageToolStripStatusLabel1});
            this.statusStrip1.Location = new System.Drawing.Point(0, 306);
            this.statusStrip1.Name = "statusStrip1";
            this.statusStrip1.Size = new System.Drawing.Size(444, 22);
            this.statusStrip1.TabIndex = 2;
            this.statusStrip1.Text = "statusStrip1";
            //
            // 파일FToolStripMenuItem
            //
            this.파일FToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.exitToolStripMenuItem});
            this.파일FToolStripMenuItem.Name = "파일FToolStripMenuItem";
            this.파일FToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
            this.파일FToolStripMenuItem.Text = "&File";
            //
            // exitToolStripMenuItem
            //
            this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
            this.exitToolStripMenuItem.Size = new System.Drawing.Size(92, 22);
            this.exitToolStripMenuItem.Text = "E&xit";
            //
            // 도구TToolStripMenuItem
            //
            this.도구TToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.showConsoleToolStripMenuItem,
            this.openLogDirectoryToolStripMenuItem});
            this.도구TToolStripMenuItem.Name = "도구TToolStripMenuItem";
            this.도구TToolStripMenuItem.Size = new System.Drawing.Size(47, 20);
            this.도구TToolStripMenuItem.Text = "&Tools";
            //
            // showConsoleToolStripMenuItem
            //
            this.showConsoleToolStripMenuItem.Name = "showConsoleToolStripMenuItem";
            this.showConsoleToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
            this.showConsoleToolStripMenuItem.Text = "Console";
            //
            // messageToolStripStatusLabel1
            //
            this.messageToolStripStatusLabel1.Name = "messageToolStripStatusLabel1";
            this.messageToolStripStatusLabel1.Size = new System.Drawing.Size(39, 17);
            this.messageToolStripStatusLabel1.Text = "Ready";
            //
            // imageList
            //
            this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
            this.imageList.ImageSize = new System.Drawing.Size(16, 16);
            this.imageList.TransparentColor = System.Drawing.Color.Transparent;
            //
            // statusLabel
            //
            this.statusLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            | System.Windows.Forms.AnchorStyles.Left)
            | System.Windows.Forms.AnchorStyles.Right)));
            this.statusLabel.Font = new System.Drawing.Font("DotumChe", 36F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
            this.statusLabel.Location = new System.Drawing.Point(88, 55);
            this.statusLabel.Name = "statusLabel";
            this.statusLabel.Size = new System.Drawing.Size(323, 65);
            this.statusLabel.TabIndex = 5;
            this.statusLabel.Text = "label2";
            this.statusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            //
            // openLogDirectoryToolStripMenuItem
            //
            this.openLogDirectoryToolStripMenuItem.Name = "openLogDirectoryToolStripMenuItem";
            this.openLogDirectoryToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
            this.openLogDirectoryToolStripMenuItem.Text = "Open Log Directory";
            //
            // aboutToolStripMenuItem
            //
            this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
            this.aboutToolStripMenuItem.Size = new System.Drawing.Size(52, 20);
            this.aboutToolStripMenuItem.Text = "About";
            //
            // pictureBox
            //
            this.pictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            | System.Windows.Forms.AnchorStyles.Left)));
            this.pictureBox.Location = new System.Drawing.Point(12, 52);
            this.pictureBox.Name = "pictureBox";
            this.pictureBox.Size = new System.Drawing.Size(70, 72);
            this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
            this.pictureBox.TabIndex = 4;
            this.pictureBox.TabStop = false;
            //
            // MainFrm
            //
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
            this.ClientSize = new System.Drawing.Size(444, 328);
            this.Controls.Add(this.splitContainer1);
            this.Controls.Add(this.statusStrip1);
            this.Controls.Add(this.menuStrip1);
            this.DoubleBuffered = true;
            this.Font = new System.Drawing.Font("DotumChe", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.MainMenuStrip = this.menuStrip1;
            this.MinimumSize = new System.Drawing.Size(460, 320);
            this.Name = "MainFrm";
            this.Text = "Fusion Log";
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
            this.splitContainer1.ResumeLayout(false);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.statusStrip1.ResumeLayout(false);
            this.statusStrip1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.SplitContainer splitContainer1;
        private System.Windows.Forms.RichTextBox logTextBox;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button checkButton;
        private System.Windows.Forms.Button activeButton;
        private System.Windows.Forms.Button browseButton;
        private System.Windows.Forms.TextBox directoryTextBox;
        private System.Windows.Forms.MenuStrip menuStrip1;
        private System.Windows.Forms.ToolStripMenuItem 파일FToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 도구TToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem showConsoleToolStripMenuItem;
        private System.Windows.Forms.StatusStrip statusStrip1;
        private System.Windows.Forms.ToolStripStatusLabel messageToolStripStatusLabel1;
        private System.Windows.Forms.ImageList imageList;
        private System.Windows.Forms.PictureBox pictureBox;
        private System.Windows.Forms.Label statusLabel;
        private System.Windows.Forms.ToolStripMenuItem openLogDirectoryToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
    }
}