text:
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
#include "src/gen-cpp2/module_types.h"
#include "src/gen-cpp2/module_types.tcc"

#include <algorithm>
#include <folly/Indestructible.h>

#include "src/gen-cpp2/module_data.h"

namespace cpp2 {

const _EmptyEnum_EnumMapFactory::ValuesToNamesMapType _EmptyEnum_VALUES_TO_NAMES = _EmptyEnum_EnumMapFactory::makeValuesToNamesMap();
const _EmptyEnum_EnumMapFactory::NamesToValuesMapType _EmptyEnum_NAMES_TO_VALUES = _EmptyEnum_EnumMapFactory::makeNamesToValuesMap();

} // cpp2
namespace std {

} // std
namespace apache { namespace thrift {

template <> const std::size_t TEnumTraits< ::cpp2::EmptyEnum>::size = 0;
template <> const folly::Range<const  ::cpp2::EmptyEnum*> TEnumTraits< ::cpp2::EmptyEnum>::values = {};
template <> const folly::Range<const folly::StringPiece*> TEnumTraits< ::cpp2::EmptyEnum>::names = {};
template <> const char* TEnumTraits< ::cpp2::EmptyEnum>::findName( ::cpp2::EmptyEnum value) {
  static auto const map = folly::Indestructible< ::cpp2::_EmptyEnum_EnumMapFactory::ValuesToNamesMapType>{ ::cpp2::_EmptyEnum_EnumMapFactory::makeValuesToNamesMap()};
  return findName(*map, value);
}

template <> bool TEnumTraits< ::cpp2::EmptyEnum>::findValue(const char* name,  ::cpp2::EmptyEnum* outValue) {
  static auto const map = folly::Indestructible< ::cpp2::_EmptyEnum_EnumMapFactory::NamesToValuesMapType>{ ::cpp2::_EmptyEnum_EnumMapFactory::makeNamesToValuesMap()};
  return findValue(*map, name, outValue);
}

}} // apache::thrift
namespace cpp2 {

const _City_EnumMapFactory::ValuesToNamesMapType _City_VALUES_TO_NAMES = _City_EnumMapFactory::makeValuesToNamesMap();
const _City_EnumMapFactory::NamesToValuesMapType _City_NAMES_TO_VALUES = _City_EnumMapFactory::makeNamesToValuesMap();

} // cpp2
namespace std {

} // std
namespace apache { namespace thrift {

template <> const std::size_t TEnumTraits< ::cpp2::City>::size = 4;
template <> const folly::Range<const  ::cpp2::City*> TEnumTraits< ::cpp2::City>::values = folly::range( ::cpp2::_CityEnumDataStorage::values);
template <> const folly::Range<const folly::StringPiece*> TEnumTraits< ::cpp2::City>::names = folly::range( ::cpp2::_CityEnumDataStorage::names);
template <> const char* TEnumTraits< ::cpp2::City>::findName( ::cpp2::City value) {
  static auto const map = folly::Indestructible< ::cpp2::_City_EnumMapFactory::ValuesToNamesMapType>{ ::cpp2::_City_EnumMapFactory::makeValuesToNamesMap()};
  return findName(*map, value);
}

template <> bool TEnumTraits< ::cpp2::City>::findValue(const char* name,  ::cpp2::City* outValue) {
  static auto const map = folly::Indestructible< ::cpp2::_City_EnumMapFactory::NamesToValuesMapType>{ ::cpp2::_City_EnumMapFactory::makeNamesToValuesMap()};
  return findValue(*map, name, outValue);
}

}} // apache::thrift
namespace cpp2 {

const _Company_EnumMapFactory::ValuesToNamesMapType _Company_VALUES_TO_NAMES = _Company_EnumMapFactory::makeValuesToNamesMap();
const _Company_EnumMapFactory::NamesToValuesMapType _Company_NAMES_TO_VALUES = _Company_EnumMapFactory::makeNamesToValuesMap();

} // cpp2
namespace std {

} // std
namespace apache { namespace thrift {

template <> const std::size_t TEnumTraits< ::cpp2::Company>::size = 4;
template <> const folly::Range<const  ::cpp2::Company*> TEnumTraits< ::cpp2::Company>::values = folly::range( ::cpp2::_CompanyEnumDataStorage::values);
template <> const folly::Range<const folly::StringPiece*> TEnumTraits< ::cpp2::Company>::names = folly::range( ::cpp2::_CompanyEnumDataStorage::names);
template <> const char* TEnumTraits< ::cpp2::Company>::findName( ::cpp2::Company value) {
  static auto const map = folly::Indestructible< ::cpp2::_Company_EnumMapFactory::ValuesToNamesMapType>{ ::cpp2::_Company_EnumMapFactory::makeValuesToNamesMap()};
  return findName(*map, value);
}

template <> bool TEnumTraits< ::cpp2::Company>::findValue(const char* name,  ::cpp2::Company* outValue) {
  static auto const map = folly::Indestructible< ::cpp2::_Company_EnumMapFactory::NamesToValuesMapType>{ ::cpp2::_Company_EnumMapFactory::makeNamesToValuesMap()};
  return findValue(*map, name, outValue);
}

}} // apache::thrift
namespace cpp2 {

void Internship::__clear() {
  // clear all fields
  weeks = 0;
  title = apache::thrift::StringTraits< std::string>::fromStringLiteral("");
  employer =  ::cpp2::Company::FACEBOOK;
  __isset.__clear();
}

bool Internship::operator==(const Internship& rhs) const {
  if (!((weeks == rhs.weeks))) {
    return false;
  }
  if (!((title == rhs.title))) {
    return false;
  }
  if (__isset.employer != rhs.__isset.employer) {
    return false;
  }
  else if (__isset.employer && !((employer == rhs.employer))) {
    return false;
  }
  return true;
}

void Internship::translateFieldName(FOLLY_MAYBE_UNUSED folly::StringPiece _fname, FOLLY_MAYBE_UNUSED int16_t& fid, FOLLY_MAYBE_UNUSED apache::thrift::protocol::TType& _ftype) {
  if (false) {}
  else if (_fname == "weeks") {
    fid = 1;
    _ftype = apache::thrift::protocol::T_I32;
  }
  else if (_fname == "title") {
    fid = 2;
    _ftype = apache::thrift::protocol::T_STRING;
  }
  else if (_fname == "employer") {
    fid = 3;
    _ftype = apache::thrift::protocol::T_I32;
  }
}

void swap(Internship& a, Internship& b) {
  using ::std::swap;
  swap(a.weeks, b.weeks);
  swap(a.title, b.title);
  swap(a.employer, b.employer);
  swap(a.__isset, b.__isset);
}

template uint32_t Internship::read<>(apache::thrift::BinaryProtocolReader*);
template uint32_t Internship::write<>(apache::thrift::BinaryProtocolWriter*) const;
template uint32_t Internship::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t Internship::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t Internship::read<>(apache::thrift::CompactProtocolReader*);
template uint32_t Internship::write<>(apache::thrift::CompactProtocolWriter*) const;
template uint32_t Internship::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const;
template uint32_t Internship::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const;

} // cpp2
namespace cpp2 {

void UnEnumStruct::__clear() {
  // clear all fields
  city = static_cast< ::cpp2::City>(-1);
  __isset.__clear();
}

bool UnEnumStruct::operator==(const UnEnumStruct& rhs) const {
  if (!((city == rhs.city))) {
    return false;
  }
  return true;
}

void UnEnumStruct::translateFieldName(FOLLY_MAYBE_UNUSED folly::StringPiece _fname, FOLLY_MAYBE_UNUSED int16_t& fid, FOLLY_MAYBE_UNUSED apache::thrift::protocol::TType& _ftype) {
  if (false) {}
  else if (_fname == "city") {
    fid = 1;
    _ftype = apache::thrift::protocol::T_I32;
  }
}

void swap(UnEnumStruct& a, UnEnumStruct& b) {
  using ::std::swap;
  swap(a.city, b.city);
  swap(a.__isset, b.__isset);
}

template uint32_t UnEnumStruct::read<>(apache::thrift::BinaryProtocolReader*);
template uint32_t UnEnumStruct::write<>(apache::thrift::BinaryProtocolWriter*) const;
template uint32_t UnEnumStruct::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t UnEnumStruct::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t UnEnumStruct::read<>(apache::thrift::CompactProtocolReader*);
template uint32_t UnEnumStruct::write<>(apache::thrift::CompactProtocolWriter*) const;
template uint32_t UnEnumStruct::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const;
template uint32_t UnEnumStruct::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const;

} // cpp2
namespace cpp2 {

void Range::__clear() {
  // clear all fields
  min = 0;
  max = 0;
}

bool Range::operator==(const Range& rhs) const {
  if (!((min == rhs.min))) {
    return false;
  }
  if (!((max == rhs.max))) {
    return false;
  }
  return true;
}

void Range::translateFieldName(FOLLY_MAYBE_UNUSED folly::StringPiece _fname, FOLLY_MAYBE_UNUSED int16_t& fid, FOLLY_MAYBE_UNUSED apache::thrift::protocol::TType& _ftype) {
  if (false) {}
  else if (_fname == "min") {
    fid = 1;
    _ftype = apache::thrift::protocol::T_I32;
  }
  else if (_fname == "max") {
    fid = 2;
    _ftype = apache::thrift::protocol::T_I32;
  }
}

void swap(Range& a, Range& b) {
  using ::std::swap;
  swap(a.min, b.min);
  swap(a.max, b.max);
}

template uint32_t Range::read<>(apache::thrift::BinaryProtocolReader*);
template uint32_t Range::write<>(apache::thrift::BinaryProtocolWriter*) const;
template uint32_t Range::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t Range::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t Range::read<>(apache::thrift::CompactProtocolReader*);
template uint32_t Range::write<>(apache::thrift::CompactProtocolWriter*) const;
template uint32_t Range::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const;
template uint32_t Range::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const;

} // cpp2
namespace cpp2 {

void struct1::__clear() {
  // clear all fields
  a = 1234567;
  b = apache::thrift::StringTraits< std::string>::fromStringLiteral("<uninitialized>");
  __isset.__clear();
}

bool struct1::operator==(const struct1& rhs) const {
  if (!((a == rhs.a))) {
    return false;
  }
  if (!((b == rhs.b))) {
    return false;
  }
  return true;
}

void struct1::translateFieldName(FOLLY_MAYBE_UNUSED folly::StringPiece _fname, FOLLY_MAYBE_UNUSED int16_t& fid, FOLLY_MAYBE_UNUSED apache::thrift::protocol::TType& _ftype) {
  if (false) {}
  else if (_fname == "a") {
    fid = 1;
    _ftype = apache::thrift::protocol::T_I32;
  }
  else if (_fname == "b") {
    fid = 2;
    _ftype = apache::thrift::protocol::T_STRING;
  }
}

void swap(struct1& a, struct1& b) {
  using ::std::swap;
  swap(a.a, b.a);
  swap(a.b, b.b);
  swap(a.__isset, b.__isset);
}

template uint32_t struct1::read<>(apache::thrift::BinaryProtocolReader*);
template uint32_t struct1::write<>(apache::thrift::BinaryProtocolWriter*) const;
template uint32_t struct1::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t struct1::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t struct1::read<>(apache::thrift::CompactProtocolReader*);
template uint32_t struct1::write<>(apache::thrift::CompactProtocolWriter*) const;
template uint32_t struct1::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const;
template uint32_t struct1::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const;

} // cpp2
namespace cpp2 {

void struct2::__clear() {
  // clear all fields
  a = 0;
  b = apache::thrift::StringTraits< std::string>::fromStringLiteral("");
  ::apache::thrift::Cpp2Ops<  ::cpp2::struct1>::clear(&c);
  d.clear();
  __isset.__clear();
}

bool struct2::operator==(const struct2& rhs) const {
  if (!((a == rhs.a))) {
    return false;
  }
  if (!((b == rhs.b))) {
    return false;
  }
  if (!((c == rhs.c))) {
    return false;
  }
  if (!((d == rhs.d))) {
    return false;
  }
  return true;
}

const  ::cpp2::struct1& struct2::get_c() const& {
  return c;
}

