text:
<?xml version="1.0"?>

<!-- ======================================================================
     Copyright 2011-2012 Google Inc.  All Rights Reserved.
     Author: kerr@google.com (Debby Wallach)
     Author: lizlooney@google.com (Liz Looney)
     Copyright © 2012-2017 Massachusetts Institute of Technology. All Rights Reserved.
     Author: jis@mit.edu (Jeffrey I. Schiller)
     Author: hal@mit.edu (Hal Abelson)
     Author: ram8647@gmail.com (Ralph Morelli)
     Author: andrew.f.mckinney@gmail.com (Andrew F. McKinney)
     Author: paulmedwal@gmail.com (Paul Medlock-Walton)
     Author: josmasflores@gmail.com (José Dominguez)
     Author: ewpatton@mit.edu (Evan W. Patton)

     App Inventor appengine app
     ====================================================================== -->

<project name="appengine" default="all">
  <description>
    Appengine server and client code
  </description>

  <!-- =====================================================================
       Definition for generating a Unique ID.
       ===================================================================== -->

  <scriptdef name="generateguid" language="javascript">
    <attribute name="property" />
    <![CDATA[
             try {
               load("nashorn:mozilla_compat.js");
             }
             catch (exception) {
               // Ignore the exception as the compat mode is only needed for Java 8
             }
             importClass( java.util.UUID );
             project.setProperty( attributes.get( "property" ), UUID.randomUUID() );
    ]]>
  </scriptdef>

  <condition property="XstartOnFirstThread" value="-XstartOnFirstThread">
    <os family="mac"/>
  </condition>
  <condition property="XstartOnFirstThread" value="">
    <not><os family="mac"/></not>
  </condition>

  <target name="all"
          depends="AiServerLib,AiClientLib,AiRebindLib,YaClientApp,Keystore,WarLibs,InstallAuthKey">
  </target>

  <target name="tests"
          depends="AiClientLibTests,AiSharedLibTests,AiServerLibTests">
  </target>

  <!-- =====================================================================
       Import common directory, task, and target definitions.
       ===================================================================== -->
  <import file="../build-common.xml" />

  <property name="gwt.sdk" location="${lib.dir}/gwt/2.8.1-patched" />
  <property name="appengine.sdk" location="${lib.dir}/appengine/appengine-java-sdk-1.9.46" />

  <property name="build.war.dir" location="${local.build.dir}/war" />
  <property name="build.extra.dir" location="${local.build.dir}/extra" />
  <property name="build.static.dir" location="${build.war.dir}/static" />

  <!-- =====================================================================
       Check whether or not the documentation needs to be (re-)compiled
       ===================================================================== -->
  <target name="CheckDocs">
    <uptodate property="Docs.uptodate">
      <srcfiles dir="${appinventor.dir}/docs/markdown">
        <include name="reference/**/*" />
      </srcfiles>
      <firstmatchmapper>
        <globmapper from="*.md" to="${appinventor.dir}/docs/html/*.html" />
        <globmapper from="*" to="${appinventor.dir}/docs/html/*" />
      </firstmatchmapper>
    </uptodate>
  </target>

  <!-- =====================================================================
       Builds the documentation from the corresponding Markdown files.
       ===================================================================== -->
  <target name="BuildDocs" depends="components_AndroidRuntime,CheckDocs"
          unless="Docs.uptodate">
    <!-- Jenkins will pass -Dforce.builddocs=true to ensure docs build correctly -->
    <property name="force.builddocs" value="false" />
    <!-- We set failifexecutionfails to false so the whole build doesn't fail
         if the developer doesn't have Jekyll set up -->
    <exec executable="bundle" failonerror="${force.builddocs}"
          failifexecutionfails="${force.builddocs}"
          dir="${docs.dir}/markdown" >
      <arg value="install" />
      <arg value="--path" />
      <arg value="vendor/bundle" />
    </exec>
    <exec executable="bundle" failonerror="${force.builddocs}"
          failifexecutionfails="${force.builddocs}"
          dir="${docs.dir}/markdown" >
      <arg value="exec" />
      <arg value="jekyll" />
      <arg value="build" />
      <arg value="-d" />
      <arg value="${docs.dir}/html" />
    </exec>
  </target>

  <!-- =====================================================================
       Copy static files to <build>/war, from war and elsewhere
       ===================================================================== -->
  <target name="CopyToBuildWar"
          description="Create and populate build/war directory structure"
          depends="init,blocklyeditor_BlocklyCompile,BuildDocs">
    <mkdir dir="${build.war.dir}" />
    <copy todir="${build.war.dir}/">
      <fileset dir="war" />
      <fileset dir="${docs.dir}">
        <include name="companions/*"/>
      </fileset>
      <fileset dir="${docs.dir}/html">
        <include name="index.html"/>
        <include name="reference/**/*"/>
        <exclude name="static/*"/>
        <exclude name="assets/*"/>
        <exclude name="images/*"/>
        <exclude name="js/*"/>
        <exclude name="css/*"/>
        <!-- Jekyll generates this even if we don't include the plugin -->
        <exclude name="feed.xml"/>
      </fileset>
    </copy>
    <copy todir="${build.static.dir}/css" flatten="true">
      <fileset dir="${lib.dir}/blockly">
        <include name="**/*.css"/>
      </fileset>
      <fileset dir="${appinventor.dir}/blocklyeditor">
        <include name="media/*.css"/>
      </fileset>
      <fileset dir="${docs.dir}/html/static/css">
        <include name="*"/>
      </fileset>
    </copy>
    <mkdir dir="${build.static.dir}/media"/>
    <copy todir="${build.static.dir}/media" flatten="true">
      <fileset dir="${lib.dir}/blockly">
        <include name="media/*"/>
        <exclude name="media/*.css"/>
        <exclude name="demo/**"/>
      </fileset>
      <fileset dir="${appinventor.dir}/blocklyeditor">
        <include name="media/*"/>
        <exclude name="media/*.css"/>
      </fileset>
    </copy>
    <copy file="${build.dir}/blocklyeditor/blockly-all.js" tofile="${build.war.dir}/WEB-INF/classes/com/google/appinventor/client/editor/youngandroid/blockly.js" />
    <copy todir="${build.static.dir}">
      <fileset dir="src/${appinventor.pkg}">
        <!-- canvas is a special case (see MockCanvas.java) -->
        <include name="images/canvas.png" />
      </fileset>
      <fileset dir="${lib.dir}">
        <include name="closure-library/closure/goog/base.js"/>
        <include name="closure-library/closure/goog/css/dialog.css"/>
        <include name="closure-library/closure/goog/css/hsvapalette.css"/>
        <include name="closure-library/closure/goog/deps.js"/>
      </fileset>
      <fileset dir="${docs.dir}/html/static">
        <include name="js/*"/>
      </fileset>
      <fileset dir="src/${appinventor.pkg}">
        <include name="images/help.png"/>
      </fileset>
    </copy>
    <!-- Resources for Maps designer view -->
    <copy todir="${build.static.dir}/">
      <fileset dir="${lib.dir}">
        <include name="leaflet/**/*"/>
        <include name="font-awesome/**/*"/>
      </fileset>
    </copy>
  </target>

  <!-- =====================================================================
       Create the keystore that is used by AiServerLib to encrypt user and
       project IDs.
       CheckKeystore checks whether the keystore has already been created.
       ===================================================================== -->
  <target name="CheckKeystore">
    <!-- If build/war/keystore/1 exists, set keystore.present to true.
         Otherwise, set keystore.present to false -->
    <available file="${build.war.dir}/WEB-INF/keystore/1" property="keystore.present"/>
  </target>

  <target name="Keystore"
          description="Generate the key used by .../server/encryption/KeyczarEncryptor"
          depends="CheckKeystore,CopyToBuildWar"
          unless="keystore.present">
    <echo message="Using KeyczarTool to generate keystore"/>
    <mkdir dir="${build.war.dir}/WEB-INF/keystore"/>
    <java failonerror="true" fork="true" jar="${lib.dir}/keyczar/KeyczarTool.jar">
      <arg line="create --location=${build.war.dir}/WEB-INF/keystore --purpose=crypt"/>
    </java>
    <java failonerror="true" fork="true" jar="${lib.dir}/keyczar/KeyczarTool.jar">
      <arg line="addkey --location=${build.war.dir}/WEB-INF/keystore"/>
    </java>
    <java failonerror="true" fork="true" jar="${lib.dir}/keyczar/KeyczarTool.jar">
      <arg line="promote --location=${build.war.dir}/WEB-INF/keystore --version=1"/>
    </java>
  </target>

  <!-- =====================================================================
       Copy jars needed by AiSharedLib and AiServerLib, that are either
       external or built by other projects, to <build>/war/WEB-INF/lib.
       ===================================================================== -->
  <target name="MakeWarLibsDir"
          description="Creates build/war/WEB-INF/lib"
          depends="init">
    <mkdir dir="${build.war.dir}/WEB-INF/lib" />
  </target>
  <target name="WarLibs"
          description="Copy libs to build/war/WEB-INF/lib"
          depends="init,MakeWarLibsDir,common_CommonUtils,common_CommonVersion,components_CommonConstants">
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${build.dir}/common/CommonUtils.jar"/>
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${build.dir}/common/CommonVersion.jar"/>
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${build.dir}/components/CommonConstants.jar"/>
    <!-- external libs -->
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/commons-fileupload/commons-fileupload-1.2.2.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/findbugs/jsr305.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/guava/guava-20.0.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/firebase/firebase-token-generator-2.0.0.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/commons-codec/commons-codec-1.7.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/json/json.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/keyczar/keyczar-0.66-080111-java-1.6.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/objectify-3.1/objectify-3.1.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/gson/gson-2.1.jar" />  <!-- for keyczar -->
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/log4j/log4j-1.2.16.jar" />  <!-- for keyczar -->
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/commons-lang3/commons-lang3-3.10.jar" />
    <!-- GCS Libs -->
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/gcs/appengine-gcs-client-0.6.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/gcs/jackson-core-2.1.3.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/gcs/google-api-client-1.22.0.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/gcs/google-api-client-appengine-1.22.0.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/gcs/google-http-client-1.22.0.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/gcs/google-http-client-appengine-1.22.0.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/gcs/google-http-client-jackson-1.22.0.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/gcs/google-http-client-jackson2-1.22.0.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/gcs/google-api-services-storage-v1-rev91-1.22.0.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/gcs/httpclient-4.0.1.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/gcs/joda-time-2.6.jar" />
    <!-- gwt libs -->
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet-deps.jar" />
    <!-- Protocol Buffers -->
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/protobuf/protobuf-2.6.1.jar" />
    <!-- OWASP -->
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${lib.dir}/owasp/owasp-java-html-sanitizer-20160628.1.jar" />
    <!-- Add any additional server libs that need to be copied -->
    <copy todir="${build.war.dir}/WEB-INF/lib" flatten="true">
      <fileset dir="${appengine.sdk}/lib/user" includes="**/*.jar"/>
    </copy>
  </target>

  <!-- =====================================================================
       Define base package path.
       ===================================================================== -->
  <property name="appinventor.pkg" value="com/google/appinventor" />

  <!-- =====================================================================
       AiServer library
       ===================================================================== -->
  <target name="AiServerLib"
          description="App Inventor Server library"
          depends="init,WarLibs,AiSharedLib">
    <property name="AiServerLib-class.dir" location="${class.dir}/AiServerLib" />
    <mkdir dir="${AiServerLib-class.dir}" />
    <copy todir="${AiServerLib-class.dir}/${appinventor.pkg}/server">
      <fileset dir="src/${appinventor.pkg}/server/" includes="*.properties" />
    </copy>
    <ai.javac destdir="${AiServerLib-class.dir}"
              source="1.7" target="1.7">
      <include name="${appinventor.pkg}/server/**/*.java" />
      <classpath>
        <!-- jars that we put in <build>/war/WEB-INF/lib -->
        <fileset dir="${build.war.dir}/WEB-INF/lib" includes="*.jar" excludes="AiServerLib.jar"/>
        <!-- gwt lib needed only at compile time for javax.servlet.http.HttpServlet* -->
        <pathelement location="${gwt.sdk}/gwt-user.jar"/>
      </classpath>
    </ai.javac>

    <jar basedir="${AiServerLib-class.dir}"
         destfile="${local.build.dir}/AiServerLib.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${local.build.dir}/AiServerLib.jar"/>
  </target>

  <!-- =====================================================================
       Checks to see if we have our own authkey ZIP file.
       ===================================================================== -->
  <target name="CheckAuthKey"
          depends="init">
    <available file="${user.home}/.appinventor/authkey.zip"
               property="authkey.exists" />
  </target>

  <!-- =====================================================================
       Makes the authkey file if it doesn't exist. This target needs
       to be called explicitly. We do not run automatically so we
       cannot accidentally over-write a valid existing file.
       ===================================================================== -->
  <target name="MakeAuthKey"
          depends="init,CheckAuthKey" unless="${authkey.exists}">
    <tempfile prefix="mkkey" property="tmp.dir" destdir="${java.io.tmpdir}"/>
    <mkdir dir="${tmp.dir}/authkey"/>
    <java failonerror="true" fork="true"
          jar="${lib.dir}/keyczar/KeyczarTool.jar">
      <arg line="create --location=${tmp.dir}/authkey
                 --purpose=crypt"/>
    </java>
    <java failonerror="true" fork="true"
          jar="${lib.dir}/keyczar/KeyczarTool.jar">
      <arg line="addkey --location=${tmp.dir}/authkey"/>
    </java>
    <java failonerror="true" fork="true"
          jar="${lib.dir}/keyczar/KeyczarTool.jar">
      <arg line="promote --location=${tmp.dir}/authkey
                 --version=1"/>
    </java>
    <zip destfile="${user.home}/.appinventor/authkey.zip"
         basedir="${tmp.dir}" includes="authkey/**" />
    <delete file="${tmp.dir}/authkey/meta"/>
    <delete file="${tmp.dir}/authkey/1"/>
  </target>

  <!-- =====================================================================
       Install the Authkey into the correct location
       ===================================================================== -->
  <target name="InstallAuthKey"
          depends="init,CheckAuthKey,WarLibs">
    <fail message="You Must Create an Auth Key see misc/docs/authkey.md"
          unless="${authkey.exists}" />
    <unzip dest="${build.war.dir}/WEB-INF"
      src="${user.home}/.appinventor/authkey.zip"/>
  </target>

  <!-- =====================================================================
       AiServerLibTests: build and run the AiServerLib tests and generate the output results
       ===================================================================== -->

  <path id="libsForAiServerLibTests.path">
    <pathelement location="${local.build.dir}/AiServerLib.jar" />
    <pathelement location="${local.build.dir}/AiSharedLib.jar" />
    <pathelement location="${build.dir}/common/CommonUtils.jar" />
    <pathelement location="${build.dir}/common/CommonTestUtils.jar" />
    <pathelement location="${build.dir}/common/CommonVersion.jar" />
    <pathelement location="${build.dir}/components/CommonConstants.jar"/>
    <pathelement location="${lib.dir}/guava/guava-20.0.jar" />
    <pathelement location="${lib.dir}/guava/error_prone_annotations-2.0.12.jar" />
    <pathelement location="${lib.dir}/guava/j2objc-annotations-1.1.jar" />
    <pathelement location="${lib.dir}/json/json.jar" />
    <pathelement location="${lib.dir}/junit/junit-4.8.2.jar" />
    <pathelement location="${lib.dir}/junit-addons/junit-addons-1.4.jar" />
    <pathelement location="${lib.dir}/keyczar/KeyczarTool.jar" />
    <pathelement location="${lib.dir}/objectify-3.1/objectify-3.1.jar" />
    <pathelement location="${lib.dir}/powermock/cglib-nodep-2.2.jar" />
    <pathelement location="${lib.dir}/powermock/easymock-3.0.jar" />
    <pathelement location="${lib.dir}/powermock/javassist-3.18.0-GA.jar" />
    <pathelement location="${lib.dir}/powermock/objenesis-1.2.jar" />
    <pathelement location="${lib.dir}/powermock/powermock-easymock-1.4.10-full.jar" />
    <pathelement location="${lib.dir}/responder-iq/responderiq-test.jar" />
    <pathelement location="${lib.dir}/gcs/appengine-gcs-client-0.6.jar" />
    <pathelement location="${lib.dir}/gcs/jackson-core-2.1.3.jar" />
    <pathelement location="${lib.dir}/gcs/google-api-client-1.22.0.jar" />
    <pathelement location="${lib.dir}/gcs/google-api-client-appengine-1.22.0.jar" />
    <pathelement location="${lib.dir}/gcs/google-http-client-1.22.0.jar" />
    <pathelement location="${lib.dir}/gcs/google-http-client-appengine-1.22.0.jar" />
    <pathelement location="${lib.dir}/gcs/google-http-client-jackson-1.22.0.jar" />
    <pathelement location="${lib.dir}/gcs/google-http-client-jackson2-1.22.0.jar" />
    <pathelement location="${lib.dir}/gcs/google-api-services-storage-v1-rev91-1.22.0.jar" />
    <pathelement location="${lib.dir}/gcs/httpclient-4.0.1.jar" />
    <pathelement location="${lib.dir}/gcs/joda-time-2.6.jar" />
    <pathelement location="${lib.dir}/protobuf/protobuf-2.6.1.jar" />
    <pathelement location="${gwt.sdk}/gwt-servlet.jar" />
    <pathelement location="${gwt.sdk}/gwt-user.jar"/>
    <pathelement location="${appengine.sdk}/lib/impl/appengine-api.jar"/>
    <pathelement location="${appengine.sdk}/lib/impl/appengine-api-labs.jar"/>
    <pathelement location="${appengine.sdk}/lib/impl/appengine-api-stubs.jar"/>
    <pathelement location="${appengine.sdk}/lib/testing/appengine-testing.jar" />
    <pathelement location="${appengine.sdk}/lib/user/orm/geronimo-jpa_3.0_spec-1.1.1.jar" />
    <fileset dir="${build.war.dir}/WEB-INF/lib" includes="*.jar" excludes="AiServerLib.jar"/>
  </path>

  <path id="AiServerLibTests.path">
    <path refid="libsForAiServerLibTests.path"/>
    <pathelement location="${local.build.dir}/AiServerLibTests.jar" />
  </path>

  <target name="AiServerLibTests"
          depends="AiServerLib,common_CommonTestUtils,common_CommonUtils,common_CommonVersion,Keystore"
          description="build and run the test suite" >
    <ai.dojunit aij-testingtarget="AiServerLibTests"
                aij-dir="${appinventor.pkg}/server" >
    </ai.dojunit>
  </target>

  <!-- =====================================================================
       AiShared library
       ===================================================================== -->
  <target name="AiSharedLib"
          description="App Inventor Shared library"
          depends="init,WarLibs">

    <property name="AiSharedLib-class.dir" location="${class.dir}/AiSharedLib" />
    <mkdir dir="${AiSharedLib-class.dir}" />

    <ai.javac destdir="${AiSharedLib-class.dir}"
              source="1.7" target="1.7">
      <include name="${appinventor.pkg}/shared/**/*.java" />
      <classpath>
        <!-- jars that we put in <build>/war/WEB-INF/lib -->
        <fileset dir="${build.war.dir}/WEB-INF/lib" includes="*.jar" excludes="AiSharedLib.jar"/>
      </classpath>
    </ai.javac>

    <jar basedir="${AiSharedLib-class.dir}"
         destfile="${local.build.dir}/AiSharedLib.jar" />
    <copy todir="${build.war.dir}/WEB-INF/lib" file="${local.build.dir}/AiSharedLib.jar"/>

  </target>

  <!-- =====================================================================
       AiSharedLibTests: build and run the AiSharedLib tests and generate the output results
       ===================================================================== -->

  <!-- requires AiServerLib for files in /server/properties/json -->
  <path id="libsForAiSharedLibTests.path">
    <pathelement location="${local.build.dir}/AiSharedLib.jar" />
    <pathelement location="${local.build.dir}/AiServerLib.jar" />
    <pathelement location="${build.dir}/common/CommonUtils.jar" />
    <pathelement location="${lib.dir}/guava/guava-20.0.jar" />
    <pathelement location="${lib.dir}/guava/error_prone_annotations-2.0.12.jar" />
    <pathelement location="${lib.dir}/guava/j2objc-annotations-1.1.jar" />
    <pathelement location="${lib.dir}/json/json.jar" />
    <pathelement location="${lib.dir}/junit/junit-4.8.2.jar" />
    <pathelement location="${lib.dir}/gcs/appengine-gcs-client-0.6.jar" />
    <pathelement location="${gwt.sdk}/gwt-servlet.jar" />
  </path>

  <path id="AiSharedLibTests.path">
    <path refid="libsForAiSharedLibTests.path"/>
    <pathelement location="${local.build.dir}/AiSharedLibTests.jar" />
  </path>

  <target name="AiSharedLibTests"
          depends="AiSharedLib,AiServerLib,common_CommonUtils"
          description="build and run the test suite" >
    <ai.dojunit aij-testingtarget="AiSharedLibTests"
                aij-dir="${appinventor.pkg}/shared" >
    </ai.dojunit>
  </target>

  <!-- =====================================================================
       Rebind library
       ===================================================================== -->
  <target name="AiRebindLib"
          description="App Inventor Rebind library"
          depends="init">

    <property name="AiRebindLib-class.dir" location="${class.dir}/AiRebindLib" />
    <mkdir dir="${AiRebindLib-class.dir}" />

    <ai.javac destdir="${AiRebindLib-class.dir}"
              source="1.7" target="1.7">
      <include name="${appinventor.pkg}/rebind/**/*.java" />
      <classpath>
        <!-- gwt libs -->
        <pathelement location="${gwt.sdk}/gwt-dev.jar"/>
        <pathelement location="${gwt.sdk}/gwt-user.jar"/>
      </classpath>
    </ai.javac>

    <jar destfile="${local.build.dir}/AiRebindLib.jar">
      <fileset dir="${AiRebindLib-class.dir}"/>
      <fileset dir="${src.dir}">
        <include name="**/AiRebindLib.gwt.xml" />
      </fileset>
    </jar>

  </target>

  <!-- =====================================================================
       AiClient library
       ===================================================================== -->
  <target name="AiClientLib"
          description="App Inventor Client library - compile java source to bytecode"
          depends="components_AndroidRuntime">
    <mkdir dir="${build.war.dir}/WEB-INF/classes"/>
    <ai.javac encoding="utf-8"
              destdir="${build.war.dir}/WEB-INF/classes"
              srcdir="${src.dir};${build.dir}/components/ComponentTranslation/src"
              source="1.7" target="1.7" nowarn="true"
              debug="true" debuglevel="lines,vars,source">
      <include name="${appinventor.pkg}/client/**/*.java" />
      <include name="${appinventor.pkg}/shared/**/*.java" />
      <classpath>
        <pathelement location="${build.dir}/common/CommonUtils.jar" />
        <pathelement location="${build.dir}/common/CommonVersion.jar" />
        <pathelement location="${build.dir}/components/CommonConstants.jar" />
        <pathelement location="${build.dir}/components/CommonConstants-gwt.jar" />
        <!-- external libs -->
        <pathelement location="${lib.dir}/guava/guava-20.0.jar" />
        <pathelement location="${lib.dir}/guava/error_prone_annotations-2.0.12.jar" />
        <pathelement location="${lib.dir}/guava/j2objc-annotations-1.1.jar" />
        <pathelement location="${lib.dir}/gwt_dragdrop/gwt-dnd-3.2.3.jar" />
        <pathelement location="${lib.dir}/gwt_incubator/gwt-incubator-20101117-r1766.jar" />
        <pathelement location="${lib.dir}/gwt_query/gwtquery-1.5-beta1.jar" />
        <!-- gwt libs -->
        <pathelement location="${gwt.sdk}/gwt-user.jar"/>
      </classpath>
    </ai.javac>
    <copy todir="${build.war.dir}/WEB-INF/classes/com/google/appinventor"
          file="${build.dir}/components/simple_components.json" />
    <copy todir="${build.war.dir}/WEB-INF/classes">
      <fileset dir="src" excludes="**/*.java"/>
    </copy>
  </target>

  <!-- =====================================================================
       YaClientApp GWT application
       CheckYaClientApp - checks whether it is already up-to-date.
       ===================================================================== -->
  <target name="CheckYaClientApp"
          depends="common_CommonUtils,common_CommonVersion,components_CommonConstants,AiClientLib,AiRebindLib,CopyToBuildWar">
    <!-- If ode.nocache.js is up-to-date, set YaClientApp.uptodate to true.
         Otherwise, set YaClientApp.uptodate to false -->
    <uptodate property="YaClientApp.uptodate"
              targetfile="${build.war.dir}/ode/ode.nocache.js">
      <srcfiles dir="${build.war.dir}/WEB-INF/classes"/>
      <srcfiles file="${local.build.dir}/AiRebindLib.jar" />
      <srcfiles file="${build.dir}/common/CommonUtils-gwt.jar" />
      <srcfiles file="${build.dir}/common/CommonVersion-gwt.jar" />
      <srcfiles file="${build.dir}/components/CommonConstants-gwt.jar" />
    </uptodate>
  </target>

  <target name="YaClientApp"
          description="GWT compile to JavaScript"
          depends="common_CommonUtils,common_CommonVersion,components_CommonConstants,AiClientLib,AiRebindLib,CheckYaClientApp"
          unless="YaClientApp.uptodate">
    <mkdir dir="${build.extra.dir}" />
    <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
      <classpath>
        <pathelement location="src"/>
        <pathelement location="${build.dir}/components/ComponentTranslation/src"/>
        <pathelement location="${build.war.dir}/WEB-INF/classes"/>
        <pathelement location="${local.build.dir}/AiRebindLib.jar" />
        <pathelement location="${build.dir}/common/CommonUtils-gwt.jar" />
        <pathelement location="${build.dir}/common/CommonVersion-gwt.jar" />
        <pathelement location="${build.dir}/components/CommonConstants-gwt.jar" />
        <!-- external libs -->
        <pathelement location="${lib.dir}/findbugs/jsr305.jar" />
        <pathelement location="${lib.dir}/guava/guava-20.0.jar" />
        <pathelement location="${lib.dir}/guava/guava-gwt-20.0.jar" />
        <pathelement location="${lib.dir}/guava/error_prone_annotations-2.0.12.jar" />
        <pathelement location="${lib.dir}/guava/j2objc-annotations-1.1.jar" />
        <pathelement location="${lib.dir}/gwt_dragdrop/gwt-dnd-3.2.3.jar" />
        <pathelement location="${lib.dir}/gwt_incubator/gwt-incubator-20101117-r1766.jar" />
        <pathelement location="${lib.dir}/gwt_query/gwtquery-1.5-beta1.jar" />
        <!-- gwt libs -->
        <pathelement location="${gwt.sdk}/gwt-dev.jar"/>
        <pathelement location="${gwt.sdk}/gwt-user.jar"/>
        <pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar" />
        <pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar" />
      </classpath>
      <jvmarg value="-Xss2M"/>  <!-- increase if you see a StackOverflowError -->
      <jvmarg value="-Xmx2G"/>
      <jvmarg line="${XstartOnFirstThread}"/>
      <jvmarg value="-Dfile.encoding=UTF-8" />
      <arg line="-war"/>
      <arg value="${build.war.dir}"/>
      <arg line="-logLevel INFO -extra ${build.extra.dir} -style pretty"/>
      <arg value="com.google.appinventor.YaClient"/>
    </java>
  </target>

  <target name="devmode"
          depends="common_CommonUtils,common_CommonVersion,components_CommonConstants,AiClientLib,AiRebindLib,CheckYaClientApp"
          description="Run development mode">
    <java failonerror="true" fork="true" classname="com.google.gwt.dev.codeserver.CodeServer">
      <classpath>
        <pathelement location="src" />
        <pathelement location="${build.dir}/components/ComponentTranslation/src" />
        <pathelement location="${build.war.dir}/WEB-INF/classes" />
        <pathelement location="${local.build.dir}/AiRebindLib.jar" />
        <pathelement location="${build.dir}/common/BlocksEditorHttpConstants-gwt.jar" />
        <pathelement location="${build.dir}/common/CommonUtils-gwt.jar" />
        <pathelement location="${build.dir}/common/CommonVersion-gwt.jar" />
        <pathelement location="${build.dir}/components/CommonConstants-gwt.jar" />
        <!-- external libs -->
        <pathelement location="${lib.dir}/findbugs/jsr305.jar" />
        <pathelement location="${lib.dir}/guava/guava-20.0.jar" />
        <pathelement location="${lib.dir}/guava/guava-gwt-20.0.jar" />
        <pathelement location="${lib.dir}/guava/error_prone_annotations-2.0.12.jar" />
        <pathelement location="${lib.dir}/guava/j2objc-annotations-1.1.jar" />
        <pathelement location="${lib.dir}/gwt_dragdrop/gwt-dnd-3.2.3.jar" />
        <pathelement location="${lib.dir}/gwt_incubator/gwt-incubator-20101117-r1766.jar" />
        <pathelement location="${lib.dir}/gwt_query/gwtquery-1.5-beta1.jar" />
        <!-- gwt libs -->
        <pathelement location="${gwt.sdk}/gwt-codeserver.jar" />
        <pathelement location="${gwt.sdk}/gwt-dev.jar" />
        <pathelement location="${gwt.sdk}/gwt-user.jar" />
        <pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar" />
        <pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar" />
      </classpath>
      <jvmarg value="-Xmx1G" />
      <arg line="-style PRETTY -logLevel INFO" />
      <arg value="com.google.appinventor.YaClient" />
      <arg value="-bindAddress"/>
      <arg value="0.0.0.0"/>
    </java>
  </target>

  <!-- =====================================================================
       AiClientLibTests: build and run the AiClientLib tests and generate the output results
       ===================================================================== -->

  <!-- requires AiServerLib for files in /server/properties/json -->
  <path id="libsForAiClientLibTests.path">
    <pathelement location="${build.war.dir}/WEB-INF/classes"/>
    <pathelement location="${local.build.dir}/AiServerLib.jar" />
    <pathelement location="${local.build.dir}/AiRebindLib.jar" />
    <pathelement location="${local.build.dir}/AiSharedLib.jar" />
    <pathelement location="${build.dir}/common/CommonTestUtils.jar" />
    <pathelement location="${build.dir}/components/CommonConstants.jar"/>
    <pathelement location="${build.dir}/components/CommonConstants-gwt.jar"/>
    <pathelement location="${build.dir}/common/CommonUtils.jar" />
    <pathelement location="${build.dir}/common/CommonUtils-gwt.jar" />
    <pathelement location="${build.dir}/common/CommonVersion-gwt.jar" />
    <pathelement location="${lib.dir}/guava/guava-20.0.jar" />
    <pathelement location="${lib.dir}/guava/error_prone_annotations-2.0.12.jar" />
    <pathelement location="${lib.dir}/guava/j2objc-annotations-1.1.jar" />
    <pathelement location="${lib.dir}/gwt_query/gwtquery-1.5-beta1.jar" />
    <pathelement location="${lib.dir}/gwt_dragdrop/gwt-dnd-3.2.3.jar" />
    <pathelement location="${lib.dir}/gwt_incubator/gwt-incubator-20101117-r1766.jar" />
    <pathelement location="${lib.dir}/guava/guava-gwt-20.0.jar" />
    <pathelement location="${lib.dir}/json/json.jar" />
    <pathelement location="${lib.dir}/junit/junit-4.8.2.jar" />
    <pathelement location="${gwt.sdk}/gwt-user.jar"/>
    <pathelement location="${gwt.sdk}/gwt-dev.jar"/>
    <pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar"/>
    <pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar"/>
    <!-- Paths to sources (needed by GWTTestCase) -->
    <pathelement location="${build.dir}/components/ComponentTranslation/src" />
    <pathelement location="src"/>
    <pathelement location="tests"/>
  </path>

  <path id="AiClientLibTests.path">
    <path refid="libsForAiClientLibTests.path"/>
    <path refid="libsForAiServerLibTests.path"/>
    <pathelement location="${local.build.dir}/AiSharedLib.jar" />
    <pathelement location="${local.build.dir}/AiClientLibTests.jar" />
  </path>

  <target name="AiClientLibTests"
          depends="AiClientLib,AiServerLib,common_CommonTestUtils,components_CommonConstants,common_CommonUtils"
          description="build and run the test suite" >
    <ai.dojunit aij-testingtarget="AiClientLibTests"
                aij-prod="true"
                aij-dir="${appinventor.pkg}/client" >
    </ai.dojunit>
  </target>

