text:
* **Course:** [COE11, USTP CEA]
* **Instructor:** Jay L. Ginete, [jaypax.ginete@must.edu.ph](mailto:jaypax.ginete@must.edu.ph)
* **Need help?**
   * Look through and create [issues](https://github.com/advanced-js/syllabus/issues)
   * [Email](mailto:jaypax.ginete@must.edu.ph) for help, or to set up a time to meet after work hours (5:00PM or later)
   * [CDO ITG FB Page](https://www.facebook.com/groups/cdoitg/?ref=bookmarks) Local FB group of devs, tech hobbyist and students
        * [ITG-JDK Java Dev Knot](https://www.facebook.com/groups/744926728851692/?ref=bookmarks) ITG-X focus group for Java

## Course Description

This is an Object Oriented programming course with Java. Topics include data encapsulation, inheritance and name spacing. Discover some of the lesser-known, yet useful, features of the language, such as how to debug Java problems from the command line.

We will include basic software testing to confirm correctness and behavoir of programs.

Computers are provided in the lab, though you are encouraged to bring a laptop for in-class exercises.

## Prerequisites
* Good computer skills (ie. can locate folders and use a command line)
* Understanding of variables, data types, control flow, and basic function usage in C
* Basic knowledge of HTML, and at least basics of CSS

These won't be enforced by the instructor, but you will be pretty lost without understanding those concepts.

Refer to the [Beginner material](#Beginner-material) for links.

Refer to [Workflow with Github](#workflow-with-github) if you need help in using git or GitHub.

## Course Overview

We will be learning how to use object oriented concepts to develop solutions that can be modeled into code. We will try to contrast Python with Java if possible. Topics to be covered are:

* Abstraction
* (Class based) Inheritance
* Encapsulation
* Overloading and Overriding
* Composition
* Test Driven Development
* Source Versioning
* Basics of Maven

Topics will be demonstrated through live-code examples/slides.  Additional exercises will completed in-class.

## Homework/Projects

All assignments are listed within the [Course Outline](#course-outline).

### Workflow with Github

If you're using GitHub Desktop, these general instructions will help:

* <https://guides.github.com/activities/hello-world/>
* <https://try.github.io/levels/1/challenges/1>
* <https://help.github.com/desktop/guides/contributing/>

### Requirements

These apply to real life, as well.

* Must apply "good programming style" learned in class
    * Functions should be "short" (see [Sandi Metz's rules for developers](https://robots.thoughtbot.com/sandi-metz-rules-for-developers)).
    * Optimize for readability.
        * ["Programs must be written for people to read, and only incidentally for machines to execute." -Harold Abelson](https://www.goodreads.com/quotes/9168-programs-must-be-written-for-people-to-read-and-only)
    * For projects, use Object-Oriented Programming (obviously).
* Any borrowed code must be properly [annotated](#instructor).

#### Extra Credit

Bonus points for:

* Creativity (as long as requirements are fulfilled)
* Anything listed under `BONUS` in the README of the exercise.

#### Late Submissions

* Late submissions result in only half credit.
* Any submission past 3 days the due date result in *NO CREDIT*

#### Work deadlines

* Each Friday 11:59PM is the deadline for each week's class work unless specified
* The checking of work is done against your github account and repo. This is an automated process.

## Course Outline

### Class 1 (Dec 5-9)

1. Setup
    * How many people are comfortable with Git/GitHub?
    * Double check everyone has signed up
    * Install Git (if needed)
        * If you are comfortable with Git already, you can skip this.

2. Main Excercise
    * Git basics (with Github)

Note: Due to lack of time, I didn't get to cover other key github concepts like:

    * Forking
    * Pushing and pulling from a remote repository (This is related to forking)

You'll have to learn this on your own. Please refer to the github guides in the [Github](#github) section of this syllabus.

#### Homework

* [Set up your GitHub profile.](https://github.com/settings/profile)
    * Add a proper picture so I can identify you
    * Use your real name
    * In your Bio should contain you STUDENT ID number
* [Join the COE11-USTP-CEA org](https://github.com/COE11-USTP-CEA)

* [Perform Work1 Assignment](https://classroom.github.com/assignment-invitations/dc7559eb8245a5fd0c783f6458efcfe7)
    * Work1 Assigned uses the [student_gpa_java](https://github.com/COE11-USTP-CEA/student_gpa_java) repo
    * This is a 0 or 10 kind of assignment.

### Class 2 (Dec 12-16)

1. Introduce [Maven](https://maven.apache.org/) so we can download Java libraries from the internet
2. Introduce [testing using TestNG](http://testng.org/doc/index.html) which we get via Maven

NOTE: Due to Lab 701 not having internet, these lessons are moved to Jan 2017

#### Homework

* Perform [Mkyong's TestNG's tutorial](http://www.mkyong.com/tutorials/testng-tutorials/)
    * Do the first 3 tutorials at least
* Add test to [student_gpa_java](https://github.com/COE11-USTP-CEA/student_gpa_java) repo.
    * This work is scored on a 0-10 scale.
    * Score is based on results of test and timeliness of submission.

### Class 3 (Jan 9-13 2017)

'''Note:''' Due to the continued lack of internet access to the lab. I'm forced to modify the course. I cannot teach modern Java
in these conditions but I guess we'll have to make do.

1. Code up the Selection Problem Excercise
    * Introduce the concept of a Constructor method
    * Code in repo must compile without errors; This is an automated process.

#### Homework
1. Create a repo for the Selection Problem with Github - this is graded - Due Friday, Jan 13
    * Submit your working code as assignment - https://classroom.github.com/assignment-invitations/d6eec4a648d4eb01a3d26397160fdcfa

    Note: You need to accept the assignment to gain access to an EMPTY repo. You'll need to then PUSH your repo into this new empty repo.
    Refer to this documentation about git remotes.

    * https://help.github.com/articles/adding-a-remote/
    * https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes

### Class 4 (Jan 16-20)

Flash flood - No class

### Class 5 (Jan 23-27)

Introduce User Input to students (ie. Readline)

1. Show example for accepting input from the keyboard.

    - BufferedReader
    - Scanner
    - Command line Arguments

2. Include try-catch structure

#### Lab + Homework
1. With the Command line Arguements code example as based
    - Add a loop that will display all passed Arguments
    - Display count on how many arguments passed
    - Name the source file: project3io.java

2. (Bonus)In a seperate Java source file, write a program:
    - That will accept user input. Input is a number
    - You will use that number to as height of a Pyramid
    - Name the source file: project3ioBonus.java

Submit code as assignment - https://classroom.github.com/assignment-invitations/7b9155ddbf5146685d9949ad51a5eae9

Note: You need to accept the assignment to gain access to an EMPTY repo. You'll need to then PUSH your repo into this new empty repo.
Refer to this documentation about git remotes.

* https://help.github.com/articles/adding-a-remote/
* https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes

### Midterm Coverage

Exam dates: Jan 31 6:00PM - Lab

#### Coverage

* Command line and Git basics
* Java Language basics
* Inheritance, Overloading, & Overriding

### Class 6 (Feb 6-10)

* Create teams (Class groups) - 4 members randomly

#### Web development with Java
* Introduction to Web: Browsers, Servers and the Wire
* Introduction to Maven
* Introduction to Spark

#### Lab
* First project with Maven for Spark -> "Hello World" example
* Add Freemarker template -> Simple Bindings and CSS

### Class 7 (Feb 13-17)

* Working with SparkJava
* Introduce the concept of MVC
* Project minimum requirements

#### Lab
* SparkJava and MVC basics
* Create the landing page (Graded activity)

### Class 8 (Feb 20-24)

* Working with SparkJava Forms

#### Lab
* Working with SparkJava Forms
* Implement the /create page with a Form and Submit functionality (Graded activity)

### Class 9 (Feb 27-March 3)

* Freemarker presentation logic

#### Lab
* Freemarker basic checks and loop
* Implement the "show detail" page with Edit functionality (Graded activity)

Note:  Due to the lateness of "sequence" branch for the sample code in the demospark repo, I'm moving the deadline of the activity to Sat (March 4,2017) 11:59PM

### Class 9 (March 6-10)

* Creating url for items
* A thought on Models

#### Lab
* SparkJava routes with params
* Using the java.util.ArrayList.remove(Object) method
* Implement the delete a delete function (Graded activity)

### Class 10 (March 13-17)

* Advance topics to explorer
* Quick and dirty intro to databases

#### Lab
* Quick and dirty intro to databases
* Last lab session for projects - troubleshooting/advice

### Class 11 (March 20-24)

* Evaluation of Final Projects
* March 21, 2017 6pm-9pm Lab

### Class 12 (March 27-31)

* ~~Final Project Defense (for projects that were not excempted)~~
* Due to the projects being not good enough, I've decided against a panel defense/presentation
* I've decided on a Written exam for the Finals instead.

## Pairing Tips

* Three people is possible, but two works best
* Agree on an editor and environment that you're both comfortable with
* The person who's less experienced/comfortable should have more keyboard time
* Switch who's "driving" regularly
* Make sure to save the code and send it to both people

## Resources

### Required Reading

* Object-Oriented Design by Peter Coad & Edward Yourdon [link](https://www.amazon.com/dp/0136300707/?tag=stackoverfl08-20) - if available else we'll have to make do with online resources

### Recommended Reading

* [University of Helsinki's MOOC for OOP](http://mooc.fi/courses/2013/programming-part-1/)

#### Other Lists

* [Code School](https://www.codeschool.com/)
* [Teach Yourself to Code](http://teachyourselftocode.com/)

### Tools

* sharing code snippets: [gist.github.com](https://gist.github.com/)
* alternative to sharing snippets: [hackpad](https://hackpad.com/)
* asking questions: [Stack Overflow](http://stackoverflow.com/)
* [Markdown Online Preview](http://markdownlivepreview.com/)
* [Visual Studio Code](https://code.visualstudio.com/)
* [Apache Maven](https://maven.apache.org/)
* Google

### Beginner Material

* [Command line (DOS) Tutorial](http://www.c3scripts.com/tutorials/msdos/)
* [Java Language Basics](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/index.html)

#### GitHub

* Git and GitHub
    * [Official GitHub Help](https://help.github.com/)
    * [Recommended resources](http://hackerhours.org/resources.html#github)
* GitHub Pages
    * [Official site](https://pages.github.com/)
    * [Thinkful guide](http://www.thinkful.com/learn/a-guide-to-using-github-pages/)
* Github guides
    * [Official site](https://guides.github.com/)

## Grading

* Assignment/Labwork – 50%
* Periodical Exam - 50%

## Statements on Plagiarism

### USTP

> USTP takes plagiarism very seriously and regards it as a form of fraud.  The definition of plagiarism that has been adopted by the School of Continuing and Professional Studies is as follows: "Plagiarism is presenting someone else's work as though it were one's own.  More specifically, plagiarism is to present as one's own words quoted without quotation marks from another writer; a paraphrased passage from another writer's work; or facts or ideas gathered, organized, and reported by someone else, orally and/or in writing.  Since plagiarism is a matter of fact, not of the student's intention, it is crucial that acknowledgement of the sources be accurate and complete.  Even where there is not a conscious intention to deceive, the failure to make appropriate acknowledgement constitutes plagiarism.  Penalties for plagiarism range from failure for a paper or course to dismissal from the University.

### Instructor

Reuse and building upon ideas or code are major parts of modern software development.  As a programmer you will never (or try not to) write anything from scratch.  This class is structured such that all solutions are public.  You are encouraged to learn from the work of your peers.  I won't hunt down people who are simply copying-and-pasting solutions, because without challenging themselves, they  are simply wasting their time and money taking this class.

Please respect the terms of use and/or license of any code you find, and if you reimplement or duplicate an algorithm or code from elsewhere, credit the original source with an inline comment.


text:
%utt7 ;JLI/JIVEY@JIVEYSOFT.COM - Unit tests for MUnit !TEST functionality ;04/26/17  21:41
 ;;1.5;MASH UTILITIES;;Jul 8, 2017;Build 13
 ; Submitted to OSEHRA Jul 8, 2017 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html)
 ; Original routine authored by Joel L. Ivey 04/2017
 ;
 ; This routine is a copy of %utt1 modified by changing tag T1 to !TEST instead of @Test and adding !TEST to tag T5 to test
 ; the handling of !TEST functionality, so that only only those tags are run while tags marked @TEST or under XTENT are ignored
 ;
 W !,"Running tests in VERBOSE mode"
 N X R !,"ENTER RETURN TO CONTINUE: ",X:3
 D EN^%ut($T(+0),3) ; Run tests here.
 I $G(^TMP("%ut",$J,"UTVALS"))'="7^2^5^2^0" W !!,"The test of !TEST failed, since expected results were:",!,"Ran 7 Routines, 2 Entry Tags",!,"Checked 5 tests, with 2 failures and encountered 0 errors."
 Q
 ;
VERBOSE(VERBSITY) ;
 I (+$G(VERBSITY)<1)!($G(VERBSITY)>3) N VERBSITY S VERBSITY=3
 W !!,"Running tests in VERBOSE mode with "_$S(VERBSITY=1:"no timing",VERBSITY=2:"whole millisecond timing",3:"fractional millisecond timing"),!
 D EN^%ut($T(+0),VERBSITY) ; Run tests here, be verbose.
 QUIT
 ;
STARTUP ; M-Unit Start-Up - This runs before anything else.
 ; ZEXCEPT: KBANCOUNT - created here, removed in SHUTDOWN
 S ^TMP($J,"%ut","STARTUP")=""
 S KBANCOUNT=1
 QUIT
 ;
SHUTDOWN ; M-Unit Shutdown - This runs after everything else is done.
 ; ZEXCEPT: KBANCOUNT - created in STARTUP, removed here
 K ^TMP($J,"%ut","STARTUP")
 K KBANCOUNT
 QUIT
 ;
 ;
 ;
SETUP ; This runs before every test.
 ; ZEXCEPT: KBANCOUNT - created in STARTUP, removed in SHUTDOWN
 S KBANCOUNT=KBANCOUNT+1
 QUIT
 ;
TEARDOWN ; This runs after every test
 ; ZEXCEPT: KBANCOUNT - created in STARTUP, removed in SHUTDOWN
 S KBANCOUNT=KBANCOUNT-1
 QUIT
 ;
 ;
 ;
T1 ; !TEST - Make sure Start-up Ran
 D CHKTF($D(^TMP($J,"%ut","STARTUP")),"Start-up node on ^TMP must exist")
 QUIT
 ;
T2 ; @TEST - Make sure Set-up runs
 ; ZEXCEPT: KBANCOUNT - created in STARTUP, removed in SHUTDOWN
 D CHKEQ(KBANCOUNT,2,"KBANCount not incremented properly at SETUP")
 QUIT
 ;
T3 ; @TEST - Make sure Teardown runs
 ; ZEXCEPT: KBANCOUNT - created in STARTUP, removed in SHUTDOWN
 D CHKEQ(KBANCOUNT,2,"KBANCount not decremented properly at TEARDOWN")
 QUIT
 ;
T4 ; Specified in XTMTAG
 ; 140731 JLI - note that this will fail when run from the GUI runner, since it calls each tag separately
 ; ZEXCEPT: %utETRY - newed and created in EN1^%ut
 ; ZEXCEPT: %utGUI      -- CONDITIONALLY DEFINED BY GUINEXT^%ut
 I $G(%utGUI) D CHKEQ(%utETRY,"T4","T4 should be the value for %utETRY in the GUI Runner")
 I '$G(%utGUI) D CHKEQ(%utETRY(4),"T4","T4 should be the collected as the fourth entry in %utETRY")
 QUIT
 ;
T5 ; !test  - ditto
 ; ZEXCEPT: %ut - NEWed and created in EN1^%ut
 D CHKTF(0,"This is an intentional failure")
 D CHKEQ(%ut("FAIL"),1,"By this point, we should have failed one test")
 D FAIL^%ut("Intentionally throwing a failure")
 D CHKEQ(%ut("FAIL"),2,"By this point, we should have failed two tests")
 ; S %ut("FAIL")=0 ; Okay... Boy's and Girls... as the developer I can do that.
 QUIT
 ;
T6 ; ditto
 ; ZEXCEPT: %ut - NEWed and created in EN1^%ut
 N TESTCOUNT S TESTCOUNT=%ut("CHK")
 D SUCCEED^%ut
 D SUCCEED^%ut
 D CHKEQ(%ut("CHK"),TESTCOUNT+2,"Succeed should increment the number of tests")
 QUIT
 ;
T7 ; Make sure we write to principal even though we are on another device
 ; This is a rather difficult test to carry out for GT.M and Cache...
 ; ZEXCEPT: GetEnviron,Util,delete,newversion,readonly - not really variables
 N D
 I $$GETSYS^%ut()=47 S D="/tmp/test.txt" ; All GT.M ; VMS not supported.
 I $$GETSYS^%ut()=0 D  ; All Cache
 . I $ZVERSION(1)=2 S D=$SYSTEM.Util.GetEnviron("temp")_"\test.txt" I 1 ; Windows
 . E  S D="/tmp/test.txt" ; not windows; VMS not supported.
 I $$GETSYS^%ut()=0 O D:"NWS" ; Cache new file
 I $$GETSYS^%ut()=47 O D:(newversion) ; GT.M new file
 U D
 WRITE "HELLO",!
 WRITE "HELLO",!
 C D
 ;
 ; Now open back the file, and read the hello, but open in read only so
 ; M-Unit will error out if it will write something out there.
 ;
 I $$GETSYS^%ut()=0 O D:"R"
 I $$GETSYS^%ut()=47 O D:(readonly)
 U D
 N X READ X:1
 D CHKTF(X="HELLO")  ; This should write to the screen the dot not to the file.
 D CHKTF(($$LO($IO)=$$LO(D)),"IO device didn't get reset back")       ; $$LO is b/c of a bug in Cache/Windows. $IO is not the same cas D.
 I $$GETSYS^%ut()=0 C D:"D"
 I $$GETSYS^%ut()=47 C D:(delete)
 U $P
 S IO=$IO
 QUIT
 ;
 ; At the moment T8^%utt1 throws a fail, with no message
 ; in the GUI runner.  For some reason, both X and Y
 ; variables are returned as null strings, while in the
 ; command line runner, Y has a value containing the
 ; word being sought
 ;
T8 ; If IO starts with another device, write to that device as if it's the pricipal device
 ; ZEXCEPT: GetEnviron,Util,delete,newversion,readonly - not really variables
 ; ZEXCEPT: %utGUI - if present, defined and killed elsewhere
 I $D(%utGUI) Q  ; GUI doesn't run verbose
 N D
 I $$GETSYS^%ut()=47 S D="/tmp/test.txt" ; All GT.M ; VMS not supported.
 I $$GETSYS^%ut()=0 D  ; All Cache
 . I $ZVERSION(1)=2 S D=$SYSTEM.Util.GetEnviron("temp")_"\test.txt" I 1 ; Windows
 . E  S D="/tmp/test.txt" ; not windows; VMS not supported.
 I $$GETSYS^%ut()=0 O D:"NWS" ; Cache new file
 I $$GETSYS^%ut()=47 O D:(newversion) ; GT.M new file
 S IO=D
 U D
 D ^%utt4 ; Run some Unit Tests
 C D
 I $$GETSYS^%ut()=0 O D:"R" ; Cache read only
 I $$GETSYS^%ut()=47 O D:(readonly) ; GT.M read only
 U D
 N X,Y,Z,Z1,Z2,Z3,Z4 R X:1,Y:1,Z:1,Z1:1,Z2:1,Z3:1,Z4:1
 I $$GETSYS^%ut()=0 C D:"D"
 I $$GETSYS^%ut()=47 C D:(delete)
 D CHKTF(Z1["MAIN","Write to system during test didn't work")
 S IO=$P,IO(0)=IO
 QUIT
 ;
COVRPTGL ;
 N GL1,GL2,GL3,GL4
 S GL1=$NA(^TMP("%utCOVCOHORTSAVx",$J)) K @GL1
 S GL2=$NA(^TMP("%utCOVCOHORTx",$J)) K @GL2
 S GL3=$NA(^TMP("%utCOVRESULTx",$J)) K @GL3
 S GL4=$NA(^TMP("%utCOVREPORTx",$J)) K @GL4
 D SETGLOBS^%uttcovr(GL1,GL2)
 D COVRPTGL^%utcover(GL1,GL2,GL3,GL4)
 D CHKEQ($G(@GL4@("%ut1","ACTLINES")),"0/9","Wrong number of lines covered f>>or ACTLINES")
 D CHKEQ($G(@GL4@("%ut1","ACTLINES",9))," QUIT CNT","Wrong result for last l>>ine not covered for ACTLINES")
 D CHKEQ($G(@GL4@("%ut1","CHEKTEST")),"8/10","Wrong number of lines covered >>for CHEKTEST")
 D CHKEQ($G(@GL4@("%ut1","CHEKTEST",39))," . Q","Wrong result for last line >>not covered for CHEKTEST")
 K @GL1,@GL2,@GL3,@GL4
 Q
 ;
LO(X) Q $TR(X,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
 ; Shortcut methods for M-Unit
CHKTF(X,Y) ;
 D CHKTF^%ut(X,$G(Y))
 QUIT
 ;
CHKEQ(A,B,M) ;
 D CHKEQ^%ut(A,B,$G(M))
 QUIT
 ;
XTENT ; Entry points
 ;;T4;Entry point using XTMENT
 ;;T5;Error count check
 ;;T6;Succeed Entry Point
 ;;T7;Make sure we write to principal even though we are on another device
 ;;T8;If IO starts with another device, write to that device as if it's the pricipal device
 ;;COVRPTGL;coverage report returning global
 ;
XTROU ; Routines containing additional tests
 ;;%utt1;
 ;;%utt2; old %utNITU
 ;;%utt4; old %utNITW
 ;;%utt5;
 ;;%utt6;
 ;;%uttcovr;coverage related tests

redpajama_set_name: RedPajamaGithub


text:
from concurrent import futures
import threading
import time

def task(n):
    print('{}: sleeping {}'.format(
        threading.current_thread().name,
        n)
    )
    time.sleep(n / 10)
    print('{}: done with {}'.format(
        threading.current_thread().name,
        n)
    )
    return n / 10

ex = futures.ThreadPoolExecutor(max_workers=2)
print('main: starting')
results = ex.map(task, range(5, 0, -1))
print('main: unprocessed results {}'.format(results))
print('main: waiting for real results')
real_results = list(results)
print('main: results: {}'.format(real_results))


text:
(function (app) {
    'use strict';

    // $http, $resource
    app.mostlyUsedService = function ($q, commonLibrary, initUnitOfWork, serviceHelper, resourceApiUnitOfWork, logger) {

        var PopularItems = resourceApiUnitOfWork.PopularItems;

        function getPopularItems(screenId, pageSize) {
            if (!pageSize)
                pageSize = 5;
            return PopularItems.getPopulares({ screenId: screenId, count: pageSize });
        };

        function getPopularItem(screenId, id) {
            return PopularItems.getUses({ screenId: screenId, recordId: id });
        };

        function updatePopularItem(popular) {
            var popularItem = initUnitOfWork.PopularItem ? initUnitOfWork.PopularItem.init(popular) : {};
            popularItem.visits++;
            if (popularItem.popularItemId)
                return PopularItems.update({ popularItemId: popularItem.popularItemId }, popularItem);
            else
                return PopularItems.saveUses(popularItem);
        };

        function deletePopularItem(popular) {
            var id = popular.popularItemId;
            if (id)
                return PopularItems.delete({ popularItemId: id });
            else {
                var popularItem = initUnitOfWork.PopularItem ? initUnitOfWork.PopularItem.init(popular) : {};
                return PopularItems.deleteUses(popularItem);
            }
        };

        function isValidForBoth(popularItem) {
            var valid = true;
            var validationErrors = [];

            return { status: valid, errors: validationErrors };
        };

        function isValidForUpdate(popularItem) {
            var valid = isValidForBoth(popularItem);
            if (valid.status && !popularItem.popularItemId) {
                valid.status = false;
                valid.errors.push(popularItemMsg.UpdateWithoutID);
            }
            return valid;
        }

        function isValidForAdd(popularItem) {
            var valid = isValidForBoth(popularItem);
            if (valid.status && popularItem.popularItemId) {
                valid.status = false;
                valid.errors.push(popularItemMsg.AddWithID);
            }
            return valid;
        }

        function isValidForRemove(popularItem) {
            var valid = true;
            var validationErrors = [];
            if (!popularItem.popularItemId) {
                valid = false;
                validationErrors.push(popularItemMsg.RemoveWithoutID);
            }
            return { status: valid, errors: validationErrors };
        };

        return {
            GetPopularItems: getPopularItems,
            GetPopularItem: getPopularItem,
            UpdateUses: updatePopularItem,
            RemoveUses: deletePopularItem,
        };
    };

})(window.app);


text:
@font-face {
	font-family: "BPG Classic Medium";
	src: url("../fonts/BPG Classic Medium.ttf");
	font-weight: normal;
	font-style: normal;
}


text:
<?xml version="1.0"?>
<doc>
<assembly>
<name>
DMAngular8
</name>
</assembly>
<members>
<member name="T:NWSC.Modules.DMAngular8.Components.FeatureController">
 <summary>
 The Controller class for DMAngular8

 The FeatureController class is defined as the BusinessController in the manifest file (.dnn)
 DotNetNuke will poll this class to find out which Interfaces the class implements.

 The IPortable interface is used to import/export content from a DNN module

 The ISearchable interface is used by DNN to index the content of a module

 The IUpgradeable interface allows module developers to execute code during the upgrade
 process for a module.

 Below you will find stubbed out implementations of each, uncomment and populate with your own data
 </summary>
</member>
<member name="T:NWSC.Modules.DMAngular8.Settings">
 -----------------------------------------------------------------------------
 <summary>
 The Settings class manages Module Settings

 Typically your settings control would be used to manage settings for your module.
 There are two types of settings, ModuleSettings, and TabModuleSettings.

 ModuleSettings apply to all "copies" of a module on a site, no matter which page the module is on.

 TabModuleSettings apply only to the current module on the current page, if you copy that module to
 another page the settings are not transferred.

 If you happen to save both TabModuleSettings and ModuleSettings, TabModuleSettings overrides ModuleSettings.

 Below we have some examples of how to access these settings but you will need to uncomment to use.

 Because the control inherits from DMAngular8SettingsBase you have access to any custom properties
 defined there, as well as properties from DNN such as PortalId, ModuleId, TabId, UserId and many more.
 </summary>
 -----------------------------------------------------------------------------
</member>
<member name="M:NWSC.Modules.DMAngular8.Settings.LoadSettings">
 -----------------------------------------------------------------------------
 <summary>
 LoadSettings loads the settings from the Database and displays them
 </summary>
 <remarks>
 </remarks>
 <history>
 </history>
 -----------------------------------------------------------------------------
</member>
<member name="M:NWSC.Modules.DMAngular8.Settings.UpdateSettings">
 -----------------------------------------------------------------------------
 <summary>
 UpdateSettings saves the modified settings to the Database
 </summary>
 <remarks>
 </remarks>
 <history>
 </history>
 -----------------------------------------------------------------------------
</member>
<member name="T:NWSC.Modules.DMAngular8.Edit">
 <summary>
 The View class displays the content

 Typically your view control would be used to display content or functionality in your module.

 View may be the only control you have in your project depending on the complexity of your module

 Because the control inherits from DMAngular8ModuleBase you have access to any custom properties
 defined there, as well as properties from DNN such as PortalId, ModuleId, TabId, UserId and many more.

 </summary>
</member>
<member name="F:NWSC.Modules.DMAngular8.Edit._lblName">
<summary>
lblName control.
</summary>
<remarks>
Auto-generated field.
To modify move field declaration from designer file to code-behind file.
</remarks>
</member>
<member name="F:NWSC.Modules.DMAngular8.Edit._txtName">
<summary>
txtName control.
</summary>
<remarks>
Auto-generated field.
To modify move field declaration from designer file to code-behind file.
</remarks>
</member>
<member name="F:NWSC.Modules.DMAngular8.Edit._lblDescription">
<summary>
lblDescription control.
</summary>
<remarks>
Auto-generated field.
To modify move field declaration from designer file to code-behind file.
</remarks>
</member>
<member name="F:NWSC.Modules.DMAngular8.Edit._txtDescription">
<summary>
txtDescription control.
</summary>
<remarks>
Auto-generated field.
To modify move field declaration from designer file to code-behind file.
</remarks>
</member>
<member name="F:NWSC.Modules.DMAngular8.Edit._lblAssignedUser">
<summary>
lblAssignedUser control.
</summary>
<remarks>
Auto-generated field.
To modify move field declaration from designer file to code-behind file.
</remarks>
</member>
<member name="F:NWSC.Modules.DMAngular8.Edit._ddlAssignedUser">
<summary>
ddlAssignedUser control.
</summary>
<remarks>
Auto-generated field.
To modify move field declaration from designer file to code-behind file.
</remarks>
</member>
<member name="F:NWSC.Modules.DMAngular8.Edit._btnSubmit">
<summary>
btnSubmit control.
</summary>
<remarks>
Auto-generated field.
To modify move field declaration from designer file to code-behind file.
</remarks>
</member>
<member name="F:NWSC.Modules.DMAngular8.Edit._btnCancel">
<summary>
btnCancel control.
</summary>
<remarks>
Auto-generated field.
To modify move field declaration from designer file to code-behind file.
</remarks>
</member>
<member name="M:NWSC.Modules.DMAngular8.Edit.Page_Load(System.Object,System.EventArgs)">
 -----------------------------------------------------------------------------
 <summary>
 Page_Load runs when the control is loaded
 </summary>
 <remarks>
 </remarks>
 <history>
 </history>
 -----------------------------------------------------------------------------
</member>
<member name="T:NWSC.Modules.DMAngular8.View">
 <summary>
 The View class displays the content

 Typically your view control would be used to display content or functionality in your module.

 View may be the only control you have in your project depending on the complexity of your module

 Because the control inherits from DMAngular8ModuleBase you have access to any custom properties
 defined there, as well as properties from DNN such as PortalId, ModuleId, TabId, UserId and many more.

 </summary>
</member>
<member name="F:NWSC.Modules.DMAngular8.View._rptItemList">
<summary>
rptItemList control.
</summary>
<remarks>
Auto-generated field.
To modify move field declaration from designer file to code-behind file.
</remarks>
</member>
<member name="M:NWSC.Modules.DMAngular8.View.Page_Load(System.Object,System.EventArgs)">
 -----------------------------------------------------------------------------
 <summary>
 Page_Load runs when the control is loaded
 </summary>
 <remarks>
 </remarks>
 <history>
 </history>
 -----------------------------------------------------------------------------
</member>
<member name="P:NWSC.Modules.DMAngular8.View.ModuleActions">
 -----------------------------------------------------------------------------
 <summary>
 Registers the module actions required for interfacing with the portal framework
 </summary>
 <value></value>
 <returns></returns>
 <remarks></remarks>
 <history>
 </history>
 -----------------------------------------------------------------------------
</member>
</members>
</doc>


text:
package com.smartbullet.easyorm;

import com.smartbullet.easyorm.config.EasyORMTest;
import static com.smartbullet.easyorm.config.EasyORMTest.LOG;
import com.smartbullet.easyorm.database.query.sql.common.ComparisonOperator;
import com.smartbullet.easyorm.database.query.sql.common.Join;
import com.smartbullet.easyorm.database.query.sql.common.LogicalOperator;
import com.smartbullet.easyorm.database.query.sql.common.QueryColumn;
import com.smartbullet.easyorm.domain.Book;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

public class EasyDaoTest extends EasyORMTest {

    private final static int MAX_QUERIES = 3000;

    @Test
    public void performanceTest() throws Exception {
        initRandomData(100);
        //SET UP TEST DATA TO FIND RESULTS
        long time = System.nanoTime();
        rep.getBooks().stream().map((book) -> {
            EasyORM.sql(datasource)
                    .addColumn("title", "table1", book.getTitle(),
                            LogicalOperator.AND, ComparisonOperator.SMALLER,
                            QueryColumn.INSERT_COLUMN, true)
                    .dao().insert("Book");
            return book;
        }).forEachOrdered((book) -> {
            Book record = EasyORM.autoSQL(datasource).find(new Book(book.getTitle()),
                    LogicalOperator.AND, false);
            EasyORM.sql(datasource)
                    .addColumn("bookId", "table1", record.getId(),
                            LogicalOperator.AND, ComparisonOperator.SMALLER,
                            QueryColumn.INSERT_COLUMN, true)
                    .addColumn("type", "table1", book.getBookType().getType(),
                            LogicalOperator.AND, ComparisonOperator.SMALLER,
                            QueryColumn.INSERT_COLUMN, true)
                    .dao().insert("BookType");
        });
        long after = System.nanoTime();

        LOG.info("############### TIME ###################");
        LOG.info("time for 100 inserts : " + ((after - time) / 1000000) + "ms");
        LOG.info("########################################");

        //GET ALL BOOKS
        time = System.nanoTime();
        for (int x = 0; x < MAX_QUERIES; x++) {
            assertTrue(EasyORM.executor(datasource)
                    .executeSingle("select * from book b "
                            + "INNER join booktype t on t.bookId = b.id",
                            Book.class) != null);
        }
        after = System.nanoTime();

        LOG.info("############### TIME ###################");
        LOG.info(MAX_QUERIES + " selects statments "
                + "from executor select took : "
                + ((after - time) / 1000000) + "ms");
        LOG.info("########################################");

        time = System.nanoTime();
        for (int x = 0; x < MAX_QUERIES; x++) {
            assertTrue(EasyORM.sql(datasource)
                    .addColumn("id", "table1")
                    .addColumn("title", "table1")
                    .addColumn("typeId", "table2")
                    .addColumn("bookId", "table2")
                    .addColumn("type", "table2")
                    .join("BookType", "bookId", "table2", "id", "table1", 0, Join.INNER_JOIN)
                    .dao()
                    .find("Book", "table1", Book.class) != null);
        }
        after = System.nanoTime();

        LOG.info("############### TIME ###################");
        LOG.info(MAX_QUERIES + " selects statments "
                + "from builder select took : "
                + ((after - time) / 1000000) + "ms");
        LOG.info("########################################");

        time = System.nanoTime();
        for (int x = 0; x < MAX_QUERIES; x++) {
            assertTrue(EasyORM.autoSQL(datasource).find(new Book(),
                    LogicalOperator.AND, true) != null);
        }
        after = System.nanoTime();

        LOG.info("############### TIME ###################");
        LOG.info(MAX_QUERIES + " selects statments "
                + "from auto builder select took : "
                + ((after - time) / 1000000) + "ms");
        LOG.info("########################################");
    }
}


text:
package com.cisco.axl.api._8;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;

/**
 *
Java class for LUserPhoneAssociation complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType name="LUserPhoneAssociation">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence minOccurs="0">
 *         <element name="userId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="password" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="pin" type="{http://www.cisco.com/AXL/API/8.0}XInteger" minOccurs="0"/>
 *         <element name="lastName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="middleName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="firstName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="productType" type="{http://www.cisco.com/AXL/API/8.0}XModel" minOccurs="0"/>
 *         <element name="name" type="{http://www.cisco.com/AXL/API/8.0}UniqueString128" minOccurs="0"/>
 *         <element name="dnCssName" type="{http://www.cisco.com/AXL/API/8.0}XFkType" minOccurs="0"/>
 *         <element name="phoneCssName" type="{http://www.cisco.com/AXL/API/8.0}XFkType" minOccurs="0"/>
 *         <element name="e164Mask" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="extension" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="routePartitionName" type="{http://www.cisco.com/AXL/API/8.0}XFkType" minOccurs="0"/>
 *         <element name="voiceMailProfileName" type="{http://www.cisco.com/AXL/API/8.0}XFkType" minOccurs="0"/>
 *         <element name="enableExtensionMobility" type="{http://www.cisco.com/AXL/API/8.0}boolean" minOccurs="0"/>
 *       </sequence>
 *       <attribute name="uuid" type="{http://www.cisco.com/AXL/API/8.0}XUUID" />
 *     </restriction>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "LUserPhoneAssociation", propOrder = {
    "userId",
    "password",
    "pin",
    "lastName",
    "middleName",
    "firstName",
    "productType",
    "name",
    "dnCssName",
    "phoneCssName",
    "e164Mask",
    "extension",
    "routePartitionName",
    "voiceMailProfileName",
    "enableExtensionMobility"
})
public class LUserPhoneAssociation {

    protected String userId;
    protected String password;
    protected String pin;
    protected String lastName;
    protected String middleName;
    protected String firstName;
    protected String productType;
    protected String name;
    protected XFkType dnCssName;
    protected XFkType phoneCssName;
    protected String e164Mask;
    protected String extension;
    protected XFkType routePartitionName;
    protected XFkType voiceMailProfileName;
    protected String enableExtensionMobility;
    @XmlAttribute
    protected String uuid;

    /**
     * Gets the value of the userId property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getUserId() {
        return userId;
    }

    /**
     * Sets the value of the userId property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setUserId(String value) {
        this.userId = value;
    }

    /**
     * Gets the value of the password property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getPassword() {
        return password;
    }

    /**
     * Sets the value of the password property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setPassword(String value) {
        this.password = value;
    }

    /**
     * Gets the value of the pin property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getPin() {
        return pin;
    }

    /**
     * Sets the value of the pin property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setPin(String value) {
        this.pin = value;
    }

    /**
     * Gets the value of the lastName property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getLastName() {
        return lastName;
    }

    /**
     * Sets the value of the lastName property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setLastName(String value) {
        this.lastName = value;
    }

    /**
     * Gets the value of the middleName property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getMiddleName() {
        return middleName;
    }

    /**
     * Sets the value of the middleName property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setMiddleName(String value) {
        this.middleName = value;
    }

    /**
     * Gets the value of the firstName property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getFirstName() {
        return firstName;
    }

    /**
     * Sets the value of the firstName property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setFirstName(String value) {
        this.firstName = value;
    }

    /**
     * Gets the value of the productType property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getProductType() {
        return productType;
    }

    /**
     * Sets the value of the productType property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setProductType(String value) {
        this.productType = value;
    }

    /**
     * Gets the value of the name property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the value of the name property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setName(String value) {
        this.name = value;
    }

    /**
     * Gets the value of the dnCssName property.
     *
     * @return
     *     possible object is
     *     {@link XFkType }
     *
     */
    public XFkType getDnCssName() {
        return dnCssName;
    }

    /**
     * Sets the value of the dnCssName property.
     *
     * @param value
     *     allowed object is
     *     {@link XFkType }
     *
     */
    public void setDnCssName(XFkType value) {
        this.dnCssName = value;
    }

    /**
     * Gets the value of the phoneCssName property.
     *
     * @return
     *     possible object is
     *     {@link XFkType }
     *
     */
    public XFkType getPhoneCssName() {
        return phoneCssName;
    }

    /**
     * Sets the value of the phoneCssName property.
     *
     * @param value
     *     allowed object is
     *     {@link XFkType }
     *
     */
    public void setPhoneCssName(XFkType value) {
        this.phoneCssName = value;
    }

    /**
     * Gets the value of the e164Mask property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getE164Mask() {
        return e164Mask;
    }

    /**
     * Sets the value of the e164Mask property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setE164Mask(String value) {
        this.e164Mask = value;
    }

    /**
     * Gets the value of the extension property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getExtension() {
        return extension;
    }

    /**
     * Sets the value of the extension property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setExtension(String value) {
        this.extension = value;
    }

    /**
     * Gets the value of the routePartitionName property.
     *
     * @return
     *     possible object is
     *     {@link XFkType }
     *
     */
    public XFkType getRoutePartitionName() {
        return routePartitionName;
    }

    /**
     * Sets the value of the routePartitionName property.
     *
     * @param value
     *     allowed object is
     *     {@link XFkType }
     *
     */
    public void setRoutePartitionName(XFkType value) {
        this.routePartitionName = value;
    }

    /**
     * Gets the value of the voiceMailProfileName property.
     *
     * @return
     *     possible object is
     *     {@link XFkType }
     *
     */
    public XFkType getVoiceMailProfileName() {
        return voiceMailProfileName;
    }

    /**
     * Sets the value of the voiceMailProfileName property.
     *
     * @param value
     *     allowed object is
     *     {@link XFkType }
     *
     */
    public void setVoiceMailProfileName(XFkType value) {
        this.voiceMailProfileName = value;
    }

    /**
     * Gets the value of the enableExtensionMobility property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getEnableExtensionMobility() {
        return enableExtensionMobility;
    }

    /**
     * Sets the value of the enableExtensionMobility property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setEnableExtensionMobility(String value) {
        this.enableExtensionMobility = value;
    }

    /**
     * Gets the value of the uuid property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getUuid() {
        return uuid;
    }

    /**
     * Sets the value of the uuid property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setUuid(String value) {
        this.uuid = value;
    }

}


text:
AboutDialog::AboutDialog(QWidget* pParent)
    : QDialog(pParent, Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
{
    setupUi(this);

    version->setText(QString("Система имитационного моделирования\n\n%1")
        .arg(QString::fromStdString(rdo::version::g_versionName)));

    www->setText(QString::fromStdString(boost::str(
        boost::format("%2%")
        % rdo::version::g_site
        % boost::algorithm::erase_first_copy(rdo::version::g_site, "http://")
    )));

    if (pParent)
    {
        move(pParent->frameGeometry().center() - frameGeometry().center());
    }
}


text:
describe ActiveRecord::Sharding::ModuloRouter do
  let(:cluster_config) do
    cluster_config = ActiveRecord::Sharding::ClusterConfig.new :user
    cluster_config.register_connection :db_connection_001
    cluster_config.register_connection :db_connection_002
    cluster_config.register_connection :db_connection_003
    cluster_config
  end

  let(:router) { described_class.new cluster_config }

  describe '#route' do
    it "returns database connection name by id % cluster nodes" do
      expect(router.route(1)).to eq :db_connection_002
      expect(router.route(2)).to eq :db_connection_003
      expect(router.route(3)).to eq :db_connection_001
      expect(router.route(4)).to eq :db_connection_002
      expect(router.route(5)).to eq :db_connection_003
      expect(router.route(6)).to eq :db_connection_001
    end
  end
end


text:
package org.apache.apex.malhar.lib.fs.s3;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestWatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.apex.malhar.lib.fs.FSRecordReaderModule;
import org.apache.apex.malhar.lib.fs.FSRecordReaderTest.DelimitedValidator;
import org.apache.apex.malhar.lib.fs.FSRecordReaderTest.FixedWidthValidator;
import org.apache.apex.malhar.lib.io.block.BlockMetadata.FileBlockMetadata;
import org.apache.apex.malhar.lib.io.block.ReaderContext;
import org.apache.apex.malhar.lib.io.fs.S3BlockReader;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.Path;

import com.amazonaws.services.s3.AmazonS3;

import com.datatorrent.api.Context.OperatorContext;
import com.datatorrent.api.DAG;
import com.datatorrent.api.LocalMode;
import com.datatorrent.api.StreamingApplication;

import static org.mockito.Mockito.mock;

public class S3RecordReaderMockTest
{
  private String inputDir;
  static String outputDir;
  private static final String FILE_1 = "file1.txt";
  private static final String FILE_2 = "file2.txt";
  private static final String FILE_1_DATA = "1234\n567890\nabcde\nfgh\ni\njklmop";
  private static final String FILE_2_DATA = "qr\nstuvw\nxyz\n";

  public static class TestMeta extends TestWatcher
  {
    public String baseDirectory;

    @Override
    protected void starting(org.junit.runner.Description description)
    {
      this.baseDirectory = "target/" + description.getClassName() + "/" + description.getMethodName();
    }

  }

  @Rule
  public TestMeta testMeta = new TestMeta();

  @Before
  public void setup() throws Exception
  {
    inputDir = testMeta.baseDirectory + File.separator + "input";

    FileUtils.writeStringToFile(new File(inputDir + File.separator + FILE_1), FILE_1_DATA);
    FileUtils.writeStringToFile(new File(inputDir + File.separator + FILE_2), FILE_2_DATA);
  }

  @Test
  public void testDelimitedRecords() throws Exception
  {

    DelimitedApplication app = new DelimitedApplication();
    LocalMode lma = LocalMode.newInstance();
    Configuration conf = new Configuration(false);
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.files", inputDir);
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.blockSize", "3");
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.blocksThreshold", "1");
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.scanIntervalMillis", "10000");

    lma.prepareDAG(app, conf);
    LocalMode.Controller lc = lma.getController();
    lc.setHeartbeatMonitoringEnabled(true);
    lc.runAsync();

    Set<String> expectedRecords = new HashSet<String>(Arrays.asList(FILE_1_DATA.split("\n")));
    expectedRecords.addAll(Arrays.asList(FILE_2_DATA.split("\n")));

    while (DelimitedValidator.getRecords().size() != expectedRecords.size()) {
      LOG.debug("Waiting for app to finish");
      Thread.sleep(1000);
    }
    lc.shutdown();
    Assert.assertEquals(expectedRecords, DelimitedValidator.getRecords());

  }

  private static class S3RecordReaderMock extends S3RecordReader
  {
    AmazonS3 s3ClientObject;

    @Override
    protected FSDataInputStream setupStream(FileBlockMetadata block) throws IOException
    {
      super.setupStream(block);
      return fs.open(new Path(block.getFilePath()));
    }

    @Override
    public void setup(OperatorContext context)
    {
      s3ClientObject = mock(AmazonS3.class);
      super.setup(context);
    }

    @Override
    protected ReaderContext<FSDataInputStream> createDelimitedReaderContext()
    {
      S3DelimitedRecordReaderContextMock s3DelimitedRecordReaderContextMock = new S3DelimitedRecordReaderContextMock();
      s3DelimitedRecordReaderContextMock.getS3Params().setBucketName("S3RecordReaderMock");
      s3DelimitedRecordReaderContextMock.getS3Params().setS3Client(s3ClientObject);
      return s3DelimitedRecordReaderContextMock;
    }

    @Override
    protected ReaderContext<FSDataInputStream> createFixedWidthReaderContext()
    {
      S3FixedWidthRecordReaderContextMock s3FixedWidthRecordReaderContextMock = new S3FixedWidthRecordReaderContextMock();
      s3FixedWidthRecordReaderContextMock.getS3Params().setBucketName("S3RecordReaderMock");
      s3FixedWidthRecordReaderContextMock.getS3Params().setS3Client(s3ClientObject);
      s3FixedWidthRecordReaderContextMock.setLength(this.getRecordLength());
      return s3FixedWidthRecordReaderContextMock;
    }

    private class S3DelimitedRecordReaderContextMock extends S3DelimitedRecordReaderContext
    {
      @Override
      protected int readData(long bytesFromCurrentOffset, int bytesToFetch) throws IOException
      {
        if (buffer == null) {
          buffer = new byte[bytesToFetch];
        }
        return stream.read(offset + bytesFromCurrentOffset, buffer, 0, bytesToFetch);
      }
    }

    private static class S3FixedWidthRecordReaderContextMock extends S3FixedWidthRecordReaderContext
    {
      @Override
      protected int readData(long startOffset, long endOffset) throws IOException
      {
        int bufferSize = Long.valueOf(endOffset - startOffset + 1).intValue();
        if (buffer == null) {
          buffer = new byte[bufferSize];
        }
        return stream.read(startOffset, buffer, 0, bufferSize);
      }
    }
  }

  private static class S3RecordReaderModuleMock extends S3RecordReaderModule
  {
    @Override
    public S3RecordReader createRecordReader()
    {
      S3RecordReader s3RecordReader = new S3RecordReaderMock();
      s3RecordReader.setBucketName(S3BlockReader.extractBucket(getFiles()));
      s3RecordReader.setAccessKey("****");
      s3RecordReader.setSecretAccessKey("*****");
      s3RecordReader.setMode(this.getMode().toString());
      s3RecordReader.setRecordLength(this.getRecordLength());
      return s3RecordReader;
    }
  }

  private static class DelimitedApplication implements StreamingApplication
  {

    public void populateDAG(DAG dag, Configuration conf)
    {

      S3RecordReaderModuleMock recordReader = dag.addModule("S3RecordReaderModuleMock", new S3RecordReaderModuleMock());
      recordReader.setMode("delimited_record");
      DelimitedValidator validator = dag.addOperator("Validator", new DelimitedValidator());
      dag.addStream("records", recordReader.records, validator.data);
    }

  }

  @Test
  public void testFixedWidthRecords() throws Exception
  {

    FixedWidthApplication app = new FixedWidthApplication();
    LocalMode lma = LocalMode.newInstance();
    Configuration conf = new Configuration(false);
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.files", inputDir);
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.recordLength", "8");
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.blockSize", "3");
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.blocksThreshold", "1");
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.scanIntervalMillis", "10000");

    lma.prepareDAG(app, conf);
    LocalMode.Controller lc = lma.getController();
    lc.setHeartbeatMonitoringEnabled(true);
    lc.runAsync();
    LOG.debug("Waiting for app to finish");
    Thread.sleep(1000 * 1);
    lc.shutdown();
  }

  @Test(expected = IllegalArgumentException.class)
  public void testMissingRecordLength() throws Exception
  {
    FixedWidthApplication app = new FixedWidthApplication();
    LocalMode lma = LocalMode.newInstance();
    Configuration conf = new Configuration(false);
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.files", inputDir);
    //Should give IllegalArgumentException since recordLength is not set
    //conf.set("dt.operator.HDFSRecordReaderModule.prop.recordLength", "8");
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.blocksThreshold", "1");
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.blockSize", "3");
    conf.set("dt.operator.S3RecordReaderModuleMock.prop.scanIntervalMillis", "10000");

    lma.prepareDAG(app, conf);
    LocalMode.Controller lc = lma.getController();
    lc.setHeartbeatMonitoringEnabled(true);
    lc.runAsync();
    LOG.debug("Waiting for app to finish");
    Thread.sleep(1000 * 1);
    lc.shutdown();
  }

  private static class FixedWidthApplication implements StreamingApplication
  {

    public void populateDAG(DAG dag, Configuration conf)
    {
      FSRecordReaderModule recordReader = dag.addModule("S3RecordReaderModuleMock", FSRecordReaderModule.class);
      recordReader.setMode("FIXED_WIDTH_RECORD");
      FixedWidthValidator validator = dag.addOperator("Validator", new FixedWidthValidator());
      dag.addStream("records", recordReader.records, validator.data);
    }

  }

  private static Logger LOG = LoggerFactory.getLogger(S3RecordReaderMockTest.class);

}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web.Mvc;
using BaselineSolution.Framework.Infrastructure.Attributes;

namespace BaselineSolution.WebApp.Components.Models.SelectLists
{
    /// <summary>
    /// Builder class for where the grouping has already been done
    /// </summary>
    /// <typeparam name="TModel"></typeparam>
    /// <typeparam name="TProperty"></typeparam>
    /// <typeparam name="TGroup"></typeparam>
    /// <typeparam name="TOption"></typeparam>
    public class GroupBuilder <TModel, TProperty, TGroup, TOption> : IGroupBuilder<TGroup, TOption>
    {
        [NotNull] private readonly IEnumerable<IGrouping<TGroup, TOption>> _groupedOptions;
        [NotNull] private readonly HtmlHelper<TModel> _html;
        [CanBeNull] private readonly object _htmlAttributes;
        [CanBeNull] private readonly string _optionLabel;
        [NotNull] private readonly Expression<Func<TModel, TProperty>> _propertyExpression;

        public GroupBuilder([NotNull] HtmlHelper<TModel> html,
                            [NotNull] Expression<Func<TModel, TProperty>> propertyExpression,
                            [NotNull] IEnumerable<IGrouping<TGroup, TOption>> groupedOptions,
                            [CanBeNull] string optionLabel,
                            [CanBeNull] object htmlAttributes)
        {
            _html = html;
            _propertyExpression = propertyExpression;
            _groupedOptions = groupedOptions;
            _optionLabel = optionLabel;
            _htmlAttributes = htmlAttributes;
        }

        public IOptionsBuilder<TOption> Group(Func<TGroup, IEnumerable<TOption>, string> groupLabelFunction, Func<TGroup, IEnumerable<TOption>, object> groupHtmlAttributesFunction)
        {
            return new GroupedOptionsBuilder<TModel, TProperty, TGroup, TOption>(_html,
                                             _propertyExpression,
                                             _optionLabel,
                                             _htmlAttributes,
                                             _groupedOptions,
                                             groupLabelFunction,
                                             groupHtmlAttributesFunction);
        }

        public IOptionsBuilder<TOption> Group(Func<TGroup, IEnumerable<TOption>, string> groupLabelFunction)
        {
            return Group(groupLabelFunction, (Func<TGroup, IEnumerable<TOption>, object>)null);
        }

        public IOptionsBuilder<TOption> Group(Func<TGroup, string> groupLabelFunction, Func<TGroup, object> groupHtmlAttributesFunction)
        {
            return Group((group, options) => groupLabelFunction(group), (groupHtmlAttributesFunction != null ? (group, options) => groupHtmlAttributesFunction(group) : (Func<TGroup, IEnumerable<TOption>, object>) null));
        }

        public IOptionsBuilder<TOption> Group(Func<TGroup, string> groupLabelFunction)
        {
            return Group(groupLabelFunction, (Func<TGroup, object>) null);
        }

        public IOptionsBuilder<TOption> Group()
        {
            return Group(group => Convert.ToString(group), (Func<TGroup, object>) null);
        }
    }
}


text:
namespace System.Collections
{
    public interface IEnumerable
    {
        /// <summary>
        /// Gets an enummerator to enumerate over all elements in this sequence.
        /// </summary>
        /// <returns></returns>
        IEnumerator GetEnumerator();
    }
}


text:
define(function (require) {
  const [$, $$] = require('/vools.js')
  const envir = require('src/envir.js')
  const Article = require('model/article.js')
  const TopButton = require('controller/top-panel.js')
  const Editor = require('controller/editor/editor.js')

  const new_post = {
    new() {
      const art = Article.init({
        title: '',
        content: '',
        contentType: 'markdown',
        tags: [],
        is_draft: false,
        is_repost: false,
      })
      Editor.apply(art)
      Editor.show()
    }
  }

  const button = TopButton.getElement('new')

  TopButton.click('new', new_post.new.bind(new_post))

  return new_post
})


text:
package ezvcard;

/*
 Copyright (c) 2012-2015, Michael Angstadt
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:

 1. Redistributions of source code must retain the above copyright notice, this
 list of conditions and the following disclaimer.
 2. Redistributions in binary form must reproduce the above copyright notice,
 this list of conditions and the following disclaimer in the documentation
 and/or other materials provided with the distribution.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 The views and conclusions contained in the software and documentation are those
 of the authors and should not be interpreted as representing official policies,
 either expressed or implied, of the FreeBSD Project.
 */

/**
 * Contains the vCard versions that this library supports.
 * @author George El-Haddad
 * @author Michael Angstadt
 */
public enum VCardVersion {
	/**
	 * The original vCard specification.
	 * @see 2.1 specs
	 */
	V2_1("2.1", null),

	/**
	 * Version 3.0.
	 * @see RFC 2426
	 */
	V3_0("3.0", null),

	/**
	 * The lastest specification.
	 * @see RFC 6350
	 */
	V4_0("4.0", "urn:ietf:params:xml:ns:vcard-4.0");

	private final String version;
	private final String xmlNamespace;

	/**
	 * @param version the text representation
	 */
	private VCardVersion(String version, String xmlNamespace) {
		this.version = version;
		this.xmlNamespace = xmlNamespace;
	}

	/**
	 * Gets the text representation of this version.
	 * @return the text representation
	 */
	public String getVersion() {
		return version;
	}

	/**
	 * Gets the XML namespace of this version.
	 * @return the XML namespace or null if this version does not support xCard
	 */
	public String getXmlNamespace() {
		return xmlNamespace;
	}

	/**
	 * Gets a {@link VCardVersion} instance based on the given text
	 * representation.
	 * @param value the text representation
	 * @return the object or null if not found
	 */
	public static VCardVersion valueOfByStr(String value) {
		for (VCardVersion version : VCardVersion.values()) {
			if (version.getVersion().equals(value)) {
				return version;
			}
		}
		return null;
	}

	/**
	 * Gets a {@link VCardVersion} instance based on the given XML namespace.
	 * @param ns the XML namespace
	 * @return the object or null if not found
	 */
	public static VCardVersion valueOfByXmlNamespace(String ns) {
		for (VCardVersion version : VCardVersion.values()) {
			String versionNs = version.getXmlNamespace();
			if (versionNs != null && versionNs.equals(ns)) {
				return version;
			}
		}
		return null;
	}

	@Override
	public String toString() {
		return version;
	}
}


text:
#pragma once

#import "mscorlib.tlb" raw_interfaces_only raw_native_types named_guids rename("_Module", "_ReflectionModule") rename("ReportEvent", "_ReflectionReportEvent") rename("value", "_value")
#include "vcclr.h"
#include "CompilerContext.h"

class VbContext
#if FV_DEADBEEF
    : public Deadbeef<VbContext> // Must be last base class!
#endif
{
public:
    VbContext(gcroot<Microsoft::Compiler::VisualBasic::CompilerContext ^> compilerContext = gcroot<Microsoft::Compiler::VisualBasic::CompilerContext ^>());

    virtual ~VbContext();

    static STDMETHODIMP SetAssemblyRefs(/*[in]*/ gcroot<System::Collections::Generic::IList<System::Reflection::Assembly ^> ^> referenceAssemblies, /*[in]*/ class Compiler *pCompiler, /*[in]*/ struct IVbCompilerProject *pVbCompilerProject, /*[in]*/ ErrorTable *pErrorTable);
    STDMETHODIMP SetImports(/*[in]*/ struct IVbCompilerProject *pVbCompilerProject);
    STDMETHODIMP NamespaceExists(/*[in]*/ BSTR name, /*[out,retval]*/ BOOL *pRetVal);
    STDMETHODIMP FindTypes(/*[in]*/ BSTR name,
                           /*[in]*/ BSTR prefix,
                           /*[out,retval]*/ gcroot<array<System::Type^,1>^>& pType );
    STDMETHODIMP FindVariable(/*[in]*/ BSTR name,
                              /*[out, retval]*/ gcroot<System::Type^>& pType);
    STDMETHODIMP SetOptions(/*[in]*/ struct IVbCompilerProject *pVbCompilerProject);
    static STDMETHODIMP SetDefaultOptions(/*[in]*/ struct IVbCompilerProject *pVbCompilerProject);
    STDMETHODIMP SetOptions(/*[in]*/ SourceFile *pSourceFile);

private:
    static STDMETHODIMP SetOptions(/*[in]*/ struct IVbCompilerProject *pVbCompilerProject, /*[in]*/ gcroot<Microsoft::Compiler::VisualBasic::CompilerOptions ^> compilerOptions);
    gcroot<Microsoft::Compiler::VisualBasic::CompilerContext ^> m_compilerContext;

    // Do not want to support copy semantics for this class, so
    // declare as private and don't implement...
    VbContext(const VbContext &source);
    VbContext &operator=(const VbContext &source);
};


text:
@import Cocoa;

@class TDEffectStyleProduction;

@interface TDNamedEffectProduction : TDEffectStyleProduction

- (NSString *)displayName;

@end


text:
import { observable, action, ObservableMap, toJS, IObservableArray } from 'mobx';

interface IResponse {
  statusCode:number
  message:string
}

class NetworkStore {
  @observable pendingRequest:number = 0
  @observable lastResponse:IResponse = {statusCode:0, message: 'none'}

  @action updateLastResponse = ({statusCode, message}:IResponse) => {
    this.lastResponse.message = message;
    this.lastResponse.statusCode = statusCode;
  }

  @action addPendingRequest = () => {
    this.pendingRequest += 1;
  }

  @action removePendingRequest = () => {
    this.pendingRequest -= 1;
  }
}

const networkStore = new NetworkStore();

export default networkStore;


text:
using System;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.ConstrainedExecution;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using Microsoft.Win32.SafeHandles;
using System.Diagnostics.Contracts;

namespace System.Security.Cryptography {

    /// <summary>
    ///     Native interop with CAPI. Native code definitions can be found in wincrypt.h
    /// </summary>
    internal static class CapiNative {
        /// <summary>
        ///     Class fields for CAPI algorithm identifiers
        /// </summary>
        internal enum AlgorithmClass
        {
            Any = (0 << 13),                    // ALG_CLASS_ANY
            Signature = (1 << 13),              // ALG_CLASS_SIGNATURE
            Hash = (4 << 13),                   // ALG_CLASS_HASH
            KeyExchange = (5 << 13),            // ALG_CLASS_KEY_EXCHANGE
        }

        /// <summary>
        ///     Type identifier fields for CAPI algorithm identifiers
        /// </summary>
        internal enum AlgorithmType
        {
            Any = (0 << 9),                     // ALG_TYPE_ANY
            Rsa = (2 << 9),                     // ALG_TYPE_RSA
        }

        /// <summary>
        ///     Sub identifiers for CAPI algorithm identifiers
        /// </summary>
        internal enum AlgorithmSubId
        {
            Any = 0,                            // ALG_SID_ANY

            RsaAny = 0,                         // ALG_SID_RSA_ANY

            Sha1 = 4,                           // ALG_SID_SHA1
            Sha256 = 12,                        // ALG_SID_SHA_256
            Sha384 = 13,                        // ALG_SID_SHA_384
            Sha512 = 14,                        // ALG_SID_SHA_512
        }

        /// <summary>
        ///     CAPI algorithm identifiers
        /// </summary>
        internal enum AlgorithmID
        {
            None = 0,

            RsaSign =                   (AlgorithmClass.Signature           | AlgorithmType.Rsa             | AlgorithmSubId.RsaAny),                   // CALG_RSA_SIGN
            RsaKeyExchange =            (AlgorithmClass.KeyExchange         | AlgorithmType.Rsa             | AlgorithmSubId.RsaAny),                   // CALG_RSA_KEYX

            Sha1 =                      (AlgorithmClass.Hash                | AlgorithmType.Any             | AlgorithmSubId.Sha1),                     // CALG_SHA1
            Sha256 =                    (AlgorithmClass.Hash                | AlgorithmType.Any             | AlgorithmSubId.Sha256),                   // CALG_SHA_256
            Sha384 =                    (AlgorithmClass.Hash                | AlgorithmType.Any             | AlgorithmSubId.Sha384),                   // CALG_SHA_384
            Sha512 =                    (AlgorithmClass.Hash                | AlgorithmType.Any             | AlgorithmSubId.Sha512),                   // CALG_SHA_512
        }

        /// <summary>
        ///     Flags for the CryptAcquireContext API
        /// </summary>
        [Flags]
        internal enum CryptAcquireContextFlags {
            None = 0x00000000,
            NewKeyset = 0x00000008,                         // CRYPT_NEWKEYSET
            DeleteKeyset = 0x00000010,                      // CRYPT_DELETEKEYSET
            MachineKeyset = 0x00000020,                     // CRYPT_MACHINE_KEYSET
            Silent = 0x00000040,                            // CRYPT_SILENT
            VerifyContext = unchecked((int)0xF0000000)      // CRYPT_VERIFYCONTEXT
        }

        /// <summary>
        ///     Error codes returned by CAPI
        /// </summary>
        internal enum ErrorCode {
            Ok = 0x00000000,
            MoreData = 0x000000ea,                          // ERROR_MORE_DATA
            BadHash = unchecked((int)0x80090002),           // NTE_BAD_HASH
            BadData = unchecked((int)0x80090005),           // NTE_BAD_DATA
            BadSignature = unchecked((int)0x80090006),      // NTE_BAD_SIGNATURE
            NoKey = unchecked((int)0x8009000d)              // NTE_NO_KEY
        }

        /// <summary>
        ///     Properties of CAPI hash objects
        /// </summary>
        internal enum HashProperty {
            None = 0,
            HashValue = 0x0002,                             // HP_HASHVAL
            HashSize = 0x0004,                              // HP_HASHSIZE
        }

        /// <summary>
        ///     Flags for the CryptGenKey API
        /// </summary>
        [Flags]
        internal enum KeyGenerationFlags {
            None = 0x00000000,
            Exportable = 0x00000001,                        // CRYPT_EXPORTABLE
            UserProtected = 0x00000002,                     // CRYPT_USER_PROTECTED
            Archivable = 0x00004000                         // CRYPT_ARCHIVABLE
        }

        /// <summary>
        ///     Properties that can be read or set on a key
        /// </summary>
        internal enum KeyProperty {
            None = 0,
            AlgorithmID = 7,                                // KP_ALGID
            KeyLength = 9                                   // KP_KEYLEN
        }

        /// <summary>
        ///     Key numbers for identifying specific keys within a single container
        /// </summary>
        internal enum KeySpec {
            KeyExchange = 1,                                // AT_KEYEXCHANGE
            Signature = 2                                   // AT_SIGNATURE
        }

        /// <summary>
        ///     Well-known names of crypto service providers
        /// </summary>
        internal static class ProviderNames {
            // MS_ENHANCED_PROV
            internal const string MicrosoftEnhanced = "Microsoft Enhanced Cryptographic Provider v1.0";
        }

        /// <summary>
        ///     Provider type accessed in a crypto service provider. These provide the set of algorithms
        ///     available to use for an application.
        /// </summary>
        internal enum ProviderType {
            RsaFull = 1         // PROV_RSA_FULL
        }

        [System.Security.SecurityCritical]
        internal static class UnsafeNativeMethods {
            /// <summary>
            ///     Open a crypto service provider, if a key container is specified KeyContainerPermission
            ///     should be demanded.
            /// </summary>
            [DllImport("advapi32", SetLastError = true, CharSet = CharSet.Unicode)]
            [return: MarshalAs(UnmanagedType.Bool)]
            internal static extern bool CryptAcquireContext([Out] out SafeCspHandle phProv,
                                                            string pszContainer,
                                                            string pszProvider,
                                                            ProviderType dwProvType,
                                                            CryptAcquireContextFlags dwFlags);

            /// <summary>
            ///     Create an object to hash data with
            /// </summary>
            [DllImport("advapi32", SetLastError = true)]
            [return: MarshalAs(UnmanagedType.Bool)]
            internal static extern bool CryptCreateHash(SafeCspHandle hProv,
                                                        AlgorithmID Algid,
                                                        IntPtr hKey,                        // SafeCspKeyHandle
                                                        int dwFlags,
                                                        [Out] out SafeCspHashHandle phHash);

            /// <summary>
            ///     Create a new key in the given key container
            /// </summary>
            [DllImport("advapi32", SetLastError = true)]
            [return: MarshalAs(UnmanagedType.Bool)]
            internal static extern bool CryptGenKey(SafeCspHandle hProv,
                                                    int Algid,
                                                    uint dwFlags,
                                                    [Out] out SafeCspKeyHandle phKey);

            /// <summary>
            ///     Fill a buffer with randomly generated data
            /// </summary>
            [DllImport("advapi32", SetLastError = true)]
            [return: MarshalAs(UnmanagedType.Bool)]
            internal static extern bool CryptGenRandom(SafeCspHandle hProv,
                                                       int dwLen,
                                                       [In, Out, MarshalAs(UnmanagedType.LPArray)] byte[] pbBuffer);

            /// <summary>
            ///     Fill a buffer with randomly generated data
            /// </summary>
            [DllImport("advapi32", SetLastError = true)]
            [return: MarshalAs(UnmanagedType.Bool)]
            internal static extern unsafe bool CryptGenRandom(SafeCspHandle hProv,
                                                       int dwLen,
                                                       byte* pbBuffer);

            /// <summary>
            ///     Read the value of a property from a hash object
            /// </summary>
            [DllImport("advapi32", SetLastError = true)]
            [return: MarshalAs(UnmanagedType.Bool)]
            internal static extern bool CryptGetHashParam(SafeCspHashHandle hHash,
                                                          HashProperty dwParam,
                                                          [In, Out, MarshalAs(UnmanagedType.LPArray)] byte[] pbData,
                                                          [In, Out] ref int pdwDataLen,
                                                          int dwFlags);

            /// <summary>
            ///     Read the value of a property from a key
            /// </summary>
            [DllImport("advapi32", SetLastError = true)]
            [return: MarshalAs(UnmanagedType.Bool)]
            internal static extern bool CryptGetKeyParam(SafeCspKeyHandle hKey,
                                                         KeyProperty dwParam,
                                                         [In, Out, MarshalAs(UnmanagedType.LPArray)] byte[] pbData,
                                                         [In, Out] ref int pdwDataLen,
                                                         int dwFlags);

            /// <summary>
            ///     Import a key blob into a CSP
            /// </summary>
            [DllImport("advapi32", SetLastError = true)]
            [return: MarshalAs(UnmanagedType.Bool)]
            internal static extern bool CryptImportKey(SafeCspHandle hProv,
                                                       [In, MarshalAs(UnmanagedType.LPArray)] byte[] pbData,
                                                       int pdwDataLen,
                                                       IntPtr hPubKey,                      // SafeCspKeyHandle
                                                       KeyGenerationFlags dwFlags,
                                                       [Out] out SafeCspKeyHandle phKey);

            /// <summary>
            ///     Set the value of a property on a hash object
            /// </summary>
            [DllImport("advapi32", SetLastError = true)]
            [return: MarshalAs(UnmanagedType.Bool)]
            internal static extern bool CryptSetHashParam(SafeCspHashHandle hHash,
                                                          HashProperty dwParam,
                                                          [In, MarshalAs(UnmanagedType.LPArray)] byte[] pbData,
                                                          int dwFlags);

            /// <summary>
            ///     Verify the a digital signature
            /// </summary>
            [DllImport("advapi32", SetLastError = true, CharSet = CharSet.Unicode)]
            [return: MarshalAs(UnmanagedType.Bool)]
            internal static extern bool CryptVerifySignature(SafeCspHashHandle hHash,
                                                             [In, MarshalAs(UnmanagedType.LPArray)] byte[] pbSignature,
                                                             int dwSigLen,
                                                             SafeCspKeyHandle hPubKey,
                                                             string sDescription,
                                                             int dwFlags);
        }

        /// <summary>
        ///     Acquire a handle to a crypto service provider and optionally a key container
        /// </summary>
        [SecurityCritical]
        internal static SafeCspHandle AcquireCsp(string keyContainer,
                                                 string providerName,
                                                 ProviderType providerType,
                                                 CryptAcquireContextFlags flags) {
            Contract.Assert(keyContainer == null, "Key containers are not supported");

            // Specifying both verify context (for an ephemeral key) and machine keyset (for a persisted machine key)
            // does not make sense.  Additionally, Widows is beginning to lock down against uses of MACHINE_KEYSET
            // (for instance in the app container), even if verify context is present.   Therefore, if we're using
            // an ephemeral key, strip out MACHINE_KEYSET from the flags.
            if (((flags & CryptAcquireContextFlags.VerifyContext) == CryptAcquireContextFlags.VerifyContext) &&
                ((flags & CryptAcquireContextFlags.MachineKeyset) == CryptAcquireContextFlags.MachineKeyset)) {
                flags &= ~CryptAcquireContextFlags.MachineKeyset;
            }

            SafeCspHandle cspHandle = null;
            if (!UnsafeNativeMethods.CryptAcquireContext(out cspHandle,
                                                            keyContainer,
                                                            providerName,
                                                            providerType,
                                                            flags)) {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }

            return cspHandle;
        }

        /// <summary>
        ///     Create a CSP hash object for the specified hash algorithm
        /// </summary>
        [SecurityCritical]
        internal static SafeCspHashHandle CreateHashAlgorithm(SafeCspHandle cspHandle, AlgorithmID algorithm) {
            Contract.Assert(cspHandle != null && !cspHandle.IsInvalid, "cspHandle != null && !cspHandle.IsInvalid");
            Contract.Assert(((AlgorithmClass)algorithm & AlgorithmClass.Hash) == AlgorithmClass.Hash, "Invalid hash algorithm");

            SafeCspHashHandle hashHandle = null;
            if (!UnsafeNativeMethods.CryptCreateHash(cspHandle, algorithm, IntPtr.Zero, 0, out hashHandle)) {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }

            return hashHandle;
        }

        /// <summary>
        ///     Fill a buffer with random data generated by the CSP
        /// </summary>
        [SecurityCritical]
        internal static void GenerateRandomBytes(SafeCspHandle cspHandle, byte[] buffer) {
            Contract.Assert(cspHandle != null && !cspHandle.IsInvalid, "cspHandle != null && !cspHandle.IsInvalid");
            Contract.Assert(buffer != null && buffer.Length > 0, "buffer != null && buffer.Length > 0");

            if (!UnsafeNativeMethods.CryptGenRandom(cspHandle, buffer.Length, buffer)) {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }
        }

        /// <summary>
        ///     Fill part of a buffer with random data generated by the CSP
        /// </summary>
        [SecurityCritical]
        internal static unsafe void GenerateRandomBytes(SafeCspHandle cspHandle, byte[] buffer, int offset, int count)
        {
            Contract.Assert(cspHandle != null && !cspHandle.IsInvalid, "cspHandle != null && !cspHandle.IsInvalid");
            Contract.Assert(buffer != null && buffer.Length > 0, "buffer != null && buffer.Length > 0");
            Contract.Assert(offset >= 0 && count > 0, "offset >= 0 && count > 0");
            Contract.Assert(buffer.Length >= offset + count, "buffer.Length >= offset + count");

            fixed (byte* pBuffer = &buffer[offset])
            {
                if (!UnsafeNativeMethods.CryptGenRandom(cspHandle, count, pBuffer))
                {
                    throw new CryptographicException(Marshal.GetLastWin32Error());
                }
            }
        }

        /// <summary>
        ///     Get a DWORD sized property of a hash object
        /// </summary>
        [SecurityCritical]
        internal static int GetHashPropertyInt32(SafeCspHashHandle hashHandle, HashProperty property) {
            byte[] rawProperty = GetHashProperty(hashHandle, property);
            Contract.Assert(rawProperty.Length == sizeof(int) || rawProperty.Length == 0, "Unexpected property size");
            return rawProperty.Length == sizeof(int) ? BitConverter.ToInt32(rawProperty, 0) : 0;
        }

        /// <summary>
        ///     Get an arbitrary property of a hash object
        /// </summary>
        [SecurityCritical]
        internal static byte[] GetHashProperty(SafeCspHashHandle hashHandle, HashProperty property) {
            Contract.Assert(hashHandle != null && !hashHandle.IsInvalid, "keyHandle != null && !keyHandle.IsInvalid");

            int bufferSize = 0;
            byte[] buffer = null;

            // Figure out how big of a buffer we need to hold the property
            if (!UnsafeNativeMethods.CryptGetHashParam(hashHandle, property, buffer, ref bufferSize, 0)) {
                int errorCode = Marshal.GetLastWin32Error();
                if (errorCode != (int)ErrorCode.MoreData) {
                    throw new CryptographicException(errorCode);
                }
            }

            // Now get the property bytes directly
            buffer = new byte[bufferSize];
            if (!UnsafeNativeMethods.CryptGetHashParam(hashHandle, property, buffer, ref bufferSize, 0)) {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }

            return buffer;
        }

        /// <summary>
        ///     Get a DWORD sized property of a key stored in a CSP
        /// </summary>
        [SecurityCritical]
        internal static int GetKeyPropertyInt32(SafeCspKeyHandle keyHandle, KeyProperty property) {
            byte[] rawProperty = GetKeyProperty(keyHandle, property);
            Contract.Assert(rawProperty.Length == sizeof(int) || rawProperty.Length == 0, "Unexpected property size");
            return rawProperty.Length == sizeof(int) ? BitConverter.ToInt32(rawProperty, 0) : 0;
        }

        /// <summary>
        ///     Get an arbitrary property of a key stored in a CSP
        /// </summary>
        [SecurityCritical]
        internal static byte[] GetKeyProperty(SafeCspKeyHandle keyHandle, KeyProperty property) {
            Contract.Assert(keyHandle != null && !keyHandle.IsInvalid, "keyHandle != null && !keyHandle.IsInvalid");

            int bufferSize = 0;
            byte[] buffer = null;

            // Figure out how big of a buffer we need to hold the property
            if (!UnsafeNativeMethods.CryptGetKeyParam(keyHandle, property, buffer, ref bufferSize, 0)) {
                int errorCode = Marshal.GetLastWin32Error();
                if (errorCode != (int)ErrorCode.MoreData) {
                    throw new CryptographicException(errorCode);
                }
            }

            // Now get the property bytes directly
            buffer = new byte[bufferSize];
            if (!UnsafeNativeMethods.CryptGetKeyParam(keyHandle, property, buffer, ref bufferSize, 0)) {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }

            return buffer;
        }

        /// <summary>
        ///     Set an arbitrary property on a hash object
        /// </summary>
        [SecurityCritical]
        internal static void SetHashProperty(SafeCspHashHandle hashHandle,
                                             HashProperty property,
                                             byte[] value) {
            Contract.Assert(hashHandle != null && !hashHandle.IsInvalid, "hashHandle != null && !hashHandle.IsInvalid");

            if (!UnsafeNativeMethods.CryptSetHashParam(hashHandle, property, value, 0)) {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }
        }

        /// <summary>
        ///     Verify that the digital signature created with the specified hash and asymmetric algorithm
        ///     is valid for the given hash value.
        /// </summary>
        [SecurityCritical]
        internal static bool VerifySignature(SafeCspHandle cspHandle,
                                             SafeCspKeyHandle keyHandle,
                                             AlgorithmID signatureAlgorithm,
                                             AlgorithmID hashAlgorithm,
                                             byte[] hashValue,
                                             byte[] signature) {
            Contract.Assert(cspHandle != null && !cspHandle.IsInvalid, "cspHandle != null && !cspHandle.IsInvalid");
            Contract.Assert(keyHandle != null && !keyHandle.IsInvalid, "keyHandle != null && !keyHandle.IsInvalid");
            Contract.Assert(((AlgorithmClass)signatureAlgorithm & AlgorithmClass.Signature) == AlgorithmClass.Signature, "Invalid signature algorithm");
            Contract.Assert(((AlgorithmClass)hashAlgorithm & AlgorithmClass.Hash) == AlgorithmClass.Hash, "Invalid hash algorithm");
            Contract.Assert(hashValue != null, "hashValue != null");
            Contract.Assert(signature != null, "signature != null");

            // CAPI and the CLR have inverse byte orders for signatures, so we need to reverse before verifying
            byte[] signatureValue = new byte[signature.Length];
            Array.Copy(signature, signatureValue, signatureValue.Length);
            Array.Reverse(signatureValue);

            using (SafeCspHashHandle hashHandle = CreateHashAlgorithm(cspHandle, hashAlgorithm)) {
                // Make sure the hash value is the correct size and import it into the CSP
                if (hashValue.Length != GetHashPropertyInt32(hashHandle, HashProperty.HashSize)) {
                    throw new CryptographicException((int)ErrorCode.BadHash);
                }
                SetHashProperty(hashHandle, HashProperty.HashValue, hashValue);

                // Do the signature verification.  A TRUE result means that the signature was valid.  A FALSE
                // result either means an invalid signature or some other error, so we need to check the last
                // error to see which occured.
                if (UnsafeNativeMethods.CryptVerifySignature(hashHandle,
                                                                signatureValue,
                                                                signatureValue.Length,
                                                                keyHandle,
                                                                null,
                                                                0)) {
                    return true;
                }
                else {
                    int error = Marshal.GetLastWin32Error();

                    if (error != (int)ErrorCode.BadSignature) {
                        throw new CryptographicException(error);
                    }

                    return false;
                }
            }
        }
    }

    /// <summary>
    ///    SafeHandle representing a native HCRYPTPROV on Windows, or representing all state associated with
    ///    loading a CSSM CSP on the Mac.  The HCRYPTPROV SafeHandle usage is straightforward, however CSSM
    ///    usage is slightly different.
    ///
    ///    For CSSM we hold three pieces of state:
    ///      * m_initializedCssm - a flag indicating that CSSM_Init() was successfully called
    ///      * m_cspModuleGuid   - the module GUID of the CSP we loaded, if that CSP was successfully loaded
    ///      * handle            - handle resulting from attaching to the CSP
    ///
    ///    We need to keep all three pieces of state, since we need to teardown in a specific order. If
    ///    these pieces of state were in seperate SafeHandles we could not guarantee their order of
    ///    finalization.
    /// </summary>
    [SecurityCritical]
    internal sealed class SafeCspHandle : SafeHandleZeroOrMinusOneIsInvalid {

        private SafeCspHandle() : base(true) {
        }

        [DllImport("advapi32")]
#if FEATURE_CORECLR || FEATURE_CER
        [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif // FEATURE_CORECLR || FEATURE_CER
        [return: MarshalAs(UnmanagedType.Bool)]
        private extern static bool CryptReleaseContext(IntPtr hProv, int dwFlags);

        /// <summary>
        ///     Clean up the safe handle's resources.
        ///
        ///     On Windows the cleanup is a straightforward release of the HCRYPTPROV handle.  However, on
        ///     the Mac, CSSM requires that we release resources in the following order:
        ///
        ///       1. Detach from the CSP
        ///       2. Unload the CSP
        ///       3. Terminate CSSM
        ///
        ///     Both the unload and terminate operations are ref-counted by CSSM, so it is safe to do these
        ///     even if other handles are open on the CSP or other CSSM objects are in use.
        /// </summary>
        [SecurityCritical]
        protected override bool ReleaseHandle() {
            return CryptReleaseContext(handle, 0);
        }

    }

    /// <summary>
    ///     SafeHandle representing a native HCRYPTHASH
    /// </summary>
    [SecurityCritical]
    internal sealed class SafeCspHashHandle : SafeHandleZeroOrMinusOneIsInvalid {
        private SafeCspHashHandle() : base(true) {
        }

        [DllImport("advapi32")]
#if FEATURE_CORECLR || FEATURE_CER
        [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif // FEATURE_CORECLR || FEATURE_CER
        [return: MarshalAs(UnmanagedType.Bool)]
        private extern static bool CryptDestroyHash(IntPtr hKey);

        [SecurityCritical]
        protected override bool ReleaseHandle() {
            return CryptDestroyHash(handle);
        }
    }

    /// <summary>
    ///     SafeHandle representing a native HCRYPTKEY on Windows.
    ///
    ///     On the Mac, we generate our keys by hand, so they are really just CSSM_KEY structures along with
    ///     the associated data blobs.  Because of this, the only resource that needs to be released when the
    ///     key is freed is the memory associated with the key blob.
    ///
    ///     However, in order for a SafeCspKeyHandle to marshal as a CSSM_KEY_PTR, as one would expect, the
    ///     handle value on the Mac is actually a pointer to the CSSM_KEY.  We maintain a seperate m_data
    ///     pointer which is the buffer holding the actual key data.
    ///
    ///     Both of these details add a further invarient that on the Mac a SafeCspKeyHandle may never be an
    ///     [out] parameter from an API.  This is because we always expect that we control the memory buffer
    ///     that the CSSM_KEY resides in and that we don't have to call CSSM_FreeKey on the data.
    ///
    ///     Keeping this in a SafeHandle rather than just marshaling the key structure direclty buys us a
    ///     level of abstraction, in that if we ever do need to work with keys that require a CSSM_FreeKey
    ///     call, we can continue to use the same key handle object.  It also means that keys are represented
    ///     by the same type on both Windows and Mac, so that consumers of the CapiNative layer don't have
    ///     to know the difference between the two.
    /// </summary>
    [SecurityCritical]
    internal sealed class SafeCspKeyHandle : SafeHandleZeroOrMinusOneIsInvalid {

        internal SafeCspKeyHandle() : base(true) {
        }

        [DllImport("advapi32")]
#if FEATURE_CORECLR || FEATURE_CER
        [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif // FEATURE_CORECLR || FEATURE_CER
        [return: MarshalAs(UnmanagedType.Bool)]
        private extern static bool CryptDestroyKey(IntPtr hKey);

        [SecurityCritical]
        protected override bool ReleaseHandle() {
            return CryptDestroyKey(handle);
        }
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="MainActivity" parent="AppTheme">
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
    </style>

    <style name="AppStyle" parent="AppTheme.NoActionBar">
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
    </style>

    <style name="HomeTabStyle" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">#33475f</item>
        <item name="android:windowTranslucentStatus">true</item>
    </style>
</resources>


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Ophiobolus vulgaris var. gnaphalii Sacc. & Bres.

### Remarks
null