 ::cpp2::struct1 struct2::get_c() && {
  return std::move(c);
}

const std::vector<int32_t>& struct2::get_d() const& {
  return d;
}

std::vector<int32_t> struct2::get_d() && {
  return std::move(d);
}

void struct2::translateFieldName(FOLLY_MAYBE_UNUSED folly::StringPiece _fname, FOLLY_MAYBE_UNUSED int16_t& fid, FOLLY_MAYBE_UNUSED apache::thrift::protocol::TType& _ftype) {
  if (false) {}
  else if (_fname == "a") {
    fid = 1;
    _ftype = apache::thrift::protocol::T_I32;
  }
  else if (_fname == "b") {
    fid = 2;
    _ftype = apache::thrift::protocol::T_STRING;
  }
  else if (_fname == "c") {
    fid = 3;
    _ftype = apache::thrift::protocol::T_STRUCT;
  }
  else if (_fname == "d") {
    fid = 4;
    _ftype = apache::thrift::protocol::T_LIST;
  }
}

void swap(struct2& a, struct2& b) {
  using ::std::swap;
  swap(a.a, b.a);
  swap(a.b, b.b);
  swap(a.c, b.c);
  swap(a.d, b.d);
  swap(a.__isset, b.__isset);
}

template uint32_t struct2::read<>(apache::thrift::BinaryProtocolReader*);
template uint32_t struct2::write<>(apache::thrift::BinaryProtocolWriter*) const;
template uint32_t struct2::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t struct2::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t struct2::read<>(apache::thrift::CompactProtocolReader*);
template uint32_t struct2::write<>(apache::thrift::CompactProtocolWriter*) const;
template uint32_t struct2::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const;
template uint32_t struct2::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const;

} // cpp2
namespace cpp2 {

void struct3::__clear() {
  // clear all fields
  a = apache::thrift::StringTraits< std::string>::fromStringLiteral("");
  b = 0;
  ::apache::thrift::Cpp2Ops<  ::cpp2::struct2>::clear(&c);
  __isset.__clear();
}

bool struct3::operator==(const struct3& rhs) const {
  if (!((a == rhs.a))) {
    return false;
  }
  if (!((b == rhs.b))) {
    return false;
  }
  if (!((c == rhs.c))) {
    return false;
  }
  return true;
}

const  ::cpp2::struct2& struct3::get_c() const& {
  return c;
}

 ::cpp2::struct2 struct3::get_c() && {
  return std::move(c);
}

void struct3::translateFieldName(FOLLY_MAYBE_UNUSED folly::StringPiece _fname, FOLLY_MAYBE_UNUSED int16_t& fid, FOLLY_MAYBE_UNUSED apache::thrift::protocol::TType& _ftype) {
  if (false) {}
  else if (_fname == "a") {
    fid = 1;
    _ftype = apache::thrift::protocol::T_STRING;
  }
  else if (_fname == "b") {
    fid = 2;
    _ftype = apache::thrift::protocol::T_I32;
  }
  else if (_fname == "c") {
    fid = 3;
    _ftype = apache::thrift::protocol::T_STRUCT;
  }
}

void swap(struct3& a, struct3& b) {
  using ::std::swap;
  swap(a.a, b.a);
  swap(a.b, b.b);
  swap(a.c, b.c);
  swap(a.__isset, b.__isset);
}

template uint32_t struct3::read<>(apache::thrift::BinaryProtocolReader*);
template uint32_t struct3::write<>(apache::thrift::BinaryProtocolWriter*) const;
template uint32_t struct3::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t struct3::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t struct3::read<>(apache::thrift::CompactProtocolReader*);
template uint32_t struct3::write<>(apache::thrift::CompactProtocolWriter*) const;
template uint32_t struct3::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const;
template uint32_t struct3::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const;

} // cpp2
namespace cpp2 {

void union1::__clear() {
  // clear all fields
  if (type_ == Type::__EMPTY__) { return; }
  switch(type_) {
    case Type::i:
    {
      destruct(value_.i);
      break;
    }
    case Type::d:
    {
      destruct(value_.d);
      break;
    }
    default:
    {
      assert(false);
      break;
    }
  }
  type_ = Type::__EMPTY__;
}

bool union1::operator==(const union1& rhs) const {
  if (type_ != rhs.type_) { return false; }
  switch(type_) {
    case Type::i:
    {
      return value_.i == rhs.value_.i;
    }
    case Type::d:
    {
      return value_.d == rhs.value_.d;
    }
    default:
    {
      return true;
    }
  }
}
void union1::translateFieldName(FOLLY_MAYBE_UNUSED folly::StringPiece _fname, FOLLY_MAYBE_UNUSED int16_t& fid, FOLLY_MAYBE_UNUSED apache::thrift::protocol::TType& _ftype) {
  if (false) {}
  else if (_fname == "i") {
    fid = 1;
    _ftype = apache::thrift::protocol::T_I32;
  }
  else if (_fname == "d") {
    fid = 2;
    _ftype = apache::thrift::protocol::T_DOUBLE;
  }
}

void swap(union1& a, union1& b) {
  union1 temp(std::move(a));
  a = std::move(b);
  b = std::move(temp);
}

template uint32_t union1::read<>(apache::thrift::BinaryProtocolReader*);
template uint32_t union1::write<>(apache::thrift::BinaryProtocolWriter*) const;
template uint32_t union1::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t union1::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t union1::read<>(apache::thrift::CompactProtocolReader*);
template uint32_t union1::write<>(apache::thrift::CompactProtocolWriter*) const;
template uint32_t union1::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const;
template uint32_t union1::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const;

} // cpp2
namespace cpp2 {

void union2::__clear() {
  // clear all fields
  if (type_ == Type::__EMPTY__) { return; }
  switch(type_) {
    case Type::i:
    {
      destruct(value_.i);
      break;
    }
    case Type::d:
    {
      destruct(value_.d);
      break;
    }
    case Type::s:
    {
      destruct(value_.s);
      break;
    }
    case Type::u:
    {
      destruct(value_.u);
      break;
    }
    default:
    {
      assert(false);
      break;
    }
  }
  type_ = Type::__EMPTY__;
}

bool union2::operator==(const union2& rhs) const {
  if (type_ != rhs.type_) { return false; }
  switch(type_) {
    case Type::i:
    {
      return value_.i == rhs.value_.i;
    }
    case Type::d:
    {
      return value_.d == rhs.value_.d;
    }
    case Type::s:
    {
      return value_.s == rhs.value_.s;
    }
    case Type::u:
    {
      return value_.u == rhs.value_.u;
    }
    default:
    {
      return true;
    }
  }
}
void union2::translateFieldName(FOLLY_MAYBE_UNUSED folly::StringPiece _fname, FOLLY_MAYBE_UNUSED int16_t& fid, FOLLY_MAYBE_UNUSED apache::thrift::protocol::TType& _ftype) {
  if (false) {}
  else if (_fname == "i") {
    fid = 1;
    _ftype = apache::thrift::protocol::T_I32;
  }
  else if (_fname == "d") {
    fid = 2;
    _ftype = apache::thrift::protocol::T_DOUBLE;
  }
  else if (_fname == "s") {
    fid = 3;
    _ftype = apache::thrift::protocol::T_STRUCT;
  }
  else if (_fname == "u") {
    fid = 4;
    _ftype = apache::thrift::protocol::T_STRUCT;
  }
}

void swap(union2& a, union2& b) {
  union2 temp(std::move(a));
  a = std::move(b);
  b = std::move(temp);
}

template uint32_t union2::read<>(apache::thrift::BinaryProtocolReader*);
template uint32_t union2::write<>(apache::thrift::BinaryProtocolWriter*) const;
template uint32_t union2::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t union2::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const;
template uint32_t union2::read<>(apache::thrift::CompactProtocolReader*);
template uint32_t union2::write<>(apache::thrift::CompactProtocolWriter*) const;
template uint32_t union2::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const;
template uint32_t union2::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const;

} // cpp2


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

	<groupId>com.jd</groupId>
	<artifactId>jdmvc</artifactId>
	<version>1.2.5</version>
	<packaging>jar</packaging>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<version>3.1</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring</artifactId>
			<version>2.5.6</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
			<version>1.1.39</version>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
		</dependency>
		<dependency>
			<groupId>commons-fileupload</groupId>
			<artifactId>commons-fileupload</artifactId>
			<version>1.2.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>cglib</groupId>
			<artifactId>cglib</artifactId>
			<version>2.1_3</version>
		</dependency>
		<dependency>
			<groupId>org.freemarker</groupId>
			<artifactId>freemarker</artifactId>
			<version>2.3.14</version>
			<scope>provided</scope>
		</dependency>
	</dependencies>