</project>


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Sydowia 9: 50 (1955)

#### Original name
Meliola telosmae var. telosmae

### Remarks
null

redpajama_set_name: RedPajamaGithub


text:
"""Management command tests."""

from modoboa.admin import factories as admin_factories
from modoboa.lib.tests import ModoTestCase

from . import mixins
from .. import models

class ManagementCommandTestCase(mixins.CallCommandMixin, ModoTestCase):
    """Test management command."""

    @classmethod
    def setUpTestData(cls):
        super(ManagementCommandTestCase, cls).setUpTestData()
        cls.domain = admin_factories.DomainFactory(name="ngyn.org")

    def test_import_from_archive(self):
        """Import report from archive."""
        self.import_reports()
        self.import_fail_reports()
        self.assertTrue(self.domain.record_set.exists())
        self.assertTrue(
            models.Reporter.objects.filter(
                org_name="FastMail Pty Ltd").exists())


text:
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/platform_device.h>

static int __init pdc_probe(struct platform_device *pdev)
{
	struct clk *pclk, *hclk;

	pclk = clk_get(&pdev->dev, "pclk");
	if (IS_ERR(pclk)) {
		dev_err(&pdev->dev, "no pclk defined\n");
		return PTR_ERR(pclk);
	}
	hclk = clk_get(&pdev->dev, "hclk");
	if (IS_ERR(hclk)) {
		dev_err(&pdev->dev, "no hclk defined\n");
		clk_put(pclk);
		return PTR_ERR(hclk);
	}

	clk_enable(pclk);
	clk_enable(hclk);

	dev_info(&pdev->dev, "Atmel Peripheral DMA Controller enabled\n");
	return 0;
}

