text:
package matrix;

import ring.modInt.ModInt_M;
import ring.modInt.Z_M;

import java.util.Random;

import matrix.matrixException.*;

/**
 * A Class that performs modular arithmetic with matrices
 * @author Noah Kime
 */
public class GLn_Zm extends GLn<ModInt_M> {

	protected GLn_Zm inverse;

	/**
	 * Constructs a new GLn_Zm matrix using a given Grid
	 * @param nums The given Grid for this GLn_Zm
	 * @throws InvalidDimException Thrown if given grid nums does not have equivalent
	 * 	columns and rows
	 * @throws InvalidDetException Thrown if given grid corresponds to a Singular (noninvertible)
	 *  Matrix
	 */
	public GLn_Zm(Grid<ModInt_M> nums) throws InvalidDimException, InvalidDetException {
		super(nums);

		inverse = new GLn_Zm(inv.copyGrid(), det.getMultInverse(), this);
	} //END GLn_Zm (constructor)

	/**
	 * Generates a random GLn_Zm with given size n over the ring Z_M
	 * @param n The given size for this random GLn_Zm
	 * @param z The given Z_M to randomize this GLn_Zm over
	 * @throws InvalidDimException Thrown if this GLn_Zm has invalid dimensions
	 * @throws InvalidDetException Thrown if this GLn_Zm has an invalid determinant
	 * @throws OutOfBoundsException Thrown if randomization includes invalid matrix multiplication
	 */
	public GLn_Zm(int n, Z_M z) throws InvalidDimException, InvalidDetException, OutOfBoundsException {
		super();

		this.n = n;
		this.m = n;

		this.nums = genRandGrid(n,z);
		genDet();
	}

	/**
	 * Constructs a new GLn_Zm matrix using a given Grid, a known determinate, and inverse
	 * @param nums The given Grid for this GLn_Zm
	 * @param det The known determinate of this GLn_Zm
	 * @param inv The inverse of this GLn_Zm
	 */
	private GLn_Zm(Grid<ModInt_M> nums, ModInt_M det, GLn_Zm inv) {
		super(nums, det, inv);
	} //END GLn_Zm (constructor)

	/**
	 * Returns the transpose of this GLn_Zm
	 * @return The Transpose of this GLn_Zm
	 * @throws InvalidDimException Thrown if this GLn_Zm has invalid dimensions
	 * @throws InvalidDetException Thrown if this GLn_Zm has an invalid determinant
	 */
	public GLn_Zm getTranspose() throws InvalidDimException, InvalidDetException {
		return(new GLn_Zm(this.nums.transpose()));
	} //END getTranspose

	/**
	 * Returns the multiplicative inverse of this GLn_Zm
	 * @return The multiplicative inverse of this GLn_Zm
	 */
	@Override
	public GLn_Zm getInverse() {
		return inverse;
	} //END getInverse

	/**
	 * Returns an nxn identity matrix of ModInt_M integers
	 * @return An nxn identity matrix of ModInt_M integers
	 */
	@Override
	public GLn_Zm getIdentity() {
		Grid<ModInt_M> temp = this.getIdentityGrid();

		try {
			return new GLn_Zm(temp);
		}
		catch (Exception e){
			return null;
		}
	} //END getIdentity

	/**
	 * Returns an nxn grid for an identity matrix of ModInt_M integers
	 * @return An nxn grid for an identity matrix of ModInt_M integers
	 */
	@Override
	protected Grid<ModInt_M> getIdentityGrid() {
		Grid<ModInt_M> temp = new Grid<ModInt_M>(n,n);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				temp.set(i,j,
				(i == j) ? 	new ModInt_M(this.nums.get(0,0).getMultIdentity().getVal(), this.nums.get(0,0).getM()):
							new ModInt_M(this.nums.get(0,0).getAddIdentity().getVal(), this.nums.get(0,0).getM()));
			}
		}

		return temp;
	} //END getIdentityGrid

	/**
	 * Generates a random invertible Grid of ModInt_M with given size n
	 * @param n The given size for the random Grid
	 * @param z The given Z_M to
	 * @return A random invertible Grid of ModInt_M with size n
	 * @throws InvalidDimException Thrown if random Grid has invalid dimensions
	 * @throws InvalidDetException Thrown if random Grid has an invalid determinant
	 * @throws OutOfBoundsException Thrown if multiplication of triangular matrices is invalid
	 */
	private Grid<ModInt_M> genRandGrid(int n, Z_M z) throws InvalidDimException, InvalidDetException, OutOfBoundsException {
		GLn_Zm upper  = new GLn_Zm(getNonSingular(n,z));
		GLn_Zm lower  = new GLn_Zm(getNonSingular(n,z)).getTranspose();

		return(lower.multRRet(upper).asGrid());
	} //END genRandGrid

	/**
	 * Generates a random nonsingular matrix uniformly using a modified algorithm
	 * Algorithm credit: Dana Randall, Efficient Generation of Nonsingular Matrices,
	 * http://www.eecs.berkeley.edu/Pubs/TechRpts/1991/CSD-91-658.pdf
	 * @return A random nonsingular matrix of ModInt_M
	 */
	private Grid<ModInt_M> getNonSingular(int n, Z_M z) {
		//00 INITIALIZE MATRIX GRIDS
		Grid<ModInt_M> mtxA = new Grid<ModInt_M>(n, n);
		Grid<ModInt_M> mtxT = new Grid<ModInt_M>(n, n);
		Random rand = new Random();

		//01 GENERATE NONSINGULAR ENTRIES
		genNonSingular(mtxA, mtxT, n, n, z, rand);

		//02.1 INITIALIZE TEMPORARY GRID
		Grid<ModInt_M> temp = new Grid<ModInt_M>(n, n);
		initializeGrid(temp, new ModInt_M(z.getAddIdentity(),z));

		//02.2 MULTIPLY mtxA*mtxT
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				for (int k = 0; k < n; k++)
					temp.set( i, j, temp.get(i, j).add(mtxA.get(i,k).mult(mtxT.get(k,j))) );

		//03 RETURN NONSINGULAR MATRIX, THE PRODUCT A*T
		return temp;
	} //END getNonSingular

	/**
	 * Recursively generates a random nonsingular matrix uniformly using a modified algorithm
	 * Algorithm credit: Dana Randall, Efficient Generation of Nonsingular Matrices,
	 * http://www.eecs.berkeley.edu/Pubs/TechRpts/1991/CSD-91-658.pdf
	 * @param mtxA Matrix A
	 * @param mtxT Matrix T
	 * @param n	The size of this matrix minor
	 * @param rand A random number generator
	 */
	private void genNonSingular(Grid<ModInt_M> mtxA, Grid<ModInt_M> mtxT, int N, int n, Z_M z, Random rand) {
		if (n == 1) {
			int r = -1;

			//00.1 SET FINAL ENTRY OF mtxA TO THE MULTIPLICITIVE IDENTITY
			//	SET r AS COLUMN COORDINATE OF FINAL ENTRY OF mtxA
			for (int i = 0; i < N; i++) {
				if (mtxA.get(N-n, i) == null) {
					mtxA.set(N-n, i, new ModInt_M(z.getMultIdentity(), z));
					r = i;
				}
			}

			//00.2 SET FINAL ENTRY OF mtxT, IN THE rTH COLUMN, TO A RANDOM INVERTIBLE VALUE
			for (int i = 0; i < N; i++) {
				if (mtxT.get(i, r) == null) {
					mtxT.set(i, r, new ModInt_M(z.getMultSet().get(rand.nextInt(z.getMultSet().size())), z));
				}
			}
		} //END if (n == 1)

		else {
			int temp;
			int r = -1;
			ModInt_M[] v = new ModInt_M[n];

			//01.1	RANDOMIZE VECTOR v
			//	GET r, THE FIRST INVERTIBLE ENTRY'S COORDINATE
			//	IF NO INVERTIBLE ENTRY, TRY AGAIN
			while (r == -1) {
				for (int i = 0; i < n; i++) {
					temp = rand.nextInt(z.getM());
					r = (r == -1 && z.getMultSet().contains(temp)) ? i : r;
					v[i] = new ModInt_M(temp, z);
				}
			}

			//01.2 FIND CORRESPONDING COORDINATE FOR r, realR, WHICH INDICATES
			//	THE TRUE COLUMN COORDINATE AND NOT THE MINOR'S COORDINATE
			int realR = r;
			int skip = 0;
			for (int i = 0; i < N; i++) {
				if ( (i-skip <= r) && mtxA.get(N-n, i) != null) {
					realR++;
					skip++;
				}
			}

			//02.1 FILL THE FIRST EMPTRY ROW OF mtxA WITH e_r, THAT IS, SET ALL ENTRIES TO ZERO EXCEPT THE rTH
			skip = 0;
			for (int i = 0; i < n; i++) {
				while ( mtxA.get(N - n, i+skip) != null ) {
					skip++;
				}

				if (i == r)
					mtxA.set(N - n, i+skip, new ModInt_M(z.getMultIdentity(), z));
				else
					mtxA.set(N - n, i+skip, new ModInt_M(z.getAddIdentity(), z));
			}

			//02.2 FILL THE realRTH COLUMN OF mtxA WITH ZERO
			for (int i = 1; i < n; i++) {
				mtxA.set(i+N-n, realR, new ModInt_M(z.getAddIdentity(), z));
			}

			//03.1 FILL THE realRTH ROW OF mtxT WITH v
			skip = 0;
			for (int i = 0; i < n; i++) {
				while ( mtxT.get(realR, i+skip) != null ) {
					skip++;
				}

				mtxT.set(realR, i+skip, v[i]);
			}

			//03.2 FILL THE realRTH COLUMN of mtxT WITH THE ADDITIVE IDDENTITY
			skip = 0;
			for (int i = 0; i < n-1; i++) {
				while ( mtxT.get(i+skip, realR) != null ) {
					skip++;
				}
				mtxT.set(i+skip, realR, new ModInt_M(z.getAddIdentity(), z));
			}

			//04 RECURSE OVER NEXT MINOR
			genNonSingular(mtxA, mtxT, N, n-1, z, rand);
		} //END else (n == 1)
	} //END genNonSingular

} //END GLn_Zm


text:
package org.apache.accumulo.server.fs;

import java.io.IOException;
import java.util.Collection;
import java.util.Optional;

import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.volume.Volume;
import org.apache.accumulo.server.ServerConstants;
import org.apache.hadoop.fs.ContentSummary;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.Path;

/**
 * A wrapper around multiple hadoop FileSystem objects, which are assumed to be different volumes. This also concentrates a bunch of meta-operations like
 * waiting for SAFE_MODE, and closing WALs. N.B. implementations must be thread safe.
 */
public interface VolumeManager {

  public static enum FileType {
    TABLE(ServerConstants.TABLE_DIR), WAL(ServerConstants.WAL_DIR), RECOVERY(ServerConstants.RECOVERY_DIR);

    private String dir;

    FileType(String dir) {
      this.dir = dir;
    }

    public String getDirectory() {
      return dir;
    }

    private static int endOfVolumeIndex(String path, String dir) {
      // Strip off the suffix that starts with the FileType (e.g. tables, wal, etc)
      int dirIndex = path.indexOf('/' + dir);
      if (dirIndex != -1) {
        return dirIndex;
      }

      if (path.contains(":"))
        throw new IllegalArgumentException(path + " is absolute, but does not contain " + dir);
      return -1;

    }

