text:
module SimpleQueue (
    -- type of simple queues
    Seq, -- instance of Sequence, Functor, Monad, MonadPlus

    -- sequence operations
    empty,single,cons,snoc,append,lview,lhead,ltail,rview,rhead,rtail,
    null,size,concat,reverse,reverseOnto,fromList,toList,
    map,concatMap,foldr,foldl,foldr1,foldl1,reducer,reducel,reduce1,
    copy,tabulate,inBounds,lookup,lookupM,lookupWithDefault,update,adjust,
    mapWithIndex,foldrWithIndex,foldlWithIndex,
    take,drop,splitAt,subseq,filter,partition,takeWhile,dropWhile,splitWhile,
    zip,zip3,zipWith,zipWith3,unzip,unzip3,unzipWith,unzipWith3,

    -- documentation
    moduleName,

    -- re-export view type from EdisonPrelude for convenience
    Maybe2(Just2,Nothing2)
) where

import Prelude hiding (concat,reverse,map,concatMap,foldr,foldl,foldr1,foldl1,
                       filter,takeWhile,dropWhile,lookup,take,drop,splitAt,
                       zip,zip3,zipWith,zipWith3,unzip,unzip3,null)

import EdisonPrelude(Maybe2(Just2,Nothing2))
import qualified Sequence as S ( Sequence(..) )
import SequenceDefaults
import qualified ListSeq as L
import Monad
import QuickCheck

-- signatures for exported functions
moduleName     :: String
empty          :: Seq a
single         :: a -> Seq a
cons           :: a -> Seq a -> Seq a
snoc           :: Seq a -> a -> Seq a
append         :: Seq a -> Seq a -> Seq a
lview          :: Seq a -> Maybe2 a (Seq a)
lhead          :: Seq a -> a
ltail          :: Seq a -> Seq a
rview          :: Seq a -> Maybe2 (Seq a) a
rhead          :: Seq a -> a
rtail          :: Seq a -> Seq a
null           :: Seq a -> Bool
size           :: Seq a -> Int
concat         :: Seq (Seq a) -> Seq a
reverse        :: Seq a -> Seq a
reverseOnto    :: Seq a -> Seq a -> Seq a
fromList       :: [a] -> Seq a
toList         :: Seq a -> [a]
map            :: (a -> b) -> Seq a -> Seq b
concatMap      :: (a -> Seq b) -> Seq a -> Seq b
foldr          :: (a -> b -> b) -> b -> Seq a -> b
foldl          :: (b -> a -> b) -> b -> Seq a -> b
foldr1         :: (a -> a -> a) -> Seq a -> a
foldl1         :: (a -> a -> a) -> Seq a -> a
reducer        :: (a -> a -> a) -> a -> Seq a -> a
reducel        :: (a -> a -> a) -> a -> Seq a -> a
reduce1        :: (a -> a -> a) -> Seq a -> a
copy           :: Int -> a -> Seq a
tabulate       :: Int -> (Int -> a) -> Seq a
inBounds       :: Seq a -> Int -> Bool
lookup         :: Seq a -> Int -> a
lookupM        :: Seq a -> Int -> Maybe a
lookupWithDefault :: a -> Seq a -> Int -> a
update         :: Int -> a -> Seq a -> Seq a
adjust         :: (a -> a) -> Int -> Seq a -> Seq a
mapWithIndex   :: (Int -> a -> b) -> Seq a -> Seq b
foldrWithIndex :: (Int -> a -> b -> b) -> b -> Seq a -> b
foldlWithIndex :: (b -> Int -> a -> b) -> b -> Seq a -> b
take           :: Int -> Seq a -> Seq a
drop           :: Int -> Seq a -> Seq a
splitAt        :: Int -> Seq a -> (Seq a, Seq a)
subseq         :: Int -> Int -> Seq a -> Seq a
filter         :: (a -> Bool) -> Seq a -> Seq a
partition      :: (a -> Bool) -> Seq a -> (Seq a, Seq a)
takeWhile      :: (a -> Bool) -> Seq a -> Seq a
dropWhile      :: (a -> Bool) -> Seq a -> Seq a
splitWhile     :: (a -> Bool) -> Seq a -> (Seq a, Seq a)
zip            :: Seq a -> Seq b -> Seq (a,b)
zip3           :: Seq a -> Seq b -> Seq c -> Seq (a,b,c)
zipWith        :: (a -> b -> c) -> Seq a -> Seq b -> Seq c
zipWith3       :: (a -> b -> c -> d) -> Seq a -> Seq b -> Seq c -> Seq d
unzip          :: Seq (a,b) -> (Seq a, Seq b)
unzip3         :: Seq (a,b,c) -> (Seq a, Seq b, Seq c)
unzipWith      :: (a -> b) -> (a -> c) -> Seq a -> (Seq b, Seq c)
unzipWith3     :: (a -> b) -> (a -> c) -> (a -> d) -> Seq a -> (Seq b, Seq c, Seq d)

moduleName = "SimpleQueue"

-- Adapted from
--   Chris Okasaki. Purely Functional Data Structures. 1998.
--   Section 5.2.
-- and
--   F. Warren Burton. "An efficient functional implementation of FIFO queues".
--   Information Processing Letters, 14(5):205-206, July 1982.

data Seq a = Q [a] [a]
  -- invariant: front empty only if rear also empty

-- not exported
makeQ [] ys = Q (L.reverse ys) []
makeQ xs ys = Q xs ys

empty = Q [] []
single x = Q [x] []
cons x (Q xs ys) = Q (x:xs) ys

snoc (Q [] _) y = Q [y] []
snoc (Q xs ys) y = Q xs (y:ys)

append (Q xs1 ys1) (Q xs2 ys2) =
    Q (xs1 ++ L.reverseOnto ys1 xs2) ys2

lview (Q [] _) = Nothing2
lview (Q [x] ys) = Just2 x (Q (L.reverse ys) [])
lview (Q (x:xs) ys) = Just2 x (Q xs ys)

lhead (Q [] _) = error "SimpleQueue.lhead: empty sequence"
lhead (Q (x:xs) _) = x

ltail (Q [x] ys) = Q (L.reverse ys) []
ltail (Q (x:xs) ys) = Q xs ys
ltail q@(Q [] _) = q

rview (Q xs (y:ys)) = Just2 (Q xs ys) y
rview (Q xs []) =
  case L.rview xs of
    Nothing2 -> Nothing2
    Just2 xs' x -> Just2 (Q xs' []) x

rhead (Q xs (y:ys)) = y
rhead (Q [] []) = error "SimpleQueue.rhead: empty sequence"
rhead (Q xs []) = L.rhead xs

rtail (Q xs (y:ys)) = Q xs ys
rtail q@(Q [] []) = q
rtail (Q xs []) = Q (L.rtail xs) []

null (Q [] _) = True
null _ = False

size (Q xs ys) = length xs + length ys

reverse (Q xs []) = Q (L.reverse xs) []
reverse (Q xs ys) = Q ys xs

reverseOnto (Q xs1 ys1) (Q xs2 ys2) =
    Q (ys1 ++ L.reverseOnto xs1 xs2) ys2

fromList xs = Q xs []

toList (Q xs []) = xs
toList (Q xs ys) = xs ++ L.reverse ys

map f (Q xs ys) = Q (L.map f xs) (L.map f ys)

-- local fn on lists
revfoldr f e [] = e
revfoldr f e (x:xs) = revfoldr f (f x e) xs

-- local fn on lists
revfoldl f e [] = e
revfoldl f e (x:xs) = f (revfoldl f e xs) x

foldr f e (Q xs ys) = L.foldr f (revfoldr f e ys) xs

foldl f e (Q xs ys) = revfoldl f (L.foldl f e xs) ys

foldr1 f (Q xs (y:ys)) = L.foldr f (revfoldr f y ys) xs
foldr1 f (Q [] []) = error "SimpleQueue.foldr1: empty sequence"
foldr1 f (Q xs []) = L.foldr1 f xs

foldl1 f (Q (x:xs) ys) = revfoldl f (L.foldl f x xs) ys
foldl1 f (Q [] _) = error "SimpleQueue.foldl1: empty sequence"

filter p (Q xs ys) = makeQ (L.filter p xs) (L.filter p ys)

partition p (Q xs ys)
  = (makeQ xsT ysT, makeQ xsF ysF)
 where
   (xsT,xsF) = L.partition p xs
   (ysT,ysF) = L.partition p ys

-- the remaining functions all use defaults

concat = concatUsingFoldr
concatMap = concatMapUsingFoldr
reducer = reducerUsingReduce1
reducel = reducelUsingReduce1
reduce1 = reduce1UsingLists
copy = copyUsingLists
tabulate = tabulateUsingLists
inBounds = inBoundsUsingLookupM
lookup = lookupUsingLookupM
lookupM = lookupMUsingDrop
lookupWithDefault = lookupWithDefaultUsingLookupM
update = updateUsingAdjust
adjust = adjustUsingLists
mapWithIndex = mapWithIndexUsingLists
foldrWithIndex = foldrWithIndexUsingLists
foldlWithIndex = foldlWithIndexUsingLists
take = takeUsingLists
drop = dropUsingLists
splitAt = splitAtDefault
subseq = subseqDefault
takeWhile = takeWhileUsingLview
dropWhile = dropWhileUsingLview
splitWhile = splitWhileUsingLview
zip = zipUsingLists
zip3 = zip3UsingLists
zipWith = zipWithUsingLists
zipWith3 = zipWith3UsingLists
unzip = unzipUsingLists
unzip3 = unzip3UsingLists
unzipWith = unzipWithUsingLists
unzipWith3 = unzipWith3UsingLists

-- instances

instance S.Sequence Seq where
  {empty = empty; single = single; cons = cons; snoc = snoc;
   append = append; lview = lview; lhead = lhead; ltail = ltail;
   rview = rview; rhead = rhead; rtail = rtail; null = null;
   size = size; concat = concat; reverse = reverse;
   reverseOnto = reverseOnto; fromList = fromList; toList = toList;
   map = map; concatMap = concatMap; foldr = foldr; foldl = foldl;
   foldr1 = foldr1; foldl1 = foldl1; reducer = reducer;
   reducel = reducel; reduce1 = reduce1; copy = copy;
   tabulate = tabulate; inBounds = inBounds; lookup = lookup;
   lookupM = lookupM; lookupWithDefault = lookupWithDefault;
   update = update; adjust = adjust;
   mapWithIndex = mapWithIndex;
   foldrWithIndex = foldrWithIndex; foldlWithIndex = foldlWithIndex;
   take = take; drop = drop; splitAt = splitAt; subseq = subseq;
   filter = filter; partition = partition; takeWhile = takeWhile;
   dropWhile = dropWhile; splitWhile = splitWhile; zip = zip;
   zip3 = zip3; zipWith = zipWith; zipWith3 = zipWith3; unzip = unzip;
   unzip3 = unzip3; unzipWith = unzipWith; unzipWith3 = unzipWith3;
   instanceName s = moduleName}

instance Functor Seq where
  fmap = map

instance Monad Seq where
  return = single
  xs >>= k = concatMap k xs

instance MonadPlus Seq where
  mplus = append
  mzero = empty

instance Eq a => Eq (Seq a) where
  q1 == q2 = toList q1 == toList q2

instance Show a => Show (Seq a) where
  show q = show (toList q)

instance Arbitrary a => Arbitrary (Seq a) where
  arbitrary = do xs <- arbitrary
                 ys <- arbitrary
                 return (if L.null xs then Q ys [] else Q xs ys)

  coarbitrary (Q xs ys) = coarbitrary xs . coarbitrary ys


text:
package com.twitter.scalding

import org.scalatest.{ Matchers, WordSpec }