static struct platform_driver pdc_driver = {
	.driver		= {
		.name	= "pdc",
	},
};

static int __init pdc_init(void)
{
	return platform_driver_probe(&pdc_driver, pdc_probe);
}
arch_initcall(pdc_init);


text:
//
//  KSArchSpecific.h
//
//  Created by Karl Stenerud on 2012-02-17.
//
//  Copyright (c) 2012 Karl Stenerud. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall remain in place
// in this source code.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

/* Architecture-dependent defines.
 */

#ifndef HDR_KSArchSpecific_h
#define HDR_KSArchSpecific_h

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/_structs.h>

#ifdef __LP64__
    #define STRUCT_NLIST struct nlist_64
#else
    #define STRUCT_NLIST struct nlist
#endif

#ifdef __arm64__
    #define STRUCT_MCONTEXT_L _STRUCT_MCONTEXT64
#else
    #define STRUCT_MCONTEXT_L _STRUCT_MCONTEXT
#endif

#ifdef __cplusplus
}
#endif

#endif // HDR_KSArchSpecific_h


text:
<?php

namespace DataBreakers;

use DataBreakers\DataApi\Client;
use Tester\TestCase;

abstract class IntegrationTestCase extends TestCase
{

	/** @var Client */
	protected $client;

	/**
	 * @inheritdoc
	 */
	protected function setUp()
	{
		parent::setUp();

		$credentials = require __DIR__ . '/credentials.php';
		$this->client = new Client($credentials['accountId'], $credentials['secretKey']);

		$seeder = new Seeder($this->client);
		$seeder->clear();
		$seeder->seed();
	}

}