    public Path getVolume(Path path) {
      String pathString = path.toString();

      int eopi = endOfVolumeIndex(pathString, dir);
      if (eopi != -1)
        return new Path(pathString.substring(0, eopi + 1));

      return null;
    }

    public Path removeVolume(Path path) {
      String pathString = path.toString();

      int eopi = endOfVolumeIndex(pathString, dir);
      if (eopi != -1)
        return new Path(pathString.substring(eopi + 1));

      return null;
    }
  }

  // close the underlying FileSystems
  void close() throws IOException;

  // forward to the appropriate FileSystem object
  FSDataOutputStream create(Path dest) throws IOException;

  // forward to the appropriate FileSystem object
  FSDataOutputStream create(Path path, boolean b) throws IOException;

  // forward to the appropriate FileSystem object
  FSDataOutputStream create(Path path, boolean b, int int1, short int2, long long1) throws IOException;

  // create a file, but only if it doesn't exist
  boolean createNewFile(Path writable) throws IOException;

  // create a file which can be sync'd to disk
  FSDataOutputStream createSyncable(Path logPath, int buffersize, short replication, long blockSize) throws IOException;

  // delete a file
  boolean delete(Path path) throws IOException;

  // delete a directory and anything under it
  boolean deleteRecursively(Path path) throws IOException;

  // forward to the appropriate FileSystem object
  boolean exists(Path path) throws IOException;

  // forward to the appropriate FileSystem object
  FileStatus getFileStatus(Path path) throws IOException;

  // find the appropriate FileSystem object given a path
  Volume getVolumeByPath(Path path);

  // return the item in options that is in the same volume as source
  Path matchingFileSystem(Path source, String[] options);

  // forward to the appropriate FileSystem object
  FileStatus[] listStatus(Path path) throws IOException;

  // forward to the appropriate FileSystem object
  boolean mkdirs(Path directory) throws IOException;

  // forward to the appropriate FileSystem object
  FSDataInputStream open(Path path) throws IOException;

  // forward to the appropriate FileSystem object, throws an exception if the paths are in different volumes
  boolean rename(Path path, Path newPath) throws IOException;

  // forward to the appropriate FileSystem object
  boolean moveToTrash(Path sourcePath) throws IOException;

  // forward to the appropriate FileSystem object
  short getDefaultReplication(Path logPath);

  // forward to the appropriate FileSystem object
  boolean isFile(Path path) throws IOException;

  // all volume are ready to provide service (not in SafeMode, for example)
  boolean isReady() throws IOException;

  // forward to the appropriate FileSystem object
  FileStatus[] globStatus(Path path) throws IOException;

  // Convert a file or directory metadata reference into a path
  Path getFullPath(Key key);

  Path getFullPath(String tableId, String path);

  // Given a filename, figure out the qualified path given multiple namespaces
  Path getFullPath(FileType fileType, String fileName) throws IOException;

  // forward to the appropriate FileSystem object
  ContentSummary getContentSummary(Path dir) throws IOException;

  // decide on which of the given locations to create a new file
  String choose(Optional<String> tableId, String[] options);

  /**
   * Fetch the default Volume
   */
  public Volume getDefaultVolume();

  /**
   * Fetch the configured Volumes, excluding the default Volume
   */
  public Collection<Volume> getVolumes();

}

redpajama_set_name: RedPajamaGithub


text:
import React from "react"
import CommentList from "./CommentList"
import CommentForm from "./CommentForm"

export default class CommentBox extends React.Component {
  constructor(props) {
    super(props)

    this.state = {
      data: []
    }
  }

  componentDidMount() {
    // Pull data from server.
  }

  handleCommentSubmit(comment) {
    var comments = this.state.data;
    var newComments = comments.concat([comment])
    this.setState({data: newComments})

    // Send data to server.
  }

  render() {
    return(

Comments

        <CommentForm onCommentSubmit={this.handleCommentSubmit.bind(this)} />
        <CommentList data={this.state.data} />

    )
  }
}


text:
<?php

declare(strict_types=1);

namespace Pnz\MattermostClient\Exception;

use Pnz\MattermostClient\Model\Error;
use Psr\Http\Message\ResponseInterface;

interface DomainException extends Exception
{
    public function getResponse(): ResponseInterface;

    /**
     * Returns the underlying Error, if available.
     */
    public function getError(): ?Error;
}


text:
{% load staticfiles i18n filters %}
<html>
    <head>
        <link rel="stylesheet" href="{% static 'css/enketo/plain.css' %}">

        <style>
            body {
                font-family: 'PT Sans', sans-serif;
                background-color: #f0f0f0;
                height: 100vh;
                margin: 0;
                padding: 0;
                display: grid;
                align-items: center;
                justify-content: center;
                color: #565656;
                font-size: 14px;
            }

            .form {
                width: 480px;
                background-color: #fff;
                padding: 16px 24px;
                border-radius: 5px;
            }

            form {
                width: 100%;
            }

            .submit-button {
                font-family: inherit;
                border: 0;
                background-color: #41d698;
                color: #fff;
                padding: 5px 12px;
                text-transform: uppercase;
                cursor: pointer;
                border-radius: 3px;
                box-shadow: 0 2px 10px -3px rgba(0, 0, 0, .5);
            }

            .submit-button:active {
                box-shadow: 0 1px 5px -2px rgba(0, 0, 0, .5);
            }
        </style>
    </head>
    <body>
        <div class="form">
            {{ html_form | safe }}
            <button class="submit-button" onClick="submit()">Submit</button>
        </div>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="{{STATIC_URL}}js/enketo-core.js"></script>
        <script>
            const formSelector = 'form.or:eq(0)';
            const data = {
                modelStr: '{{ model_str|escapejs|safe }}',
                instanceStr: {% if existing %}'{{ existing.instance.xml|escapejs|safe }}'{% else %}null{% endif %},
                submitted: false,
                external: [],
                session: {},
            };

            const csrfInput = $("{% csrf_token %}");
            const hiddenInput = $('<input type="hidden" name="enketo_xml_data">');

            const formElement = $(formSelector);
            hiddenInput.appendTo(formElement);
            csrfInput.appendTo(formElement);

            const form = new enketo.Form(formSelector, data, {});
            form.init();

            formElement.removeAttr('onsubmit')
                .attr('method', 'POST')
                .attr('enctype', 'multipart/form-data')
                .attr('encoding', 'multipart/form-data');

            function submit() {
                form.validate().then((valid) => {
                    if (valid) {
                        hiddenInput.val(form.getDataStr());
                        formElement.submit();
                    }
                    // TODO Alert with errors
                });
            }
        </script>
    </body>
</html>


text:
'use strict';

angular.module('spotmop.common.tracklist', [])

/**
 * Tracklist controller
 * This is the parent object for all lists of tracks (top tracks, queue, playlists, the works!)
 **/