</project>

redpajama_set_name: RedPajamaGithub


text:
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE AutoDeriveTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  Data.Monoid
-- Copyright   :  (c) Andy Gill 2001,
--                (c) Oregon Graduate Institute of Science and Technology, 2001
-- License     :  BSD-style (see the file libraries/base/LICENSE)
--
-- Maintainer  :  libraries@haskell.org
-- Stability   :  experimental
-- Portability :  portable
--
-- A class for monoids (types with an associative binary operation that
-- has an identity) with various general-purpose instances.
--
-----------------------------------------------------------------------------

module Data.Monoid (
        -- * 'Monoid' typeclass
        Monoid(..),
        (<>),
        Dual(..),
        Endo(..),
        -- * 'Bool' wrappers
        All(..),
        Any(..),
        -- * 'Num' wrappers
        Sum(..),
        Product(..),
        -- * 'Maybe' wrappers
        -- $MaybeExamples
        First(..),
        Last(..),
        -- * 'Alternative' wrapper
        Alt (..)
  ) where

-- Push down the module in the dependency hierarchy.
import GHC.Base hiding (Any)
import GHC.Enum
import GHC.Num
import GHC.Read
import GHC.Show
import GHC.Generics

{-
-- just for testing
import Data.Maybe
import Test.QuickCheck
-- -}

infixr 6 <>