text:
/*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.
*/
package skyring

import (
	"encoding/json"
	"fmt"
	"github.com/skyrings/skyring-common/conf"
	"github.com/skyrings/skyring-common/db"
	"github.com/skyrings/skyring-common/models"
	"github.com/skyrings/skyring-common/tools/logger"
	"net/http"
	"strings"
)

func (a *App) About(w http.ResponseWriter, r *http.Request) {
	ctxt, err := GetContext(r)
	if err != nil {
		logger.Get().Error("Error Getting the context. error: %v", err)
	}
	var syscapabilities conf.SystemCapabilities
	sessionCopy := db.GetDatastore().Copy()
	defer sessionCopy.Close()
	coll := sessionCopy.DB(conf.SystemConfig.DBConfig.Database).C(models.COLL_NAME_SYSTEM_CAPABILITIES)
	if err := coll.Find(nil).One(&syscapabilities); err != nil {
		HttpResponse(w, http.StatusBadRequest, fmt.Sprintf("Error in retrieving System Capabilities detail. error: %v", err))
		logger.Get().Error("%s-Error in retrieving System Capabilities detail. error: %v", ctxt, err)
		return
	}
	storage_provider_details := make(map[string]string)
	for key, val := range syscapabilities.StorageProviderDetails {
		storage_provider_details[strings.Title(key)] = val
		delete(syscapabilities.StorageProviderDetails, key)
	}
	syscapabilities.StorageProviderDetails = storage_provider_details
	if err := json.NewEncoder(w).Encode(syscapabilities); err != nil {
		logger.Get().Error("%s-Error encoding data: %v", ctxt, err)
		HttpResponse(w, http.StatusInternalServerError, err.Error())
	}
}