.directive('tracklist', function( $compile ){
	return {
		restrict: 'E',
		templateUrl: 'app/common/tracklist/template.html',
		scope: {
			tracks: '=',		// = means to pass through an array/object
			type: '@',			// @ means to listen for a string
            limit: '@'
		},
		link: function( $scope, element, attrs ){
		},
		controller: function( $element, $scope, $filter, $rootScope, $stateParams, MopidyService, SpotifyService, DialogService, NotifyService, SettingsService, PlayerService, PlaylistManagerService ){

			// store our selected track uris
			$rootScope.selectedTrackURIs = [];

			function updateSelectedTracksArray(){

				var selectedTracks = $filter('filter')( $scope.tracks, {selected: true} );
				var selectedTracksUris = [];

				angular.forEach( selectedTracks, function(track){

					// if we have a nested track object (ie TlTrack objects)
					if( typeof(track.track) !== 'undefined' ) selectedTracksUris.push( track.track.uri );

					// nope, so let's use a non-nested version
					else selectedTracksUris.push( track.uri );
				});

				$rootScope.selectedTrackURIs = selectedTracksUris;
			}

			// prevent right-click menus
			$(document).contextmenu( function(evt){

				// only if clicking in a tracklist
				if( $(evt.target).closest('.tracklist').length > 0 )
					return false;
			});

            /**
             * Limits on tracklist display
             * This allows us to limit the number of tracks visible within this tracklist
             * Used on the QueueController to handle huge tracklists
             **/
            $scope.tracksWrapper = function(){
                if( $scope.limit && $scope.limit > 0 ){
                    return $filter('limitTo')($scope.tracks, parseInt($scope.limit));
                }else{
                    return $scope.tracks;
                }
            }

			/**
			 * Dragging a track
			 * This event is detected and $emitted from the track/tltrack directive
			 **/
			$scope.$on('spotmop:track:dragging', function( event ){

			});

			/**
			 * When the tracklist focus changes
			 * This is useful for when we have multiple tracklists in one state (ie My Albums)
			 * NOTE: We need to run as $rootScope otherwise we only ever listen to ourselves
			 **/
			var listenForFocusChange = $rootScope.$on('spotmop:tracklist:focusChanged', function( event, tracklistID ){

				$rootScope.tracklistInFocus = tracklistID;

				// if the focus has changed to a tracklist OTHER than me, I need to deselect all my tracks
				if( $scope.$id != tracklistID ){
					unselectAllTracks();
				}
			});

            // Clean up our $rootScope listeners when this $scope is destroyed (ie page navigation)
            // This is essential to avoid memory leaks and dirty listeners. Nobody likes dirty listeners.
            $scope.$on('$destroy', listenForFocusChange);

			/**
			 * Click on a single track
			 * This event is detected by the track/tltrack directive
			 * We have it within the tracklist directive so we have one place that this event is handled
			 **/
			$scope.trackClicked = function( $track ){

				// let all fellow tracklists the focus has changed to ME
				$rootScope.$broadcast('spotmop:tracklist:focusChanged', $scope.$id);

				// if we're in a drag event, then we don't do nothin'
				// this drag event will be handled by the 'candrag' directive
				if( !$rootScope.dragging ){

					// if ctrl key held down
					if( $rootScope.ctrlKeyHeld || $rootScope.isTouchMode() ){

						// toggle selection for this track
						if( $track.track.selected ){
							$track.$apply( function(){ $track.track.selected = false; });
						}else{
							$track.$apply( function(){ $track.track.selected = true; });
						}

					// if ctrl key not held down
					}else if( !$rootScope.ctrlKeyHeld ){

						// unselect all tracks
						angular.forEach( $scope.tracks, function(track){
							track.selected = false;
						});

						// and select only me
						// TODO: Figure out why this selects all instances of this object
						$track.$apply( function(){ $track.track.selected = true; });
					}

					// if shift key held down, select all tracks between this track, and the last clicked one
					if( $rootScope.shiftKeyHeld ){

						// make sure we have an existing selection to select from
						if( typeof($scope.lastSelectedTrack) === 'undefined' ){

							// nope? just select me and leave it at that
							$track.$apply( function(){ $track.track.selected = true; });
							return;
						}

						// figure out the limits of our selection (use the array's index)
						// assume last track clicked is the lower index value, to start with
						var firstTrackIndex = $scope.lastSelectedTrack.$index;
						var lastTrackIndex = $track.$index;

						// if we've selected a lower-indexed track, let's swap our limits accordingly
						if( $track.$index < firstTrackIndex ){
							firstTrackIndex = $track.$index;
							lastTrackIndex = $scope.lastSelectedTrack.$index;
						}

						// now loop through our subset limits, and make them all selected!
						for( var i = firstTrackIndex; i <= lastTrackIndex; i++ ){
							$scope.tracks[i].selected = true;
						};

						// tell our templates to re-read the arrays
						$scope.$apply();
					}

					// save this item to our last-clicked (used for shift-click)
					$scope.lastSelectedTrack = $track;

					/**
					 * Hide/show mobile version of the context menu
					 **/
					if( $rootScope.isTouchMode() ){
						if( $filter('filter')($scope.tracks, {selected: true}).length > 0 )
							$rootScope.$broadcast('spotmop:touchContextMenu:show', $scope.type );
						else
							$rootScope.$broadcast('spotmop:contextMenu:hide' );
					}

					// store our updated selected track uris
					updateSelectedTracksArray();
				}
			};

			/**
			 * Selected Tracks >> Add to queue
			 **/
			$scope.$on('spotmop:tracklist:enqueueSelectedTracks', function(event, playNext){

				// ignore if we're not the tracklist in focus
				if( $rootScope.tracklistInFocus !== $scope.$id )
					return;

				var atPosition = null;

				// if we're adding these tracks to play next
				if( typeof( playNext ) !== 'undefined' && playNext == true ){
					atPosition = PlayerService.state().currentTracklistPosition();
				}

				var selectedTracks = $filter('filter')( $scope.tracks, {selected: true} );
				var selectedTracksUris = [];

				angular.forEach( selectedTracks, function( track ){
					selectedTracksUris.push( track.uri );
				});

				var message = 'Adding '+selectedTracks.length+' tracks to queue';
				if( selectedTracks.length > 10 )
					message += '... this could take some time';

				NotifyService.notify( message );

				MopidyService.addToTrackList( selectedTracksUris, atPosition );
			});

			/**
			 * Selected Tracks >> Play
			 **/

			// listeners
			$scope.$on('spotmop:tracklist:playSelectedTracks', function(){ playSelectedTracks() });
			$scope.$on('spotmop:keyboardShortcut:enter', function(){ playSelectedTracks() });

			// the actual behavior
			function playSelectedTracks(){

				// ignore if we're not the tracklist in focus
				if( $rootScope.tracklistInFocus !== $scope.$id )
					return;

				// if we're in radio mode, turn it off
				if( PlayerService.state().radio.enabled ){
					PlayerService.stopRadio();
					NotifyService.notify("Stopping radio");
				}

				var selectedTracks = $filter('filter')( $scope.tracks, {selected: true} );
				var firstSelectedTrack = selectedTracks[0];

				// depending on context, make the selected track(s) play
				// queue
				if( $scope.type == 'tltrack'){

					// get the queue's tracks
					// we need to re-get the queue because at this point some tracks may not have tlids
					// TODO: simplify this and get the tracklist with a filter applied, by tlid. This will remove the need for fetching the whole tracklist, but I suspect the performance gain from this will be negligible
					MopidyService.getCurrentTlTracks().then( function( tracklist ){

						// find our double-clicked track in the tracklist
						$.each( tracklist, function(key, track){
							if( track.tlid == firstSelectedTrack.tlid ){

								// then play our track
								return MopidyService.playTlTrack({ tl_track: track });
							}
						});
					});

				// generic tracklist (playlist, top-tracks, album, etc)
				}else{

					// build an array of track uris (and subtract the first one, as we play him immediately)
					var selectedTracksUris = [];
					for( var i = 0; i < selectedTracks.length; i++ ){
						selectedTracksUris.push( selectedTracks[i].uri );
					};

					var message = 'Adding '+selectedTracks.length+' tracks to queue';
					if( selectedTracks.length > 10 )
						message += '... this could take some time';

					NotifyService.notify( message );

					MopidyService.playTrack(
						selectedTracksUris,
						0,
						PlayerService.state().currentTracklistPosition()
					);
				}
			}

			/**
			 * Selected Tracks >> Delete from queue (aka unqueue)
			 **/
			$scope.$on('spotmop:tracklist:unqueueSelectedTracks', function(event){

				// ignore if we're not the tracklist in focus
				if( $rootScope.tracklistInFocus !== $scope.$id )
					return;

				var selectedTracks = $filter('filter')( $scope.tracks, {selected: true} );
				var selectedTracksTlids = [];

				angular.forEach( selectedTracks, function( track ){
					selectedTracksTlids.push( track.tlid );
				});

				MopidyService.removeFromTrackList( selectedTracksTlids );
			});

			/**
			 * Selected Tracks >> Add to playlist via dialog
			 **/
			$scope.$on('spotmop:tracklist:addSelectedTracksToPlaylist', function(event){

				// ignore if we're not the tracklist in focus
				if( $rootScope.tracklistInFocus !== $scope.$id )
					return;

				var selectedTracks = $filter('filter')( $scope.tracks, {selected: true} );
				var selectedTracksUris = [];

				angular.forEach( selectedTracks, function(track){
					selectedTracksUris.push( track.uri );
				});

				DialogService.create('addToPlaylist', $scope);
			});

            /**
             * Selected Tracks >> Add to playlist immediately
             **/
            $scope.$on('spotmop:tracklist:addSelectedTracksToPlaylistByUri', function(event, uri){

				// ignore if we're not the tracklist in focus
				if( $rootScope.tracklistInFocus !== $scope.$id ) return;

                var tracks = $filter('filter')( $scope.tracks, {selected: true} );
                var trackUris = [];

				// Loop all our selected tracks to build a uri array
                angular.forEach( tracks, function(track){
					trackUris.push( track.uri );
                });

				PlaylistManagerService.addTracksToPlaylist(uri, trackUris);
            });

			/**
			 * Misc other tracklist events
			 **/

			$scope.$on('spotmop:tracklist:startRadio', function(event){

				var selectedTracks = $filter('filter')( $scope.tracks, {selected: true} );
				var selectedTracksUris = [];

				angular.forEach( selectedTracks, function(track){

					// if we have a nested track object (ie TlTrack objects)
					if( typeof(track.track) !== 'undefined' ) selectedTracksUris.push( track.track.uri );

					// nope, so let's use a non-nested version
					else selectedTracksUris.push( track.uri );
				});

				NotifyService.notify('Starting track radio');

				PlayerService.startRadio( selectedTracksUris );
			});

			/**
			 * Selected Tracks >> Add to library
			 * TODO: Disallow non-spotify tracks
			 **/
			$scope.$on('spotmop:tracklist:addSelectedTracksToLibrary', function(event){

				// ignore if we're not the tracklist in focus
				if( $rootScope.tracklistInFocus !== $scope.$id ) return;

				var selectedTracks = $filter('filter')( $scope.tracks, {selected: true} );
				var selectedTracksUris = [];

				angular.forEach( selectedTracks, function(track){
					selectedTracksUris.push( SpotifyService.getFromUri('trackid', track.uri) );
				});

				// tell spotify to go'on get
				SpotifyService.addTracksToLibrary( selectedTracksUris );
			});

			/**
			 * Manipulate selected tracks
			 **/

			$scope.$on('spotmop:tracklist:selectAll', function(event){
				unselectAllTracks();
			});
			$scope.$on('spotmop:tracklist:unselectAll', function(event){
				unselectAllTracks();
			});
			function unselectAllTracks(){
				angular.forEach( $scope.tracks, function( track ){
					track.selected = false;
				});
			}

			/**
			 * Misc other tracklist events
			 **/

			$scope.$on('spotmop:tracklist:copyURIsToClipboard', function(event){

				var selectedTracks = $filter('filter')( $scope.tracks, {selected: true} );
				var selectedTracksUris = '';

				angular.forEach( selectedTracks, function(track){

					if( selectedTracksUris != '' ) selectedTracksUris += ',';

					// if we have a nested track object (ie TlTrack objects)
					if( typeof(track.track) !== 'undefined' ) selectedTracksUris += track.track.uri;

					// nope, so let's use a non-nested version
					else selectedTracksUris += track.uri;
				});

				console.log( selectedTracksUris );
			});
		}
	}
});


text:
var n = 15;

console.log (n.toLocaleString());
console.log (Object.prototype.toLocaleString.call(n));


text:
package jp.ac.tsukuba.cs.conclave.utils;

import java.util.Random;

/**
 * Mathematical Utilities that I haven't found easily elsewhere
 *
 * @author Claus Aranha (caranha@cs.tsukuba.ac.jp)
 *
 */
public class MathUtils {

	static public double deviation(Double[] doubles)
	{
		double ret = 0;
		double mean = 0;

		for (int i = 0; i < doubles.length; i++)
			mean += doubles[i];
		mean = mean/doubles.length;

		for (int i = 0; i < doubles.length; i++)
			ret = ret + Math.pow((mean - doubles[i]),2);
		ret = ret/(doubles.length-1);

		return Math.sqrt(ret);
	}

	/**
	 * Algorithm based on the random generation of Poissonian numbers,
	 * based on Knuth and Numerical Recipes (7.3.12).
	 *
	 * In the sources above, prob is actually a uniform random number
	 * between 0-1, sampled each iteration. I have to make sure that
	 * my alteration for a fixed value (to replace gene values) is
	 * correct...
	 *
	 * @param lambda
	 * @return
	 */
	static public int getPoisson(double prob, double lambda)
	{
		double L = Math.exp(-lambda);
		int k = 0;
		double p = 1;

		do {
			k++;
			p = p*prob;
		} while (p > L);

		// The original algorithm has k-1. We remove the -1 to guarantee
		// at least 1 event for every bin.
		return k;
	}

	static public int getRandomPoisson(Random dice, double mu)
	{
		double L = Math.exp(-mu);
		int k = 0;
		double p = 1;

		do {
			k++;
			p = p*dice.nextDouble();
		} while (p > L);

		// The original algorithm has k-1. We remove the -1 to guarantee
		// at least 1 event for every bin.
		return k -1;
	}

}


text:
The `Date` API is full of
[major design flaws and pitfalls](https://codeblog.jonskeet.uk/2017/04/23/all-about-java-util-date/)
and should be avoided at all costs. Prefer the `java.time` APIs, specifically,
`java.time.Instant` (for physical time) and `java.time.LocalDate[Time]` (for
civil time).


text:
class V1::PermissionController < ApplicationController
  def ownership(project)
    if current_user&.user&.confirmed
      return {
        mine: user_id == project.user.id,
        may_edit: project.collaboration.map(&:user_id).include?(user_id) || user_id == project.user_id
      }
    else
      return {
        is_mine: false,
        may_edit: false
      }
    end
  end

  private

  def user_id
    current_user ? current_user.user.id : false
  end

  def user
    return current_user ? current_user.user : false
  end
end


text:
#include "c.h"

#if defined(__hpux)

/* System includes */
#include <a.out.h>
#include <dl.h>

void *
dlopen(const char *file, int mode)
{
	int			flags = 0;

	if (mode & RTLD_NOW)
		flags |= BIND_IMMEDIATE;
#ifdef NOT_USED
	if (mode & RTLD_LAZY)
		flags |= BIND_DEFERRED;
#endif

	return shl_load(file, flags | BIND_VERBOSE, 0L);
}

void *
dlsym(void *handle, const char *symbol)
{
	void	   *value;

	if (shl_findsym((shl_t *) & handle, symbol, TYPE_PROCEDURE, &value) == -1)
		return NULL;
	return value;
}

int
dlclose(void *handle)
{
	return shl_unload((shl_t) handle);
}

char *
dlerror(void)
{
	static char errmsg[] = "shl_load failed";

	if (errno)
		return strerror(errno);

	return errmsg;
}

#elif defined(WIN32)

static char last_dyn_error[512];

static void
set_dl_error(void)
{
	DWORD		err = GetLastError();

	if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
					  FORMAT_MESSAGE_FROM_SYSTEM,
					  NULL,
					  err,
					  MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
					  last_dyn_error,
					  sizeof(last_dyn_error) - 1,
					  NULL) == 0)
	{
		snprintf(last_dyn_error, sizeof(last_dyn_error) - 1,
				 "unknown error %lu", err);
	}
}

