text:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.cardpay.pccredit.manager.dao.ManagerBelongMapDao" >

	<resultMap id="ResultMap" type="com.cardpay.pccredit.manager.web.ManagerBelongMapForm">
		<result property="id" column="ID" />
		<result property="parentId" column="PARENT_ID" />
		<result property="childId" column="CHILD_ID" />
		<result property="isLeaf" column="IS_LEAF" />
		<result property="userName" column="DISPLAY_NAME" />
		<result property="levelInformation" column="LEVEL_INFORMATION" />
	</resultMap>

	<resultMap id="SysOrganMap" type="com.cardpay.pccredit.manager.web.SysOrganizationForm">
		<result property="userId" column="ID" />
		<result property="displayName" column="NAME" />
	</resultMap>

	<resultMap id="managerBelongMap" type="com.cardpay.pccredit.manager.model.ManagerBelongMap">
		<result property="id" column="ID" />
		<result property="childId" column="CHILD_ID" />
		<result property="parentId" column="PARENT_ID" />
		<result property="isLeaf" column="IS_LEAF" />
	</resultMap>

	<resultMap id="AccountManagerParameterFormMap"
		type="com.cardpay.pccredit.manager.web.AccountManagerParameterForm">
		<result property="id" column="ID" />
		<result property="userId" column="USER_ID" />
		<result property="displayName" column="DISPLAY_NAME" />
		<result property="rewardIncentiveInformation" column="REWARD_INCENTIVE_INFORMATION" />
		<result property="levelInformation" column="LEVEL_INFORMATION" />
		<result property="creditLine" column="CREDIT_LINE" />
		<result property="monthlyOverdraftBalance" column="MONTHLY_OVERDRAFT_BALANCE" />
		<result property="teamOverdraftBalance" column="TEAM_OVERDRAFT_BALANCE" />
		<result property="tubeNumber" column="TUBE_NUMBER" />
		<result property="activationRate" column="ACTIVATION_RATE" />
		<result property="activeRate" column="ACTIVE_RATE" />
		<result property="entryTime" column="ENTRY_TIME" />
		<result property="riskTolerance" column="RISK_TOLERANCE" />
		<result property="createdTime" column="CREATED_TIME" />
		<result property="createdBy" column="CREATED_BY" />
		<result property="modifiedTime" column="MODIFIED_TIME" />
		<result property="modifiedBy" column="MODIFIED_BY" />
	</resultMap>

	<select id="findManagerBelongMapByFilter" resultMap="ResultMap"
		parameterType="com.cardpay.pccredit.manager.filter.ManagerBelongMapFilter">
		SELECT * FROM
			(SELECT ROW_.*,ROWNUM ROWNUM_
				FROM (
					 SELECT mbm.*,
							su.DISPLAY_NAME,
							amp.LEVEL_INFORMATION
					 FROM  manager_belong_map mbm
					 LEFT JOIN account_manager_parameter amp
					 	on amp.id = mbm.child_id
					 LEFT JOIN sys_user su
					    ON su.id = amp.user_id
					 WHERE 1=1 and mbm.parent_id = #{parentId}
 			<![CDATA[
					) ROW_
				WHERE ROWNUM <= #{limit}*#{page} + #{limit})
			WHERE ROWNUM_ > #{limit}*#{page}
			]]>
	</select>

	<select id="findManagerBelongMapCountByFilter" resultType="int"
		parameterType="com.cardpay.pccredit.manager.filter.ManagerBelongMapFilter">
		SELECT count(*)
		 FROM  manager_belong_map mbm
		 LEFT JOIN account_manager_parameter amp
		 	on amp.id = mbm.child_id
		 LEFT JOIN sys_user su
		    ON su.id = amp.user_id
		 WHERE 1=1 and mbm.parent_id = #{parentId}
	</select>

	<select id="findByParentId" resultMap="ResultMap">
		 SELECT mbm.*,
				su.DISPLAY_NAME,
				amp.LEVEL_INFORMATION
		 FROM  manager_belong_map mbm
		 LEFT JOIN account_manager_parameter amp
		 	on amp.id = mbm.child_id
		 LEFT JOIN sys_user su
		    ON su.id = amp.user_id
		 WHERE mbm.parent_id = #{parentId}
	</select>

	<select id="findByChildId" resultMap="ResultMap">
		 SELECT mbm.*,
				su.DISPLAY_NAME,
				amp.LEVEL_INFORMATION
		 FROM  manager_belong_map mbm
		 LEFT JOIN account_manager_parameter amp
		 	on amp.id = mbm.child_id
		 LEFT JOIN sys_user su
		    ON su.id = amp.user_id
		 WHERE mbm.child_id = #{childId}
	</select>

	<select id="getManagerBelongRoot" resultMap="managerBelongMap">
		 SELECT * FROM manager_belong_map
		 WHERE parent_id is null
	</select>

	<select id="findAccountManagerParameterByChildIds" resultMap="AccountManagerParameterFormMap">
		SELECT T.*, s.DISPLAY_NAME
		FROM ACCOUNT_MANAGER_PARAMETER T
		LEFT JOIN SYS_USER s ON s.id = T.USER_ID
		WHERE  s.USER_TYPE = '1'
		and t.id in ${childIdInStr}
		ORDER BY t.CREATED_TIME DESC
	</select>

	<select id="findOrgManagerById" resultMap="AccountManagerParameterFormMap">
       select e.display_name,
       		  e.id as user_id
         from sys_charge a,
              sys_organization b,
              sys_department c,
              sys_dept_user d,
              sys_user e
          where a.org_id = b.id
            and c.org_id = b.id
            and d.dept_id = c.id
            and e.id = d.user_id
            and a.user_id = #{userId}
            and e.user_type ='1'
	</select>

	<select id="findDeptManagerById" resultMap="AccountManagerParameterFormMap">
      select d.display_name,
             d.id as user_id
		  from sys_organization a,
		       sys_department b,
		       sys_dept_user c, sys_user d
		 where a.id = b.org_id
		   and b.id = c.dept_id
		   and c.user_id = d.id
		   and d.user_type ='1'
	</select>

	<select id="findDeptOrgan" resultMap="SysOrganMap">
      select t.*,t.rowid from sys_organization  t
	</select>

	<select id="findOrgOrgan" resultMap="SysOrganMap">
     select b.id,
	        b.name,
	        b.short_name
	 from
	        sys_charge a,
	        sys_organization b,
	        sys_user c
     where a.org_id =b.id
      and a.user_id = c.id
      and a.user_id = #{userId}
	</select>

	<select id="findManagerOrgan" resultMap="SysOrganMap">
      select d.id,
             d.name,
             d.short_name
      from   sys_user         a,
             sys_dept_user    b,
             sys_department   c,
             sys_organization d
       where a.id = b.user_id
         and b.dept_id = c.id
         and c.org_id = d.id
         and a.id = #{userId}
	</select>
</mapper>


text:
  <md-fab-toolbar md-open="false" count="2" md-direction="right">
      <md-fab-trigger class="align-with-text" id="menu-button">
        <md-button aria-label="menu" class="md-fab">
          <md-icon md-svg-src="images/menu.svg"></md-icon>
        </md-button>
      </md-fab-trigger>

      <md-toolbar>
        <md-fab-actions class="md-toolbar-tools">
          <md-button ng-href="#/" class="nav-button">Home</md-button>
          <md-button ng-href="#pineapple" class="nav-button">Pineapple</md-button>
          <md-button ng-href="#greentea" class="nav-button">Green Tea</md-button>
          <md-button ng-href="#lemon" class="nav-button">Lemon</md-button>
          <md-button ng-href="#orange" class="nav-button">Orange</md-button>
          <md-button ng-href="#about" class="nav-button">About</md-button>

        </md-fab-actions>
      </md-toolbar>
  </md-fab-toolbar>

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2019 Red Hat, Inc. and/or its affiliates.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~       http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<component xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.3 http://maven.apache.org/xsd/component-1.1.3.xsd">
  <!-- Assembly configuration for WildFly 10 and EAP 7, shared between the community and product assemblies. -->
  <dependencySets>
    <dependencySet>
      <includes>
        <include>org.kie:${artifactId}-webapp:jar:swarm</include>
      </includes>
      <outputDirectory>.</outputDirectory>
      <unpack>true</unpack>
      <unpackOptions>
        <excludes>
          <exclude>_bootstrap/${artifactId}-webapp.war</exclude>
        </excludes>
      </unpackOptions>
      <useStrictFiltering>true</useStrictFiltering>
    </dependencySet>
  </dependencySets>

  <files>

    <file>
      <source>${project.basedir}/target/business-central-${version.org.kie}-eap7-redhat.war</source>
      <outputDirectory>_bootstrap</outputDirectory>
      <destName>business-central-webapp.war</destName>
    </file>

    <file>
      <source>${project.parent.basedir}/src/main/productized/swarm/project-defaults.yml</source>
      <outputDirectory>.</outputDirectory>
      <destName>project-defaults.yml</destName>
    </file>
  </files>
</component>


text:
using System;
using Machine.Specifications;
using Microsoft.Azure.Documents;

namespace MassTransit.Extras.MessageData.DocumentDb.Tests
{
    [Subject(typeof(UriBuilder))]
    public class When_a_Uri_is_built
    {
        Establish context = () =>
        {
            Document = ("{\"_self\": \"" + Link + "\"}").ToDocument();
            Subject = new UriBuilder();
        };

        Because of = () =>
        {
            Uri = Subject.Build(Document);
        };

        It should_be_a_relative_Uri = () =>
        {
            Uri.IsAbsoluteUri.ShouldBeFalse();
        };

        It should_be_the_self_link = () =>
        {
            Uri.OriginalString.ShouldEqual(Link);
        };

        static string Link = "/link/to/doc";
        static UriBuilder Subject;
        static Document Document;
        static Uri Uri;
    }
}


text:
layout: shared/narrow
title: "Story concatenation"
description: "Remove jank from scrolling when stories added"
notes:
  styling:
    - Styling will come later
published_on: 2015-09-28
updated_on: 2015-09-28
order: 3
translation_priority: 1
authors:
  - megginkearney
notes:
  raf: "When a JavaScript function is called without specific timing, it runs immediately, basically interrupting the browser's current task. Recall that at 60fps, the browser has a maximum of 16ms (realistically, 10-12ms) to render a frame. Unexpected scripts can easily take up a lot of that time, and may cause some previously completed work to be redone, which could result in a missed frame.

requestAnimationFrame schedules a script to run at the earliest possible moment in the frame pipeline, giving the browser as much time as possible to complete the remaining steps: style recalculation, layout, painting, and compositing. Thus, requestAnimationFrame is the go-to tool for running scripts that animate some part of the page, such as our loadStoryBatch function."

---

  Another issue that affects the app's smoothness is the janky scrolling when
  stories are added to the list. Note the call to loadStoryBatch
  in the scroll event listener code.

{% highlight javascript %}
main.addEventListener('scroll', function() {
  ...
  // Check if we need to load the next batch of stories.
  var loadThreshold = (main.scrollHeight - main.offsetHeight -
      LAZY_LOAD_THRESHOLD);
  if (main.scrollTop > loadThreshold)
    loadStoryBatch();
});
{% endhighlight %}

This function makes visible changes to the page by inserting new stories to the
page as it's loaded, specifically by appending DOM nodes using `appendChild`.
There's nothing inherently wrong in the function, nor in the design approach
that uses it, but consider how it is being called.

The `loadStoryBatch` function is catch-as-catch-can; it runs whenever it
needs to, based on the `loadThreshold` test, without regard to what else is
going on in the page or where the browser is in the frame construction
process. This is because the JavaScript engine pays no attention to the
rendering pipeline when executing scripts. That immediacy will cause a
performance problem, especially as more stories are added to the list. We
can address this issue by using `requestAnimationFrame`.

{% include shared/note.liquid list=page.notes.raf %}

Ideally, anything that makes a visible change to the page should happen inside
a `requestAnimationFrame` call. Let's make that modification to the `scroll`
event listener code.

{% highlight javascript %}
main.addEventListener('scroll', function() {
  ...
  // Check if we need to load the next batch of stories.
  var loadThreshold = (main.scrollHeight - main.offsetHeight -
      LAZY_LOAD_THRESHOLD);
  if (main.scrollTop > loadThreshold)
    requestAnimationFrame(loadStoryBatch);
});
{% endhighlight %}

This simple change ensures that our animation-related script runs early in the
pipeline process, and provides a small but significant performance boost.


text:
package org.switchyard.rhq.plugin.operations;

import static org.switchyard.rhq.plugin.SwitchYardConstants.ADDRESS_SWITCHYARD;
import static org.switchyard.rhq.plugin.SwitchYardConstants.DMR_SHOW_METRICS;
import static org.switchyard.rhq.plugin.SwitchYardConstants.PARAM_SERVICE_NAME;
import static org.switchyard.rhq.plugin.SwitchYardConstants.PARAM_TYPE;

import org.rhq.modules.plugins.jbossas7.json.Operation;

/**
 * Read Application operation
 */
public class ReadComponentServiceMetrics extends Operation {
    public ReadComponentServiceMetrics() {
        this("*");
    }

    public ReadComponentServiceMetrics(final String service) {
        super(DMR_SHOW_METRICS, ADDRESS_SWITCHYARD);
        addAdditionalProperty(PARAM_TYPE, "componentService");
        addAdditionalProperty(PARAM_SERVICE_NAME, service);
    }
}


text:
var xmlHttp;
function srvTime(){
	try {
		//FF, Opera, Safari, Chrome
		xmlHttp = new XMLHttpRequest();
	}
	catch (err1) {
		//IE
		try {
			xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch (err2) {
			try {
				xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
			}
			catch (err3) {
				//AJAX not supported, use CPU time.
				alert("AJAX not supported");
			}
		}
	}
	xmlHttp.open('HEAD',window.location.href.toString(),false);
	xmlHttp.setRequestHeader("Content-Type", "text/html");
	xmlHttp.send('');
	alert (xmlHttp.getResponseHeader("Date"));
	return xmlHttp.getResponseHeader("Date");
}


text:
static int Errors;

#define expectTrue(expr)                                            \
  do {                                                              \
    if (!(expr)) {                                                  \
      printf("%s:%d: not true:  %s\n", __FILE__, __LINE__, #expr);  \
      Errors++;                                                     \
    }                                                               \
  } while (0)

#define expectFalse(expr)                                           \
  do {                                                              \
    if (expr) {                                                     \
      printf("%s:%d: not false: %s\n", __FILE__, __LINE__, #expr);  \
      Errors++;                                                     \
    }                                                               \
  } while (0)

#define fail(format, ...)                                           \
  do {                                                              \
    printf("%s:%d: " format, __FILE__, __LINE__, ##__VA_ARGS__);    \
    Errors++;                                                       \
  } while (0)

BOOL TestSwiftNativeNSBase_RetainCount(id object)
{
  Errors = 0;
  NSUInteger rc1 = [object retainCount];
  id object2 = [object retain];
  expectTrue(object == object2);
  NSUInteger rc2 = [object retainCount];
  expectTrue(rc2 > rc1);
  [object release];
  NSUInteger rc3 = [object retainCount];
  expectTrue(rc3 < rc2);
  return Errors == 0;
}

BOOL TestSwiftNativeNSBase_UnwantedCdtors()
{
  Errors = 0;
  printf("TestSwiftNativeNSBase\n");

  unsigned int classCount;
  Class *classes = objc_copyClassList(&classCount);

  NSMutableSet *expectedClasses =
    [NSMutableSet setWithObjects:
      @"__SwiftNativeNSArrayBase",
      @"__SwiftNativeNSMutableArrayBase",
      @"__SwiftNativeNSDictionaryBase",
      @"__SwiftNativeNSSetBase",
      @"__SwiftNativeNSStringBase",
      @"__SwiftNativeNSEnumeratorBase",
      nil];

  for (unsigned int i = 0; i < classCount; i++) {
    Class cls = classes[i];
    NSString *name = @(class_getName(cls));
    if (! ([name hasPrefix:@"__SwiftNativeNS"] && [name hasSuffix:@"Base"])) {
      continue;
    }
    if ([name isEqual: @"__SwiftNativeNSDataBase"] ||
        [name isEqual: @"__SwiftNativeNSIndexSetBase"]) {
      //These two were removed but are still present when back-deploying
      continue;
    }
    if (! [expectedClasses containsObject:name]) {
      fail("did not expect class %s\n", name.UTF8String);
      continue;
    }

    // cls is some __SwiftNativeNS*Base class
    [expectedClasses removeObject:name];
    printf("checking class %s\n", name.UTF8String);

    // Check for unwanted C++ cdtors (rdar://18950072)
    expectFalse([cls instancesRespondToSelector:sel_registerName(".cxx_construct")]);
    expectFalse([cls instancesRespondToSelector:sel_registerName(".cxx_destruct")]);
  }

  expectTrue(expectedClasses.count == 0);

  printf("TestSwiftNativeNSBase: %d error%s\n",
         Errors, Errors == 1 ? "" : "s");
  return Errors == 0;
}


text:
import os

BASE_DIR = os.path.dirname(
    os.path.dirname(
        os.path.dirname(
            os.path.abspath(__file__))))

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY')

ALLOWED_HOSTS = ['*']

DEBUG = True

# region apps

INSTALLED_APPS = (

    # Django PRE
    'flat_responsive',  # Mobile support for flat theme
    'flat',  # Admin flat theme
    'colorfield',  # colorpicker field for admin

    # Django
    'django.contrib.auth',
    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.humanize',

    # Mandelbrew
    'core',
    'pages',
    'blog',

    # Wagtail
    'wagtail.wagtailforms',
    'wagtail.wagtailredirects',
    'wagtail.wagtailembeds',
    'wagtail.wagtailsites',
    'wagtail.wagtailusers',
    'wagtail.wagtailsnippets',
    'wagtail.wagtaildocs',
    'wagtail.wagtailimages',
    'wagtail.wagtailsearch',
    'wagtail.wagtailadmin',
    'wagtail.wagtailcore',
    'wagtail.contrib.settings',
    'wagtail.contrib.wagtailsitemaps',
    'wagtail.contrib.table_block',
    'wagtail.contrib.wagtailstyleguide',  # Development only!

    # Django plugins
    'django_extensions',
    'django_markup',
    'meta',
    'wagtailmetadata',
    'modelcluster',
    'taggit',
    'honeypot',
    'overextends',
    'widget_tweaks',
    'analytical',
    'svg_templatetag',  # adds template tag to inline SVGs
    'debug_toolbar',  # Development only!

)

# endregion

# region Middleware

MIDDLEWARE_CLASSES = (

    # Django
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',

    # Debug toolbar
    'debug_toolbar.middleware.DebugToolbarMiddleware',

    # Whitenoise
    'whitenoise.middleware.WhiteNoiseMiddleware',

    # Wagtail
    'wagtail.wagtailcore.middleware.SiteMiddleware',
    'wagtail.wagtailredirects.middleware.RedirectMiddleware',

    # Honeypot
    'honeypot.middleware.HoneypotMiddleware'

)

# endregion

ROOT_URLCONF = 'config.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                # Django
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                # Wagtail
                'wagtail.contrib.settings.context_processors.settings',
            ],
        },
    },
]

WSGI_APPLICATION = 'config.wsgi.application'

# region Database

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.getenv('DJANGO_DB_NAME'),
        'USER': os.getenv('DJANGO_DB_USER'),
        'PASSWORD': os.getenv('DJANGO_DB_PASSWORD'),
        'HOST': os.getenv('DJANGO_DB_HOST'),
        'PORT': os.getenv('DJANGO_DB_PORT'),
    }
}