text:
require 'ansible/ruby/modules/base'

module Ansible
  module Ruby
    module Modules
      # Apstra AOS Logical Device module let you manage your Logical Devices easily. You can create create and delete Logical Device by Name, ID or by using a JSON File. This module is idempotent and support the I(check) mode. It's using the AOS REST API.
      class Aos_logical_device < Base
        # @return [String] An existing AOS session as obtained by M(aos_login) module.
        attribute :session
        validates :session, presence: true, type: String

        # @return [String, nil] Name of the Logical Device to manage. Only one of I(name), I(id) or I(content) can be set.
        attribute :name
        validates :name, type: String

        # @return [String, nil] AOS Id of the Logical Device to manage (can't be used to create a new Logical Device), Only one of I(name), I(id) or I(content) can be set.
        attribute :id
        validates :id, type: String

        # @return [String, nil] Datastructure of the Logical Device to create. The data can be in YAML / JSON or directly a variable. It's the same datastructure that is returned on success in I(value).
        attribute :content
        validates :content, type: String

        # @return [:present, :absent, nil] Indicate what is the expected state of the Logical Device (present or not).
        attribute :state
        validates :state, expression_inclusion: {:in=>[:present, :absent], :message=>"%{value} needs to be :present, :absent"}, allow_nil: true
      end
    end
  end
end


text:
import urllib2
import os
import sys
import time

if len(sys.argv) != 3:
    print "USAGE: fetch_genome.py <genome_id_list> <out_dir>"
    sys.exit(1)

url_template = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nucleotide&id=%s&rettype=fasta&retmode=text"

os.mkdir(sys.argv[2])

for id in open(sys.argv[1]):
    id = id.strip()
    if id == "":
        continue

    sys.stdout.write("Fetching %s..." % id)
    sys.stdout.flush()
    gbk_out_file = os.path.join(sys.argv[2], id + ".fa")
    if os.path.exists(gbk_out_file):
        print "already fetched"
    gbseq = urllib2.urlopen(url_template % id).read()
    if not gbseq == "":
    	open(gbk_out_file, "w").write(gbseq)
    print "Done"
    time.sleep(1.0/3)


text:
import { newSession, WindowRect } from '../src';
import { log } from '../src/logger';
import testEnv, { Browser } from '../test-env';
import { startDriver, stopDriver } from '../test-env/browserDriver';
import { startTestApp, stopTestApp } from '../test-env/testApp';

log.enabled = true;

let windowRect: WindowRect;

before(async () => {
  await startDriver();
  await startTestApp();
})

before(async () => {
  const { driver, capabilities, desiredCapabilities } = testEnv;
  const url = process.env.WEB_DRIVER_URL || '';
  log(`Creating session on ${url}.`);
  try {
    testEnv.session = await newSession({
      url,
      ...(capabilities && { capabilities }),
      ...(desiredCapabilities && { desiredCapabilities }),
      headers: driver.headers
    })
    log(`Session created.`);
  } catch (error) {
    log(error);
    throw error;
  }
  windowRect = await testEnv.session.getWindowRect();
});

beforeEach(async () => {
  const { session } = testEnv;
  const testAppPort = process.env.TEST_APP_PORT;
  await session.navigateTo(`http://localhost:${testAppPort}`);
  await session.setWindowRect(windowRect);
});

after(async () => {
  const { session, browser, driver } = testEnv;
  const url = process.env.WEB_DRIVER_URL;
  log(`Deleting session on ${url}.`);
  await session.close();
  log(`Session deleted.`);
  if (browser === Browser.Safari || driver.host) {
    log(`Wait for 2 seconds...`);
    await new Promise(resolve =>
      setTimeout(() => {
        resolve();
      }, 2000)
    );
  }
});

after(async () => {
  await stopDriver();
  await stopTestApp();
});


text:
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace APT {

    public partial class ImageUserControl {

        /// <summary>
        /// imageLink1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlAnchor imageLink1;

        /// <summary>
        /// imageSRC1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlImage imageSRC1;

        /// <summary>
        /// imageLink2 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlAnchor imageLink2;

        /// <summary>
        /// imageSRC2 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlImage imageSRC2;

        /// <summary>
        /// imageLink3 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlAnchor imageLink3;

        /// <summary>
        /// imageSRC3 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlImage imageSRC3;
    }
}


text:
"""
Copyright (c) 2006-2013 sqlmap developers (http://sqlmap.org/)
See the file 'doc/COPYING' for copying permission
"""

import re

from lib.core.enums import HTTP_HEADER
from lib.core.settings import WAF_ATTACK_VECTORS

__product__ = "FortiWeb Web Application Firewall (Fortinet Inc.)"

def detect(get_page):
    retval = False

    for vector in WAF_ATTACK_VECTORS:
        page, headers, code = get_page(get=vector)
        retval = re.search(r"\AFORTIWAFSID=", headers.get(HTTP_HEADER.SET_COOKIE, ""), re.I) is not None
        if retval:
            break

    return retval