char *
dlerror(void)
{
	if (last_dyn_error[0])
		return last_dyn_error;
	else
		return NULL;
}

int
dlclose(void *handle)
{
	if (!FreeLibrary((HMODULE) handle))
	{
		set_dl_error();
		return 1;
	}
	last_dyn_error[0] = 0;
	return 0;
}

void *
dlsym(void *handle, const char *symbol)
{
	void	   *ptr;

	ptr = GetProcAddress((HMODULE) handle, symbol);
	if (!ptr)
	{
		set_dl_error();
		return NULL;
	}
	last_dyn_error[0] = 0;
	return ptr;
}

void *
dlopen(const char *file, int mode)
{
	HMODULE		h;
	int			prevmode;

	/* Disable popup error messages when loading DLLs */
	prevmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
	h = LoadLibrary(file);
	SetErrorMode(prevmode);

	if (!h)
	{
		set_dl_error();
		return NULL;
	}
	last_dyn_error[0] = 0;
	return (void *) h;
}

#endif


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>IRowCacheEntry (apache-cassandra API)</title>
<meta name="date" content="2016-04-28">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

org.apache.cassandra.cache

Interface IRowCacheEntry

All Known Implementing Classes:

ArrayBackedSortedColumns, AtomicBTreeColumns, ColumnFamily, RowCacheSentinel

public interface IRowCacheEntry

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

Copyright © 2016 The Apache Software Foundation


text:
using System.Runtime.InteropServices;
using Xunit;
using System.Linq;

namespace System.IO.Tests
{
    public class Directory_GetFileSystemEntries_str_str : Directory_GetFileSystemEntries_str
    {
        #region Utilities

        public override string[] GetEntries(string dirName)
        {
            return Directory.GetFileSystemEntries(dirName, "*");
        }

        public virtual string[] GetEntries(string dirName, string searchPattern)
        {
            return Directory.GetFileSystemEntries(dirName, searchPattern);
        }

        #endregion

        #region UniversalTests

        [Fact]
        public void SearchPatternNull()
        {
            Assert.Throws<ArgumentNullException>(() => GetEntries(TestDirectory, null));
        }

        [Fact]
        public void SearchPatternEmpty()
        {
            // To avoid OS differences we have decided not to throw an argument exception when empty
            // string passed. But we should return 0 items.
            Assert.Empty(GetEntries(TestDirectory, string.Empty));
        }

        [Fact]
        public void SearchPatternValid()
        {
            Assert.Empty(GetEntries(TestDirectory, "a..b abc..d")); //Should not throw
        }

        [Fact]
        public void SearchPatternDotIsStar()
        {
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
            testDir.CreateSubdirectory("TestDir1");
            testDir.CreateSubdirectory("TestDir2");
            using (File.Create(Path.Combine(testDir.FullName, "TestFile1")))
            using (File.Create(Path.Combine(testDir.FullName, "TestFile2")))
            {
                string[] strArr = GetEntries(testDir.FullName, ".");
                if (TestFiles)
                {
                    Assert.Contains(Path.Combine(testDir.FullName, "TestFile1"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "TestFile2"), strArr);
                }
                if (TestDirectories)
                {
                    Assert.Contains(Path.Combine(testDir.FullName, "TestDir1"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "TestDir2"), strArr);
                }
            }
        }

        [Fact]
        public void SearchPatternWithTrailingStar()
        {
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
            testDir.CreateSubdirectory("TestDir1");
            testDir.CreateSubdirectory("TestDir2");
            testDir.CreateSubdirectory("TestDir3");
            using (File.Create(Path.Combine(testDir.FullName, "TestFile1")))
            using (File.Create(Path.Combine(testDir.FullName, "TestFile2")))
            using (File.Create(Path.Combine(testDir.FullName, "Test1File2")))
            using (File.Create(Path.Combine(testDir.FullName, "Test1Dir2")))
            {
                string[] strArr = GetEntries(testDir.FullName, "Test1*");
                if (TestFiles)
                {
                    Assert.Contains(Path.Combine(testDir.FullName, "Test1File2"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "Test1Dir2"), strArr);
                }

                strArr = GetEntries(testDir.FullName, "*");
                if (TestFiles)
                {
                    Assert.Contains(Path.Combine(testDir.FullName, "TestFile1"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "TestFile2"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "Test1File2"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "Test1Dir2"), strArr);
                }
                if (TestDirectories)
                {
                    Assert.Contains(Path.Combine(testDir.FullName, "TestDir1"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "TestDir2"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "TestDir3"), strArr);
                }
            }
        }

        [Fact]
        public void SearchPatternWithLeadingStar()
        {
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
            testDir.CreateSubdirectory("TestDir1");
            testDir.CreateSubdirectory("TestDir2");
            testDir.CreateSubdirectory("TestDir3");
            using (File.Create(Path.Combine(testDir.FullName, "TestFile1")))
            using (File.Create(Path.Combine(testDir.FullName, "TestFile2")))
            using (File.Create(Path.Combine(testDir.FullName, "Test1File2")))
            using (File.Create(Path.Combine(testDir.FullName, "Test1Dir2")))
            {
                string[] strArr = GetEntries(testDir.FullName, "*2");
                if (TestFiles)
                {
                    Assert.Contains(Path.Combine(testDir.FullName, "Test1Dir2"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "Test1File2"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "TestFile2"), strArr);
                }
                if (TestDirectories)
                {
                    Assert.Contains(Path.Combine(testDir.FullName, "TestDir2"), strArr);
                }

                strArr = GetEntries(testDir.FullName, "*Dir*");
                if (TestFiles)
                {
                    Assert.Contains(Path.Combine(testDir.FullName, "Test1Dir2"), strArr);
                }
                if (TestDirectories)
                {
                    Assert.Contains(Path.Combine(testDir.FullName, "TestDir1"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "TestDir2"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "TestDir3"), strArr);
                }
            }
        }

        [Fact]
        public void SearchPatternByExtension()
        {
            if (TestFiles)
            {
                DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
                using (File.Create(Path.Combine(testDir.FullName, "TestFile1.txt")))
                using (File.Create(Path.Combine(testDir.FullName, "TestFile2.xxt")))
                using (File.Create(Path.Combine(testDir.FullName, "Test1File2.txt")))
                using (File.Create(Path.Combine(testDir.FullName, "Test1Dir2.txx")))
                {
                    string[] strArr = GetEntries(testDir.FullName, "*.txt");
                    Assert.Equal(2, strArr.Length);
                    Assert.Contains(Path.Combine(testDir.FullName, "TestFile1.txt"), strArr);
                    Assert.Contains(Path.Combine(testDir.FullName, "Test1File2.txt"), strArr);
                }
            }
        }

        [Fact]
        public void SearchPatternExactMatch()
        {
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
            Directory.CreateDirectory(Path.Combine(testDir.FullName, "AAA"));
            Directory.CreateDirectory(Path.Combine(testDir.FullName, "AAAB"));
            Directory.CreateDirectory(Path.Combine(testDir.FullName, "CAAA"));
            using (File.Create(Path.Combine(testDir.FullName, "AAABB")))
            using (File.Create(Path.Combine(testDir.FullName, "AAABBC")))
            using (File.Create(Path.Combine(testDir.FullName, "CAAABB")))
            {
                if (TestFiles)
                {
                    string[] results = GetEntries(testDir.FullName, "AAABB");
                    Assert.Equal(1, results.Length);
                    Assert.Contains(Path.Combine(testDir.FullName, "AAABB"), results);
                }
                if (TestDirectories)
                {
                    string[] results = GetEntries(testDir.FullName, "AAA");
                    Assert.Equal(1, results.Length);
                    Assert.Contains(Path.Combine(testDir.FullName, "AAA"), results);
                }
            }
        }

        [Fact]
        public void SearchPatternIgnoreSubDirectories()
        {
            //Shouldn't get files on full path by default
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
            Directory.CreateDirectory(Path.Combine(testDir.FullName, GetTestFileName()));
            using (File.Create(Path.Combine(testDir.FullName, GetTestFileName())))
            using (File.Create(Path.Combine(TestDirectory, GetTestFileName())))
            {
                string[] results = GetEntries(TestDirectory, Path.Combine(testDir.Name, "*"));
                if (TestDirectories && TestFiles)
                    Assert.Equal(2, results.Length);
                else
                    Assert.Equal(1, results.Length);
            }
        }

        [Theory,
            // '[' should not matter, but is special to Unix matching APIs
            InlineData(
                "[foo]",
                new string[] { @"f", @"o", @"o", @"foo", @"[foo]" },
                new string[] { @"[foo]" }),
            ]
        public void PatternTests_UnixPatterns(string pattern, string[] sourceFiles, string[] expected)
        {
            string testDir = PrepareDirectory(sourceFiles);
            ValidatePatternMatch(expected, GetEntries(testDir, pattern));
        }