import java.io.BufferedWriter
import java.io.FileWriter
import scala.io.Source.fromFile
import java.io.File
import cascading.cascade.Cascade
import cascading.flow.FlowSkipIfSinkNotStale

class Job1(args: Args) extends Job(args) {
  Tsv(args("input0"), ('line)).pipe.map[String, String]('line -> 'line)((x: String) => "job1:" + x).write(Tsv(args("output0"), fields = 'line))
}

class Job2(args: Args) extends Job(args) {
  Tsv(args("output0"), ('line)).pipe.map[String, String]('line -> 'line)((x: String) => "job2" + x).write(Tsv(args("output1")))
}

class CascadeTestJob(args: Args) extends CascadeJob(args) {

  val jobs = List(new Job1(args), new Job2(args))

  override def preProcessCascade(cascade: Cascade) = {
    cascade.setFlowSkipStrategy(new FlowSkipIfSinkNotStale())
  }

  override def postProcessCascade(cascade: Cascade) = {
    println(cascade.getCascadeStats())
  }

}

class TwoPhaseCascadeTest extends WordSpec with Matchers with FieldConversions {
  "A Cascade job" should {
    CascadeTest("com.twitter.scalding.CascadeTestJob")
      .arg("input0", "input0")
      .arg("output0", "output0")
      .arg("output1", "output1")
      .source(Tsv("input0", ('line)), List(Tuple1("line1"), Tuple1("line2"), Tuple1("line3"), Tuple1("line4")))
      .sink[String](Tsv("output1")) { ob =>
        "verify output got changed by both flows" in {
          ob.toList shouldBe List("job2job1:line1", "job2job1:line2", "job2job1:line3", "job2job1:line4")
        }
      }
      .runHadoop
      .finish
  }

  "A Cascade job run though Tool.main" should {
    val input0 = File.createTempFile("cascading-job-input0-", "")
    input0.mkdirs()

    val writer = new BufferedWriter(new FileWriter(input0));
    writer.write("a\nb\nc\nd\ne");
    writer.close();

    val output0 = File.createTempFile("cascading-job-output0-", "")
    output0.mkdir()

    val output1 = File.createTempFile("cascading-job-output1-", "")
    output1.mkdir()

    val args = Array[String]("com.twitter.scalding.CascadeTestJob", "--local",
      "--input0", input0.getAbsolutePath,
      "--output0", output0.getAbsolutePath,
      "--output1", output1.getAbsolutePath)

    Tool.main(args)

    val lines = fromFile(output1.getAbsolutePath).getLines.toList

    "verify output got changed by both flows" in {
      lines shouldBe List("job2job1:a", "job2job1:b", "job2job1:c", "job2job1:d", "job2job1:e")
    }

    input0.delete()
    output0.delete()
    output1.delete()

    ()
  }
}

redpajama_set_name: RedPajamaGithub


text:
package org.assertj.core.api.atomic.referencearray;

import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.test.AlwaysEqualStringComparator.ALWAY_EQUALS;

import java.util.Comparator;
import java.util.concurrent.atomic.AtomicReferenceArray;

import org.assertj.core.api.AtomicReferenceArrayAssert;
import org.assertj.core.api.AtomicReferenceArrayAssertBaseTest;
import org.assertj.core.internal.AtomicReferenceArrayElementComparisonStrategy;
import org.assertj.core.internal.ComparatorBasedComparisonStrategy;
import org.assertj.core.internal.ObjectArrays;
import org.junit.Before;
import org.junit.Test;

public class AtomicReferenceArrayAssert_usingRecursiveFieldByFieldElementComparator_Test
    extends AtomicReferenceArrayAssertBaseTest {

  private ObjectArrays arraysBefore;

  @Before
  public void before() {
    arraysBefore = getArrays(assertions);
  }

  @Override
  protected AtomicReferenceArrayAssert<Object> invoke_api_method() {
    return assertions.usingRecursiveFieldByFieldElementComparator();
  }

  @Override
  protected void verify_internal_effects() {
    assertThat(arraysBefore).isNotSameAs(getArrays(assertions));
    assertThat(getArrays(assertions).getComparisonStrategy()).isInstanceOf(ComparatorBasedComparisonStrategy.class);
    assertThat(getObjects(assertions).getComparisonStrategy()).isInstanceOf(AtomicReferenceArrayElementComparisonStrategy.class);
  }

  @Test
  public void successful_isEqualTo_assertion_using_recursive_field_by_field_element_comparator() {
    AtomicReferenceArray<Foo> array1 = atomicArrayOf(new Foo("id", new Bar(1)));
    Foo[] array2 = { new Foo("id", new Bar(1)) };
    assertThat(array1).usingRecursiveFieldByFieldElementComparator().isEqualTo(array2);
  }

  @Test
  public void successful_isIn_assertion_using_recursive_field_by_field_element_comparator() {
    AtomicReferenceArray<Foo> array1 = atomicArrayOf(new Foo("id", new Bar(1)));
    Foo[] array2 = { new Foo("id", new Bar(1)) };
    assertThat(array1).usingRecursiveFieldByFieldElementComparator().isIn(new Object[] { (array2) });
  }

  @Test
  public void failed_isEqualTo_assertion_using_recursive_field_by_field_element_comparator() {
    AtomicReferenceArray<Foo> array1 = atomicArrayOf(new Foo("id", new Bar(1)));
    Foo[] array2 = { new Foo("id", new Bar(2)) };
    try {
      assertThat(array1).usingRecursiveFieldByFieldElementComparator().isEqualTo(array2);
    } catch (AssertionError e) {
      // @format:off
      assertThat(e).hasMessage(format("%nExpecting:%n" +
                                      " <[Foo(id=id, bar=Bar [id=1])]>%n" +
                                      "to be equal to:%n" +
                                      " <[Foo(id=id, bar=Bar [id=2])]>%n" +
                                      "when comparing elements using 'recursive field/property by field/property comparator on all fields/properties' but was not."));
      // @format:on
      return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
  }

  @Test
  public void failed_isIn_assertion_using_recursive_field_by_field_element_comparator() {
    AtomicReferenceArray<Foo> array1 = atomicArrayOf(new Foo("id", new Bar(1)));
    Foo[] array2 = { new Foo("id", new Bar(2)) };
    try {
      assertThat(array1).usingRecursiveFieldByFieldElementComparator().isIn(new Object[] { array2 });
    } catch (AssertionError e) {
      assertThat(e).hasMessage(format("%nExpecting:%n" +
                                      " <[Foo(id=id, bar=Bar [id=1])]>%n" +
                                      "to be in:%n" +
                                      " <[[Foo(id=id, bar=Bar [id=2])]]>%n" +
                                      "when comparing elements using 'recursive field/property by field/property comparator on all fields/properties'"));
      return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
  }

  @Test
  public void should_be_able_to_use_a_comparator_for_specified_fields_of_elements_when_using_recursive_field_by_field_element_comparator() {
    Foo actual = new Foo("1", new Bar(1));
    Foo other = new Foo("1", new Bar(2));
    final class AlwaysEqualIntegerComparator implements Comparator<Integer> {
      @Override
      public int compare(Integer o1, Integer o2) {
        return 0;
      }
    }

    assertThat(atomicArrayOf(actual)).usingComparatorForElementFieldsWithNames(new AlwaysEqualIntegerComparator(),
                                                                               "bar.id")
                                     .usingRecursiveFieldByFieldElementComparator()
                                     .contains(other);
  }

  @Test
  public void comparators_for_element_field_names_should_have_precedence_over_comparators_for_element_field_types_when_using_recursive_field_by_field_element_comparator() {
    Comparator<String> comparator = new Comparator<String>() {
      public int compare(String o1, String o2) {
        return o1.compareTo(o2);
      }
    };
    Foo actual = new Foo("1", new Bar(1));
    Foo other = new Foo("2", new Bar(1));

    assertThat(atomicArrayOf(actual)).usingComparatorForElementFieldsWithNames(ALWAY_EQUALS, "id")
                                     .usingComparatorForElementFieldsWithType(comparator, String.class)
                                     .usingRecursiveFieldByFieldElementComparator()
                                     .contains(other);
  }

  @Test
  public void should_be_able_to_use_a_comparator_for_element_fields_with_specified_type_when_using_recursive_field_by_field_element_comparator() {
    Foo actual = new Foo("1", new Bar(1));
    Foo other = new Foo("2", new Bar(1));

    assertThat(atomicArrayOf(actual)).usingComparatorForElementFieldsWithType(ALWAY_EQUALS, String.class)
                                     .usingRecursiveFieldByFieldElementComparator()
                                     .contains(other);
  }

  public static class Foo {
    public String id;
    public Bar bar;

    public Foo(String id, Bar bar) {
      this.id = id;
      this.bar = bar;
    }

    @Override
    public String toString() {
      return "Foo(id=" + id + ", bar=" + bar + ")";
    }
  }

  public static class Bar {
    public int id;

    public Bar(int id) {
      this.id = id;
    }

    @Override
    public String toString() {
      return "Bar [id=" + id + "]";
    }
  }
}


text:
/*********************************************************************************************************************/
/*   File Name: angbase.h                                                                                */
/*   Author: Ing. Jesus Rocha <chuyangel.rm@gmail.com>, July 2016.                                                   */
/*   File description: this file is exposes many native types and wrappers for them as well as useful macros.        */
/*                                                                                */
/*   Copyright (C) angsys, Jesus Angel Rocha Morales                                                                 */
/*   You may opt to use, copy, modify, merge, publish and/or distribute copies of the Software, and permit persons   */
/*   to whom the Software is furnished to do so.                                                                     */
/*   This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.      */
/*                                                                                */
/*********************************************************************************************************************/

#ifndef __ANG_BASE_H__
#define __ANG_BASE_H__

#include <angtypes.h>
#include <ang/utils.h>
#include <ang/interface.h>
#include <ang/enum.h>

#ifdef LINK
#undef LINK
#endif//LINK

#if defined WINDOWS_PLATFORM
#if defined ANGSYS_DYNAMIC_LIBRARY

#ifdef ANGSYS_EXPORTS
#define LINK __declspec(dllexport)
#else
#define LINK __declspec(dllimport)
#endif//ANGSYS_EXPORTS
#else//#elif defined ANGSYS_STATIC_LIBRARY
#define LINK
#endif//ANGSYS_DYNAMIC_LIBRARY
#elif defined LINUX_PLATFORM || defined ANDROID_PLATFORM
#define LINK
#else
#define LINK
#endif

namespace ang
{
	class object;
	class safe_pointer;
	template<typename T> struct value;
	template<typename T> class intf_wrapper;
	template<typename T> class object_wrapper;
	template<typename T> class intf_wrapper_ptr;
	template<typename T> class object_wrapper_ptr;

	typedef object_wrapper<object> object_t;
	typedef object_t objptr;

	class exception_data;
	typedef object_wrapper<exception_data> exception_t;
	typedef exception_t exception;
	//typedef exception

	typedef decltype(nullptr) nullptr_t;
	template<typename T> using initializer_list_t = std::initializer_list<T>;

	windex const invalid_index = -1;
	nullptr_t const null = {};

	typedef value<pointer>			unknown_t;
	typedef value<pointer*>			unknown_ptr_t;

	typedef value<char*>			str_t;
	typedef value<wchar*>			wstr_t;
	typedef value<mchar*>			mstr_t;
	typedef value<char const*>		cstr_t;
	typedef value<wchar const*>		cwstr_t;
	typedef value<mchar const*>		cmstr_t;
	typedef value<char const*>		type_name_t;

	namespace collections
	{
		const wsize ITERATOR_TYPE_DEFAULT = 0;
		const wsize ITERATOR_TYPE_REVERSE = 1;

		template<typename T> class iterator;
		template<typename T> class base_iterator;
		template<typename T> class forward_iterator;
		template<typename T> class backward_iterator;

		template<typename T> using const_iterator = iterator<const T>;
		template<typename T> using const_forward_iterator = forward_iterator<const T>;
		template<typename T> using const_backward_iterator = backward_iterator<const T>;

		template<typename T> struct static_array;
		template<typename T> using static_const_array = struct static_array<const T>;
		template<class T> class array_buffer;
		template<class K, class T>struct pair;
		template<typename T>using array_t = object_wrapper<array_buffer<T>>;
		template<typename T>using array = array_t<T>;
	}

	using collections::array;
	using collections::static_array;
	using collections::static_const_array;

	namespace strings
	{
		class string_buffer;
		class wstring_buffer;
		class mstring_buffer;

		typedef object_wrapper<string_buffer> string, string_t;
		typedef object_wrapper<wstring_buffer> wstring, wstring_t;
		typedef object_wrapper<mstring_buffer> mstring, mstring_t;
	}

	using strings::string;
	using strings::wstring;
	using strings::mstring;

}

#include <ang/value.h>
#include <ang/stringbase.h>
#include <ang/value/mbyte.h>
#include <ang/value/char.h>
#include <ang/value/static_array.h>
#include <ang/runtime.h>
#include <ang/properties.h>

namespace ang
{
	/******************************************************************/
	/* enum ang::comparision_result_t :                                */
	/*  -> represents the result of a comparison operation            */
	/******************************************************************/
	ANG_BEGIN_ENUM(LINK, comparision_result, int)
		minor = -1,
		same = 0,
		mayor = 1,
		diferent = 20
	ANG_END_ENUM(comparision_result);

	/******************************************************************/
	/* interface ang::interface_t :                                   */
	/*  -> implements basic methods for dynamic naming and conversion */
	/******************************************************************/
	typedef struct _interface
	{
		visible virtual type_name_t object_name()const pure;
		visible virtual bool is_kind_of(type_name_t)const pure;
		visible virtual bool query_object(type_name_t, unknown_ptr_t) pure;
	}interface_t, *interface_ptr_t;

	typedef intf_wrapper<interface_t> intfptr;

	/******************************************************************/
	/* interface ang::iobject :                                       */
	/*  -> implements basic methods for smart pointer management      */
	/******************************************************************/
	ANG_BEGIN_INTERFACE(LINK, iobject)
		visible vcall dword add_ref() pure;
		visible vcall dword release() pure;
	ANG_END_INTERFACE();

#if defined _DEBUG || defined _DEVELOPPER
	namespace debug
	{
		/******************************************************************/
		/* enum ang::debug::log_level :                                   */
		/*  -> describes the log level only available for debug config.   */
		/******************************************************************/
		ANG_BEGIN_ENUM(LINK, log_level, int)
			verbose = 0,
			info = 1,
			warning = 2,
			error = 3
		ANG_END_ENUM(log_level);

		/******************************************************************/
		/* interface ang::debug::ilogger :                                */
		/*  -> interface used to print messages to debug output console   */
		/******************************************************************/
		ANG_BEGIN_INTERFACE(LINK, ilogger)
			visible vcall void print(log_level_t, cstr_t, ...)const pure;
		ANG_END_INTERFACE();
		typedef intf_wrapper<ilogger> ilogger_t;

		extern ilogger* get_platform_logger();
	}
#endif

	namespace memory
	{
		/******************************************************************/
		/* interface ang::memory::iallocator :                            */
		/*  -> implements methods for memory allocation and releasing     */
		/******************************************************************/
		ANG_BEGIN_INTERFACE(LINK, iallocator)
			visible vcall bool can_delete_from(iallocator*)const pure;
			visible vcall pointer malloc(wsize)pure;
			visible vcall void free(pointer)pure;
#if defined _DEBUG || defined _DEVELOPPER
#ifdef _DEBUG
			visible vcall pointer malloc(wsize, const char* file, int line)pure;
#endif
			visible vcall void set_logger(debug::ilogger_t)pure;
#endif
			template<class obj_t> obj_t* alloc_object(wsize count, const char* file = NULL, int line = 0) {
				if (count == 0) return null;
#ifdef _DEBUG
				return static_cast<obj_t*>(malloc(count * sizeof(obj_t), file, line));
#else
				return static_cast<obj_t*>(malloc(count * sizeof(obj_t)));
#endif
			}

			template<class obj_t, class... args_t> obj_t* construct(obj_t* obj, args_t... args)const {
				return new((pointer)obj)obj_t(args...);
			}
			template<class obj_t> pointer destruct(obj_t* obj)const {
				if (obj)
					obj->~obj_t();
				return obj;
			}
		ANG_END_INTERFACE();

		/******************************************************************/
		/* interface ang::memory::ialigned_allocator :                    */
		/*  -> implements methods for aligned memory allocation and       */
		/*     releasing                                                  */
		/******************************************************************/
		ANG_BEGIN_INTERFACE_WITH_BASE(LINK, ialigned_allocator, public iallocator)
			visible vcall pointer aligned_malloc(wsize, wsize)pure;
#ifdef _DEBUG
		visible vcall pointer aligned_malloc(wsize, wsize, ang_cstr_t file, int line)pure;
#endif
		template<class obj_t, wsize ALIGNMENT = 4> obj_t* aligned_object_alloc(wsize count) {
			if (count == 0)
				return null;
			return static_cast<obj_t*>(aligned_malloc(count * sizeof(obj_t), ALIGNMENT));
		}
		ANG_END_INTERFACE();

		/******************************************************************/
		/* static class ang::memory::allocator_manager :                  */
		/*  -> manager for obtaining the default allocators               */
		/******************************************************************/
		class LINK allocator_manager
		{
		public:
			enum : index
			{
				default_allocator,
				object_allocator,
				buffer_allocator,
				aligned_allocator,
			};

			static iallocator* get_allocator(index);
			static index regist_allocator(iallocator*);
		};

	}

	namespace collections
	{

		/******************************************************************/
		/* interface ang::collections::ienum :                            */
		/*  -> represents an enumeration of objects or variables which    */
		/*     can be accessed orderly                                    */
		/******************************************************************/
		template<typename T>
		ANG_BEGIN_INLINE_INTERFACE(ienum)
			visible vcall uint counter()const pure;

			visible vcall T& at(base_iterator<T> const&) pure;
			visible vcall bool increase(base_iterator<T>&)const pure;
			visible vcall bool increase(base_iterator<T>&, int offset)const pure;
			visible vcall bool decrease(base_iterator<T>&)const pure;
			visible vcall bool decrease(base_iterator<T>&, int offset)const pure;

			visible vcall forward_iterator<T> begin() pure;
			visible vcall forward_iterator<T> end() pure;
			visible vcall const_forward_iterator<T> begin()const pure;
			visible vcall const_forward_iterator<T> end()const pure;

			visible vcall backward_iterator<T> rbegin() pure;
			visible vcall backward_iterator<T> rend() pure;
			visible vcall const_backward_iterator<T> rbegin()const pure;
			visible vcall const_backward_iterator<T> rend()const pure;
		ANG_END_INTERFACE();

		template<class T> using ienum_t = intf_wrapper<ienum<T>>;

		/******************************************************************/
		/* interface ang::collections::iarray :							  */
		/*  -> represents a collection of objects or variables which      */
		/*     can be accessed unorderly                                  */
		/******************************************************************/
		template<typename T>
		ANG_BEGIN_INLINE_INTERFACE_WITH_BASE(iarray, public ienum<T>)
			using ienum<T>::at;
			visible vcall iterator<T> at(index) pure;
			visible vcall const_iterator<T> at(index)const pure;
			visible vcall void copy(const ienum<T>*) pure;
			visible vcall index find(const T&, bool invert = false)const pure;
			visible vcall index find(const T&, base_iterator<T> next_to, bool invert = false)const pure;
		ANG_END_INTERFACE();

		template<class T> using iarray_t = intf_wrapper<iarray<T>>;

		/******************************************************************/
		/* interface ang::collections::ilist :                            */
		/*  -> represents a list of objects or variables where the user   */
		/*     can insert or remove elements randoml y                    */
		/******************************************************************/
		template<typename T>
		ANG_BEGIN_INLINE_INTERFACE_WITH_BASE(ilist, public iarray<T>)
			visible vcall void extend(const ienum<T>*) pure;
			visible vcall void push(T const&, bool last = true) pure;
			visible vcall bool insert(index idx, T const&) pure;
			visible vcall bool insert(base_iterator<T> it, T const&) pure;
			visible vcall bool pop(bool last = true) pure;
			visible vcall bool pop(T&, bool last = true) pure;
			visible vcall bool pop_at(index idx) pure;
			visible vcall bool pop_at(base_iterator<T> it) pure;
			visible vcall bool pop_at(index idx, T&) pure;
			visible vcall bool pop_at(base_iterator<T> it, T&) pure;
		ANG_END_INTERFACE();

		template<class T> using ilist_t = intf_wrapper<ilist<T>>;

		/******************************************************************/
		/* interface ang::collections::iqueue :                           */
		/*  -> represents a list of objects or variables where the user   */
		/*     can insert or remove elements sequentially                 */
		/******************************************************************/
		template<typename T>
		ANG_BEGIN_INLINE_INTERFACE_WITH_BASE(iseqlist, public ienum<T>)
			visible vcall void extend(const ienum<T>*) pure;
			visible vcall void push(T const&) pure;
			visible vcall bool pop() pure;
			visible vcall bool pop(T&) pure;
		ANG_END_INTERFACE();

		template<class T> using iseqlist_t = intf_wrapper<iseqlist<T>>;

		/******************************************************************/
		/* interface ang::collections::imap :                             */
		/*  -> represents a map of objects or vareiables which can be     */
		/*     accessed by a key. Also the user can insert, find and      */
		/*     remove the elements, the items may or may not be sorted    */
		/******************************************************************/
		template<typename K, typename T>
		ANG_BEGIN_INLINE_INTERFACE_WITH_BASE(imap, public ienum<pair<K, T>>)
			using ienum<T>::at;
			visible vcall iterator<T> at(K const&) pure;
			visible vcall const_iterator<T> at(K const&)const pure;
			visible vcall bool copy(const ienum<pair<K, T>>*) pure;
			visible vcall void extend(const ienum<pair<K, T>>*) pure;
			visible vcall bool insert(K, T) pure;
			visible vcall bool insert(pair<K, T>) pure;
			visible vcall bool update(K, T) pure;
			visible vcall bool update(pair<K, T>) pure;
			visible vcall bool remove(K const&) pure;
			visible vcall bool remove(K const&, T&) pure;
			visible vcall bool remove(base_iterator<pair<K, T>> it) pure;
			visible vcall bool remove(base_iterator<pair<K, T>> it, T&) pure;
			visible vcall bool has_key(const K&)const pure;
			visible vcall iterator<pair<K, T>> find(const K&) pure;
			visible vcall const_iterator<pair<K, T>> find(const K&)const pure;
		ANG_END_INTERFACE();

		template<class K, class T> using imap_t = intf_wrapper<imap<K,T>>;
	}

}

#ifdef LINK
#undef LINK
#endif//LINK

#ifndef __PLACEMENT_NEW_INLINE
#define __PLACEMENT_NEW_INLINE
inline pointer operator new(wsize, pointer ptr) throw() { return ptr; }
inline void operator delete(pointer, pointer) throw() { return; }
#endif

#endif//__ANG_BASE_H__


text:
<!DOCTYPE html>

	<meta charset="UTF-8">
	<title>youtube Chromeless Player - mb.YTPlayer</title>
	<link href='http://fonts.googleapis.com/css?family=Lekton|Lobster' rel='stylesheet' type='text/css'>
	<link href="css/jquery.mb.YTPlayer.min.css?_bn=5685" media="all" rel="stylesheet" type="text/css">

			<button onclick="jQuery('#bgndVideo').toggleVolume()">mute/unmute</button>
			<button onclick="jQuery('#bgndVideo').YTPFullscreen()">go fullscreen</button>
			<button id="debugBtn" class="command" onclick="jQuery('#debug').toggle()"> show/hide the console</button>

jQuery.mb.YTPlayer

An HTML5 Background player

for YouTube videos

Apply filters

* Does not work in IE.

			<button id="toggleFilters" onclick="jQuery('#bgndVideo').YTPToggleFilters(function(a){if(!a) {$('#toggleFilters').html('enable filters')} else {$('#toggleFilters').html('disable filters')}})"> disable all filters </button>

			<button id="removeFilters" onclick="jQuery('#bgndVideo').YTPRemoveFilter(rFCallback)"> remove all filters </button>

				grayscale

				hue rotate

				invert

				sepia

				opacity

				saturate

				brightness

				contrast

				blur

Change video

			<button class="command" onclick="jQuery('#bgndVideo').YTPChangeMovie({videoURL: '7SnmCUwOsts', mute:false, addRaster:false})">video 1</button>
			<button class="command" onclick="jQuery('#bgndVideo').YTPChangeMovie({videoURL: 'BsekcY04xvQ', mute:false, addRaster:false})">video 2</button>
			<button class="command" onclick="jQuery('#bgndVideo').YTPChangeMovie({videoURL: 'kcihcYEOeic', mute:false, startAt:10, addRaster:false})">video 3</button>

				Or insert here the ID or the complete URL of the Youtube video:
				<input id="videoID" type="text" value="r1xohS2u69E" onfocus="$('#loadOptions').slideDown()">

					<input id="startAt" type="number" placeholder="starts at">
					<input id="stopAt" type="number" placeholder="stops at">

					<input id="audioOff" type="checkbox" checked> Audio is OFF

				<button onclick="$('#loadOptions').slideUp(); jQuery('#bgndVideo').YTPChangeMovie({videoURL: $('#videoID').val(), startAt: checkForVal($('#startAt').val()), stopAt: checkForVal($('#stopAt').val()), mute: $('#audioOff').is(':checked') })">change video</button>

Current video:

				<button onclick="jQuery.mbYTPlayer.removeStoredData()"> Remove stored data </button>

			<button id="togglePlay" class="command pause" onclick="jQuery('#bgndVideo').YTPTogglePlay(changeLabel)">pause</button>

			See the doc
			Download it

		My video

Events console:


text:
/*
 * Hibernate Validator, declare and validate application constraints
 *
 * License: Apache License, Version 2.0
 * See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
 */

package org.hibernate.validator.test.constraints.boolcomposition;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Pattern.List;

import org.hibernate.validator.constraints.ConstraintComposition;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.hibernate.validator.constraints.CompositionType.ALL_FALSE;

/**
 * Blacklisted SSN numbers
 *
 * @author Federico Mancini
 * @author Dag Hovland
 */

@ConstraintComposition(ALL_FALSE)
@Target({ METHOD, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
@Constraint(validatedBy = { })
@List({
		@Pattern(regexp = "12345678901"),
		@Pattern(regexp = "98765678765"),
		@Pattern(regexp = "55555555555"),
		@Pattern(regexp = "123456")
})
public @interface Blacklist {
	String message() default "Blacklisted SSN";

	Class<?>[] groups() default { };

	Class<? extends Payload>[] payload() default { };
}


text:
package java.lang.invoke;

import jdk.internal.misc.CDS;
import jdk.internal.misc.Unsafe;
import sun.security.action.GetPropertyAction;

import java.util.Properties;

import static java.lang.invoke.LambdaForm.basicTypeSignature;
import static java.lang.invoke.LambdaForm.shortenSignature;

/**
 * This class consists exclusively of static names internal to the
 * method handle implementation.
 * Usage:  {@code import static java.lang.invoke.MethodHandleStatics.*}
 * @author John Rose, JSR 292 EG
 */
/*non-public*/
class MethodHandleStatics {

    private MethodHandleStatics() { }  // do not instantiate

    static final Unsafe UNSAFE = Unsafe.getUnsafe();

    static final boolean DEBUG_METHOD_HANDLE_NAMES;
    static final boolean DUMP_CLASS_FILES;
    static final boolean TRACE_INTERPRETER;
    static final boolean TRACE_METHOD_LINKAGE;
    static final boolean TRACE_RESOLVE;
    static final int COMPILE_THRESHOLD;
    static final boolean LOG_LF_COMPILATION_FAILURE;
    static final int DONT_INLINE_THRESHOLD;
    static final int PROFILE_LEVEL;
    static final boolean PROFILE_GWT;
    static final int CUSTOMIZE_THRESHOLD;
    static final boolean VAR_HANDLE_GUARDS;
    static final int MAX_ARITY;
    static final boolean VAR_HANDLE_IDENTITY_ADAPT;

    static {
        Properties props = GetPropertyAction.privilegedGetProperties();
        DEBUG_METHOD_HANDLE_NAMES = Boolean.parseBoolean(
                props.getProperty("java.lang.invoke.MethodHandle.DEBUG_NAMES"));
        DUMP_CLASS_FILES = Boolean.parseBoolean(
                props.getProperty("java.lang.invoke.MethodHandle.DUMP_CLASS_FILES"));
        TRACE_INTERPRETER = Boolean.parseBoolean(
                props.getProperty("java.lang.invoke.MethodHandle.TRACE_INTERPRETER"));
        TRACE_METHOD_LINKAGE = Boolean.parseBoolean(
                props.getProperty("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE"));
        TRACE_RESOLVE = Boolean.parseBoolean(
                props.getProperty("java.lang.invoke.MethodHandle.TRACE_RESOLVE"));
        COMPILE_THRESHOLD = Integer.parseInt(
                props.getProperty("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", "0"));
        LOG_LF_COMPILATION_FAILURE = Boolean.parseBoolean(
                props.getProperty("java.lang.invoke.MethodHandle.LOG_LF_COMPILATION_FAILURE", "false"));
        DONT_INLINE_THRESHOLD = Integer.parseInt(
                props.getProperty("java.lang.invoke.MethodHandle.DONT_INLINE_THRESHOLD", "30"));
        PROFILE_LEVEL = Integer.parseInt(
                props.getProperty("java.lang.invoke.MethodHandle.PROFILE_LEVEL", "0"));
        PROFILE_GWT = Boolean.parseBoolean(
                props.getProperty("java.lang.invoke.MethodHandle.PROFILE_GWT", "true"));
        CUSTOMIZE_THRESHOLD = Integer.parseInt(
                props.getProperty("java.lang.invoke.MethodHandle.CUSTOMIZE_THRESHOLD", "127"));
        VAR_HANDLE_GUARDS = Boolean.parseBoolean(
                props.getProperty("java.lang.invoke.VarHandle.VAR_HANDLE_GUARDS", "true"));
        VAR_HANDLE_IDENTITY_ADAPT = Boolean.parseBoolean(
                props.getProperty("java.lang.invoke.VarHandle.VAR_HANDLE_IDENTITY_ADAPT", "false"));

        // Do not adjust this except for special platforms:
        MAX_ARITY = Integer.parseInt(
                props.getProperty("java.lang.invoke.MethodHandleImpl.MAX_ARITY", "255"));

        if (CUSTOMIZE_THRESHOLD < -1 || CUSTOMIZE_THRESHOLD > 127) {
            throw newInternalError("CUSTOMIZE_THRESHOLD should be in [-1...127] range");
        }
    }

    /** Tell if any of the debugging switches are turned on.
     *  If this is the case, it is reasonable to perform extra checks or save extra information.
     */
    /*non-public*/
    static boolean debugEnabled() {
        return (DEBUG_METHOD_HANDLE_NAMES |
                DUMP_CLASS_FILES |
                TRACE_INTERPRETER |
                TRACE_METHOD_LINKAGE |
                LOG_LF_COMPILATION_FAILURE);
    }

    /**
     * If requested, logs the result of resolving the LambdaForm to stdout
     * and informs the CDS subsystem about it.
     */
    /*non-public*/
    static void traceLambdaForm(String name, MethodType type, Class<?> holder, MemberName resolvedMember) {
        if (TRACE_RESOLVE) {
            System.out.println("[LF_RESOLVE] " + holder.getName() + " " + name + " " +
                    shortenSignature(basicTypeSignature(type)) +
                    (resolvedMember != null ? " (success)" : " (fail)"));
        }
        if (CDS.isDumpingClassList()) {
            CDS.traceLambdaFormInvoker("[LF_RESOLVE]", holder.getName(), name, shortenSignature(basicTypeSignature(type)));
        }
    }

    /**
     * If requested, logs the result of resolving the species type to stdout
     * and the CDS subsystem.
     */
    /*non-public*/
    static void traceSpeciesType(String cn, Class<?> salvage) {
        if (TRACE_RESOLVE) {
            System.out.println("[SPECIES_RESOLVE] " + cn + (salvage != null ? " (salvaged)" : " (generated)"));
        }
        if (CDS.isDumpingClassList()) {
            CDS.traceSpeciesType("[SPECIES_RESOLVE]", cn);
        }
    }
    // handy shared exception makers (they simplify the common case code)
    /*non-public*/
    static InternalError newInternalError(String message) {
        return new InternalError(message);
    }
    /*non-public*/
    static InternalError newInternalError(String message, Exception cause) {
        return new InternalError(message, cause);
    }
    /*non-public*/
    static InternalError newInternalError(Exception cause) {
        return new InternalError(cause);
    }
    /*non-public*/
    static RuntimeException newIllegalStateException(String message) {
        return new IllegalStateException(message);
    }
    /*non-public*/
    static RuntimeException newIllegalStateException(String message, Object obj) {
        return new IllegalStateException(message(message, obj));
    }
    /*non-public*/
    static RuntimeException newIllegalArgumentException(String message) {
        return new IllegalArgumentException(message);
    }
    /*non-public*/
    static RuntimeException newIllegalArgumentException(String message, Object obj) {
        return new IllegalArgumentException(message(message, obj));
    }
    /*non-public*/
    static RuntimeException newIllegalArgumentException(String message, Object obj, Object obj2) {
        return new IllegalArgumentException(message(message, obj, obj2));
    }
    /** Propagate unchecked exceptions and errors, but wrap anything checked and throw that instead. */
    /*non-public*/
    static Error uncaughtException(Throwable ex) {
        if (ex instanceof Error)  throw (Error) ex;
        if (ex instanceof RuntimeException)  throw (RuntimeException) ex;
        throw new InternalError("uncaught exception", ex);
    }
    private static String message(String message, Object obj) {
        if (obj != null)  message = message + ": " + obj;
        return message;
    }
    private static String message(String message, Object obj, Object obj2) {
        if (obj != null || obj2 != null)  message = message + ": " + obj + ", " + obj2;
        return message;
    }
    /*non-public*/
    static void rangeCheck2(int start, int end, int size) {
        if (0 > start || start > end || end > size)
            throw new IndexOutOfBoundsException(start+".."+end);
    }
    /*non-public*/
    static int rangeCheck1(int index, int size) {
        if (0 > index || index >= size)
            throw new IndexOutOfBoundsException(index);
        return index;
    }
}


text:
#ifndef CUTELYSTVALIDATORREQUIREDUNLESS_P_H
#define CUTELYSTVALIDATORREQUIREDUNLESS_P_H

#include "validatorrequiredunless.h"
#include "validatorrule_p.h"

namespace Cutelyst {

class ValidatorRequiredUnlessPrivate : public ValidatorRulePrivate
{
public:
    ValidatorRequiredUnlessPrivate(const QString &f, const QString &of, const QStringList &ov, const ValidatorMessages &m) :
        ValidatorRulePrivate(f, m, QString()),
        otherField(of),
        otherValues(ov)
    {}

    QString otherField;
    QStringList otherValues;
};

}

#endif //CUTELYSTVALIDATORREQUIREDUNLESS_P_H


text:
package org.multibit.hd.ui.views.components;

import org.multibit.hd.ui.MultiBitUI;
import org.multibit.hd.ui.languages.Languages;
import org.multibit.hd.ui.languages.MessageKey;
import org.multibit.hd.ui.views.fonts.AwesomeDecorator;
import org.multibit.hd.ui.views.fonts.AwesomeIcon;
import org.multibit.hd.ui.views.themes.Themes;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import java.awt.*;

/**
 *
Tree cell renderer to provide the following to sidebar tree:

 *

 *
Adding appropriate spacing across platforms

 *
Font Awesome iconography

 *

 *
 * @since 0.0.1
 *
 */
public class ThemeAwareTreeCellRenderer extends DefaultTreeCellRenderer {

  // Provide padding for rows
  private Border border = BorderFactory.createEmptyBorder(5, 0, 5, 0);

  @Override
  public Color getBackgroundNonSelectionColor() {

    return null;

  }

  @Override
  public Color getBackgroundSelectionColor() {

    return null;

  }

  @Override
  public Color getBackground() {

    return null;
  }

  @Override
  public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {

    final JLabel ret = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;

    SidebarNodeInfo nodeInfo = (SidebarNodeInfo) node.getUserObject();

    // Content
    ret.setText(nodeInfo.getText());

    // Theme
    ret.setBorder(border);
    final Color iconColor;
    if (sel) {
      iconColor = Themes.currentTheme.sidebarSelectedText();
    } else {
      iconColor = Themes.currentTheme.text();
    }
    ret.setForeground(iconColor);

    // No border selection
    setBorderSelectionColor(Themes.currentTheme.sidebarPanelBackground());

    // Iconography (not all icons are created with the same size)
    if (leaf) {
      switch (nodeInfo.getDetailScreen()) {

        case SEND_REQUEST:
          if (nodeInfo.getText().equals(Languages.safeText(MessageKey.SEND_OR_REQUEST))) {
            setIcon(AwesomeDecorator.createIcon(AwesomeIcon.EXCHANGE, iconColor, MultiBitUI.NORMAL_ICON_SIZE - 3));
            setIconTextGap(9);
          } else {
            // In "single mode" this is the home
            setIcon(AwesomeDecorator.createIcon(AwesomeIcon.HOME, iconColor, MultiBitUI.NORMAL_ICON_SIZE));
            setIconTextGap(7);
          }
          break;
        case CONTACTS:
          setIcon(AwesomeDecorator.createIcon(AwesomeIcon.USER, iconColor, MultiBitUI.NORMAL_ICON_SIZE));
          setIconTextGap(10);
          break;
        case TRANSACTIONS:
          setIcon(AwesomeDecorator.createIcon(AwesomeIcon.LIST, iconColor, MultiBitUI.NORMAL_ICON_SIZE - 2));
          setIconTextGap(8);
          break;
        case HELP:
          setIcon(AwesomeDecorator.createIcon(AwesomeIcon.QUESTION, iconColor, MultiBitUI.NORMAL_ICON_SIZE + 10));
          setIconTextGap(9);
          break;
        case SETTINGS:
          setIcon(AwesomeDecorator.createIcon(AwesomeIcon.GEARS, iconColor, MultiBitUI.NORMAL_ICON_SIZE - 1));
          setIconTextGap(6);
          break;
        case MANAGE_WALLET:
          setIcon(AwesomeDecorator.createIcon(AwesomeIcon.EDIT, iconColor, MultiBitUI.NORMAL_ICON_SIZE));
          setIconTextGap(6);
          break;
        case TOOLS:
          setIcon(AwesomeDecorator.createIcon(AwesomeIcon.WRENCH, iconColor, MultiBitUI.NORMAL_ICON_SIZE));
          setIconTextGap(6);
          break;
        case EXIT:
          setIcon(AwesomeDecorator.createIcon(AwesomeIcon.SIGN_OUT, iconColor, MultiBitUI.NORMAL_ICON_SIZE + 2));
          setIconTextGap(6);
          break;
        default:
          throw new IllegalStateException("Unexpected screen:" + nodeInfo.getDetailScreen());
      }

    } else {

      setOpenIcon(
        AwesomeDecorator.createIcon(
          AwesomeIcon.CARET_DOWN,
          Themes.currentTheme.text(),
          MultiBitUI.NORMAL_ICON_SIZE)
      );

      setClosedIcon(
        AwesomeDecorator.createIcon(
          AwesomeDecorator.select(AwesomeIcon.CARET_RIGHT, AwesomeIcon.CARET_LEFT),
          Themes.currentTheme.text(),
          MultiBitUI.NORMAL_ICON_SIZE)
      );

    }

    return ret;
  }

}


text:
class Config(dict):
    def from_module(self, module_name):
        module = __import__(module_name)

        for k in dir(module):
            if not k.isupper():
                continue

            self[k] = getattr(module, k)


text:
package javax.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Locale;

/**
 *
 * Provides a convenient implementation of the ServletResponse interface that
 * can be subclassed by developers wishing to adapt the response from a Servlet.
 * This class implements the Wrapper or Decorator pattern. Methods default to
 * calling through to the wrapped response object.
 *
 * @author Various
 * @since Servlet 2.3
 *
 * @see javax.servlet.ServletResponse
 */

public class ServletResponseWrapper implements ServletResponse {
	private ServletResponse response;
	/**
	* Creates a ServletResponse adaptor wrapping the given response object.
	* @throws java.lang.IllegalArgumentException if the response is null.
	*/

	public ServletResponseWrapper(ServletResponse response) {
	    if (response == null) {
		throw new IllegalArgumentException("Response cannot be null");
	    }
	    this.response = response;
	}

	/**
	* Return the wrapped ServletResponse object.
	*/

	public ServletResponse getResponse() {
		return this.response;
	}

	/**
	* Sets the response being wrapped.
	* @throws java.lang.IllegalArgumentException if the response is null.
	*/

	public void setResponse(ServletResponse response) {
	    if (response == null) {
		throw new IllegalArgumentException("Response cannot be null");
	    }
	    this.response = response;
	}

    /**
     * The default behavior of this method is to call setCharacterEncoding(String charset)
     * on the wrapped response object.
     *
     * @since Servlet 2.4
     */

    public void setCharacterEncoding(String charset) {
	this.response.setCharacterEncoding(charset);
    }

    /**
     * The default behavior of this method is to return getCharacterEncoding()
     * on the wrapped response object.
     */

    public String getCharacterEncoding() {
	return this.response.getCharacterEncoding();
	}

	  /**
     * The default behavior of this method is to return getOutputStream()
     * on the wrapped response object.
     */

    public ServletOutputStream getOutputStream() throws IOException {
	return this.response.getOutputStream();
    }

     /**
     * The default behavior of this method is to return getWriter()
     * on the wrapped response object.
     */

    public PrintWriter getWriter() throws IOException {
	return this.response.getWriter();
	}

    /**
     * The default behavior of this method is to call setContentLength(int len)
     * on the wrapped response object.
     */

    public void setContentLength(int len) {
	this.response.setContentLength(len);
    }

    /**
     * The default behavior of this method is to call setContentType(String type)
     * on the wrapped response object.
     */

    public void setContentType(String type) {
	this.response.setContentType(type);
    }

    /**
     * The default behavior of this method is to return getContentType()
     * on the wrapped response object.
     *
     * @since Servlet 2.4
     */

    public String getContentType() {
	return this.response.getContentType();
    }

    /**
     * The default behavior of this method is to call setBufferSize(int size)
     * on the wrapped response object.
     */
    public void setBufferSize(int size) {
	this.response.setBufferSize(size);
    }

    /**
     * The default behavior of this method is to return getBufferSize()
     * on the wrapped response object.
     */
    public int getBufferSize() {
	return this.response.getBufferSize();
    }

    /**
     * The default behavior of this method is to call flushBuffer()
     * on the wrapped response object.
     */

    public void flushBuffer() throws IOException {
	this.response.flushBuffer();
    }

    /**
     * The default behavior of this method is to return isCommitted()
     * on the wrapped response object.
     */
    public boolean isCommitted() {
	return this.response.isCommitted();
    }

    /**
     * The default behavior of this method is to call reset()
     * on the wrapped response object.
     */

    public void reset() {
	this.response.reset();
    }

    /**
     * The default behavior of this method is to call resetBuffer()
     * on the wrapped response object.
     */

    public void resetBuffer() {
	this.response.resetBuffer();
    }

    /**
     * The default behavior of this method is to call setLocale(Locale loc)
     * on the wrapped response object.
     */

    public void setLocale(Locale loc) {
	this.response.setLocale(loc);
    }

    /**
     * The default behavior of this method is to return getLocale()
     * on the wrapped response object.
     */
    public Locale getLocale() {
	return this.response.getLocale();
    }

    /**
     * Checks (recursively) if this ServletResponseWrapper wraps the given
     * {@link ServletResponse} instance.
     *
     * @param wrapped the ServletResponse instance to search for
     *
     * @return true if this ServletResponseWrapper wraps the
     * given ServletResponse instance, false otherwise
     *
     * @since Servlet 3.0
     */
    public boolean isWrapperFor(ServletResponse wrapped) {
        if (response == wrapped) {
            return true;
        } else if (response instanceof ServletResponseWrapper) {
            return ((ServletResponseWrapper) response).isWrapperFor(wrapped);
        } else {
            return false;
        }
    }

    /**
     * Checks (recursively) if this ServletResponseWrapper wraps a
     * {@link ServletResponse} of the given class type.
     *
     * @param wrappedType the ServletResponse class type to
     * search for
     *
     * @return true if this ServletResponseWrapper wraps a
     * ServletResponse of the given class type, false otherwise
     *
     * @throws IllegalArgumentException if the given class does not
     * implement {@link ServletResponse}
     *
     * @since Servlet 3.0
     */
    public boolean isWrapperFor(Class wrappedType) {
        if (!ServletResponse.class.isAssignableFrom(wrappedType)) {
            throw new IllegalArgumentException("Given class " +
                wrappedType.getName() + " not a subinterface of " +
                ServletResponse.class.getName());
        }
        if (wrappedType.isAssignableFrom(response.getClass())) {
            return true;
        } else if (response instanceof ServletResponseWrapper) {
            return ((ServletResponseWrapper) response).isWrapperFor(wrappedType);
        } else {
            return false;
        }
    }

}


text:
#include "screen.h"

#include <assert.h>
#include <string.h>
#include <SDL2/SDL.h>

#include "events.h"
#include "icon.h"
#include "options.h"
#include "video_buffer.h"
#include "util/log.h"

#define DISPLAY_MARGINS 96

#define DOWNCAST(SINK) container_of(SINK, struct sc_screen, frame_sink)

static inline struct sc_size
get_rotated_size(struct sc_size size, int rotation) {
    struct sc_size rotated_size;
    if (rotation & 1) {
        rotated_size.width = size.height;
        rotated_size.height = size.width;
    } else {
        rotated_size.width = size.width;
        rotated_size.height = size.height;
    }
    return rotated_size;
}

// get the window size in a struct sc_size
static struct sc_size
get_window_size(const struct sc_screen *screen) {
    int width;
    int height;
    SDL_GetWindowSize(screen->window, &width, &height);

    struct sc_size size;
    size.width = width;
    size.height = height;
    return size;
}

static struct sc_point
get_window_position(const struct sc_screen *screen) {
    int x;
    int y;
    SDL_GetWindowPosition(screen->window, &x, &y);

    struct sc_point point;
    point.x = x;
    point.y = y;
    return point;
}

// set the window size to be applied when fullscreen is disabled
static void
set_window_size(struct sc_screen *screen, struct sc_size new_size) {
    assert(!screen->fullscreen);
    assert(!screen->maximized);
    SDL_SetWindowSize(screen->window, new_size.width, new_size.height);
}

// get the preferred display bounds (i.e. the screen bounds with some margins)
static bool
get_preferred_display_bounds(struct sc_size *bounds) {
    SDL_Rect rect;
    if (SDL_GetDisplayUsableBounds(0, &rect)) {
        LOGW("Could not get display usable bounds: %s", SDL_GetError());
        return false;
    }

    bounds->width = MAX(0, rect.w - DISPLAY_MARGINS);
    bounds->height = MAX(0, rect.h - DISPLAY_MARGINS);
    return true;
}

static bool
is_optimal_size(struct sc_size current_size, struct sc_size content_size) {
    // The size is optimal if we can recompute one dimension of the current
    // size from the other
    return current_size.height == current_size.width * content_size.height
                                                     / content_size.width
        || current_size.width == current_size.height * content_size.width
                                                     / content_size.height;
}

// return the optimal size of the window, with the following constraints:
//  - it attempts to keep at least one dimension of the current_size (i.e. it
//    crops the black borders)
//  - it keeps the aspect ratio
//  - it scales down to make it fit in the display_size
static struct sc_size
get_optimal_size(struct sc_size current_size, struct sc_size content_size,
                 bool within_display_bounds) {
    if (content_size.width == 0 || content_size.height == 0) {
        // avoid division by 0
        return current_size;
    }

    struct sc_size window_size;

    struct sc_size display_size;
    if (!within_display_bounds ||
            !get_preferred_display_bounds(&display_size)) {
        // do not constraint the size
        window_size = current_size;
    } else {
        window_size.width = MIN(current_size.width, display_size.width);
        window_size.height = MIN(current_size.height, display_size.height);
    }

    if (is_optimal_size(window_size, content_size)) {
        return window_size;
    }

    bool keep_width = content_size.width * window_size.height
                    > content_size.height * window_size.width;
    if (keep_width) {
        // remove black borders on top and bottom
        window_size.height = content_size.height * window_size.width
                           / content_size.width;
    } else {
        // remove black borders on left and right (or none at all if it already
        // fits)
        window_size.width = content_size.width * window_size.height
                          / content_size.height;
    }

    return window_size;
}

// initially, there is no current size, so use the frame size as current size
// req_width and req_height, if not 0, are the sizes requested by the user
static inline struct sc_size
get_initial_optimal_size(struct sc_size content_size, uint16_t req_width,
                         uint16_t req_height) {
    struct sc_size window_size;
    if (!req_width && !req_height) {
        window_size = get_optimal_size(content_size, content_size, true);
    } else {
        if (req_width) {
            window_size.width = req_width;
        } else {
            // compute from the requested height
            window_size.width = (uint32_t) req_height * content_size.width
                              / content_size.height;
        }
        if (req_height) {
            window_size.height = req_height;
        } else {
            // compute from the requested width
            window_size.height = (uint32_t) req_width * content_size.height
                               / content_size.width;
        }
    }
    return window_size;
}

static inline bool
sc_screen_is_relative_mode(struct sc_screen *screen) {
    // screen->im.mp may be NULL if --no-control
    return screen->im.mp && screen->im.mp->relative_mode;
}

static void
sc_screen_set_mouse_capture(struct sc_screen *screen, bool capture) {
#ifdef __APPLE__
    // Workaround for SDL bug on macOS:
    // <https://github.com/libsdl-org/SDL/issues/5340>
    if (capture) {
        int mouse_x, mouse_y;
        SDL_GetGlobalMouseState(&mouse_x, &mouse_y);

        int x, y, w, h;
        SDL_GetWindowPosition(screen->window, &x, &y);
        SDL_GetWindowSize(screen->window, &w, &h);

        bool outside_window = mouse_x < x || mouse_x >= x + w
                           || mouse_y < y || mouse_y >= y + h;
        if (outside_window) {
            SDL_WarpMouseInWindow(screen->window, w / 2, h / 2);
        }
    }
#else
    (void) screen;
#endif
    if (SDL_SetRelativeMouseMode(capture)) {
        LOGE("Could not set relative mouse mode to %s: %s",
             capture ? "true" : "false", SDL_GetError());
    }
}

static inline bool
sc_screen_get_mouse_capture(struct sc_screen *screen) {
    (void) screen;
    return SDL_GetRelativeMouseMode();
}

static inline void
sc_screen_toggle_mouse_capture(struct sc_screen *screen) {
    (void) screen;
    bool new_value = !sc_screen_get_mouse_capture(screen);
    sc_screen_set_mouse_capture(screen, new_value);
}

static void
sc_screen_update_content_rect(struct sc_screen *screen) {
    int dw;
    int dh;
    SDL_GL_GetDrawableSize(screen->window, &dw, &dh);

    struct sc_size content_size = screen->content_size;
    // The drawable size is the window size * the HiDPI scale
    struct sc_size drawable_size = {dw, dh};

    SDL_Rect *rect = &screen->rect;

    if (is_optimal_size(drawable_size, content_size)) {
        rect->x = 0;
        rect->y = 0;
        rect->w = drawable_size.width;
        rect->h = drawable_size.height;
        return;
    }

    bool keep_width = content_size.width * drawable_size.height
                    > content_size.height * drawable_size.width;
    if (keep_width) {
        rect->x = 0;
        rect->w = drawable_size.width;
        rect->h = drawable_size.width * content_size.height
                                      / content_size.width;
        rect->y = (drawable_size.height - rect->h) / 2;
    } else {
        rect->y = 0;
        rect->h = drawable_size.height;
        rect->w = drawable_size.height * content_size.width
                                       / content_size.height;
        rect->x = (drawable_size.width - rect->w) / 2;
    }
}

static inline SDL_Texture *
create_texture(struct sc_screen *screen) {
    SDL_Renderer *renderer = screen->renderer;
    struct sc_size size = screen->frame_size;
    SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12,
                                             SDL_TEXTUREACCESS_STREAMING,
                                             size.width, size.height);
    if (!texture) {
        return NULL;
    }

    if (screen->mipmaps) {
        struct sc_opengl *gl = &screen->gl;

        SDL_GL_BindTexture(texture, NULL, NULL);

        // Enable trilinear filtering for downscaling
        gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
                          GL_LINEAR_MIPMAP_LINEAR);
        gl->TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -1.f);

        SDL_GL_UnbindTexture(texture);
    }

    return texture;
}

// render the texture to the renderer
//
// Set the update_content_rect flag if the window or content size may have
// changed, so that the content rectangle is recomputed
static void
sc_screen_render(struct sc_screen *screen, bool update_content_rect) {
    if (update_content_rect) {
        sc_screen_update_content_rect(screen);
    }

    SDL_RenderClear(screen->renderer);
    if (screen->rotation == 0) {
        SDL_RenderCopy(screen->renderer, screen->texture, NULL, &screen->rect);
    } else {
        // rotation in RenderCopyEx() is clockwise, while screen->rotation is
        // counterclockwise (to be consistent with --lock-video-orientation)
        int cw_rotation = (4 - screen->rotation) % 4;
        double angle = 90 * cw_rotation;

        SDL_Rect *dstrect = NULL;
        SDL_Rect rect;
        if (screen->rotation & 1) {
            rect.x = screen->rect.x + (screen->rect.w - screen->rect.h) / 2;
            rect.y = screen->rect.y + (screen->rect.h - screen->rect.w) / 2;
            rect.w = screen->rect.h;
            rect.h = screen->rect.w;
            dstrect = ▭
        } else {
            assert(screen->rotation == 2);
            dstrect = &screen->rect;
        }

        SDL_RenderCopyEx(screen->renderer, screen->texture, NULL, dstrect,
                         angle, NULL, 0);
    }
    SDL_RenderPresent(screen->renderer);
}

#if defined(__APPLE__) || defined(__WINDOWS__)
# define CONTINUOUS_RESIZING_WORKAROUND
#endif

#ifdef CONTINUOUS_RESIZING_WORKAROUND
// On Windows and MacOS, resizing blocks the event loop, so resizing events are
// not triggered. As a workaround, handle them in an event handler.
//
// <https://bugzilla.libsdl.org/show_bug.cgi?id=2077>
// <https://stackoverflow.com/a/40693139/1987178>
static int
event_watcher(void *data, SDL_Event *event) {
    struct sc_screen *screen = data;
    if (event->type == SDL_WINDOWEVENT
            && event->window.event == SDL_WINDOWEVENT_RESIZED) {
        // In practice, it seems to always be called from the same thread in
        // that specific case. Anyway, it's just a workaround.
        sc_screen_render(screen, true);
    }
    return 0;
}
#endif

static bool
sc_screen_frame_sink_open(struct sc_frame_sink *sink) {
    struct sc_screen *screen = DOWNCAST(sink);
    (void) screen;
#ifndef NDEBUG
    screen->open = true;
#endif

    // nothing to do, the screen is already open on the main thread
    return true;
}

static void
sc_screen_frame_sink_close(struct sc_frame_sink *sink) {
    struct sc_screen *screen = DOWNCAST(sink);
    (void) screen;
#ifndef NDEBUG
    screen->open = false;
#endif

    // nothing to do, the screen lifecycle is not managed by the frame producer
}

static bool
sc_screen_frame_sink_push(struct sc_frame_sink *sink, const AVFrame *frame) {
    struct sc_screen *screen = DOWNCAST(sink);
    return sc_video_buffer_push(&screen->vb, frame);
}

static void
sc_video_buffer_on_new_frame(struct sc_video_buffer *vb, bool previous_skipped,
                             void *userdata) {
    (void) vb;
    struct sc_screen *screen = userdata;

    // event_failed implies previous_skipped (the previous frame may not have
    // been consumed if the event was not sent)
    assert(!screen->event_failed || previous_skipped);

    bool need_new_event;
    if (previous_skipped) {
        sc_fps_counter_add_skipped_frame(&screen->fps_counter);
        // The EVENT_NEW_FRAME triggered for the previous frame will consume
        // this new frame instead, unless the previous event failed
        need_new_event = screen->event_failed;
    } else {
        need_new_event = true;
    }

    if (need_new_event) {
        static SDL_Event new_frame_event = {
            .type = EVENT_NEW_FRAME,
        };

        // Post the event on the UI thread
        int ret = SDL_PushEvent(&new_frame_event);
        if (ret < 0) {
            LOGW("Could not post new frame event: %s", SDL_GetError());
            screen->event_failed = true;
        } else {
            screen->event_failed = false;
        }
    }
}

bool
sc_screen_init(struct sc_screen *screen,
               const struct sc_screen_params *params) {
    screen->resize_pending = false;
    screen->has_frame = false;
    screen->fullscreen = false;
    screen->maximized = false;
    screen->event_failed = false;
    screen->mouse_capture_key_pressed = 0;

    screen->req.x = params->window_x;
    screen->req.y = params->window_y;
    screen->req.width = params->window_width;
    screen->req.height = params->window_height;
    screen->req.fullscreen = params->fullscreen;
    screen->req.start_fps_counter = params->start_fps_counter;

    static const struct sc_video_buffer_callbacks cbs = {
        .on_new_frame = sc_video_buffer_on_new_frame,
    };

    bool ok = sc_video_buffer_init(&screen->vb, params->buffering_time, &cbs,
                                   screen);
    if (!ok) {
        return false;
    }

    ok = sc_video_buffer_start(&screen->vb);
    if (!ok) {
        goto error_destroy_video_buffer;
    }

    if (!sc_fps_counter_init(&screen->fps_counter)) {
        goto error_stop_and_join_video_buffer;
    }

    screen->frame_size = params->frame_size;
    screen->rotation = params->rotation;
    if (screen->rotation) {
        LOGI("Initial display rotation set to %u", screen->rotation);
    }
    struct sc_size content_size =
        get_rotated_size(screen->frame_size, screen->rotation);
    screen->content_size = content_size;

    uint32_t window_flags = SDL_WINDOW_HIDDEN
                          | SDL_WINDOW_RESIZABLE
                          | SDL_WINDOW_ALLOW_HIGHDPI;
    if (params->always_on_top) {
        window_flags |= SDL_WINDOW_ALWAYS_ON_TOP;
    }
    if (params->window_borderless) {
        window_flags |= SDL_WINDOW_BORDERLESS;
    }

    // The window will be positioned and sized on first video frame
    screen->window =
        SDL_CreateWindow(params->window_title, 0, 0, 0, 0, window_flags);
    if (!screen->window) {
        LOGE("Could not create window: %s", SDL_GetError());
        goto error_destroy_fps_counter;
    }

    screen->renderer = SDL_CreateRenderer(screen->window, -1,
                                          SDL_RENDERER_ACCELERATED);
    if (!screen->renderer) {
        LOGE("Could not create renderer: %s", SDL_GetError());
        goto error_destroy_window;
    }

    SDL_RendererInfo renderer_info;
    int r = SDL_GetRendererInfo(screen->renderer, &renderer_info);
    const char *renderer_name = r ? NULL : renderer_info.name;
    LOGI("Renderer: %s", renderer_name ? renderer_name : "(unknown)");

    screen->mipmaps = false;

    // starts with "opengl"
    bool use_opengl = renderer_name && !strncmp(renderer_name, "opengl", 6);
    if (use_opengl) {
        struct sc_opengl *gl = &screen->gl;
        sc_opengl_init(gl);

        LOGI("OpenGL version: %s", gl->version);

        if (params->mipmaps) {
            bool supports_mipmaps =
                sc_opengl_version_at_least(gl, 3, 0, /* OpenGL 3.0+ */
                                               2, 0  /* OpenGL ES 2.0+ */);
            if (supports_mipmaps) {
                LOGI("Trilinear filtering enabled");
                screen->mipmaps = true;
            } else {
                LOGW("Trilinear filtering disabled "
                     "(OpenGL 3.0+ or ES 2.0+ required)");
            }
        } else {
            LOGI("Trilinear filtering disabled");
        }
    } else if (params->mipmaps) {
        LOGD("Trilinear filtering disabled (not an OpenGL renderer)");
    }

    SDL_Surface *icon = scrcpy_icon_load();
    if (icon) {
        SDL_SetWindowIcon(screen->window, icon);
        scrcpy_icon_destroy(icon);
    } else {
        LOGW("Could not load icon");
    }

    LOGI("Initial texture: %" PRIu16 "x%" PRIu16, params->frame_size.width,
                                                  params->frame_size.height);
    screen->texture = create_texture(screen);
    if (!screen->texture) {
        LOGE("Could not create texture: %s", SDL_GetError());
        goto error_destroy_renderer;
    }

    screen->frame = av_frame_alloc();
    if (!screen->frame) {
        LOG_OOM();
        goto error_destroy_texture;
    }

    struct sc_input_manager_params im_params = {
        .controller = params->controller,
        .fp = params->fp,
        .screen = screen,
        .kp = params->kp,
        .mp = params->mp,
        .forward_all_clicks = params->forward_all_clicks,
        .legacy_paste = params->legacy_paste,
        .clipboard_autosync = params->clipboard_autosync,
        .shortcut_mods = params->shortcut_mods,
    };

    sc_input_manager_init(&screen->im, &im_params);

#ifdef CONTINUOUS_RESIZING_WORKAROUND
    SDL_AddEventWatch(event_watcher, screen);
#endif

    static const struct sc_frame_sink_ops ops = {
        .open = sc_screen_frame_sink_open,
        .close = sc_screen_frame_sink_close,
        .push = sc_screen_frame_sink_push,
    };

    screen->frame_sink.ops = &ops;

#ifndef NDEBUG
    screen->open = false;
#endif

    return true;

error_destroy_texture:
    SDL_DestroyTexture(screen->texture);
error_destroy_renderer:
    SDL_DestroyRenderer(screen->renderer);
error_destroy_window:
    SDL_DestroyWindow(screen->window);
error_destroy_fps_counter:
    sc_fps_counter_destroy(&screen->fps_counter);
error_stop_and_join_video_buffer:
    sc_video_buffer_stop(&screen->vb);
    sc_video_buffer_join(&screen->vb);
error_destroy_video_buffer:
    sc_video_buffer_destroy(&screen->vb);

    return false;
}

static void
sc_screen_show_initial_window(struct sc_screen *screen) {
    int x = screen->req.x != SC_WINDOW_POSITION_UNDEFINED
          ? screen->req.x : (int) SDL_WINDOWPOS_CENTERED;
    int y = screen->req.y != SC_WINDOW_POSITION_UNDEFINED
          ? screen->req.y : (int) SDL_WINDOWPOS_CENTERED;

    struct sc_size window_size =
        get_initial_optimal_size(screen->content_size, screen->req.width,
                                                       screen->req.height);

    set_window_size(screen, window_size);
    SDL_SetWindowPosition(screen->window, x, y);

    if (screen->req.fullscreen) {
        sc_screen_switch_fullscreen(screen);
    }

    if (screen->req.start_fps_counter) {
        sc_fps_counter_start(&screen->fps_counter);
    }

    SDL_ShowWindow(screen->window);
}

void
sc_screen_hide_window(struct sc_screen *screen) {
    SDL_HideWindow(screen->window);
}

void
sc_screen_interrupt(struct sc_screen *screen) {
    sc_video_buffer_stop(&screen->vb);
    sc_fps_counter_interrupt(&screen->fps_counter);
}

void
sc_screen_join(struct sc_screen *screen) {
    sc_video_buffer_join(&screen->vb);
    sc_fps_counter_join(&screen->fps_counter);
}

void
sc_screen_destroy(struct sc_screen *screen) {
#ifndef NDEBUG
    assert(!screen->open);
#endif
    av_frame_free(&screen->frame);
    SDL_DestroyTexture(screen->texture);
    SDL_DestroyRenderer(screen->renderer);
    SDL_DestroyWindow(screen->window);
    sc_fps_counter_destroy(&screen->fps_counter);
    sc_video_buffer_destroy(&screen->vb);
}

static void
resize_for_content(struct sc_screen *screen, struct sc_size old_content_size,
                   struct sc_size new_content_size) {
    struct sc_size window_size = get_window_size(screen);
    struct sc_size target_size = {
        .width = (uint32_t) window_size.width * new_content_size.width
                / old_content_size.width,
        .height = (uint32_t) window_size.height * new_content_size.height
                / old_content_size.height,
    };
    target_size = get_optimal_size(target_size, new_content_size, true);
    set_window_size(screen, target_size);
}

static void
set_content_size(struct sc_screen *screen, struct sc_size new_content_size) {
    if (!screen->fullscreen && !screen->maximized) {
        resize_for_content(screen, screen->content_size, new_content_size);
    } else if (!screen->resize_pending) {
        // Store the windowed size to be able to compute the optimal size once
        // fullscreen and maximized are disabled
        screen->windowed_content_size = screen->content_size;
        screen->resize_pending = true;
    }

    screen->content_size = new_content_size;
}

static void
apply_pending_resize(struct sc_screen *screen) {
    assert(!screen->fullscreen);
    assert(!screen->maximized);
    if (screen->resize_pending) {
        resize_for_content(screen, screen->windowed_content_size,
                                   screen->content_size);
        screen->resize_pending = false;
    }
}

void
sc_screen_set_rotation(struct sc_screen *screen, unsigned rotation) {
    assert(rotation < 4);
    if (rotation == screen->rotation) {
        return;
    }

    struct sc_size new_content_size =
        get_rotated_size(screen->frame_size, rotation);

    set_content_size(screen, new_content_size);

    screen->rotation = rotation;
    LOGI("Display rotation set to %u", rotation);

    sc_screen_render(screen, true);
}

// recreate the texture and resize the window if the frame size has changed
static bool
prepare_for_frame(struct sc_screen *screen, struct sc_size new_frame_size) {
    if (screen->frame_size.width != new_frame_size.width
            || screen->frame_size.height != new_frame_size.height) {
        // frame dimension changed, destroy texture
        SDL_DestroyTexture(screen->texture);

        screen->frame_size = new_frame_size;

        struct sc_size new_content_size =
            get_rotated_size(new_frame_size, screen->rotation);
        set_content_size(screen, new_content_size);

        sc_screen_update_content_rect(screen);

        LOGI("New texture: %" PRIu16 "x%" PRIu16,
                     screen->frame_size.width, screen->frame_size.height);
        screen->texture = create_texture(screen);
        if (!screen->texture) {
            LOGE("Could not create texture: %s", SDL_GetError());
            return false;
        }
    }

    return true;
}

// write the frame into the texture
static void
update_texture(struct sc_screen *screen, const AVFrame *frame) {
    SDL_UpdateYUVTexture(screen->texture, NULL,
            frame->data[0], frame->linesize[0],
            frame->data[1], frame->linesize[1],
            frame->data[2], frame->linesize[2]);

    if (screen->mipmaps) {
        SDL_GL_BindTexture(screen->texture, NULL, NULL);
        screen->gl.GenerateMipmap(GL_TEXTURE_2D);
        SDL_GL_UnbindTexture(screen->texture);
    }
}

static bool
sc_screen_update_frame(struct sc_screen *screen) {
    av_frame_unref(screen->frame);
    sc_video_buffer_consume(&screen->vb, screen->frame);
    AVFrame *frame = screen->frame;

    sc_fps_counter_add_rendered_frame(&screen->fps_counter);

    struct sc_size new_frame_size = {frame->width, frame->height};
    if (!prepare_for_frame(screen, new_frame_size)) {
        return false;
    }
    update_texture(screen, frame);

    if (!screen->has_frame) {
        screen->has_frame = true;
        // this is the very first frame, show the window
        sc_screen_show_initial_window(screen);

        if (sc_screen_is_relative_mode(screen)) {
            // Capture mouse on start
            sc_screen_set_mouse_capture(screen, true);
        }
    }

    sc_screen_render(screen, false);
    return true;
}

void
sc_screen_switch_fullscreen(struct sc_screen *screen) {
    uint32_t new_mode = screen->fullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP;
    if (SDL_SetWindowFullscreen(screen->window, new_mode)) {
        LOGW("Could not switch fullscreen mode: %s", SDL_GetError());
        return;
    }

    screen->fullscreen = !screen->fullscreen;
    if (!screen->fullscreen && !screen->maximized) {
        apply_pending_resize(screen);
    }

    LOGD("Switched to %s mode", screen->fullscreen ? "fullscreen" : "windowed");
    sc_screen_render(screen, true);
}

void
sc_screen_resize_to_fit(struct sc_screen *screen) {
    if (screen->fullscreen || screen->maximized) {
        return;
    }

    struct sc_point point = get_window_position(screen);
    struct sc_size window_size = get_window_size(screen);

    struct sc_size optimal_size =
        get_optimal_size(window_size, screen->content_size, false);

    // Center the window related to the device screen
    assert(optimal_size.width <= window_size.width);
    assert(optimal_size.height <= window_size.height);
    uint32_t new_x = point.x + (window_size.width - optimal_size.width) / 2;
    uint32_t new_y = point.y + (window_size.height - optimal_size.height) / 2;

    SDL_SetWindowSize(screen->window, optimal_size.width, optimal_size.height);
    SDL_SetWindowPosition(screen->window, new_x, new_y);
    LOGD("Resized to optimal size: %ux%u", optimal_size.width,
                                           optimal_size.height);
}

void
sc_screen_resize_to_pixel_perfect(struct sc_screen *screen) {
    if (screen->fullscreen) {
        return;
    }

    if (screen->maximized) {
        SDL_RestoreWindow(screen->window);
        screen->maximized = false;
    }

    struct sc_size content_size = screen->content_size;
    SDL_SetWindowSize(screen->window, content_size.width, content_size.height);
    LOGD("Resized to pixel-perfect: %ux%u", content_size.width,
                                            content_size.height);
}

static inline bool
sc_screen_is_mouse_capture_key(SDL_Keycode key) {
    return key == SDLK_LALT || key == SDLK_LGUI || key == SDLK_RGUI;
}

void
sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
    bool relative_mode = sc_screen_is_relative_mode(screen);

    switch (event->type) {
        case EVENT_NEW_FRAME: {
            bool ok = sc_screen_update_frame(screen);
            if (!ok) {
                LOGW("Frame update failed\n");
            }
            return;
        }
        case SDL_WINDOWEVENT:
            if (!screen->has_frame) {
                // Do nothing
                return;
            }
            switch (event->window.event) {
                case SDL_WINDOWEVENT_EXPOSED:
                    sc_screen_render(screen, true);
                    break;
                case SDL_WINDOWEVENT_SIZE_CHANGED:
                    sc_screen_render(screen, true);
                    break;
                case SDL_WINDOWEVENT_MAXIMIZED:
                    screen->maximized = true;
                    break;
                case SDL_WINDOWEVENT_RESTORED:
                    if (screen->fullscreen) {
                        // On Windows, in maximized+fullscreen, disabling
                        // fullscreen mode unexpectedly triggers the "restored"
                        // then "maximized" events, leaving the window in a
                        // weird state (maximized according to the events, but
                        // not maximized visually).
                        break;
                    }
                    screen->maximized = false;
                    apply_pending_resize(screen);
                    sc_screen_render(screen, true);
                    break;
                case SDL_WINDOWEVENT_FOCUS_LOST:
                    if (relative_mode) {
                        sc_screen_set_mouse_capture(screen, false);
                    }
                    break;
            }
            return;
        case SDL_KEYDOWN:
            if (relative_mode) {
                SDL_Keycode key = event->key.keysym.sym;
                if (sc_screen_is_mouse_capture_key(key)) {
                    if (!screen->mouse_capture_key_pressed) {
                        screen->mouse_capture_key_pressed = key;
                    } else {
                        // Another mouse capture key has been pressed, cancel
                        // mouse (un)capture
                        screen->mouse_capture_key_pressed = 0;
                    }
                    // Mouse capture keys are never forwarded to the device
                    return;
                }
            }
            break;
        case SDL_KEYUP:
            if (relative_mode) {
                SDL_Keycode key = event->key.keysym.sym;
                SDL_Keycode cap = screen->mouse_capture_key_pressed;
                screen->mouse_capture_key_pressed = 0;
                if (sc_screen_is_mouse_capture_key(key)) {
                    if (key == cap) {
                        // A mouse capture key has been pressed then released:
                        // toggle the capture mouse mode
                        sc_screen_toggle_mouse_capture(screen);
                    }
                    // Mouse capture keys are never forwarded to the device
                    return;
                }
            }
            break;
        case SDL_MOUSEWHEEL:
        case SDL_MOUSEMOTION:
        case SDL_MOUSEBUTTONDOWN:
            if (relative_mode && !sc_screen_get_mouse_capture(screen)) {
                // Do not forward to input manager, the mouse will be captured
                // on SDL_MOUSEBUTTONUP
                return;
            }
            break;
        case SDL_FINGERMOTION:
        case SDL_FINGERDOWN:
        case SDL_FINGERUP:
            if (relative_mode) {
                // Touch events are not compatible with relative mode
                // (coordinates are not relative)
                return;
            }
            break;
        case SDL_MOUSEBUTTONUP:
            if (relative_mode && !sc_screen_get_mouse_capture(screen)) {
                sc_screen_set_mouse_capture(screen, true);
                return;
            }
            break;
    }

    sc_input_manager_handle_event(&screen->im, event);
}

struct sc_point
sc_screen_convert_drawable_to_frame_coords(struct sc_screen *screen,
                                           int32_t x, int32_t y) {
    unsigned rotation = screen->rotation;
    assert(rotation < 4);

    int32_t w = screen->content_size.width;
    int32_t h = screen->content_size.height;

    x = (int64_t) (x - screen->rect.x) * w / screen->rect.w;
    y = (int64_t) (y - screen->rect.y) * h / screen->rect.h;

    // rotate
    struct sc_point result;
    switch (rotation) {
        case 0:
            result.x = x;
            result.y = y;
            break;
        case 1:
            result.x = h - y;
            result.y = x;
            break;
        case 2:
            result.x = w - x;
            result.y = h - y;
            break;
        default:
            assert(rotation == 3);
            result.x = y;
            result.y = w - x;
            break;
    }
    return result;
}

struct sc_point
sc_screen_convert_window_to_frame_coords(struct sc_screen *screen,
                                         int32_t x, int32_t y) {
    sc_screen_hidpi_scale_coords(screen, &x, &y);
    return sc_screen_convert_drawable_to_frame_coords(screen, x, y);
}

void
sc_screen_hidpi_scale_coords(struct sc_screen *screen, int32_t *x, int32_t *y) {
    // take the HiDPI scaling (dw/ww and dh/wh) into account
    int ww, wh, dw, dh;
    SDL_GetWindowSize(screen->window, &ww, &wh);
    SDL_GL_GetDrawableSize(screen->window, &dw, &dh);

    // scale for HiDPI (64 bits for intermediate multiplications)
    *x = (int64_t) *x * dw / ww;
    *y = (int64_t) *y * dh / wh;
}


text:
Simple docker volume driver to pack the contents of a mount and store in a HDFS cluster.  This driver does NOT make incremental changes to HDFS.  After a container exits pack creates a tar of the data in the volume and stores the tar in HDFS.  When the volume is mounted the tar is read from HDFS and extracted on the local host machine for the container to mount.  The tar maintains the permissions, group, and owner information between mounts.

## Building pack as a Docker container.
~~~~
docker build -t pack .
~~~~

## Running pack as a Docker container.
~~~~
docker run -d \
  --name pack \
  --cap-add SYS_ADMIN \
  --device /dev/fuse \
  -e PACK_ZOOKEEPER_CONNECTION_STR="<zk>/pack" \
  -e HDFS_CONF_DIR="/pack/hadoop-conf" \
  -v <hdfs config>:/pack/hadoop-conf \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /var/run/docker/plugins/:/var/run/docker/plugins/ \
  pack <[pack|compactor]>
~~~~

~~~~
docker run -it --rm \
  --name pack \
  --cap-add SYS_ADMIN \
  --device /dev/fuse \
  -e TEST_ZK=true \
  -e TEST_HDFS=true \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /var/run/docker/plugins/:/var/run/docker/plugins/ \
  pack pack
~~~~


text:
<?php

defined('_JEXEC') or die;

if (!is_file(__DIR__ . '/vendor/autoload.php'))
{
	return;
}

require_once __DIR__ . '/vendor/autoload.php';

use RegularLabs\AdvancedModules\Plugin;
use RegularLabs\Library\Protect as RL_Protect;

class PlgSystemAdvancedModules extends Plugin
{
	public $_alias       = 'advancedmodules';
	public $_title       = 'ADVANCED_MODULE_MANAGER';
	public $_lang_prefix = 'AMM';

	public $_page_types      = ['html'];
	public $_enable_in_admin = true;

	public function extraChecks()
	{
		if (!RL_Protect::isComponentInstalled('advancedmodules'))
		{
			return false;
		}

		return true;
	}
}


text:
1.13.2
------

* Fixing a bug that prevented multiple macros from successfully being
  applied to a file.

1.13.1
------

* Patch version bump because I ran the release for 1.13.0 from the wrong
  branch, so it was missing some minor bugfixes.

1.13.0
------

* Changes functionality of "Macro Plugins" to apply only to file-based
  fields.  This will prevent misbehaving macros from making the general
  field file from becoming conflicted.

1.12.0
------

* Adds enable/disable functionality to macro plugins.
* Moved ``{list-table}`` plugin out into its own repository.  To install this
  macro again, see https://github.com/coddingtonbear/jirafs-list-table.
* Adds new ``macropatch`` command allowing you to reset or see the existing
  macropatch.  This is especially important for use in situations where you
  disable a macro plugin.
* Fixed a bug in config handling where on Python 2.7 configparser would
  raise an error when attempting to enable a plugin.

1.11.0
------

* Adds new "Macro Plugins" support including a new built-in macro --
  ``{list-table}`` used for making tables a little bit simpler.
* Alters ``field`` command to return text *after* being processed
  by macros.  Use the ``--raw`` argument to instead return the
  pre-processed field contents.

1.10.0
------

* Adds new ``create`` command providing you with a way of interactively
  creating a new issue.  Note that ``create`` will automatically
  clone the issue once you've supplied the requisite informaiton.
* Adds new ``submit`` command which runs a ``commit`` followed by
  a ``push`` (which itself automatically runs ``pull``); although
  the lower-level git-like commands are still available, using ``submit``
  is now the preferred method of interacting with Jirafs.

1.9.0
-----

* Adds new ``search_users`` command allowing one to search for users.  This
  is particularly useful for when attempting to mention somebody in a ticket
  comment, but you're not sure what their user name is.
* When running ``merge`` (even via ``pull``) messages will be displayed
  indicating remote changes that are being merged-in to your working copy.
* Adds basic integration tests; this should add a lot of insulation preventing
  me (or anybody else) from accidentally breaking Jirafs for versions of
  Python not in use by the writer.

1.8.0
-----

* Adds link-management functionality.  You can now create, remove, and modify
  remote (arbitrary http links) and issue (links to other JIRA issues) by
  editing the ``links.rst`` file.
* Adds new ``--subtask`` command-line argument allowing one to run a command
  upon subtasks even if that command is not configured to do so automatically.
  This is particularly useful for getting the status of a task and all
  subtasks simultaneously by running ``jirafs status --subtask``.
* Now displays a summary of changes from JIRA when ``merge``-ing or
  ``pull``-ing.

1.7.0
-----

* Fetching an issue will automatically clone all subtasks.
* Adds new ``subtask`` command that allows one to create new subtasks.

1.6.0
-----

* Separates concepts of ``.jirafs_ignore`` from ``.jirafs_local``; you can now
  keep files out of JIRA and prevent them from being tracked in the local
  git repository simultaneously.

1.5.0
-----

* Adds Python 3.0 support.

1.4.0
-----

* It's now possible to edit non-string/integer fields; they'll appear
  in your fields file as editable JSON.

1.3.0
-----

* Adds new ``field`` command that allows one to fetch the value of any
  ticket field from the command-line.

1.2.0
-----

* Adds functionality for cloning issues from git repositories.
* Adds new ``transition`` command that allows one to transition an issue
  from one status to another.
* Adds better formatting for error messages.

1.0.0
-----

* Close enough to the beginning that it doesn't really matter all that much.