text:
{-# LANGUAGE FlexibleInstances #-}
-- |
-- Module    : Text.XML.Light
-- Copyright : (c) Galois, Inc. 2007
-- License   : BSD3
--
-- Maintainer: Iavor S. Diatchki <diatchki@galois.com>
-- Stability : provisional
-- Portability: portability
--
-- A lightweight XML parsing, filtering and generating library.
--
-- This module reexports functions from:
--
-- 1. "Text.XML.Light.Types"
-- 2. "Text.XML.Light.Proc"
-- 3. "Text.XML.Light.Input"
-- 4. "Text.XML.Light.Output"

module Text.XML.Light (

    module Text.XML.Light,
    module Text.XML.Light.Types,
    module Text.XML.Light.Proc,
    module Text.XML.Light.Input,
    module Text.XML.Light.Output

  ) where

import Text.XML.Light.Types
import Text.XML.Light.Proc
import Text.XML.Light.Input
import Text.XML.Light.Output

-- | Add an attribute to an element.
add_attr :: Attr -> Element -> Element
add_attr a e = add_attrs [a] e

-- | Add some attributes to an element.
add_attrs :: [Attr] -> Element -> Element
add_attrs as e = e { elAttribs = as ++ elAttribs e }

-- | Create an unqualified name.
unqual :: String -> QName
unqual x = blank_name { qName = x }

-- | A smart element constructor which uses the type of its argument
-- to determine what sort of element to make.
class Node t where
  node :: QName -> t -> Element

--
instance Node ([Attr],[Content]) where
  node n (attrs,cont) = blank_element { elName     = n
                                      , elAttribs  = attrs
                                      , elContent  = cont
                                      }

instance Node [Attr]             where node n as   = node n (as,[]::[Content])
instance Node Attr               where node n a    = node n [a]
instance Node ()                 where node n ()   = node n ([]::[Attr])

instance Node [Content]          where node n cs     = node n ([]::[Attr],cs)
instance Node Content            where node n c      = node n [c]
instance Node ([Attr],Content)   where node n (as,c) = node n (as,[c])
instance Node (Attr,Content)     where node n (a,c)  = node n ([a],[c])

instance Node ([Attr],[Element]) where
  node n (as,cs) = node n (as,map Elem cs)

instance Node ([Attr],Element)   where node n (as,c) = node n (as,[c])
instance Node (Attr,Element)     where node n (a,c)  = node n ([a],c)
instance Node ([Element])        where node n es     = node n ([]::[Attr],es)
instance Node (Element)          where node n e      = node n [e]

instance Node ([Attr],[CData])   where
  node n (as,cs) = node n (as,map Text cs)

instance Node ([Attr],CData)     where node n (as,c) = node n (as,[c])
instance Node (Attr,CData)       where node n (a,c)  = node n ([a],c)
instance Node [CData]            where node n es     = node n ([]::[Attr],es)
instance Node CData              where node n e      = node n [e]

instance Node ([Attr],String)    where
  node n (as,t) = node n (as,blank_cdata { cdData = t })

instance Node (Attr,String)      where node n (a,t)  = node n ([a],t)
instance Node [Char]             where node n t      = node n ([]::[Attr],t)

-- | Create node with unqualified name
unode :: Node t => String -> t -> Element
unode = node . unqual


text:
"""A python3 implementation of the Thud! boardgame
"""

__author__ = "William Dizon"
__license__ = "MIT License"
__version__ = "1.8.0"
__email__ = "wdchromium@gmail.com"

import sys
import re
from thud import *
from thudclasses import *
from itertools import cycle

if __name__ == '__main__':
    ply_list = [l.strip('\n') for l in sys.stdin.readlines()]
    newgame = Gameboard('classic')

    if sys.argv[1] == 'captures':
        last_move = ply_list.pop()

    try:
        turn = itertools.cycle(['dwarf', 'troll'])
        for move in ply_list:
            if ',' in move: continue
            p = Ply.parse_string(move)
            if p.token != next(turn):
                raise RuntimeError(len(newgame.ply_list), move)

            if not p:
                if len(newgame.ply_list) == 0:
                    continue
                break

            valid = newgame.validate_move(p.origin, p.dest)
            if valid[0] or valid[1]:
                newgame.apply_ply(p)
                newgame.ply_list.append(p)
            else:
                raise RuntimeError(len(newgame.ply_list), move)

    except RuntimeError as e:
        if sys.argv[1] == 'next_move':
            print('{}:{}'.format(e[0], e[1]))
        elif sys.argv[1] == 'validate':
            print('False')
    else:
        if sys.argv[1] == 'next_move':
            ai_thread = threading.Thread(target=AIEngine.calculate_best_move(newgame, \
                                                                             newgame.turn_to_act(), \
                                                                             30))
            ai_thread.start()
            ai_thread.join()
            print(ai.decision)
        elif sys.argv[1] == 'validate':
            print('True')
        elif sys.argv[1] == 'turn':
            print(newgame.turn_to_act())
        elif sys.argv[1] == 'captures':
            candidates = sorted([str(x) for x in list(newgame.find_caps(newgame.turn_to_act()))],
                                key=len,
                                reverse=True)
            for p in candidates:
                if last_move in p:
                    print(str(p))
                    break
            else:
                print()
    finally:
        exit(0)


text:
// Copyright 2021 The Oppia Authors. All Rights Reserved.
//
// 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.

/**
 * @fileoverview Unit tests for Merge Skill Modal.
 */

import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { MatCardModule } from '@angular/material/card';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatRadioModule } from '@angular/material/radio';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { MergeSkillModalComponent } from './merge-skill-modal.component';
import { SkillSelectorComponent } from './skill-selector.component';