        [ActiveIssue(20779, TestPlatforms.AnyUnix)]
        [Theory,
            // Question marks collapse (right) to periods
            InlineData(
                "f???.txt",
                new string[] { @"f.txt", @"foo.txt", @"foob.txt", @"fooba.txt", @"foobar.txt" },
                new string[] { @"f.txt", @"foo.txt", @"foob.txt" }),
            // Question marks don't collapse to !periods
            InlineData(
                "???b??.txt",
                new string[] { @"f.txt", @"foo.txt", @"foob.txt", @"fooba.txt", @"foobar.txt" },
                new string[] { @"foob.txt", @"fooba.txt", @"foobar.txt" }),
            // Question marks collapse (right) to end
            InlineData(
                "foo.t??",
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo.t", @"foo.tx", @"foo.txt" }),
            ]
        public void PatternTests_DosQM(string pattern, string[] sourceFiles, string[] expected)
        {
            // Question marks always collapse right to periods or the end of the string if they are contiguous
            string testDir = PrepareDirectory(sourceFiles);
            ValidatePatternMatch(expected, GetEntries(testDir, pattern));
        }

        [ActiveIssue(20779, TestPlatforms.AnyUnix)]
        [ActiveIssue(20780, TestPlatforms.AnyUnix)]
        [Theory,
            // Periods are optional if left of ? and end of match
            InlineData(
                "foo.???",
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt" }),
            // Periods are optional if left of ? and end of match
            InlineData(
                "foo.???.?.?.?",
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt" }),
            // Periods are optional if left of ? and end of match
            InlineData(
                "foo.?.??.???.?",
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.t" }),
            // Periods are optional if left of ? and end of match
            InlineData(
                "foo.??.???.?",
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.t", @"foo.tx" }),
            // Periods are optional if left of * and end of match, question marks collapse (right) to end
            InlineData(
                "foo.*??",
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"foo.txxt" }),
            // Periods are optional if left of * and end of match, question marks collapse (right) to end
            InlineData(
                "foo.*??*",
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"foo.txxt" })
                ]
        public void PatternTests_DosDotQm(string pattern, string[] sourceFiles, string[] expected)
        {
            // Tests for collapsing question marks and DOS_DOT, ", which is what periods get changed to when they are followed by a '?' or '*'.
            string testDir = PrepareDirectory(sourceFiles);
            ValidatePatternMatch(expected, GetEntries(testDir, pattern));
        }

        [ActiveIssue(20780, TestPlatforms.AnyUnix)]
        [Theory,
            // Periods are optional if left of * and end of match
            InlineData(
                "foo.*",
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"foo.txxt" }),
            // Periods are optional if left of * and end of match
            InlineData(
                "foo.*.*.*.*",
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.t", @"foo.tx", @"foo.txt", @"foo.txxt" })
            ]
        public void PatternTests_DosDot(string pattern, string[] sourceFiles, string[] expected)
        {
            // Tests for DOS_DOT, ", which is what periods get changed to when they are followed by a '?' or '*'.
            string testDir = PrepareDirectory(sourceFiles);
            ValidatePatternMatch(expected, GetEntries(testDir, pattern));
        }

        [ActiveIssue(20780, TestPlatforms.AnyUnix)]
        // Can't do these without extended path support on Windows, UsingNewNormalization filters appropriately
        [ConditionalTheory(nameof(UsingNewNormalization)),
            // Periods are optional if left of * or ? and end of match
            InlineData(
                "foo.*",
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx", @"foo.txt", @"foo.txxt" }),
            InlineData(
                "foo.*.*",
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx", @"foo.txt", @"foo.txxt" }),
            InlineData(
                "foo.?",
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.", @"foo.t" }),
            InlineData(
                "foo.??",
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx" }),
            InlineData(
                "foo.?.?",
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.", @"foo.t" }),
            InlineData(
                "foo.??.??",
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx" }),
            InlineData(
                "foo.?.*",
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.", @"foo.t" }),
            InlineData(
                "foo.??.*",
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo.txxt" },
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx" }),
            ]
        public void PatternTests_DosDotTrailingDot(string pattern, string[] sourceFiles, string[] expected)
        {
            // Tests for DOS_DOT, ", which is what periods get changed to when they are followed by a '?' or '*'.
            // We don't want to eat trailing space/periods in this test
            string testDir = PrepareDirectory(sourceFiles, useExtendedPaths: true);
            ValidatePatternMatch(expected, GetEntries(testDir, pattern));
        }

        [ActiveIssue(20781, TestPlatforms.AnyUnix)]
        [Theory,
            InlineData(
                "foo*.",
                new string[] { @"foo", @"foobar", @"foo.bar" },
                new string[] { @"foo", @"foobar" })
                ]
        public void PatternTests_DosStar(string pattern, string[] sourceFiles, string[] expected)
        {
            // Tests for DOS_STAR, which only occurs when the source pattern ends in *.
            string testDir = PrepareDirectory(sourceFiles);
            ValidatePatternMatch(expected, GetEntries(testDir, pattern));
        }

        [ActiveIssue(20781, TestPlatforms.AnyUnix)]
        // Can't do these without extended path support on Windows, UsingNewNormalization filters appropriately
        [ConditionalTheory(nameof(UsingNewNormalization)),
            InlineData(
                "foo*.",
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo..", @"foo...", @"foo .", @"foo. . .", @"foo. t" },
                new string[] { @"foo", @"foo .", @"foo.", @"foo..", @"foo...", @"foo. . ." }),
            InlineData(
                "foodies*.",
                new string[] { @"foodies.", @"foodies. ", @"foodies.  " },
                new string[] { @"foodies." }),
            InlineData(
                "foodies*.",
                new string[] { @"foodies. ", @"foodies.  ", @"foodies.   " },
                new string[] { }),
            InlineData(
                "foooooo*.",
                new string[] { @"foooooo.", @"foooooo. ", @"foooooo.  " },
                new string[] { @"foooooo." }),
            InlineData(
                "foooooo*.",
                new string[] { @"foooooo. ", @"foooooo.  ", @"foooooo.   " },
                new string[] { }),
            InlineData(
                "foodies*.",
                new string[] { @"foodies.", @"foodies. ", @"foodies.  ", @"foodies.   ", @"foodies.    ", @"foodies.     " },
                new string[] { @"foodies." }),
            InlineData(
                "foodies*.",
                new string[] { @"foodies. ", @"foodies.  ", @"foodies.   ", @"foodies.    ", @"foodies.     " },
                new string[] { }),
            InlineData(
                "foo*.",
                new string[] { @"foo..", @"foo...", @"foo....", @"foo.....", @"foo......" },
                new string[] { @"foo..", @"foo...", @"foo....", @"foo.....", @"foo......" }),
            ]
        public void PatternTests_DosStarSpace(string pattern, string[] sourceFiles, string[] expected)
        {
            // Tests for DOS_STAR, which only occurs when the source pattern ends in *. These are the subset of tests
            // with trailing spaces that work as documented.

            // We don't want to eat trailing space/periods in this test
            string testDir = PrepareDirectory(sourceFiles, useExtendedPaths: true);
            ValidatePatternMatch(expected, GetEntries(testDir, pattern));
        }

        [ActiveIssue(20781, TestPlatforms.AnyUnix)]
        [OuterLoop("These are pretty corner, don't need to run all the time.")]
        // Can't do these without extended path support on Windows, UsingNewNormalization filters appropriately
        [ConditionalTheory(nameof(UsingNewNormalization)),
            // "foo*." actually becomes "foo<" when passed to NT. It matches all characters up to, and including, the final period.
            //
            // There is a "bug" somewhere in the Windows stack where *some* files with trailing spaces after the final period will be returned when
            // using "*." at the end of a string (which becomes "<"). According to the rules (and the actual pattern matcher used FsRtlIsNameInExpression)
            // *nothing* should match after the final period.
            //
            // The results as passed to RtlIsNameInExpression (after changing *. to <) are in comments.
            InlineData(
                "foo*.",
                new string[] { @"foo", @"foo.", @"foo.t", @"foo.tx", @"foo.txt", @"bar.txt", @"foo..", @"foo...", @"foo. ", @"foo.  ", @"foo .", @"foo. . .", @"foo. t" },
                // Really should be: new string[] { @"foo", @"foo.", @"foo..", @"foo...", @"foo .", @"foo. . ." }), but is
                new string[] { @"foo", @"foo .", @"foo.", @"foo..", @"foo...", @"foo. ", @"foo. . ." }),
            InlineData(
                "*.",
                new string[] { @"foo. ", @"foo.  ", @"foo..", @"foo. t" },
                // Really should be: new string[] { @"foo.." }), but is
                new string[] { @"foo. ", @"foo.  ", @"foo.." }),
            InlineData(
                "f*.",
                new string[] { @"foo. ", @"foo.  ", @"foo..", @"foo. t" },
                // Really should be: new string[] { @"foo.." }), but is
                new string[] { @"foo. ", @"foo.  ", @"foo.." }),
            InlineData(
                "fo*.",
                new string[] { @"foo. ", @"foo.  ", @"foo..", @"foo. t" },
                // Really should be: new string[] { @"foo.." }), but is
                new string[] { @"foo. ", @"foo.  ", @"foo.." }),
            InlineData(
                "foo*.",
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo.    " },
                // Really should be: new string[] { }), but is
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo.    " }),
            InlineData(
                "foo*.",
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo." },
                // Really should be: new string[] { @"foo." }), but is
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo." }),
            InlineData(
                "foo*.",
                new string[] { @"foo.", @"foo. ", @"foo.  ", @"foo.   ", @"foo.    " },
                // Really should be: new string[] { @"foo." }), but is
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo." }),
            InlineData(
                "foo*.",
                new string[] { @"foo.", @"foo", @"foo. ", @"foo.  ", @"foo.   ", @"foo.    " },
                // Really should be: new string[] { @"foo.", @"foo" }), but is
                new string[] { @"foo.", @"foo", @"foo.  ", @"foo.   ", @"foo. " }),
            InlineData(
                "foo*.",
                new string[] { @"foo.", @"foo. ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo" },
                // Really should be: new string[] { @"foo.", @"foo" }), but is
                new string[] { @"foo.", @"foo", @"foo.  ", @"foo.   ", @"foo. " }),
            InlineData(
                "foo*.",
                new string[] { @"foo.    ", @"foo", @"foo.", @"foo. ", @"foo.  ", @"foo.   " },
                // Really should be: new string[] { @"foo.", @"foo" }), but is
                new string[] { @"foo.", @"foo", @"foo.  ", @"foo.    ", @"foo. " }),
            InlineData(
                "foo*.",
                new string[] { @"foo.    ", @"foo", @"food", @"foo.", @"foo. ", @"foo.  ", @"foo.   " },
                // Really should be: new string[] { @"foo.", @"foo", @"food" }), but is
                new string[] { @"foo.", @"foo", @"foo.  ", @"foo.    ", @"foo. ", @"food" }),
            InlineData(
                "fo*.",
                new string[] { @"foo.", @"foo. ", @"foo.  ", @"foo.   ", @"foo.    " },
                // Really should be: new string[] { @"foo." }), but is
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo.", @"foo.    " }),
            InlineData(
                "foo*.",
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo.     " },
                // Really should be: new string[] { }), but is
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo.    " }),
            InlineData(
                "foo*.",
                new string[] { @"foo. ", @"foo. .", @"foo. . ", @"foo. . .", @"foo. . . " },
                // Really should be: new string[] { @"foo. .", @"foo. . ." }), but is
                new string[] { @"foo. ", @"foo. .", @"foo. . ", @"foo. . ." }),
            InlineData(
                "foo*.",
                new string[] { @"foo. ", @"foo. .", @"foo.. .", @"foo.... .", @"foo..... ." },
                // Really should be: new string[] { @"foo. .", @"foo.. .", @"foo.... .", @"foo..... ." }), but is
                new string[] { @"foo. ", @"foo. .", @"foo.. .", @"foo.... .", @"foo..... ." }),
            InlineData(
                "fo*.",
                new string[] { @"foo. ", @"foo. .", @"foo. . ", @"foo. . .", @"foo. . . " },
                // Really should be: new string[] { @"foo. .", @"foo. . ."}), but is
                new string[] { @"foo. ", @"foo. .", @"foo. . ", @"foo. . .", @"foo. . . " }),
            InlineData(
                "foo*.",
                new string[] { @"foo.", @"foo. ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo.     " },
                // Really should be: new string[] { @"foo." }), but is
                new string[] { @"foo.", @"foo. ", @"foo.  ", @"foo.   " }),
            InlineData(
                "food*.",
                new string[] { @"food.", @"food. ", @"food.  ", @"food.   ", @"food.    ", @"food.     " },
                // Really should be: new string[] { @"food." }), but is
                new string[] { @"food.", @"food. ", @"food.  ", @"food.   " }),
            InlineData(
                "food*.",
                new string[] { @"food.", @"food. ", @"food.  ", @"food.   ", @"food.    ", @"food.     ", @"foodi." },
                // Really should be: new string[] { @"food.", @"foodi." }), but is
                new string[] { @"food.", @"food. ", @"food.  ", @"food.   ", @"foodi." }),
            InlineData(
                "foodi*.",
                new string[] { @"foodi.", @"foodi. ", @"foodi.  ", @"foodi.   ", @"foodi.    ", @"foodi.     " },
                // Really should be: new string[] { @"foodi." }), but is
                new string[] { @"foodi.", @"foodi. ", @"foodi.  ", @"foodi.   " }),
            InlineData(
                "foodie*.",
                new string[] { @"foodie.", @"foodie. ", @"foodie.  ", @"foodie.   ", @"foodie.    ", @"foodie.     " },
                // Really should be: new string[] { @"foodie." }), but is
                new string[] { @"foodie.", @"foodie. ", @"foodie.  ", @"foodie.   " }),
            InlineData(
                "fooooo*.",
                new string[] { @"foooooo.", @"foooooo. ", @"foooooo.  " },
                // Really should be: new string[] { @"foooooo." }), but is
                new string[] { @"foooooo.", @"foooooo. ", @"foooooo.  " }),
            InlineData(
                "fooooo*.",
                new string[] { @"foooooo. ", @"foooooo.  ", @"foooooo.   " },
                // Really should be: new string[] { }), but is
                new string[] { @"foooooo. ", @"foooooo.  ", @"foooooo.   " }),
            InlineData(
                "fo*.",
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo.     " },
                // Really should be: new string[] { }), but is
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo.     " }),
            InlineData(
                "fo*.",
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo.     ", @"foo.      ", @"foo.       " },
                // Really should be: new string[] { }), but is
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo.     ", @"foo.      ", @"foo.       " }),
            InlineData(
                "fo*.",
                new string[] { @"fo. ", @"fo.  ", @"fo.   ", @"fo.    ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo.     ", @"foo.      ", @"foo.       " },
                // Really should be: new string[] { }), but is
                new string[] { @"fo. ", @"fo.  ", @"fo.   ", @"fo.    ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo.     ", @"foo.      ", @"foo.       " }),
            InlineData(
                "fo*.",
                new string[] { @"fo. ", @"fo.  ", @"fo.   ", @"fo.    ", @"fo.     ", @"fo.      ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo.     ", @"foo.      ", @"foo.       " },
                // Really should be: new string[] { }), but is
                new string[] { @"fo. ", @"fo.  ", @"fo.   ", @"fo.    ", @"fo.     ", @"fo.      ", @"foo.  ", @"foo.   ", @"foo.    ", @"foo.     ", @"foo.      ", @"foo.       " }),
            InlineData(
                "foo*.",
                new string[] { @"foo. ", @"foo.  ", @"foo..", @"foo. t", @"foo.   ", @"foo.    " },
                // Really should be: new string[] { @"foo.." }), but is
                new string[] { @"foo. ", @"foo.  ", @"foo.   ", @"foo.." }),
            ]
        public void PatternTests_DosStarOddSpace(string pattern, string[] sourceFiles, string[] expected)
        {
            // Tests for DOS_STAR, which only occurs when the source pattern ends in *.
            // These cases don't match documented behavior on Windows- matching *should* end at the final period.

            // We don't want to eat trailing space/periods in this test
            string testDir = PrepareDirectory(sourceFiles, useExtendedPaths: true);
            ValidatePatternMatch(expected, GetEntries(testDir, pattern));
        }

        private string PrepareDirectory(string[] sourceFiles, bool useExtendedPaths = false)
        {
            string testDir = Directory.CreateDirectory(GetTestFilePath()).FullName;

            foreach (string file in sourceFiles)
                CreateItem(useExtendedPaths && PlatformDetection.IsWindows
                    ? @"\\?\" + Path.Combine(testDir, file)
                    : Path.Combine(testDir, file));

            return testDir;
        }

        private void ValidatePatternMatch(string[] expected, string[] result)
        {
            Assert.Equal(expected.OrderBy(s => s), result.Select(Path.GetFileName).OrderBy(s => s));
        }

        #endregion

        #region PlatformSpecific

        [PlatformSpecific(TestPlatforms.AnyUnix)]
        [Theory,
            InlineData(
                @"foo\bar",
                new string[] { @"foo", @"bar", @"foo\bar" },
                new string[] { @"foo\bar" }),
            ]
        public void PatternTests_UnixEscape(string pattern, string[] sourceFiles, string[] expected)
        {
            // We shouldn't be allowing escaping in Unix filename searches
            string testDir = PrepareDirectory(sourceFiles);
            ValidatePatternMatch(expected, GetEntries(testDir, pattern));
        }

        [Fact]
        [PlatformSpecific(TestPlatforms.Windows)]  // Long path segment in search pattern throws PathTooLongException
        public void WindowsSearchPatternLongSegment()
        {
            // Create a path segment longer than the normal max of 255
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
            string longName = new string('k', 257);

            Assert.Throws<PathTooLongException>(() => GetEntries(testDir.FullName, longName));
        }

        [ConditionalFact(nameof(AreAllLongPathsAvailable))]
        [ActiveIssue(20117, TargetFrameworkMonikers.Uap)]
        public void SearchPatternLongPath()
        {
            // Create a destination path longer than the traditional Windows limit of 256 characters
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());

            string longName = new string('k', 254);
            string longFullname = Path.Combine(testDir.FullName, longName);

            if (TestFiles)
            {
                using (File.Create(longFullname)) { }
            }
            else
            {
                Directory.CreateDirectory(longFullname);
            }

            string[] results = GetEntries(testDir.FullName, longName);
            Assert.Contains(longFullname, results);
        }

        [Fact]
        [PlatformSpecific(TestPlatforms.Windows)]  // Search pattern with double dots throws ArgumentException
        public void WindowsSearchPatternWithDoubleDots()
        {
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, Path.Combine("..ab ab.. .. abc..d", "abc..")));
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, ".."));
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, @".." + Path.DirectorySeparatorChar));
        }

        private static char[] OldWildcards = new char[] { '*', '?' };
        private static char[] NewWildcards = new char[] { '<', '>', '\"' };

        [Fact]
        [PlatformSpecific(TestPlatforms.Windows)]  // Windows-invalid search patterns throw
        public void WindowsSearchPatternInvalid()
        {
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, "\0"));
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, "|"));

            Assert.All(Path.GetInvalidFileNameChars().Except(OldWildcards).Except(NewWildcards), invalidChar =>
            {
                switch (invalidChar)
                {
                    case '\\':
                    case '/':
                        Assert.Throws<DirectoryNotFoundException>(() => GetEntries(Directory.GetCurrentDirectory(), string.Format("te{0}st", invalidChar.ToString())));
                        break;
                    //We don't throw in V1 too
                    case ':':
                        //History:
                        // 1) we assumed that this will work in all non-9x machine
                        // 2) Then only in XP
                        // 3) NTFS?
                        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
                            FileSystemDebugInfo.IsCurrentDriveNTFS()) // testing NTFS
                        {
                            Assert.Throws<IOException>(() => GetEntries(Directory.GetCurrentDirectory(), string.Format("te{0}st", invalidChar.ToString())));
                        }
                        else
                        {
                            GetEntries(Directory.GetCurrentDirectory(), string.Format("te{0}st", invalidChar.ToString()));
                        }
                        break;
                    default:
                        Assert.Throws<ArgumentException>(() => GetEntries(Directory.GetCurrentDirectory(), string.Format("te{0}st", invalidChar.ToString())));
                        break;
                }
            });
        }

        [Fact]
        [PlatformSpecific(TestPlatforms.Windows)]  // Windows-invalid search patterns throw
        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "In netcoreapp we made three new characters be treated as valid wildcards instead of invalid characters. NetFX still treats them as InvalidChars.")]
        public void WindowsSearchPatternInvalid_Wildcards_netcoreapp()
        {
            Assert.All(OldWildcards, invalidChar =>
            {
                GetEntries(Directory.GetCurrentDirectory(), string.Format("te{0}st", invalidChar.ToString()));
            });
            Assert.All(NewWildcards, invalidChar =>
            {
                GetEntries(Directory.GetCurrentDirectory(), string.Format("te{0}st", invalidChar.ToString()));
            });
        }

        [Fact]
        [PlatformSpecific(TestPlatforms.Windows)]  // Windows-invalid search patterns throw
        [SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework, "In netcoreapp we made three new characters be treated as valid wildcards instead of invalid characters. NetFX still treats them as InvalidChars.")]
        public void WindowsSearchPatternInvalid_Wildcards_netfx()
        {
            Assert.All(OldWildcards, invalidChar =>
            {
                GetEntries(Directory.GetCurrentDirectory(), string.Format("te{0}st", invalidChar.ToString()));
            });
            Assert.All(NewWildcards, invalidChar =>
            {
                Assert.Throws<ArgumentException>(() => GetEntries(Directory.GetCurrentDirectory(), string.Format("te{0}st", invalidChar.ToString())));
            });
        }

        [Fact]
        [PlatformSpecific(TestPlatforms.AnyUnix)]  // Unix-invalid sarch patterns throw ArgumentException
        public void UnixSearchPatternInvalid()
        {
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, "\0"));
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, string.Format("te{0}st", "\0".ToString())));
        }