# endregion

# region Authentication

AUTHENTICATION_BACKENDS = (
    # Needed to login by username in Django admin
    'django.contrib.auth.backends.ModelBackend',
)

# endregion

# region Internationalization

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# endregion

# region File Storage

MEDIA_URL = os.getenv('DJANGO_MEDIA_URL')
DEFAULT_FILE_STORAGE = 'config.s3_storages.MediaStorage'

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static_collected')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

# endregion

# region Email

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.getenv('DJANGO_EMAIL_HOST')
EMAIL_PORT = os.getenv('DJANGO_EMAIL_PORT')
EMAIL_HOST_USER = os.getenv('DJANGO_EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.getenv('DJANGO_EMAIL_HOST_PASSWORD')
EMAIL_USE_TLS = True

DEFAULT_FROM_EMAIL = os.getenv('DJANGO_DEFAULT_FROM_EMAIL')

# endregion

# region Sites

SITE_ID = 1

# endregion

# region Misc

INTERNAL_IPS = [
    '127.0.0.1',  # Localhost
    '172.20.0.1',  # Docker
    '192.168.99.1'  # Docker in VirtualBox
]

# Nuclear option for toolbar to show no matter what
# def show_toolbar(request):
#     return True
#
#
# DEBUG_TOOLBAR_CONFIG = {
#     "SHOW_TOOLBAR_CALLBACK": show_toolbar,
# }
# endregion

# region AWS

AWS_S3_HOST = os.getenv('DJANGO_AWS_S3_HOST')
AWS_ACCESS_KEY_ID = os.getenv('DJANGO_AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.getenv('DJANGO_AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = os.getenv('DJANGO_AWS_STORAGE_BUCKET_NAME')
AWS_HEADERS = {'Cache-Control': 'max-age=86400', }
AWS_QUERYSTRING_AUTH = False

# endregion

# region Wagtail

WAGTAIL_SITE_NAME = os.getenv('DJANGO_PROJECT_NAME')
BLOG_PAGINATION_PER_PAGE = 3

# endregion

# region django-analytical

GOOGLE_ANALYTICS_PROPERTY_ID = os.getenv('GOOGLE_ANALYTICS_PROPERTY_ID')
GOOGLE_ANALYTICS_SITE_SPEED = True

# endregion

# region django-meta
META_SITE_PROTOCOL = 'http'
META_USE_SITES = True
META_SITE_NAME = os.getenv('DJANGO_PROJECT_NAME')
# endregion

# region honeypot

HONEYPOT_FIELD_NAME = os.getenv('DJANGO_HONEYPOT_FIELD_NAME')

# endregion


text:
import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';

import {
  ViroScene,
  ViroARScene,
  ViroARPlane,
  ViroBox,
  ViroMaterials,
  ViroNode,
  ViroOrbitCamera,
  ViroImage,
  ViroVideo,
  ViroSkyBox,
  Viro360Video,
  ViroText,
  ViroQuad,
  Viro3DObject
} from 'react-viro';

import TimerMixin from 'react-timer-mixin';

var createReactClass = require('create-react-class');

var position = [0,0,0];
var rotation = [0,0,0];
var width = 0;
var height = 0;

var boxStates = {}
for (var i = 0; i < 15; i++) {
  boxStates["box" + i] = [.5,.5];
}

var testARScene = createReactClass({
  mixins: [TimerMixin],
  getInitialState: function() {
    var initialState = {
      text : "not tapped",
      boxes: [],
      count : 0,
      width : .5,
      selectedSurface : -1,
    }
    // amend the initial states with the boxStates
    return Object.assign(initialState, boxStates);
  },
  render: function() {
    return (
        <ViroARScene ref="arscene" reticleEnabled={false} physicsWorld={{gravity:[0, -10,0], drawBounds : true}}>
          {this._getARPlanes()}
          {this._getBoxes()}
        </ViroARScene>
    );
  },
  /*
            <ViroVideo
            height={.2} width={.2} position={[0,.15,-.5]}
            onClick={()=>{this._onTap(); this._addOneBox()}}
            source={{"uri":"https://s3-us-west-2.amazonaws.com/viro/Climber1Top.mp4"}}
            transformConstraints={"billboard"}
          />

          <ViroText style={styles.welcome} position={[0, .5, -1]} text={this.state.text} />

   */
  _getARPlanes() {
    let prefix = "plane"
    let planes = []
    for (var i = 0; i < 15; i++) {
      var color;
      if (i%3 == 0) {
        color = "blue"
      } else if (i%3 == 1) {
        color = "red"
      } else {
        color = "green"
      }
      planes.push((
        <ViroARPlane key={prefix + i} onClick={this._addOneBox}
         onAnchorFound={this._updateBoxState(i)} onAnchorUpdated={this._updateBoxState(i)}
         visible={this.state.selectedSurface == -1 || this.state.selectedSurface == i}>
          <ViroBox scale={[this.state["box" + i][0], .01, this.state["box" + i][1]]} position={[0,0,0]} rotation={[0,0,0]}
            physicsBody={{
                      type:'static', restitution:0
                    }}
            materials={color}
            onClick={this._clickSurface(i)}/>
          {this._getObject(i)}
        </ViroARPlane>
      ));
    }
    return planes;
  },
  _clickSurface(planeNum) {
    return () => {
      this.setState({
        selectedSurface : planeNum == this.state.selectedSurface ? -1 : planeNum
      })
    }
  },
  _getObject(planeNum) {
    if (planeNum == this.state.selectedSurface) {
      return (<Viro3DObject source={require('./res/aliengirl.obj')} scale={[.005,.005,.005]} type="OBJ"
                materials={["aliengirl"]} onDrag={()=>{}} onClick={()=>{this.setState({showObj : false})}}/>)
    }
  },
  _updateBoxState(boxNum) {
    var boxKey = "box" + boxNum;
    return (map)=>{
      var newState = {};
      newState[boxKey] = [map.width, map.height];
      this.setState(newState);
    }
  },
  _onComponentUpdated(map) {
    console.log("------")
    console.log(map.position);
    console.log(map.rotation);
    console.log(map.width);
    console.log(map.width);
    console.log("Diffs: ");
    console.log([(map.position[0] - position[0]), (map.position[1] - position[1]), (map.position[2] - position[2])] )
    console.log([(map.rotation[0] - rotation[0]), (map.rotation[1] - rotation[1]), (map.rotation[2] - rotation[2])] )
    console.log(map.width - width);
    console.log(map.height - height);
    position = map.position;
    rotation = map.rotation;
    width = map.width;
    height = map.height;
  },
  _getBoxes() {
    let prefix = "box"
    let boxes = [];
    for (var i = 0; i < this.state.boxes.length; i++) {
      boxes.push((<ViroBox key={prefix + i} position={this.state.boxes[i]} width={.1} height={.1} length={.1}
              onDrag={()=>{}}
              physicsBody={{
                type:'dynamic',
                mass:1
              }} />));
    }
    return boxes;
  },
  _addOneBox() {
    let position = this.refs["arscene"].getCameraPositionAsync().then((position) => {
        this.state.boxes.push([position[0], 3, position[2] - .5])
        this.setState({
          boxes : this.state.boxes
        })
    });
  },
  _onTap() {
    console.log("tapped video!!!!")
    this.setState({
      text : "tapped!"
    })
    this.setTimeout( () => {
      this.setState({
        text : "not tapped"
      });
    }, 1000);
  },
  _onLoadStart(component) {
    return () => {
      console.log("scene1 " + component + " load start");
    }
  },
  _onLoadEnd(component) {
    return () => {
      console.log("scene1 " + component + " load end");
    }
  },
  _onFinish(component) {
    return () => {
      console.log("scene1 " + component + " finished");
    }
  }
});

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#FFFFFF',
  },
  welcome: {
    fontSize: 13,
    textAlign: 'center',
    color: '#ffffff',
    margin: 2,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

ViroMaterials.createMaterials({
  blue: {
    shininess: 2.0,
    lightingModel: "Constant",
    diffuseColor: "#0000ff88"
  },
  green: {
    shininess: 2.0,
    lightingModel: "Constant",
    diffuseColor: "#00ff0088"
  },
  red: {
    shininess: 2.0,
    lightingModel: "Constant",
    diffuseColor: "#ff000088"
  },
  wework_title: {
    shininess: 1.0,
    lightingModel: "Constant",
    diffuseTexture: {"uri": "https://s3-us-west-2.amazonaws.com/viro/guadalupe_360.jpg"},
    diffuseTexture: require("../res/new_menu_screen.jpg"),
    fresnelExponent: .5,
  },
  box_texture: {
    diffuseTexture: require("../res/sun_2302.jpg"),
  },
  aliengirl: {
    lightingModel: "Constant",
    diffuseTexture: require('./res/aliengirl_diffuse.png'),
    normalTexture: require('./res/aliengirl_normal.png'),
    specularTexture: require('./res/aliengirl_specular.png')
  },
});

module.exports = testARScene;


text:
import styled from 'styled-components';

const Box = styled.div`
  box-shadow: 1px 1px 1px 0 rgba(0,0,0,.15);
  background-color: #fff;
  margin-top: 25px;
  overflow: hidden;
  width: 100%;
  `;

export default Box;


text: export { from as fromArray } from 'rxjs';


text:
package com.zhihu.matisse.filter;

import android.content.Context;

import com.zhihu.matisse.MimeType;
import com.zhihu.matisse.SelectionCreator;
import com.zhihu.matisse.internal.entity.Item;
import com.zhihu.matisse.internal.entity.IncapableCause;

import java.util.Set;

/**
 * Filter for choosing a {@link Item}. You can add multiple Filters through
 * {@link SelectionCreator#addFilter(Filter)}.
 */
@SuppressWarnings("unused")
public abstract class Filter {
    /**
     * Convenient constant for a minimum value.
     */
    public static final int MIN = 0;
    /**
     * Convenient constant for a maximum value.
     */
    public static final int MAX = Integer.MAX_VALUE;
    /**
     * Convenient constant for 1024.
     */
    public static final int K = 1024;

    /**
     * Against what mime types this filter applies.
     */
    protected abstract Set<MimeType> constraintTypes();

    /**
     * Invoked for filtering each item.
     *
     * @return null if selectable, {@link IncapableCause} if not selectable.
     */
    public abstract IncapableCause filter(Context context, Item item);

    /**
     * Whether an {@link Item} need filtering.
     */
    protected boolean needFiltering(Context context, Item item) {
        for (MimeType type : constraintTypes()) {
            if (type.checkType(context.getContentResolver(), item.getContentUri())) {
                return true;
            }
        }
        return false;
    }
}


text:
package org.incode.module.communications.dom.impl.covernotes;

import java.util.List;

import javax.inject.Inject;

import com.google.common.collect.FluentIterable;

import org.apache.isis.applib.annotation.Action;
import org.apache.isis.applib.annotation.ActionLayout;
import org.apache.isis.applib.annotation.Contributed;
import org.apache.isis.applib.annotation.DomainService;
import org.apache.isis.applib.annotation.Mixin;
import org.apache.isis.applib.annotation.NatureOfService;
import org.apache.isis.applib.annotation.Programmatic;
import org.apache.isis.applib.annotation.SemanticsOf;

import org.incode.module.communications.dom.impl.comms.Communication;
import org.incode.module.document.dom.DocumentModule;
import org.incode.module.document.dom.impl.docs.Document;
import org.incode.module.document.dom.impl.paperclips.Paperclip;
import org.incode.module.document.dom.impl.paperclips.PaperclipRepository;

@Mixin(method="prop")
public class Document_coverNoteFor {

    private final Document coverNoteCandidate;
    public Document_coverNoteFor(final Document coverNoteCandidate) {
        this.coverNoteCandidate = coverNoteCandidate;
    }

    public static class ActionDomainEvent extends DocumentModule.ActionDomainEvent<Document> { }

    @Action(semantics = SemanticsOf.SAFE, domainEvent = ActionDomainEvent.class)
    @ActionLayout(contributed= Contributed.AS_ASSOCIATION)
    public Communication prop() {
        return evaluator.coverNoteFor(coverNoteCandidate);
    }

    // hide this property if this document is not in fact a cover note for any communication
    public boolean hideProp() {
        return prop() == null;
    }

    @Inject
    Evaluator evaluator;

    @DomainService(nature = NatureOfService.DOMAIN)
    public static class Evaluator {

        /**
         * @return the communication, if any, that this document is a cover note for, else null
         */
        @Programmatic
        public Communication coverNoteFor(Document coverNoteCandidate) {
            final List<Paperclip> paperclips = paperclipRepository.findByDocument(coverNoteCandidate);
            if(paperclips.size() != 1) {
                return null;
            }
            final List<Communication> supportedDocumentsIfAny =
                    FluentIterable.from(paperclips)
                            .transform(x -> x.getAttachedTo())
                            .filter(Communication.class::isInstance)
                            .transform(Communication.class::cast)
                            .toList();
            return supportedDocumentsIfAny.size() == 1
                    ? supportedDocumentsIfAny.get(0)
                    : null;
        }

        @Inject
        PaperclipRepository paperclipRepository;
    }

}