describe('Merge Skill Modal', () => {
  let fixture: ComponentFixture<MergeSkillModalComponent>;
  let componentInstance: MergeSkillModalComponent;
  let ngbActiveModal: NgbActiveModal;

  beforeEach(waitForAsync(() => {
    TestBed.configureTestingModule({
      imports: [
        MatCardModule,
        MatRadioModule,
        MatCheckboxModule,
        FormsModule
      ],
      declarations: [
        MergeSkillModalComponent,
        SkillSelectorComponent
      ],
      providers: [
        NgbActiveModal
      ]
    }).compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(MergeSkillModalComponent);
    componentInstance = fixture.componentInstance;
    ngbActiveModal = (TestBed.inject(NgbActiveModal) as unknown) as
      jasmine.SpyObj<NgbActiveModal>;
  });

  it('should be defined', () => {
    expect(componentInstance).toBeDefined();
  });

  it('should confirm', () => {
    spyOn(ngbActiveModal, 'close');
    componentInstance.confirm();
    expect(ngbActiveModal.close).toHaveBeenCalledWith({
      skill: componentInstance.skill,
      supersedingSkillId: componentInstance.selectedSkillId
    });
  });

  it('should set selected skill id', () => {
    componentInstance.setSelectedSkillId('skill_id');
    expect(componentInstance.selectedSkillId).toEqual('skill_id');
  });
});


text:
set -e

BROKER_ID=$1
PUBLIC_ADDRESS=$2
PUBLIC_ZOOKEEPER_ADDRESSES=$3
JMX_PORT=$4

cd /opt/kafka

sed \
    -e 's/broker.id=0/'broker.id=$BROKER_ID'/' \
    -e 's/#advertised.host.name=<hostname routable by clients>/'advertised.host.name=$PUBLIC_ADDRESS'/' \
    -e 's/zookeeper.connect=localhost:2181/'zookeeper.connect=$PUBLIC_ZOOKEEPER_ADDRESSES'/' \
    /opt/kafka/config/server.properties > /opt/kafka/config/server-$BROKER_ID.properties

echo "Killing server"
bin/kafka-server-stop.sh || true
sleep 5 # Because kafka-server-stop.sh doesn't actually wait
echo "Starting server"
if [[  -n $JMX_PORT ]]; then
  export JMX_PORT=$JMX_PORT
  export KAFKA_JMX_OPTS="-Djava.rmi.server.hostname=$PUBLIC_ADDRESS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false  -Dcom.sun.management.jmxremote.ssl=false "
fi
bin/kafka-server-start.sh /opt/kafka/config/server-$BROKER_ID.properties 1>> /tmp/broker.log 2>> /tmp/broker.log &


text:
#ifndef BEISCSI_H
#define BEISCSI_H

#include <linux/pci.h>
#include <linux/if_vlan.h>
#include <linux/blk-iopoll.h>
#define FW_VER_LEN	32
#define MCC_Q_LEN	128
#define MCC_CQ_LEN	256
#define MAX_MCC_CMD	16
/* BladeEngine Generation numbers */
#define BE_GEN2 2
#define BE_GEN3 3

struct be_dma_mem {
	void *va;
	dma_addr_t dma;
	u32 size;
};

struct be_queue_info {
	struct be_dma_mem dma_mem;
	u16 len;
	u16 entry_size;		/* Size of an element in the queue */
	u16 id;
	u16 tail, head;
	bool created;
	atomic_t used;		/* Number of valid elements in the queue */
};

static inline u32 MODULO(u16 val, u16 limit)
{
	WARN_ON(limit & (limit - 1));
	return val & (limit - 1);
}

static inline void index_inc(u16 *index, u16 limit)
{
	*index = MODULO((*index + 1), limit);
}

static inline void *queue_head_node(struct be_queue_info *q)
{
	return q->dma_mem.va + q->head * q->entry_size;
}

static inline void *queue_get_wrb(struct be_queue_info *q, unsigned int wrb_num)
{
	return q->dma_mem.va + wrb_num * q->entry_size;
}

static inline void *queue_tail_node(struct be_queue_info *q)
{
	return q->dma_mem.va + q->tail * q->entry_size;
}

static inline void queue_head_inc(struct be_queue_info *q)
{
	index_inc(&q->head, q->len);
}

static inline void queue_tail_inc(struct be_queue_info *q)
{
	index_inc(&q->tail, q->len);
}

/*ISCSI */

struct be_eq_obj {
	struct be_queue_info q;
	struct beiscsi_hba *phba;
	struct be_queue_info *cq;
	struct blk_iopoll	iopoll;
};

struct be_mcc_obj {
	struct be_queue_info q;
	struct be_queue_info cq;
};

struct be_ctrl_info {
	u8 __iomem *csr;
	u8 __iomem *db;		/* Door Bell */
	u8 __iomem *pcicfg;	/* PCI config space */
	struct pci_dev *pdev;

	/* Mbox used for cmd request/response */
	spinlock_t mbox_lock;	/* For serializing mbox cmds to BE card */
	struct be_dma_mem mbox_mem;
	/* Mbox mem is adjusted to align to 16 bytes. The allocated addr
	 * is stored for freeing purpose */
	struct be_dma_mem mbox_mem_alloced;

	/* MCC Rings */
	struct be_mcc_obj mcc_obj;
	spinlock_t mcc_lock;	/* For serializing mcc cmds to BE card */
	spinlock_t mcc_cq_lock;

	wait_queue_head_t mcc_wait[MAX_MCC_CMD + 1];
	unsigned int mcc_tag[MAX_MCC_CMD];
	unsigned int mcc_numtag[MAX_MCC_CMD + 1];
	unsigned short mcc_alloc_index;
	unsigned short mcc_free_index;
	unsigned int mcc_tag_available;
};

#include "be_cmds.h"

#define PAGE_SHIFT_4K 12
#define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K)
#define mcc_timeout		120000 /* 5s timeout */

/* Returns number of pages spanned by the data starting at the given addr */
#define PAGES_4K_SPANNED(_address, size)				\
		((u32)((((size_t)(_address) & (PAGE_SIZE_4K - 1)) +	\
			(size) + (PAGE_SIZE_4K - 1)) >> PAGE_SHIFT_4K))

/* Byte offset into the page corresponding to given address */
#define OFFSET_IN_PAGE(addr)						\
		((size_t)(addr) & (PAGE_SIZE_4K-1))

/* Returns bit offset within a DWORD of a bitfield */
#define AMAP_BIT_OFFSET(_struct, field)					\
		(((size_t)&(((_struct *)0)->field))%32)

/* Returns the bit mask of the field that is NOT shifted into location. */
static inline u32 amap_mask(u32 bitsize)
{
	return (bitsize == 32 ? 0xFFFFFFFF : (1 << bitsize) - 1);
}

static inline void amap_set(void *ptr, u32 dw_offset, u32 mask,
					u32 offset, u32 value)
{
	u32 *dw = (u32 *) ptr + dw_offset;
	*dw &= ~(mask << offset);
	*dw |= (mask & value) << offset;
}

#define AMAP_SET_BITS(_struct, field, ptr, val)				\
		amap_set(ptr,						\
			offsetof(_struct, field)/32,			\
			amap_mask(sizeof(((_struct *)0)->field)),	\
			AMAP_BIT_OFFSET(_struct, field),		\
			val)

static inline u32 amap_get(void *ptr, u32 dw_offset, u32 mask, u32 offset)
{
	u32 *dw = ptr;
	return mask & (*(dw + dw_offset) >> offset);
}

#define AMAP_GET_BITS(_struct, field, ptr)				\
		amap_get(ptr,						\
			offsetof(_struct, field)/32,			\
			amap_mask(sizeof(((_struct *)0)->field)),	\
			AMAP_BIT_OFFSET(_struct, field))

#define be_dws_cpu_to_le(wrb, len) swap_dws(wrb, len)
#define be_dws_le_to_cpu(wrb, len) swap_dws(wrb, len)
static inline void swap_dws(void *wrb, int len)
{
#ifdef __BIG_ENDIAN
	u32 *dw = wrb;
	WARN_ON(len % 4);
	do {
		*dw = cpu_to_le32(*dw);
		dw++;
		len -= 4;
	} while (len);
#endif /* __BIG_ENDIAN */
}
#endif /* BEISCSI_H */


text:
<?xml version="1.0" encoding="UTF-8"?><res:ErrorResponse xmlns:res='http://www.dhl.com' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation= 'http://www.dhl.com err-res.xsd'>
    <Response>
        <ServiceHeader>
            <MessageTime>2013-10-10T04:00:35+01:00</MessageTime>
            <MessageReference>1234567890123456789012345678901</MessageReference>
        </ServiceHeader>
        <Status>
            <ActionStatus>Error</ActionStatus>
            <Condition>
                <ConditionCode>111</ConditionCode>
                <ConditionData>Error in parsing request XML:Error: The
                    content of element type "ServiceHeader"
                    must match
                    "(MessageTime,MessageReference,SiteID,Password)".
                    at line 9, column 26</ConditionData>
            </Condition>
        </Status>
    </Response></res:ErrorResponse>


text:
package de.decoit.simu.cbor.ifmap.simu.metadata.singlevalue;

import de.decoit.simu.cbor.ifmap.metadata.singlevalue.AbstractSingleValueMetadata;
import de.decoit.simu.cbor.ifmap.simu.util.SimuNamespaces;
import java.time.ZonedDateTime;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

/**
 * Java representation of the service-ip metadata from the SIMU namespace.
 *
 * @author Thomas Rix (rix@decoit.de)
 */
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Slf4j
public final class CBORServiceIp extends AbstractSingleValueMetadata {
	public static final String XML_NAME = "service-ip";

	/**
	 * Create a new service-ip metadata.
	 * This constructor should be used for metadata that is sent from the SERVER to the CLIENT. It includes
	 * the attributes ifmap-publisher-id, ifmap-timestamp and ifmap-timestamp-fraction.
	 * The timestamp is stored with UTC timezone. If a timestamp with another timezone is
	 * passed into the constructor, it will be converted to UTC. The IF-MAP timestamp fraction
	 * element will be calculated from the provided timestamp.
	 *
	 * @param ifMapPublisherId IF-MAP client publisher ID
	 * @param ifMapTimestamp Timestamp for the metadata
	 */
	public CBORServiceIp(String ifMapPublisherId, ZonedDateTime ifMapTimestamp) {
		super(SimuNamespaces.SIMU, XML_NAME, ifMapPublisherId, ifMapTimestamp);
	}

	/**
	 * Create a new service-ip metadata.
	 * This constructor should be used for metadata that is sent from the CLIENT to the SERVER. It does not include
	 * the attributes ifmap-publisher-id, ifmap-timestamp and ifmap-timestamp-fraction.
	 * The timestamp is stored with UTC timezone. If a timestamp with another timezone is
	 * passed into the constructor, it will be converted to UTC. The IF-MAP timestamp fraction
	 * element will be calculated from the provided timestamp.
	 */
	public CBORServiceIp() {
		super(SimuNamespaces.SIMU, XML_NAME);
	}
}


text:
module System.Build.Access.Notree where

class Notree r where
  setNotree ::
    r
    ->  r

  unsetNotree ::
    r
    ->  r


text:
namespace ParquetSharp.Column.Values.Dictionary
{
    using System.Text;
    using ParquetSharp.Bytes;
    using ParquetSharp.Column.Impl;
    using ParquetSharp.Column.Page;
    using ParquetSharp.Column.Values.Plain;
    using ParquetSharp.External;
    using ParquetSharp.IO;
    using ParquetSharp.IO.Api;
    using Encoding = ParquetSharp.Column.Encoding;

    /**
     * a simple implementation of dictionary for plain encoded values
     *
     */
    public abstract class PlainValuesDictionary : Dictionary
    {
        /**
         * @param dictionaryPage the PLAIN encoded content of the dictionary
         * @throws IOException
         */
        protected PlainValuesDictionary(DictionaryPage dictionaryPage)
            : base(dictionaryPage.getEncoding())
        {
            if (dictionaryPage.getEncoding() != Encoding.PLAIN_DICTIONARY
                && dictionaryPage.getEncoding() != Encoding.PLAIN)
            {
                throw new ParquetDecodingException("Dictionary data encoding type not supported: " + dictionaryPage.getEncoding());
            }
        }

        /**
         * a simple implementation of dictionary for plain encoded binary
         */
        public class PlainBinaryDictionary : PlainValuesDictionary
        {

            private Binary[] binaryDictionaryContent = null;

            /**
             * Decodes {@link Binary} values from a {@link DictionaryPage}.
             *
             * Values are read as length-prefixed values with a 4-byte little-endian
             * length.
             *
             * @param dictionaryPage a {@code DictionaryPage} of encoded binary values
             * @throws IOException
             */
            public PlainBinaryDictionary(DictionaryPage dictionaryPage)
                : this(dictionaryPage, null)
            {
            }

            /**
             * Decodes {@link Binary} values from a {@link DictionaryPage}.
             *
             * If the given {@code length} is null, the values will be read as length-
             * prefixed values with a 4-byte little-endian length. If length is not
             * null, it will be used as the length for all fixed-length {@code Binary}
             * values read from the page.
             *
             * @param dictionaryPage a {@code DictionaryPage} of encoded binary values
             * @param length a fixed length of binary arrays, or null if not fixed
             * @throws IOException
             */
            public PlainBinaryDictionary(DictionaryPage dictionaryPage, int? length)
                : base(dictionaryPage)
            {
                ByteBuffer dictionaryBytes = dictionaryPage.getBytes().toByteBuffer();
                binaryDictionaryContent = new Binary[dictionaryPage.getDictionarySize()];
                // dictionary values are stored in order: size (4 bytes LE) followed by {size} bytes
                int offset = dictionaryBytes.position();
                if (length == null)
                {
                    // dictionary values are stored in order: size (4 bytes LE) followed by {size} bytes
                    for (int i = 0; i < binaryDictionaryContent.Length; i++)
                    {
                        int len = BytesUtils.readIntLittleEndian(dictionaryBytes, offset);
                        // read the length
                        offset += 4;
                        // wrap the content in a binary
                        binaryDictionaryContent[i] = Binary.fromConstantByteBuffer(dictionaryBytes, offset, len);
                        // increment to the next value
                        offset += len;
                    }
                }
                else
                {
                    // dictionary values are stored as fixed-length arrays
                    Preconditions.checkArgument(length > 0,
                        "Invalid byte array length: " + length);
                    for (int i = 0; i < binaryDictionaryContent.Length; i++)
                    {
                        // wrap the content in a Binary
                        binaryDictionaryContent[i] = Binary.fromConstantByteBuffer(
                            dictionaryBytes, offset, length.Value);
                        // increment to the next value
                        offset += length.Value;
                    }
                }
            }

            public override Binary decodeToBinary(int id)
            {
                return binaryDictionaryContent[id];
            }

            public override string ToString()
            {
                StringBuilder sb = new StringBuilder("PlainBinaryDictionary {\n");
                for (int i = 0; i < binaryDictionaryContent.Length; i++)
                {
                    sb.Append(i).Append(" => ").Append(binaryDictionaryContent[i]).Append("\n");
                }
                return sb.Append("}").ToString();
            }

            public override int getMaxId()
            {
                return binaryDictionaryContent.Length - 1;
            }
        }

        /**
         * a simple implementation of dictionary for plain encoded long values
         */
        public class PlainLongDictionary : PlainValuesDictionary
        {

            private long[] longDictionaryContent = null;

            /**
             * @param dictionaryPage
             * @throws IOException
             */
            public PlainLongDictionary(DictionaryPage dictionaryPage)
                : base(dictionaryPage)
            {
                ByteBuffer dictionaryByteBuf = dictionaryPage.getBytes().toByteBuffer();
                longDictionaryContent = new long[dictionaryPage.getDictionarySize()];
                PlainValuesReader.LongPlainValuesReader longReader = new PlainValuesReader.LongPlainValuesReader();
                longReader.initFromPage(dictionaryPage.getDictionarySize(), dictionaryByteBuf, dictionaryByteBuf.position());
                for (int i = 0; i < longDictionaryContent.Length; i++)
                {
                    longDictionaryContent[i] = longReader.readLong();
                }
            }

            public override long decodeToLong(int id)
            {
                return longDictionaryContent[id];
            }

            public override string ToString()
            {
                StringBuilder sb = new StringBuilder("PlainLongDictionary {\n");
                for (int i = 0; i < longDictionaryContent.Length; i++)
                {
                    sb.Append(i).Append(" => ").Append(longDictionaryContent[i]).Append("\n");
                }
                return sb.Append("}").ToString();
            }

            public override int getMaxId()
            {
                return longDictionaryContent.Length - 1;
            }
        }

        /**
         * a simple implementation of dictionary for plain encoded double values
         */
        public class PlainDoubleDictionary : PlainValuesDictionary
        {

            private double[] doubleDictionaryContent = null;

            /**
             * @param dictionaryPage
             * @throws IOException
             */
            public PlainDoubleDictionary(DictionaryPage dictionaryPage)
                : base(dictionaryPage)
            {
                ByteBuffer dictionaryByteBuf = dictionaryPage.getBytes().toByteBuffer();
                doubleDictionaryContent = new double[dictionaryPage.getDictionarySize()];
                PlainValuesReader.DoublePlainValuesReader doubleReader = new PlainValuesReader.DoublePlainValuesReader();
                doubleReader.initFromPage(dictionaryPage.getDictionarySize(), dictionaryByteBuf, 0);
                for (int i = 0; i < doubleDictionaryContent.Length; i++)
                {
                    doubleDictionaryContent[i] = doubleReader.readDouble();
                }
            }

            public override double decodeToDouble(int id)
            {
                return doubleDictionaryContent[id];
            }

            public override string ToString()
            {
                StringBuilder sb = new StringBuilder("PlainDoubleDictionary {\n");
                for (int i = 0; i < doubleDictionaryContent.Length; i++)
                {
                    sb.Append(i).Append(" => ").Append(doubleDictionaryContent[i]).Append("\n");
                }
                return sb.Append("}").ToString();
            }

            public override int getMaxId()
            {
                return doubleDictionaryContent.Length - 1;
            }
        }

        /**
         * a simple implementation of dictionary for plain encoded integer values
         */
        public class PlainIntegerDictionary : PlainValuesDictionary
        {

            private int[] intDictionaryContent = null;

            /**
             * @param dictionaryPage
             * @throws IOException
             */
            public PlainIntegerDictionary(DictionaryPage dictionaryPage)
                : base(dictionaryPage)
            {
                ByteBuffer dictionaryByteBuf = dictionaryPage.getBytes().toByteBuffer();
                intDictionaryContent = new int[dictionaryPage.getDictionarySize()];
                PlainValuesReader.IntegerPlainValuesReader intReader = new PlainValuesReader.IntegerPlainValuesReader();
                intReader.initFromPage(dictionaryPage.getDictionarySize(), dictionaryByteBuf, 0);
                for (int i = 0; i < intDictionaryContent.Length; i++)
                {
                    intDictionaryContent[i] = intReader.readInteger();
                }
            }

            public override int decodeToInt(int id)
            {
                return intDictionaryContent[id];
            }

            public override string ToString()
            {
                StringBuilder sb = new StringBuilder("PlainIntegerDictionary {\n");
                for (int i = 0; i < intDictionaryContent.Length; i++)
                {
                    sb.Append(i).Append(" => ").Append(intDictionaryContent[i]).Append("\n");
                }
                return sb.Append("}").ToString();
            }

            public override int getMaxId()
            {
                return intDictionaryContent.Length - 1;
            }

        }

        /**
         * a simple implementation of dictionary for plain encoded float values
         */
        public class PlainFloatDictionary : PlainValuesDictionary
        {

            private float[] floatDictionaryContent = null;

            /**
             * @param dictionaryPage
             * @throws IOException
             */
            public PlainFloatDictionary(DictionaryPage dictionaryPage)
                : base(dictionaryPage)
            {
                ByteBuffer dictionaryByteBuf = dictionaryPage.getBytes().toByteBuffer();
                floatDictionaryContent = new float[dictionaryPage.getDictionarySize()];
                PlainValuesReader.FloatPlainValuesReader floatReader = new PlainValuesReader.FloatPlainValuesReader();
                floatReader.initFromPage(dictionaryPage.getDictionarySize(), dictionaryByteBuf, dictionaryByteBuf.position());
                for (int i = 0; i < floatDictionaryContent.Length; i++)
                {
                    floatDictionaryContent[i] = floatReader.readFloat();
                }
            }

            public override float decodeToFloat(int id)
            {
                return floatDictionaryContent[id];
            }

            public override string ToString()
            {
                StringBuilder sb = new StringBuilder("PlainFloatDictionary {\n");
                for (int i = 0; i < floatDictionaryContent.Length; i++)
                {
                    sb.Append(i).Append(" => ").Append(floatDictionaryContent[i]).Append("\n");
                }
                return sb.Append("}").ToString();
            }

            public override int getMaxId()
            {
                return floatDictionaryContent.Length - 1;
            }
        }
    }
}


text:
package floobits.common;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import floobits.common.interfaces.IContext;
import floobits.utilities.Flog;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Type;
import java.nio.charset.Charset;
import java.util.HashMap;

public class Settings {
    public static String floorcJsonPath = FilenameUtils.concat(System.getProperty("user.home"), ".floorc.json");

    public static FloorcJson get() throws Exception {
        File f = new File(floorcJsonPath);
        String string;
        try {
            string = FileUtils.readFileToString(f, "UTF-8");
        } catch (IOException e) {
            // Do not change this to a log (and don't change Log.warn) or else you'll get a stack overflow!
            Flog.warn("No floorc.json found");
            return new FloorcJson();
        }
        try {
            return new Gson().fromJson(string, (Type) FloorcJson.class);
        } catch (JsonSyntaxException e) {
            throw new Exception("Invalid JSON.");
        }
    }

    public static void write(IContext context, FloorcJson floorcJson) {
        File file = new File(floorcJsonPath);
        if (!file.exists()) {
            boolean newFile;
            try {
                newFile = file.createNewFile();
            } catch (IOException e) {
                context.errorMessage("Can't write new ~/.floorc.json");
                return;
            }
            if (!newFile) {
                context.errorMessage("Can't write new ~/.floorc.json");
                return;
            }
        }

        try {
            FileUtils.write(file, new GsonBuilder().setPrettyPrinting().create().toJson(floorcJson), Charset.defaultCharset(), false);
        } catch (IOException e) {
            Flog.error(e);
            context.errorMessage("Can't write new ~/.floorc.json");
        }
    }

    public static Boolean isAuthComplete(HashMap<String, String> settings) {
        return (settings.get("secret") != null && (settings.get("username") != null || settings.get("api_key") != null));
    }

    public static Boolean canFloobits() {
        HashMap<String, HashMap<String, String>> auth;
        try {
            auth = get().auth;
        } catch (Throwable e) {
            return false;
        }
        if (auth == null) {
            return false;
        }
        for (String host : auth.keySet()) {
            if (isAuthComplete(auth.get(host))) {
                return true;
            }
        }
        return false;
    }
}