        [Fact]
        [PlatformSpecific(TestPlatforms.Windows)]  // ? in search pattern returns results
        public virtual void WindowsSearchPatternQuestionMarks()
        {
            string testDir1Str = GetTestFileName();
            DirectoryInfo testDir = new DirectoryInfo(TestDirectory);
            DirectoryInfo testDir1 = testDir.CreateSubdirectory(testDir1Str);

            using (File.Create(Path.Combine(TestDirectory, testDir1Str, GetTestFileName())))
            using (File.Create(Path.Combine(TestDirectory, GetTestFileName())))
            {
                string[] results = GetEntries(TestDirectory, string.Format("{0}.???", new string('?', GetTestFileName().Length)));
                if (TestFiles && TestDirectories)
                    Assert.Equal(2, results.Length);
                else
                    Assert.Equal(1, results.Length);
            }
        }

        [Fact]
        [PlatformSpecific(TestPlatforms.Windows)]  // Whitespace in search pattern returns nothing
        public void WindowsSearchPatternWhitespace()
        {
            Assert.Empty(GetEntries(TestDirectory, "           "));
            Assert.Empty(GetEntries(TestDirectory, "\n"));
            Assert.Empty(GetEntries(TestDirectory, " "));
            Assert.Empty(GetEntries(TestDirectory, "\t"));
        }

        [Fact]
        [PlatformSpecific(CaseSensitivePlatforms)]
        public void SearchPatternCaseSensitive()
        {
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
            string testBase = GetTestFileName();
            testDir.CreateSubdirectory(testBase + "aBBb");
            testDir.CreateSubdirectory(testBase + "aBBB");

            File.Create(Path.Combine(testDir.FullName, testBase + "AAAA")).Dispose();
            File.Create(Path.Combine(testDir.FullName, testBase + "aAAa")).Dispose();

            if (TestDirectories)
            {
                Assert.Equal(2, GetEntries(testDir.FullName, "*BB*").Length);
            }
            if (TestFiles)
            {
                Assert.Equal(2, GetEntries(testDir.FullName, "*AA*").Length);
            }
        }

        [Fact]
        [PlatformSpecific(CaseInsensitivePlatforms)]
        public void SearchPatternCaseInsensitive()
        {
            DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
            string testBase = GetTestFileName();
            testDir.CreateSubdirectory(testBase + "yZZz");
            testDir.CreateSubdirectory(testBase + "yZZZ");

            File.Create(Path.Combine(testDir.FullName, testBase + "YYYY")).Dispose();
            File.Create(Path.Combine(testDir.FullName, testBase + "yYYy")).Dispose();

            if (TestDirectories)
            {
                Assert.Equal(1, GetEntries(testDir.FullName, "*ZZ*").Length);
            }
            if (TestFiles)
            {
                Assert.Equal(1, GetEntries(testDir.FullName, "*YY*").Length);
            }
        }

        [Fact]
        [PlatformSpecific(TestPlatforms.AnyUnix)]  // Unix-valid chars in file search patterns
        public void UnixSearchPatternFileValidChar()
        {
            if (TestFiles)
            {
                DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
                foreach (string valid in WindowsInvalidUnixValid)
                    File.Create(Path.Combine(testDir.FullName, valid)).Dispose();

                foreach (string valid in WindowsInvalidUnixValid)
                    Assert.Contains(Path.Combine(testDir.FullName, valid), GetEntries(testDir.FullName, valid));
            }
        }