-- | An infix synonym for 'mappend'.
--
-- @since 4.5.0.0
(<>) :: Monoid m => m -> m -> m
(<>) = mappend
{-# INLINE (<>) #-}

-- Monoid instances.

-- | The dual of a 'Monoid', obtained by swapping the arguments of 'mappend'.
newtype Dual a = Dual { getDual :: a }
        deriving (Eq, Ord, Read, Show, Bounded, Generic, Generic1)

instance Monoid a => Monoid (Dual a) where
        mempty = Dual mempty
        Dual x `mappend` Dual y = Dual (y `mappend` x)

-- | The monoid of endomorphisms under composition.
newtype Endo a = Endo { appEndo :: a -> a }
               deriving (Generic)

instance Monoid (Endo a) where
        mempty = Endo id
        Endo f `mappend` Endo g = Endo (f . g)

-- | Boolean monoid under conjunction ('&&').
newtype All = All { getAll :: Bool }
        deriving (Eq, Ord, Read, Show, Bounded, Generic)

instance Monoid All where
        mempty = All True
        All x `mappend` All y = All (x && y)

-- | Boolean monoid under disjunction ('||').
newtype Any = Any { getAny :: Bool }
        deriving (Eq, Ord, Read, Show, Bounded, Generic)

instance Monoid Any where
        mempty = Any False
        Any x `mappend` Any y = Any (x || y)

-- | Monoid under addition.
newtype Sum a = Sum { getSum :: a }
        deriving (Eq, Ord, Read, Show, Bounded, Generic, Generic1, Num)

instance Num a => Monoid (Sum a) where
        mempty = Sum 0
        mappend = coerce ((+) :: a -> a -> a)
--        Sum x `mappend` Sum y = Sum (x + y)

-- | Monoid under multiplication.
newtype Product a = Product { getProduct :: a }
        deriving (Eq, Ord, Read, Show, Bounded, Generic, Generic1, Num)

instance Num a => Monoid (Product a) where
        mempty = Product 1
        mappend = coerce ((*) :: a -> a -> a)
--        Product x `mappend` Product y = Product (x * y)

-- $MaybeExamples
-- To implement @find@ or @findLast@ on any 'Foldable':
--
-- @
-- findLast :: Foldable t => (a -> Bool) -> t a -> Maybe a
-- findLast pred = getLast . foldMap (\x -> if pred x
--                                            then Last (Just x)
--                                            else Last Nothing)
-- @
--
-- Much of Data.Map's interface can be implemented with
-- Data.Map.alter. Some of the rest can be implemented with a new
-- @alterA@ function and either 'First' or 'Last':
--
-- > alterA :: (Applicative f, Ord k) =>
-- >           (Maybe a -> f (Maybe a)) -> k -> Map k a -> f (Map k a)
-- >
-- > instance Monoid a => Applicative ((,) a)  -- from Control.Applicative
--
-- @
-- insertLookupWithKey :: Ord k => (k -> v -> v -> v) -> k -> v
--                     -> Map k v -> (Maybe v, Map k v)
-- insertLookupWithKey combine key value =
--   Arrow.first getFirst . alterA doChange key
--   where
--   doChange Nothing = (First Nothing, Just value)
--   doChange (Just oldValue) =
--     (First (Just oldValue),
--      Just (combine key value oldValue))
-- @

-- | Maybe monoid returning the leftmost non-Nothing value.
--
-- @'First' a@ is isomorphic to @'Alt' 'Maybe' a@, but precedes it
-- historically.
newtype First a = First { getFirst :: Maybe a }
        deriving (Eq, Ord, Read, Show, Generic, Generic1,
                  Functor, Applicative, Monad)

instance Monoid (First a) where
        mempty = First Nothing
        First Nothing `mappend` r = r
        l `mappend` _             = l

-- | Maybe monoid returning the rightmost non-Nothing value.
--
-- @'Last' a@ is isomorphic to @'Dual' ('First' a)@, and thus to
-- @'Dual' ('Alt' 'Maybe' a)@
newtype Last a = Last { getLast :: Maybe a }
        deriving (Eq, Ord, Read, Show, Generic, Generic1,
                  Functor, Applicative, Monad)

instance Monoid (Last a) where
        mempty = Last Nothing
        l `mappend` Last Nothing = l
        _ `mappend` r            = r

-- | Monoid under '<|>'.
--
-- @since 4.8.0.0
newtype Alt f a = Alt {getAlt :: f a}
  deriving (Generic, Generic1, Read, Show, Eq, Ord, Num, Enum,
            Monad, MonadPlus, Applicative, Alternative, Functor)

instance forall f a . Alternative f => Monoid (Alt f a) where
        mempty = Alt empty
        mappend = coerce ((<|>) :: f a -> f a -> f a)

{-
{--------------------------------------------------------------------
  Testing
--------------------------------------------------------------------}
instance Arbitrary a => Arbitrary (Maybe a) where
  arbitrary = oneof [return Nothing, Just `fmap` arbitrary]

prop_mconcatMaybe :: [Maybe [Int]] -> Bool
prop_mconcatMaybe x =
  fromMaybe [] (mconcat x) == mconcat (catMaybes x)

prop_mconcatFirst :: [Maybe Int] -> Bool
prop_mconcatFirst x =
  getFirst (mconcat (map First x)) == listToMaybe (catMaybes x)
prop_mconcatLast :: [Maybe Int] -> Bool
prop_mconcatLast x =
  getLast (mconcat (map Last x)) == listLastToMaybe (catMaybes x)
        where listLastToMaybe [] = Nothing
              listLastToMaybe lst = Just (last lst)
-- -}


text:
{% extends "onlinejudge/base.html" %}
{% load i18n markup_tags sekizai_tags crispy_forms_tags onlinejudge_tags %}

{% block "header" %}{% endblock "header" %}

{% block "content" %}

{% addtoblock "js" %}

{% endaddtoblock %}

{% addtoblock "js" %}

{% endaddtoblock %}

{{ submission_form.media }}
{{ challenge_problem_form.media }}
{{ challenge_template_form.media }}

{{ challenge.name }}

{# Nav tabs #}

{% trans "Problem" %}

{% trans "Submission" %}

  {% if public_submissions %}

{% trans "Solution" %}

  {% endif %}
  {% if request.user.is_superuser %}

{% trans "Edit problem" %}

{% trans "Edit template" %}

  {% endif %}

{# Tab panes #}

        {{ challenge.problem|apply_markup:"markdown" }}
        {% for tc in public_test_cases %}

{% trans "Test Case" %}

          {{ tc.hint|apply_markup:"markdown" }}

{% trans "Input" %}

{{ tc.display_input }}

{% trans "Output" %}

{{ tc.display_output }}

        {% endfor %}

{% trans "Tags" %}

        {% for ti in challenge.tagged_items.all %}
          <button type="button" class="btn btn-default">{{ ti.tag.name }}</button>
        {% endfor %}

    {% crispy submission_form %}

      {% for submission in public_submissions %}
        {{ submission.code|pygmentize }}
      {% endfor %}

    {% crispy challenge_problem_form %}

    {% crispy challenge_template_form %}

{% endblock "content" %}


text:
#pragma once

#include <folly/Conv.h>
#include <folly/Range.h>
#include <stdexcept>

#include "watchman/OptionSet.h"
#include "watchman/watchman_preprocessor.h"

class json_ref;
struct watchman_client;

namespace watchman {
using command_func = void (*)(watchman_client* client, const json_ref& args);

// Should throw an exception (ideally CommandValidationError) if validation
// fails
using cli_cmd_validate_func = void (*)(json_ref& args);

struct CommandFlags : OptionSet<CommandFlags, uint8_t> {};

inline constexpr auto CMD_DAEMON = CommandFlags::raw(1);
inline constexpr auto CMD_CLIENT = CommandFlags::raw(2);
inline constexpr auto CMD_POISON_IMMUNE = CommandFlags::raw(4);
inline constexpr auto CMD_ALLOW_ANY_USER = CommandFlags::raw(8);

struct command_handler_def {
  const char* name;
  command_func func;
  CommandFlags flags;
  cli_cmd_validate_func cli_validate;
};

void register_command(command_handler_def& defs);

/**
 * Provide a way to query (and eventually modify) command line arguments
 *
 * This is not thread-safe and should only be invoked from main()
 */
command_handler_def* lookup_command(
    std::string_view cmd_name,
    CommandFlags mode);

std::vector<command_handler_def*> get_all_commands();

#define W_CMD_REG_1(symbol, name, func, flags, clivalidate) \
  static w_ctor_fn_type(symbol) {                           \
    static ::watchman::command_handler_def d = {            \
        name, func, flags, clivalidate};                    \
    ::watchman::register_command(d);                        \
  }                                                         \
  w_ctor_fn_reg(symbol)

#define W_CMD_REG(name, func, flags, clivalidate) \
  W_CMD_REG_1(w_gen_symbol(w_cmd_register_), name, func, flags, clivalidate)

#define W_CAP_REG1(symbol, name)           \
  static w_ctor_fn_type(symbol) {          \
    ::watchman::capability_register(name); \
  }                                        \
  w_ctor_fn_reg(symbol)

#define W_CAP_REG(name) W_CAP_REG1(w_gen_symbol(w_cap_reg_), name)

void capability_register(const char* name);
bool capability_supported(std::string_view name);
json_ref capability_get_list();

} // namespace watchman

/* vim:ts=2:sw=2:et:
 */


text:
using System.Runtime.Serialization;

namespace Aliencube.ReCaptcha.Wrapper.Mvc.Parameters
{
    /// <summary>
    /// This specifies the data type for reCaptcha control.
    /// </summary>
    /// <remarks>More details: https://developers.google.com/recaptcha/docs/display#render_param</remarks>
    public enum RenderDataType
    {
        /// <summary>
        /// Identifies no data type is defined.
        /// </summary>
        Unknown = 0,

        /// <summary>
        /// Identifies the image data type.
        /// </summary>
        [EnumMember(Value = "image")]
        Image = 1,

        /// <summary>
        /// Identifies the audio data type.
        /// </summary>
        [EnumMember(Value = "audio")]
        Audio = 2,
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
                                    xmlns:app="http://schemas.android.com/apk/res-auto"
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    app:contentPadding="4dp">
    <RelativeLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="@style/TextAppearance.AppCompat.Body1"
                android:text="Name"
                android:id="@+id/tvCollectibleName"
                android:layout_alignParentTop="true"/>

        <TextView
                android:layout_below="@+id/tvCollectibleName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="@style/TextAppearance.AppCompat.Caption"
                android:text="found..."
                android:id="@+id/tvCollectibleDescription"/>

        <TextView
                android:layout_toRightOf="@+id/tvCollectibleName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="@style/TextAppearance.AppCompat.Caption"
                android:text="rarity"
                android:id="@+id/tvCollectibleRarity"/>

    </RelativeLayout>

</android.support.v7.widget.CardView>


text:
[![NPM](https://nodei.co/npm/prettylogs.png?compact=true)](https://nodei.co/npm/prettylogs/)

Simple util for watching JSON logs with [prettyjson](https://github.com/rafeca/prettyjson) tool.

## Usage:
* Install Node.js
* Install prettylogs:  `npm install prettylogs -g`
* Specify log file: `prlogs project/development.log.json`


text:
#include <fcntl.h>
#include <proc_event.h>
#include <sched.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/dir.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>

#include "errnos.h"

#define MAX_ARGS 8

/* HACK! */
#define MAX_SYS 500

struct syscall_args
{
    size_t args[MAX_ARGS];
};

struct system_call
{
    const char *name;
    void (*callback)(struct syscall_args *args, struct proc_event *event);
    void (*exit)(size_t return_value, struct proc_event *event);
};

void print_errno(int err)
{
    const char *err_name = NULL;
    if (err >= NUM_ERRNOS)
    {
        err_name = __errno_table[0];
    }
    else
        err_name = __errno_table[err];

    printf("%s", err_name);
}

void do_write(struct syscall_args *args, struct proc_event *event)
{
    printf("%u, %p, %lu", args->args[0], args->args[1], args->args[2]);
}

void do_long_exit(size_t return_value, struct proc_event *event)
{
    ssize_t ret = (ssize_t) return_value;

    if (ret < 0)
    {
        printf("-1 ");
        print_errno((int) -ret);
    }
    else
        printf("%ld", ret);
}

void do_integer_exit(size_t return_value, struct proc_event *event)
{
    int ret = (int) return_value;

    if (ret < 0)
    {
        printf("-1 ");
        print_errno((int) -ret);
    }
    else
        printf("%d", ret);
}

void do_void_exit(size_t return_value, struct proc_event *event)
{
    printf("0");
}

void do_noexit(size_t return_value, struct proc_event *event)
{
    printf("?");
}

void do_pointer_exit(size_t return_value, struct proc_event *event)
{
    printf("%p", (void *) return_value);
}

void do_mmap_exit(size_t return_value, struct proc_event *event)
{
    void *ptr = (void *) return_value;
    if (ptr == MAP_FAILED)
        printf("-1 MAP_FAILED");
    else
        printf("%p", ptr);
}

void do_read(struct syscall_args *args, struct proc_event *event)
{
    printf("%u, %p, %lu", args->args[0], args->args[1], args->args[2]);
}

void do_open(struct syscall_args *args, struct proc_event *event)
{
    printf("%p, %d, %d", args->args[0], args->args[1], args->args[2]);
}

void do_close(struct syscall_args *args, struct proc_event *event)
{
    printf("%u", args->args[0]);
}

void do_dup(struct syscall_args *args, struct proc_event *event)
{
    printf("%d", args->args[0]);
}

void do_dup2(struct syscall_args *args, struct proc_event *event)
{
    printf("%d, %d", args->args[0], args->args[1]);
}

void do_noargs(struct syscall_args *args, struct proc_event *event)
{
    (void) args;
    (void) event;
}

void do_lseek(struct syscall_args *args, struct proc_event *event)
{
    int fd = args->args[0];
    off_t offset = args->args[1];
    int whence = args->args[2];

    const char *whence_str = NULL;

    switch (whence)
    {
        case SEEK_SET:
            whence_str = "SEEK_SET";
            break;
        case SEEK_CUR:
            whence_str = "SEEK_CUR";
            break;
        case SEEK_END:
            whence_str = "SEEK_END";
            break;
    }

    if (whence_str)
        printf("%d, %ld, %s", fd, offset, whence_str);
    else
        printf("%d, %ld, %d", fd, offset, whence);
}

void do_exit(struct syscall_args *args, struct proc_event *event)
{
    printf("%d", args->args[0]);
}

void print_prots(int prot)
{
    if (prot == PROT_NONE)
    {
        printf("PROT_NONE");
    }
    else
    {
        bool do_or = false;
        if (prot & PROT_READ)
        {
            printf("PROT_READ");
            do_or = true;
        }

        if (prot & PROT_WRITE)
        {
            printf(do_or ? "|PROT_WRITE" : "PROT_WRITE");
            do_or = true;
        }

        if (prot & PROT_EXEC)
        {
            printf(do_or ? "|PROT_EXEC" : "PROT_EXEC");
            do_or = true;
        }
    }
}

void do_mmap(struct syscall_args *args, struct proc_event *event)
{
    void *addr = (void *) args->args[0];
    size_t len = args->args[1];
    int prot = (int) args->args[2];
    int flags = (int) args->args[3];
    int fildes = (int) args->args[4];
    off_t off = (off_t) args->args[5];

    printf("%p, %lu, ", addr, len);

    print_prots(prot);
    printf(", ");

    bool do_or = false;
    if (flags & MAP_PRIVATE)
    {
        printf("MAP_PRIVATE");
        do_or = true;
    }

    if (flags & MAP_SHARED)
    {
        printf(do_or ? "|MAP_SHARED" : "MAP_SHARED");
        do_or = true;
    }

    if (flags & MAP_ANONYMOUS)
    {
        printf(do_or ? "|MAP_ANONYMOUS" : "MAP_ANONYMOUS");
        do_or = true;
    }

    if (flags & MAP_FIXED)
    {
        printf(do_or ? "|MAP_FIXED" : "MAP_FIXED");
        do_or = true;
    }

    /* TODO: Add flags as needed */
    printf(", %d, %ld", fildes, off);
}

void do_munmap(struct syscall_args *args, struct proc_event *event)
{
    void *addr = (void *) args->args[0];
    size_t len = args->args[1];
    printf("%p, %lu", addr, len);
}

void do_mprotect(struct syscall_args *args, struct proc_event *event)
{
    int prot = (int) args->args[2];
    /* mprotect and munmap share the same first two arguments */
    do_munmap(args, event);

    printf(", ");
    print_prots(prot);
}

void do_mount(struct syscall_args *args, struct proc_event *event)
{
    /* TODO: Don't bother print string arguments since we can't print them out yet */
}

void do_execve(struct syscall_args *args, struct proc_event *event)
{
    /* Same as above */
    const char *pathname = (const char *) args->args[0];
    char **argv = (char **) args->args[1];
    char **envp = (char **) args->args[2];
    (void) pathname;
    (void) argv;
    (void) envp;
}

void do_brk(struct syscall_args *args, struct proc_event *event)
{
    void *new_brk = (void *) args->args[0];
    printf("%p", new_brk);
}

const char *signal_names[] = {"SIGHUP",  "SIGINT",  "SIGQUIT", "SIGILL",  "SIGABRT",
                              "SIGFPE",  "SIGKILL", "SIGSEGV", "SIGPIPE", "SIGALRM",
                              "SIGTERM", "SIGUSR1", "SIGUSR2", "SIGCHLD", "SIGCONT",
                              "SIGSTOP", "SIGTSTP", "SIGTTIN", "SIGTTOU"};

const char *get_signame(int sig)
{
    if ((unsigned int) sig >= sizeof(signal_names) / sizeof(const char *))
        return NULL;
    return signal_names[sig - 1];
}

void do_kill(struct syscall_args *args, struct proc_event *event)
{
    pid_t pid = (pid_t) args->args[0];
    int sig = (int) args->args[1];
    const char *s = get_signame(sig);

    if (s)
        printf("%i, %s", pid, s);
    else
        printf("%i, %i", pid, sig);
}

void do_wait4(struct syscall_args *args, struct proc_event *event)
{
    pid_t pid = (pid_t) args->args[0];
    int *wstatus = (int *) args->args[1];
    int options = (int) args->args[2];
    struct rusage *rusage = (struct rusage *) args->args[3];

    printf("%i, %p, ", pid, wstatus);
    bool do_or = false;
    if (options & WNOHANG)
    {
        printf("WNOHANG");
        do_or = true;
    }

    if (options & WUNTRACED)
    {
        printf(do_or ? "|WUNTRACED" : "WUNTRACED");
        do_or = true;
    }

    if (options & WCONTINUED)
    {
        printf(do_or ? "|WCONTINUED" : "WCONTINUED");
    }

    printf(", %p", rusage);
}

void do_time(struct syscall_args *args, struct proc_event *event)
{
    time_t *p = (time_t *) args->args[0];
    printf("%p", p);
}

void do_gettimeofday(struct syscall_args *args, struct proc_event *event)
{
    struct timeval *tv = (struct timeval *) args->args[0];
    struct timezone *tz = (struct timezone *) args->args[1];

    printf("%p, %p", tv, tz);
}

void do_print_iov(struct syscall_args *args, struct proc_event *event)
{
    int fd = (int) args->args[0];
    struct iovec *iov = (struct iovec *) args->args[1];
    int iovec_cnt = (int) args->args[2];
    printf("%i, %p, %i", fd, iov, iovec_cnt);
}

void do_print_piov(struct syscall_args *args, struct proc_event *event)
{
    do_print_iov(args, event);
    printf(", %l", (off_t) args->args[3]);
}

void do_getdents(struct syscall_args *args, struct proc_event *event)
{
    int fd = (int) args->args[0];
    struct dirent *d = (struct dirent *) args->args[1];
    unsigned int count = (unsigned int) args->args[2];

    printf("%i, %p, %u", fd, d, count);
}

void do_ioctl(struct syscall_args *args, struct proc_event *event)
{
    /* TODO: Handle the different ioctl reqs */
    int fd = (int) args->args[0];
    unsigned long req = args->args[1];
    char *argp = (char *) args->args[2];

    printf("%i, %lu, %p", fd, req, argp);
}

void do_truncate(struct syscall_args *args, struct proc_event *event)
{
    const char *path = (const char *) args->args[0];
    off_t len = (off_t) args->args[1];

    printf("%p, %l", path, len);
}

void do_ftruncate(struct syscall_args *args, struct proc_event *event)
{
    int fd = (int) args->args[0];
    off_t len = (off_t) args->args[1];

    printf("%i, %l", fd, len);
}

void do_personality(struct syscall_args *args, struct proc_event *event)
{
    unsigned long persona = args->args[0];
    printf("%lx", persona);
}

void do_print_id(struct syscall_args *args, struct proc_event *event)
{
    /* uid_t type == gid_t type */
    uid_t id = (uid_t) args->args[0];
    printf("%lu", id);
}

void do_mremap(struct syscall_args *args, struct proc_event *event)
{
    void *old_addr = (void *) args->args[0];
    size_t old_size = args->args[1];
    size_t new_size = args->args[2];
    int flags = (int) args->args[3];
    void *new_addr = (void *) args->args[4];

    bool new_addr_valid = flags & MREMAP_FIXED;

    printf("%p, %lu, %lu, ", old_addr, old_size, new_size);
    bool do_or = false;

    if (flags & MREMAP_MAYMOVE)
    {
        printf("MREMAP_MAYMOVE");
        do_or = true;
    }

    if (flags & MREMAP_FIXED)
    {
        printf(do_or ? "|MREMAP_FIXED" : "MREMAP_FIXED");
    }

    if (new_addr_valid)
        printf(", %p", new_addr);
}

void do_insmod(struct syscall_args *args, struct proc_event *event)
{
    const char *path = (const char *) args->args[0];
    const char *name = (const char *) args->args[1];

    printf("%p, %p", path, name);
}

void do_uname(struct syscall_args *args, struct proc_event *event)
{
    struct utsname *uts = (struct utsname *) args->args[0];
    printf("%p", uts);
}

void do_sethostname(struct syscall_args *args, struct proc_event *event)
{
    const char *name = (const char *) args->args[0];
    size_t len = args->args[1];

    printf("%p, %lu", name, len);
}

const char *clock_ids[] = {
    [CLOCK_REALTIME] = "CLOCK_REALTIME", [CLOCK_MONOTONIC] = "CLOCK_MONOTONIC"};

const char *stringify_clk(clockid_t id)
{
    return clock_ids[id];
}

void do_clock_gettime(struct syscall_args *args, struct proc_event *event)
{
    clockid_t clk = (clockid_t) args->args[0];
    struct timespec *tp = (struct timespec *) args->args[1];
    const char *c;

    if (clk > sizeof(clock_ids) / sizeof(clock_ids[0]))
        c = "Unknown clock";
    else
        c = stringify_clk(clk);
    printf("%s, %p", c, tp);
}

void do_nanosleep(struct syscall_args *args, struct proc_event *event)
{
    const struct timespec *req = (const struct timespec *) args->args[0];
    struct timespec *rem = (struct timespec *) args->args[1];

    printf("%p, %p", req, rem);
}

#define ARCH_SET_GS 0x1001
#define ARCH_SET_FS 0x1002
#define ARCH_GET_FS 0x1003
#define ARCH_GET_GS 0x1004

void do_arch_prctl(struct syscall_args *args, struct proc_event *event)
{
    int code = (int) args->args[0];
    void *addr = (void *) args->args[1];
    const char *s = "Unknown";
    if (code == ARCH_SET_GS)
        s = "ARCH_SET_GS";
    else if (code == ARCH_SET_FS)
        s = "ARCH_SET_FS";
    else if (code == ARCH_GET_FS)
        s = "ARCH_GET_FS";
    else if (code == ARCH_GET_GS)
        s = "ARCH_GET_GS";

    printf("%s, %p", s, addr);
}

void do_set_tid_address(struct syscall_args *args, struct proc_event *event)
{
    void *addr = (void *) args->args[0];
    printf("%p", addr);
}

#define SYSLOG_ACTION_READ        2
#define SYSLOG_ACTION_READ_CLEAR  4
#define SYSLOG_ACTION_CLEAR       5
#define SYSLOG_ACTION_SIZE_BUFFER 10

void do_syslog(struct syscall_args *args, struct proc_event *event)
{
    int type = (int) args->args[0];
    char *buf = (char *) args->args[1];
    int len = (int) args->args[2];

    const char *type_str = "Unknown";
    if (type == SYSLOG_ACTION_READ)
        type_str = "SYSLOG_ACTION_READ";
    else if (type == SYSLOG_ACTION_READ_CLEAR)
        type_str = "SYSLOG_ACTION_READ_CLEAR";
    else if (type == SYSLOG_ACTION_CLEAR)
        type_str = "SYSLOG_ACTION_CLEAR";
    else if (type == SYSLOG_ACTION_SIZE_BUFFER)
        type_str = "SYSLOG_ACTION_SIZE_BUFFER";

    printf("%s, %p, %i", type_str, buf, len);
}

void do_fcntl(struct syscall_args *args, struct proc_event *event)
{
    int fd = (int) args->args[0];
    int cmd = (int) args->args[1];
    unsigned long arg = (unsigned long) args->args[2];

    printf("%i, ", fd);

    switch (cmd)
    {
        case F_DUPFD:
            printf("F_DUPFD, %lu", arg);
            break;
        case F_DUPFD_CLOEXEC:
            printf("F_DUPFD_CLOEXEC, %lu", arg);
            break;
        case F_GETFD:
            printf("F_GETFD");
            break;
        case F_SETFD:
            printf("F_SETFD, %lu", arg);
            break;
    }
}

void do_stat(struct syscall_args *args, struct proc_event *event)
{
    const char *pathname = (const char *) args->args[0];
    struct stat *buf = (struct stat *) args->args[1];

    printf("%p, %p", pathname, buf);
}

void do_sigaction(struct syscall_args *args, struct proc_event *event)
{
    int signum = (int) args->args[0];
    struct sigaction *act = (struct sigaction *) args->args[1];
    struct sigaction *old_act = (struct sigaction *) args->args[2];
    char *sname = get_signame(signum);

    if (sname)
        printf("%s, %p, %p", sname, act, old_act);
    else
        printf("%i, %p, %p", signum, act, old_act);
}

void do_pipe(struct syscall_args *args, struct proc_event *event)
{
    printf("%p", (int **) args->args[0]);
}

void do_memstat(struct syscall_args *args, struct proc_event *event)
{
    printf("%p", (void *) args->args[0]);
}

void do_chdir(struct syscall_args *args, struct proc_event *event)
{
    printf("%p", (void *) args->args[0]);
}

void do_fchdir(struct syscall_args *args, struct proc_event *event)
{
    printf("%i", (int) args->args[0]);
}

void do_getcwd(struct syscall_args *args, struct proc_event *event)
{
    printf("%p, %lu", (char *) args->args[0], args->args[1]);
}

void do_openat(struct syscall_args *args, struct proc_event *event)
{
    int dirfd = (int) args->args[0];
    const char *path = (const char *) args->args[1];
    int flags = (int) args->args[2];
    mode_t mode = (mode_t) args->args[3];

    /* TODO: Decode flags here and in fd-related syscalls */
    printf("%i, %p, %i, %u", dirfd, path, flags, mode);
}

void do_fstatat(struct syscall_args *args, struct proc_event *event)
{
    int dirfd = (int) args->args[0];
    const char *path = (const char *) args->args[1];
    struct stat *buf = (struct stat *) args->args[2];
    int flags = (int) args->args[3];

    printf("%i, %p, %p, %i", dirfd, path, buf, flags);
}

void do_fmount(struct syscall_args *args, struct proc_event *event)
{
    int fd = (int) args->args[0];
    const char *path = (const char *) args->args[1];
    printf("%i, %p", fd, path);
}

void do_clone(struct syscall_args *args, struct proc_event *event)
{
    void *fn = (void *) args->args[0];
    void *child_stack = (void *) args->args[1];
    int flags = (int) args->args[2];
    void *arg = (void *) args->args[3];
    pid_t *ptid = (pid_t *) args->args[4];
    void *tls = (void *) args->args[5];

    const char *flags_str = NULL;
    if (flags == CLONE_FORK)
        flags_str = "CLONE_FORK";
    else if (flags == CLONE_SPAWNTHREAD)
        flags_str = "CLONE_SPAWNTHREAD";

    if (flags_str)
        printf("%p, %p, %s, %p, %p, %p", fn, child_stack, flags_str, arg, ptid, tls);
    else
        printf("%p, %p, %x, %p, %p, %p", fn, child_stack, flags, arg, ptid, tls);
}

void do_exit_thread(struct syscall_args *args, struct proc_event *event)
{
    int val = (int) args->args[0];
    printf("%i", val);
}

void do_sigprocmask(struct syscall_args *args, struct proc_event *event)
{
    int how = (int) args->args[0];
    sigset_t *set = (sigset_t *) args->args[1];
    sigset_t *oldset = (sigset_t *) args->args[2];
    const char *how_str = NULL;

    if (how == SIG_BLOCK)
        how_str = "SIG_BLOCK";
    else if (how == SIG_UNBLOCK)
        how_str = "SIG_UNBLOCK";
    else if (how == SIG_SETMASK)
        how_str = "SIG_SETMASK";

    if (how_str)
        printf("%s, %p, %p", how_str, set, oldset);
    else
        printf("%lx, %p, %p", how, set, oldset);
}

void do_sigsuspend(struct syscall_args *args, struct proc_event *event)
{
    sigset_t *set = (sigset_t *) args->args[0];
    printf("%p", set);
}

void do_futex(struct syscall_args *args, struct proc_event *event)
{
    /* TODO: Improve this */
    void *uaddr = (void *) args->args[0];
    int futex_op = (int) args->args[1];
    int val = (int) args->args[2];
    struct timespec *arg = (struct timespec *) args->args[3];
    int *uaddr2 = (int *) args->args[4];
    int val3 = (int) args->args[5];

    printf("%p, %i, %i, %p, %p, %i", uaddr, futex_op, val, arg, uaddr2, val3);
}

void do_getrandom(struct syscall_args *args, struct proc_event *event)
{
    printf("%p, %lu, %x", (void *) args->args[0], args->args[1], (int) args->args[2]);
}

void do_socket(struct syscall_args *args, struct proc_event *event)
{
    int domain = (int) args->args[0];
    int type = (int) args->args[1];
    int protocol = (int) args->args[2];
    printf("%i, %i, %i", domain, type, protocol);
}

void do_sendto(struct syscall_args *args, struct proc_event *event)
{
    int sockfd = (int) args->args[0];
    void *buf = (void *) args->args[1];
    size_t len = (size_t) args->args[2];
    int flags = (int) args->args[3];
    struct sockaddr *addr = (struct sockaddr *) args->args[4];
    socklen_t addrlen = (socklen_t) args->args[5];

    printf("%i, %p, %lu, %x, %p, %u", sockfd, buf, len, flags, addr, addrlen);
}

void do_bind(struct syscall_args *args, struct proc_event *event)
{
    int sockfd = (int) args->args[0];
    struct sockaddr *addr = (struct sockaddr *) args->args[1];
    socklen_t addrlen = (socklen_t) args->args[2];
    printf("%i, %p, %u", sockfd, addr, addrlen);
}

void do_connect(struct syscall_args *args, struct proc_event *event)
{
    int sockfd = (int) args->args[0];
    struct sockaddr *addr = (struct sockaddr *) args->args[1];
    socklen_t addrlen = (socklen_t) args->args[2];
    printf("%i, %p, %u", sockfd, addr, addrlen);
}

void do_recvfrom(struct syscall_args *args, struct proc_event *event)
{
    int sockfd = (int) args->args[0];
    void *buf = (void *) args->args[1];
    size_t len = (size_t) args->args[2];
    int flags = (int) args->args[3];
    struct sockaddr *addr = (struct sockaddr *) args->args[4];
    socklen_t *addrlen = (socklen_t *) args->args[5];

    printf("%i, %p, %lu, %x, %p, %p", sockfd, buf, len, flags, addr, addrlen);
}

void do_times(struct syscall_args *args, struct proc_event *event)
{
    printf("%p", (void *) args->args[0]);
}

void do_getrusage(struct syscall_args *args, struct proc_event *event)
{
    int who = (int) args->args[0];
    struct rusage *usage = (struct rusage *) args->args[1];

    printf("%i, %p", who, usage);
}

void do_ptrace(struct syscall_args *args, struct proc_event *event)
{
    printf("todo_implement");
}

void do_proc_event_attach(struct syscall_args *args, struct proc_event *event)
{
    pid_t pid = (pid_t) args->args[0];
    unsigned long flags = args->args[1];
    printf("%i, %lx", pid, flags);
}

void do_access(struct syscall_args *args, struct proc_event *event)
{
    printf("%p, %x", (const char *) args->args[0], (mode_t) args->args[1]);
}

struct system_call system_calls[MAX_SYS] = {
    {"write", do_write, do_long_exit},
    {"read", do_read, do_long_exit},
    {"open", do_open, do_integer_exit},
    {"close", do_close, do_integer_exit},
    {"dup", do_dup, do_integer_exit},
    {"dup2", do_dup2, do_integer_exit},
    {"getpid", do_noargs, do_integer_exit},
    {"lseek", do_lseek, do_long_exit},
    {"exit", do_exit, do_noexit},
    {"unknown", do_noargs, do_integer_exit},
    {"fork", do_noargs, do_integer_exit},
    {"mmap", do_mmap, do_mmap_exit},
    {"munmap", do_munmap, do_integer_exit},
    {"mprotect", do_mprotect, do_integer_exit},
    {"mount", do_mount, do_integer_exit},
    {"execve", do_execve, do_integer_exit},
    {"brk", do_brk, do_pointer_exit},
    {"kill", do_kill, do_integer_exit},
    {"getppid", do_noargs, do_integer_exit},
    {"wait4", do_wait4, do_integer_exit},
    {"time", do_time, do_long_exit},
    {"gettimeofday", do_gettimeofday, do_integer_exit},
    {"reboot", do_noargs, do_void_exit},
    {"unknown", do_noargs, do_integer_exit}, // TODO
    {"readv", do_print_iov, do_long_exit},
    {"writev", do_print_iov, do_long_exit},
    {"preadv", do_print_piov, do_long_exit},
    {"pwritev", do_print_piov, do_long_exit},
    {"getdents", do_getdents, do_integer_exit},
    {"ioctl", do_ioctl, do_integer_exit},
    {"truncate", do_truncate, do_integer_exit},
    {"ftruncate", do_ftruncate, do_integer_exit},
    {"personality", do_personality, do_integer_exit},
    {"setuid", do_print_id, do_integer_exit},
    {"setgid", do_print_id, do_integer_exit},
    {"unknown", do_noargs, do_integer_exit}, // TODO
    {"mremap", do_mremap, do_mmap_exit},
    {"sigreturn", do_noargs, do_noexit},
    {"insmod", do_insmod, do_integer_exit},
    {"uname", do_uname, do_integer_exit},
    {"gethostname", do_sethostname,
     do_integer_exit}, /* same args and it's good enough while we can't read args */
    {"sethostname", do_sethostname, do_integer_exit},
    {"clock_gettime", do_clock_gettime, do_integer_exit},
    {"nanosleep", do_nanosleep, do_integer_exit},
    {"arch_prctl", do_arch_prctl, do_integer_exit},
    {"set_tid_address", do_set_tid_address, do_integer_exit},
    {"syslog", do_syslog, do_integer_exit},
    {"fcntl", do_fcntl, do_integer_exit},
    {"unknown", do_noargs, do_integer_exit},
    {"stat", do_stat, do_integer_exit},
    {"unknown", do_noargs, do_integer_exit},
    {"unknown", do_noargs, do_integer_exit},
    {"sigaction", do_sigaction, do_integer_exit},
    {"pipe", do_pipe, do_integer_exit},
    {"memstat", do_memstat, do_integer_exit},
    {"chdir", do_chdir, do_integer_exit},
    {"fchdir", do_fchdir, do_integer_exit},
    {"getcwd", do_getcwd, do_integer_exit},
    {"getuid", do_noargs, do_integer_exit},
    {"getgid", do_noargs, do_integer_exit},
    {"openat", do_openat, do_integer_exit},
    {"fstatat", do_fstatat, do_integer_exit},
    {"fmount", do_fmount, do_integer_exit},
    {"clone", do_clone, do_integer_exit},
    {"exit_thread", do_exit_thread, do_noexit},
    {"sigprocmask", do_sigprocmask, do_integer_exit},
    {"sigsuspend", do_sigsuspend, do_integer_exit},
    {"pause", do_noargs, do_integer_exit},
    {"futex", do_futex, do_integer_exit},
    {"getrandom", do_getrandom, do_integer_exit},
    {"socket", do_socket, do_integer_exit},
    {"sendto", do_sendto, do_long_exit},
    {"bind", do_bind, do_integer_exit},
    {"connect", do_connect, do_integer_exit},
    {"recvfrom", do_recvfrom, do_long_exit},
    {"times", do_times, do_long_exit},
    {"getrusage", do_getrusage, do_integer_exit},
    {"unknown", do_noargs, do_integer_exit},
    {"unknown", do_noargs, do_integer_exit},
    {"proc_event_attach", do_proc_event_attach, do_integer_exit},
    {"access", do_access, do_integer_exit}};

void print_syscall(struct proc_event *event)
{
    size_t nr = event->e_un.syscall.rax;
    if ((nr < MAX_SYS && !system_calls[nr].callback) || nr >= MAX_SYS)
    {
        printf("unknown_sys(%lu) ", nr);
    }
    else
    {
        struct syscall_args args;
        args.args[0] = event->e_un.syscall.rdi;
        args.args[1] = event->e_un.syscall.rsi;
        args.args[2] = event->e_un.syscall.rdx;
        args.args[3] = event->e_un.syscall.r10;
        args.args[4] = event->e_un.syscall.r8;
        args.args[5] = event->e_un.syscall.r9;
        printf("%s(", system_calls[nr].name);
        system_calls[nr].callback(&args, event);
        printf(") = ");
    }
}

void print_syscall_exit(struct proc_event *event)
{
    size_t nr = event->e_un.syscall_exit.syscall_nr;
    if ((nr < MAX_SYS && !system_calls[nr].exit) || nr >= MAX_SYS)
    {
        do_integer_exit((size_t) event->e_un.syscall_exit.retval, event);
    }
    else
        system_calls[nr].exit((size_t) event->e_un.syscall_exit.retval, event);

    printf("\n");
}

void strace_print_event(struct proc_event *event)
{
    if (event->type == PROC_EVENT_SYSCALL_ENTER)
    {
        print_syscall(event);
    }
    else if (event->type == PROC_EVENT_SYSCALL_EXIT)
    {
        print_syscall_exit(event);
    }
}


text:
class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TPaintBox *PaintBox;
        TMainMenu *MainMenu1;
        TMenuItem *mFile;
        TMenuItem *mSave;
        TMenuItem *N4;
        TMenuItem *mStart;
        TMenuItem *mStop;
        TMenuItem *mReset;
        TStatusBar *StatusBar;
        TPanel *Panel1;
        TToolBar *ToolBar1;
        TImageList *ImageList1;
        TSavePictureDialog *SavePictureDialog;
        TToolButton *ToolButton1;
        TToolButton *ToolButton2;
        TToolButton *StartButton;
        TToolButton *StopButton;
        TToolButton *ResetButton;
        TCGauge *Gauge;
        TToolButton *ToolButton6;
        TMenuItem *mAbout;
        TMenuItem *N1;
        TToolButton *ZoomIn;
        TToolButton *ZoomOut;
        TTrackBar *IterBar;
        TLabel *IterLabel;
        TScrollBar *PalScroll;
        TMenuItem *N2;
        TMenuItem *N3;
        TMenuItem *N5;
        TMenuItem *N6;
        TMenuItem *N7;
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall PaintBoxPaint(TObject *Sender);
        void __fastcall StartButtonClick(TObject *Sender);
        void __fastcall StopButtonClick(TObject *Sender);
        void __fastcall mStartClick(TObject *Sender);
        void __fastcall mStopClick(TObject *Sender);
        void __fastcall ResetButtonClick(TObject *Sender);
        void __fastcall mResetClick(TObject *Sender);
        void __fastcall mSaveClick(TObject *Sender);
        void __fastcall ToolButton1Click(TObject *Sender);
        void __fastcall N1Click(TObject *Sender);
        void __fastcall ZoomInClick(TObject *Sender);
        void __fastcall ZoomOutClick(TObject *Sender);
        void __fastcall IterBarChange(TObject *Sender);
        void __fastcall N6Click(TObject *Sender);
        void __fastcall N7Click(TObject *Sender);
        void __fastcall N2Click(TObject *Sender);
        void __fastcall N3Click(TObject *Sender);

private:
        void __fastcall Progress(double Percent);
        void __fastcall ThreadDone(TObject* Sender);
        double x0,y0,x1,y1;
        void UpdateStatus();

public:		// User declarations
        void Reset();
        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif


text:
package ee.ria.xroad.proxy.testsuite.testcases;

import ee.ria.xroad.proxy.testsuite.Message;
import ee.ria.xroad.proxy.testsuite.MessageTestCase;

import javax.servlet.http.HttpServletRequest;

/**
 * Check that SOAPAction header is preserved
 * Result: client receives message.
 */
public class SoapActionEmptyHeader extends MessageTestCase {

    /**
     * Constructs the test case.
     */
    public SoapActionEmptyHeader() {
        requestFileName = "getstate.query";
        responseFile = "getstate.answer";
    }

    @Override
    protected void startUp() throws Exception {
        super.startUp();
        addRequestHeader("SOAPAction", "");
    }

    @Override
    protected void onServiceReceivedHttpRequest(HttpServletRequest request) throws Exception {
        if (!"".equals(request.getHeader("SOAPAction"))) {
            throw new Exception("Expected empty SOAPAction header");
        }
    }

    @Override
    protected void validateNormalResponse(Message receivedResponse)
            throws Exception {
        // Normal response, nothing more to check here.
    }
}


text:
package com.podio;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Locale;
import java.util.TimeZone;

import javax.ws.rs.core.HttpHeaders;

import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
import org.codehaus.jackson.map.DeserializationConfig.Feature;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import org.codehaus.jackson.map.deser.CustomDeserializerFactory;
import org.codehaus.jackson.map.deser.StdDeserializerProvider;
import org.codehaus.jackson.map.ser.CustomSerializerFactory;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;

import com.podio.oauth.OAuthClientCredentials;
import com.podio.oauth.OAuthUserCredentials;
import com.podio.serialize.DateTimeDeserializer;
import com.podio.serialize.DateTimeSerializer;
import com.podio.serialize.LocalDateDeserializer;
import com.podio.serialize.LocalDateSerializer;
import com.podio.serialize.LocaleDeserializer;
import com.podio.serialize.LocaleSerializer;
import com.podio.serialize.TimeZoneDeserializer;
import com.podio.serialize.TimeZoneSerializer;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.GZIPContentEncodingFilter;
import com.sun.jersey.multipart.impl.MultiPartWriter;

/**
 * This is the main low level entry point to access the Podio API. Construct
 * this and pass it to the APIFactory.
 */
public final class ResourceFactory {

	private final WebResource apiResource;
	private final WebResource fileResource;

	private final LoginFilter loginFilter;

	public ResourceFactory(OAuthClientCredentials clientCredentials,
			OAuthUserCredentials userCredentials) {
		this("api.podio.com", "files.podio.com", 443, true, false,
				clientCredentials, userCredentials);
	}

	public ResourceFactory(String apiHostname, String fileHostname, int port,
			boolean ssl, boolean dryRun,
			OAuthClientCredentials clientCredentials,
			OAuthUserCredentials userCredentials) {
		ClientConfig config = new DefaultClientConfig();
		config.getSingletons().add(getJsonProvider());
		config.getClasses().add(MultiPartWriter.class);
		Client client = Client.create(config);
		client.addFilter(new GZIPContentEncodingFilter(false));
		client.addFilter(new ExceptionFilter());
		client.addFilter(new RateLimitFilter());
		if (dryRun) {
			client.addFilter(new DryRunFilter());
		}
		// client.addFilter(new LoggingFilter());

		this.apiResource = client.resource(getURI(apiHostname, port, ssl));
		apiResource.header(HttpHeaders.USER_AGENT, "Podio Java API Client");
		this.fileResource = client.resource(getURI(fileHostname, port, ssl));
		fileResource.header(HttpHeaders.USER_AGENT, "Podio Java API Client");

		AuthProvider authProvider = new AuthProvider(this, clientCredentials,
				userCredentials);
		this.loginFilter = new LoginFilter(authProvider);
	}

	private URI getURI(String hostname, int port, boolean ssl) {
		try {
			return new URI(ssl ? "https" : "http", null, hostname, port, null,
					null, null);
		} catch (URISyntaxException e) {
			throw new RuntimeException(e);
		}
	}

	private JacksonJsonProvider getJsonProvider() {
		ObjectMapper mapper = new ObjectMapper();
		mapper.disable(Feature.FAIL_ON_UNKNOWN_PROPERTIES);
		mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
		mapper.setSerializationInclusion(Inclusion.NON_NULL);

		CustomSerializerFactory serializerFactory = new CustomSerializerFactory();
		serializerFactory.addSpecificMapping(DateTime.class,
				new DateTimeSerializer());
		serializerFactory.addSpecificMapping(LocalDate.class,
				new LocalDateSerializer());
		serializerFactory.addGenericMapping(TimeZone.class,
				new TimeZoneSerializer());
		serializerFactory.addSpecificMapping(Locale.class,
				new LocaleSerializer());
		mapper.setSerializerFactory(serializerFactory);

		CustomDeserializerFactory deserializerFactory = new CustomDeserializerFactory();
		deserializerFactory.addSpecificMapping(DateTime.class,
				new DateTimeDeserializer());
		deserializerFactory.addSpecificMapping(LocalDate.class,
				new LocalDateDeserializer());
		deserializerFactory.addSpecificMapping(TimeZone.class,
				new TimeZoneDeserializer());
		deserializerFactory.addSpecificMapping(Locale.class,
				new LocaleDeserializer());
		mapper.setDeserializerProvider(new StdDeserializerProvider(
				deserializerFactory));

		return new CustomJacksonJsonProvider(mapper);
	}

	public WebResource getFileResource(String path) {
		return getFileResource(path, true);
	}

	public WebResource getFileResource(String path, boolean secure) {
		WebResource subResource = fileResource.path(path);
		if (secure) {
			subResource.addFilter(this.loginFilter);
		}

		return subResource;
	}

	public WebResource getApiResource(String path) {
		return getApiResource(path, true);
	}

	public WebResource getApiResource(String path, boolean secure) {
		WebResource subResource = apiResource.path(path);
		if (secure) {
			subResource.addFilter(this.loginFilter);
		}

		return subResource;
	}
}


text:
using System;
using Ninject;
using Ninject.Planning.Bindings;
using StardewModdingAPI;
using TehPers.Core.Api.Content;

namespace TehPers.Core.Api.DI
{
    /// <summary>
    /// Constrains the source for an injected <see cref="IAssetProvider"/>.
    /// </summary>
    public class ContentSourceAttribute : ConstraintAttribute
    {
        /// <summary>
        /// Gets the requested content source.
        /// </summary>
        public ContentSource Source { get; }

        /// <summary>
        /// Initializes a new instance of the <see cref="ContentSourceAttribute"/> class.
        /// </summary>
        /// <param name="source">The content source that should be used.</param>
        public ContentSourceAttribute(ContentSource source)
        {
            this.Source = source;
        }

        /// <inheritdoc />
        public override bool Matches(IBindingMetadata metadata)
        {
            _ = metadata ?? throw new ArgumentNullException(nameof(metadata));

            return metadata.Has(nameof(ContentSource))
                && metadata.Get<ContentSource>(nameof(ContentSource)) == this.Source;
        }
    }
}


text:
<?php

namespace App\Services\Sclass;

class JsonArrayHandle extends \Eloquent{
/**
	 * array foreach function to array
	 */
public static function arr_foreach ($arr) {
    static $str;
    if (!is_array ($arr)) {
    return false;
    }
    foreach ($arr as $key => $val ) {

        if (is_array ($val)) {
              return array_map(array($this, 'arr_foreach'), $val);
        } else {

            $str[] = $val;
        }
    }
  return $str;
}
	public function getContentDataAttribute($data)
{
    return json_decode($data);
}

/**
	 * Display a listing of the resource.
	 * GET /college/articles
	 *
	 * @return Response
	 */
	    /**
	 * json数组循环得到其中值
	 * get data from ktest
	 *
	 * @return Response
	 */
	public function ktest_dejson($jarr)
	{
		//
		$data=json_decode($jarr);
        $i=0;
        foreach ( $data as $unit )
         {
          $i++;
          $arr[$i]['majors']=$unit->Majors;
          $arr[$i]['careers']=$unit->Careers;

         }
   return $arr;
	}

public	 function objectToArray($d) {
 if (is_object($d)) {
 // Gets the properties of the given object
 // with get_object_vars function
 $d = get_object_vars($d);
 }

 if (is_array($d)) {
 /*
 * Return array converted to object
 * Using __FUNCTIfON__ (Magic constant)
 * for recursive call
 */
  return array_map(array($this, 'objectToArray'), $d);
 }
 else {
 // Return array
 return $d;
 }
 }

}


text:
//
//  NSString+IDCardNumberValidator.h
//  IDCardNumber-Validation-Demo
//
//  Created by Vincent on 2/26/16.
//  Copyright © 2016 Vincent. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSString (IDCardNumberValidator)
- (BOOL)validIDCardNumber;

/**
 校验身份证号,并返回格式化生日

 @param fmt 格式化
 @return 生日
 */
- (NSString *)validIDCardNumberWithBrithdayFmt:(NSString *)fmt;
@end