        [Fact]
        [PlatformSpecific(TestPlatforms.AnyUnix)]  // Unix-valid chars in directory search patterns
        public void UnixSearchPatternDirectoryValidChar()
        {
            if (TestDirectories)
            {
                DirectoryInfo testDir = Directory.CreateDirectory(GetTestFilePath());
                foreach (string valid in WindowsInvalidUnixValid)
                    testDir.CreateSubdirectory(valid);

                foreach (string valid in WindowsInvalidUnixValid)
                    Assert.Contains(Path.Combine(testDir.FullName, valid), GetEntries(testDir.FullName, valid));
            }
        }

        [Fact]
        [PlatformSpecific(TestPlatforms.AnyUnix)]  // Search pattern with DoubleDots on Unix
        public void UnixSearchPatternWithDoubleDots()
        {
            // search pattern is valid but directory doesn't exist
            Assert.Throws<DirectoryNotFoundException>(() => GetEntries(TestDirectory, Path.Combine("..ab ab.. .. abc..d", "abc..")));

            // invalid search pattern trying to go up a directory with ..
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, ".."));
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, @".." + Path.DirectorySeparatorChar));
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, Path.Combine("..ab ab.. .. abc..d", "abc", "..")));
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, Path.Combine("..ab ab.. .. abc..d", "..", "abc")));
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, Path.Combine("..", "..ab ab.. .. abc..d", "abc")));
            Assert.Throws<ArgumentException>(() => GetEntries(TestDirectory, Path.Combine("..", "..ab ab.. .. abc..d", "abc") + Path.DirectorySeparatorChar));
        }

        #endregion
    }
}


text:
<resources>

    <!-- 按钮相关 -->
    <dimen name="button_height">40dp</dimen>
    <dimen name="button_text_size">18sp</dimen>
    <!-- 标题栏相关UI -->
    <dimen name="activity_titlebar_height">50dp</dimen>
    <dimen name="activity_titlebar_text_size">20sp</dimen>
    <dimen name="activity_titlebar_icon_margin">3dp</dimen>
    <dimen name="activity_titlebar_icon_padding">5dp</dimen>
    <!-- 底部菜单相关UI -->
    <dimen name="activity_menu_height_max">60.0dip</dimen>
    <dimen name="activity_menu_height_min">50.0dip</dimen>
    <dimen name="activity_menu_pic_size">40dp</dimen>
    <dimen name="activity_menu_bitty_tips_size">20dp</dimen>
    <dimen name="bitty_tips_text_size">8sp</dimen>
    <dimen name="bitty_tips_text_margin_top">5dp</dimen>
    <dimen name="bitty_tips_text_padding">2dp</dimen>
    <!-- 关于界面 -->
    <dimen name="about_logo_top_margin">50dp</dimen>
    <!-- 新版首页相关值定义 -->
    <dimen name="home_home_new_height">150dp</dimen>
    <dimen name="home_home_new_center_image_margin">30dp</dimen>
    <dimen name="home_home_new_text_top_margin">15dp</dimen>
    <dimen name="home_home_baby_image_margin">30dp</dimen>
    <dimen name="home_home_baby_image_size">80dp</dimen>
    <dimen name="home_home_baby_parent_image_size">68dp</dimen>
    <dimen name="home_home_baby_parent_image_margin_border">31dp</dimen>
    <dimen name="home_home_ads_pager_indicator_size">14dp</dimen>
    <dimen name="home_home_ads_image_height">150dp</dimen>
    <dimen name="home_home_button_padding">10dp</dimen>
    <dimen name="home_home_button_column_width">80dp</dimen>
    <dimen name="home_home_headline_header_height">200dp</dimen>
    <dimen name="home_home_headline_image_width">75dp</dimen>
    <dimen name="home_home_headline_image_height">55dp</dimen>
    <dimen name="home_home_headline_padding">5dp</dimen>
    <dimen name="home_home_headline_text_size">15sp</dimen>
    <dimen name="home_home_headline_introduction_text_size">13sp</dimen>
    <dimen name="home_home_qa_image_size">50dp</dimen>
    <!-- 聚合相关 -->
    <dimen name="polymeric_icon_size">35dp</dimen>
    <dimen name="polymeric_title_text_size">18sp</dimen>
    <dimen name="polymeric_title_top_margin">10dp</dimen>
    <dimen name="polymeric_item_size">80dp</dimen>
    <!-- Personal Center -->
    <dimen name="personal_center_share_item_headpic_size">47dp</dimen>
    <dimen name="personal_center_share_item_pic_size">70dp</dimen>
    <dimen name="personal_center_share_item_pic_spacing">5dp</dimen>
    <dimen name="personal_margin_right_bottom">5dp</dimen>
    <dimen name="personal_margin_blank_head">8dp</dimen>
    <dimen name="personal_head_blank_size">80dp</dimen>
    <dimen name="personal_head_size">70dp</dimen>
    <dimen name="personal_head_padding">1dp</dimen>
    <dimen name="personal_topinfo_background_height_max">180.0dip</dimen>
    <dimen name="personal_topinfo_background_height_min">150.0dip</dimen>
    <dimen name="personal_sex_size">18dp</dimen>
    <dimen name="personal_sex_margin_bottom">42dp</dimen>
    <dimen name="personal_new_artic_others">50dp</dimen>
    <dimen name="personal_new_artic_image_size">70dp</dimen>
    <dimen name="personal_info_line_big">10dp</dimen>
    <dimen name="personal_info_line_big_text_size">2sp</dimen>
    <dimen name="personal_info_item_padding">13dp</dimen>
    <dimen name="personal_info_item_image_margin_top">3dp</dimen>
    <dimen name="slidingmenu_offset">30dp</dimen>
    <dimen name="shadow_width">15dp</dimen>
    <dimen name="personal_background_setting_add_new_size">90dp</dimen>
    <dimen name="personal_background_setting_item_height">140dp</dimen>
    <dimen name="personal_match_contacts_phone_bg_width">180dp</dimen>
    <dimen name="personal_match_contacts_phone_bg_height">220dp</dimen>
    <dimen name="personal_match_contacts_desc_bottom_margin">20dp</dimen>
    <dimen name="personal_qrcode_image_size">150dp</dimen>
    <!-- 新闻显示界面相关缩略图大小 -->
    <dimen name="news_displayer_share_item_size">45dp</dimen>
    <!-- 收藏中心相关缩略图大小 -->
    <dimen name="favorites_center_group_left_image_size">30dp</dimen>
    <dimen name="favorites_center_group_right_image_size">20dp</dimen>
    <!-- 默认图片缩略图大小 -->
    <dimen name="home_user_head_pic_size">110dp</dimen>
    <dimen name="image_size_home_cycles">130dp</dimen>
    <dimen name="image_size_polymerization_title_icon">50dp</dimen>
    <dimen name="image_size_polymerization_content_icon">90dp</dimen>
    <dimen name="image_size_polymerization_content_delete_icon">20dp</dimen>
    <dimen name="image_default_thumb_size1">100dp</dimen>
    <dimen name="daily_shutter_pop_title_left_margin">-4dp</dimen>
    <dimen name="daily_shutter_cover_thumbnail_size">93dp</dimen>
    <dimen name="daily_shutter_image_thumbnail_size">45dp</dimen>
    <dimen name="daily_shutter_image_thumbnail_spacing">3dp</dimen>
    <!-- 每日拍界面UI定义 -->
    <dimen name="daily_shutter_list_cover_size">80dp</dimen>
    <dimen name="daily_shutter_button_button_padding">1dp</dimen>
    <dimen name="daily_shutter_button_button_margin">2dp</dimen>
    <!-- 时间轴界面定义 -->
    <dimen name="time_line_pager_page_margin">20dp</dimen>
    <dimen name="time_line_pager_margin">30dp</dimen>
    <dimen name="time_line_album_item_size">50dp</dimen>
    <dimen name="time_line_album_item_spacing">2dp</dimen>
    <dimen name="time_line_picture_confirm_share_item_size">35dp</dimen>
    <dimen name="time_line_picture_confirm_share_item_spacing">2dp</dimen>
    <!-- 用户基本信息界面 -->
    <dimen name="user_base_info_head_image_size">65dp</dimen>
    <dimen name="user_base_info_sex_icon_size">20dp</dimen>
    <dimen name="user_base_info_item_height">45dp</dimen>
    <dimen name="user_base_info_item_padding">3dp</dimen>
    <dimen name="user_base_info_item_top_margin">1dp</dimen>
    <dimen name="user_base_info_item_image_size">25dp</dimen>
    <dimen name="user_base_info_item_text_size">15sp</dimen>
    <dimen name="user_base_info_item_description_text_size">13sp</dimen>
    <dimen name="user_base_info_item_left_image_padding">2dp</dimen>
    <dimen name="user_base_info_item_left_image_margin">3dp</dimen>
    <dimen name="user_base_info_item_right_image_padding">4dp</dimen>
    <dimen name="base_search_button_image_size">35dp</dimen>
    <dimen name="base_button_padding">5dp</dimen>
    <dimen name="base_button_height">40dp</dimen>
    <dimen name="user_base_info_item_switcher_width">60dp</dimen>
    <dimen name="user_base_info_item_switcher_height">25dp</dimen>
    <!-- 圈子添加用户UI相关 -->
    <dimen name="chat_group_builder_add_user_text_margin">20dp</dimen>
    <!-- 聊天界面相关定义 -->
    <dimen name="chat_popupwindo_top_offset">75dp</dimen>
    <dimen name="chat_contact_group_image_size">35dp</dimen>
    <dimen name="chat_contact_item_image_size">50dp</dimen>
    <dimen name="chat_contact_item_delete_container_width">65dp</dimen>
    <dimen name="chat_contact_item_delete_text_size">16sp</dimen>
    <dimen name="chat_contact_item_unread_flag_size">15dp</dimen>
    <dimen name="chat_contact_item_sex_icon_size">20dp</dimen>
    <dimen name="chat_contact_indexer_font_size">10sp</dimen>
    <dimen name="chat_contact_indexer_width">18dp</dimen>
    <dimen name="chat_add_new_item_image_size">60dp</dimen>
    <!-- 聊天对话界面 -->
    <dimen name="chat_chat_item_text_size">14sp</dimen>
    <dimen name="chat_chat_item_head_image_padding">2dp</dimen>
    <dimen name="chat_chat_item_head_image_size">45dp</dimen>
    <dimen name="chat_chat_item_head_2_content_padding">10dp</dimen>
    <dimen name="chat_chat_item_head_to_content_padding">3dp</dimen>
    <dimen name="chat_chat_item_content_ending_margin">22dp</dimen>
    <dimen name="chat_chat_item_content_starting_margin">5dp</dimen>
    <dimen name="chat_chat_item_content_padding_normal">6dp</dimen>
    <dimen name="chat_chat_item_content_padding_starging">14dp</dimen>
    <dimen name="chat_chat_item_content_image_size">50dp</dimen>
    <dimen name="chat_chat_item_content_image_max_size">40dp</dimen>
    <dimen name="chat_chat_item_content_voice_button_size">30dp</dimen>
    <dimen name="chat_chat_item_content_html_image_height">80dp</dimen>
    <!-- 聊天输入界面 -->
    <dimen name="chat_chat_input_container_padding">3dp</dimen>
    <dimen name="chat_chat_input_button_spacing">3dp</dimen>
    <dimen name="chat_chat_button_size">35dp</dimen>
    <dimen name="chat_chat_input_box_max_height">80dp</dimen>
    <dimen name="chat_chat_emoji_margin">5dp</dimen>
    <dimen name="chat_chat_bubble_padding">5dp</dimen>
    <dimen name="chat_chat_bubble_padding_bottom">16dp</dimen>
    <!-- 新版聊天输入界面 -->
    <dimen name="chat_chat_input_button_corner_size">8dp</dimen>
    <dimen name="chat_chat_input_button_image_margin">3dp</dimen>
    <dimen name="chat_chat_input_button_voice_send_width">55dp</dimen>
    <!-- SeekBar相关定义 -->
    <dimen name="seek_bar_border_size">3dp</dimen>
    <dimen name="seek_bar_progress_padding">0dp</dimen>
    <!-- 注册UI -->
    <dimen name="register_country_divider_height">30dp</dimen>
    <!-- 新闻UI -->
    <dimen name="news_displayer_news_image_height">150dp</dimen>
    <dimen name="news_displayer_news_title_text_size">18sp</dimen>

</resources>


text: export bundle


text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package es.ucm.pev.g12p2.selection;

import es.ucm.pev.g12p2.chromosome.Chromosome;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author Herros Team
 */
public class Truncation extends Selection {

    private List<Chromosome> population;

    public Truncation() {
    }

    @Override
    public List<Chromosome> select(List<Chromosome> population) {
        List<Chromosome> newPopulation = new LinkedList();
        double trunc = 0.5; //trunc = x ->[0.1, 0.5]
        double timesSelected = (Integer) 1 / trunc;
        this.population = population;
        quickSort(0, population.size() - 1);

        for (int i = 0; i < this.population.size() * trunc; i++) {
            for (int j = 0; j < timesSelected; j++) {
                newPopulation.add(this.population.get(i));
            }
        }
        return newPopulation;
    }

    private void quickSort(int lo, int hi) {
        int i = lo, j = hi;
        double p = this.population.get(lo + (hi - lo) / 2).getFitness();
        while (i <= j) {
            while (this.population.get(i).getFitness() < p) {
                i++;
            }
            while (this.population.get(j).getFitness() > p) {
                j--;
            }
            if (i <= j) {
                flipChromosomes(i, j);
                i++;
                j--;
            }
        }
        if (lo < j) {
            quickSort(lo, j);
        }
        if (i > hi) {
            quickSort(i, hi);
        }
    }

    private void flipChromosomes(int i, int j) {
        Chromosome aux = this.population.get(i).copy();
        this.population.set(i, this.population.get(j).copy());
        this.population.set(j, aux);
    }

}


text:
/**
 * Created by pi on 7/21/16.
 */
var modelBase = require('../ModelBase');

var JobLog = modelBase.define('JobLog',{
    ident : {type: modelBase.Sequelize.STRING},
    erpIdent : modelBase.Sequelize.STRING,
    jobIdent: modelBase.Sequelize.STRING,
    name : modelBase.Sequelize.STRING,
    state :  modelBase.Sequelize.INTEGER,
    recipeIdent : modelBase.Sequelize.STRING,
    lineIdent : modelBase.Sequelize.STRING,
    actualWeight: modelBase.Sequelize.DECIMAL
});

console.log('Joblog executed');
module.exports = JobLog;


text:
#include "Thrift.h"

#include "io/event_manager.h"
#include "base/logging.h"
#include "io/io_log.h"

using namespace boost::asio;

SandeshTraceBufferPtr IOTraceBuf(SandeshTraceBufferCreate(IO_TRACE_BUF, 1000));

EventManager::EventManager() {
    shutdown_ = false;
}

void EventManager::Shutdown() {
    shutdown_ = true;

    // TODO: make sure that are no users of this event manager.
    io_service_.stop();
}

void EventManager::Run() {
    using namespace apache::thrift;

    assert(mutex_.try_lock());
    io_service::work work(io_service_);
    do {
        if (shutdown_) break;
        boost::system::error_code ec;
        try {
            io_service_.run(ec);
            if (ec) {
                EVENT_MANAGER_LOG_ERROR("io_service run failed: " <<
                                        ec.message());
                break;
            }
        } catch (const TException &except) {
            // ignore thrift exceptions
            EVENT_MANAGER_LOG_ERROR("Thrift exception caught : " <<
                                    except.what() << "; ignoring");
            continue;
        } catch (std::exception &except) {
            static std::string what = except.what();
            EVENT_MANAGER_LOG_ERROR("Exception caught in io_service run : " <<
                                    what);
            assert(false);
        } catch (...) {
            EVENT_MANAGER_LOG_ERROR("Exception caught in io_service run : "
                                    "bailing out");
            assert(false);
        }
    } while (true);
    mutex_.unlock();
}

size_t EventManager::RunOnce() {
    assert(mutex_.try_lock());
    if (shutdown_) return 0;
    boost::system::error_code err;
    size_t res = io_service_.run_one(err);
    if (res == 0)
        io_service_.reset();
    mutex_.unlock();
    return res;
}

size_t EventManager::Poll() {
    assert(mutex_.try_lock());
    if (shutdown_) return 0;
    boost::system::error_code err;
    size_t res = io_service_.poll(err);
    if (res == 0)
        io_service_.reset();
    mutex_.unlock();
    return res;
}


text:
package director_test

import (
	"net/http"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"

	. "github.com/cloudfoundry/bosh-cli/director"
)

var _ = Describe("Director", func() {
	var (
		director Director
		server   *ghttp.Server
	)

	BeforeEach(func() {
		director, server = BuildServer()
	})

	AfterEach(func() {
		server.Close()
	})

	Describe("MatchPackages", func() {
		Context("when checking for non-compiled packages", func() {
			act := func() ([]string, error) {
				return director.MatchPackages(map[string]bool{"manifest": true}, false)
			}

			It("returns fingerprint matches", func() {
				server.AppendHandlers(
					ghttp.CombineHandlers(
						ghttp.VerifyRequest("POST", "/packages/matches"),
						ghttp.VerifyBasicAuth("username", "password"),
						ghttp.VerifyHeader(http.Header{
							"Content-Type": []string{"text/yaml"},
						}),
						ghttp.VerifyBody([]byte("manifest: true\n")),
						ghttp.RespondWith(http.StatusOK, `["match1","match2"]`),
					),
				)

				matches, err := act()
				Expect(err).ToNot(HaveOccurred())
				Expect(matches).To(Equal([]string{"match1", "match2"}))
			})

			It("does not return error if response is non-200", func() {
				AppendBadRequest(ghttp.VerifyRequest("POST", "/packages/matches"), server)

				matches, err := act()
				Expect(err).ToNot(HaveOccurred())
				Expect(matches).To(BeEmpty())
			})

			It("does not return error if response cannot be unmarshalled", func() {
				server.AppendHandlers(
					ghttp.CombineHandlers(
						ghttp.VerifyRequest("POST", "/packages/matches"),
						ghttp.RespondWith(http.StatusOK, ``),
					),
				)

				matches, err := act()
				Expect(err).ToNot(HaveOccurred())
				Expect(matches).To(BeEmpty())
			})
		})

		Context("when checking for compiled packages", func() {
			act := func() ([]string, error) {
				return director.MatchPackages(map[string]bool{"manifest": true}, true)
			}

			It("returns fingerprint matches", func() {
				server.AppendHandlers(
					ghttp.CombineHandlers(
						ghttp.VerifyRequest("POST", "/packages/matches_compiled"),
						ghttp.VerifyBasicAuth("username", "password"),
						ghttp.VerifyHeader(http.Header{
							"Content-Type": []string{"text/yaml"},
						}),
						ghttp.VerifyBody([]byte("manifest: true\n")),
						ghttp.RespondWith(http.StatusOK, `["match1","match2"]`),
					),
				)

				matches, err := act()
				Expect(err).ToNot(HaveOccurred())
				Expect(matches).To(Equal([]string{"match1", "match2"}))
			})

			It("does not return error if response is non-200", func() {
				AppendBadRequest(ghttp.VerifyRequest("POST", "/packages/matches_compiled"), server)

				matches, err := act()
				Expect(err).ToNot(HaveOccurred())
				Expect(matches).To(BeEmpty())
			})

			It("does not return error if response cannot be unmarshalled", func() {
				server.AppendHandlers(
					ghttp.CombineHandlers(
						ghttp.VerifyRequest("POST", "/packages/matches_compiled"),
						ghttp.RespondWith(http.StatusOK, ``),
					),
				)

				matches, err := act()
				Expect(err).ToNot(HaveOccurred())
				Expect(matches).To(BeEmpty())
			})
		})
	})
})


text:
struct turnd {
	struct sa rel_addr;
	struct sa rel_addr6;
	struct hash *ht_alloc;
	uint64_t bytec_tx;
	uint64_t bytec_rx;
	uint64_t errc_tx;
	uint64_t errc_rx;
	uint64_t allocc_tot;
	uint32_t allocc_cur;
	uint32_t lifetime_max;
	uint32_t udp_sockbuf_size;
};

struct chanlist;

struct allocation {
	struct le he;
	struct tmr tmr;
	uint8_t tid[STUN_TID_SIZE];
	struct sa cli_addr;
	struct sa srv_addr;
	struct sa rel_addr;
	struct sa rsv_addr;
	void *cli_sock;
	struct udp_sock *rel_us;
	struct udp_sock *rsv_us;
	char *username;
	struct hash *perms;
	struct chanlist *chans;
	uint64_t dropc_tx;
	uint64_t dropc_rx;
	int proto;
};

void allocate_request(struct turnd *turnd, struct allocation *alx,
		      struct restund_msgctx *ctx, int proto, void *sock,
		      const struct sa *src, const struct sa *dst,
		      const struct stun_msg *msg);
void refresh_request(struct turnd *turnd, struct allocation *al,
		     struct restund_msgctx *ctx,
		     int proto, void *sock, const struct sa *src,
		     const struct stun_msg *msg);
void createperm_request(struct allocation *al, struct restund_msgctx *ctx,
			int proto, void *sock, const struct sa *src,
			const struct stun_msg *msg);
void chanbind_request(struct allocation *al, struct restund_msgctx *ctx,
		      int proto, void *sock, const struct sa *src,
		      const struct stun_msg *msg);
struct turnd *turndp(void);

struct perm;

struct perm *perm_find(const struct hash *ht, const struct sa *addr);
struct perm *perm_create(struct hash *ht, const struct sa *peer,
			 const struct allocation *al);
void perm_refresh(struct perm *perm);
void perm_tx_stat(struct perm *perm, size_t bytc);
void perm_rx_stat(struct perm *perm, size_t bytc);
int  perm_hash_alloc(struct hash **ht, uint32_t bsize);
void perm_status(struct hash *ht, struct mbuf *mb);

struct chan;

struct chan *chan_numb_find(const struct chanlist *cl, uint16_t numb);
struct chan *chan_peer_find(const struct chanlist *cl, const struct sa *peer);
uint16_t chan_numb(const struct chan *chan);
const struct sa *chan_peer(const struct chan *chan);
int  chanlist_alloc(struct chanlist **clp, uint32_t bsize);
void chan_status(const struct chanlist *cl, struct mbuf *mb);


text:
@class MMImageCropperViewController, UIImage;

@protocol MMImageCropperDelegate <NSObject>
- (void)imageCropperDidCancel:(MMImageCropperViewController *)arg1;
- (void)imageCropper:(MMImageCropperViewController *)arg1 didFinished:(UIImage *)arg2;
@end