text:
package com.google.engedu.continentaldivide;

import android.support.annotation.VisibleForTesting;

import java.util.Arrays;
import java.util.Collections;
import java.util.Random;

public class ContinentMapController {
    private static final int MAX_HEIGHT = 255;

    @VisibleForTesting
    protected static Integer[] DEFAULT_MAP_HEIGHTS = {
            1, 2, 3, 4, 5,
            2, 3, 4, 5, 6,
            3, 4, 5, 3, 1,
            6, 7, 3, 4, 5,
            5, 1, 2, 3, 4,
    };

    @VisibleForTesting
    protected static Integer[] LAKE_MAP_HEIGHTS = {
            1, 2, 3, 4, 5,
            2, 3, 4, 5, 6,
            3, 4, 0, 3, 1,
            6, 7, 3, 4, 5,
            5, 1, 2, 3, 4,
    };

    @VisibleForTesting
    protected static Integer[] MAP_EQUAL_NEIGHBORS_HEIGHTS = {
            50, 50, 50, 50, 60,
            50, 22, 26, 70, 50,
            50, 24, 30, 30, 29,
            50, 28, 28, 29, 22,
            60, 50, 50, 50, 50,
    };

    // An inner class to store the information we need for each point in the map
    public class Cell {
        // The height of this spot
        int height = 0;

        // Whether this cell flows to the Green Ocean
        boolean flowsNW = false;

        // Whether this cell flows to the Blue Ocean
        boolean flowsSE = false;

        // Whether this cell has been determined to flow to neither ocean
        boolean basin = false;

        // A flag to allow us to track whether the current cell is already being evaluated
        boolean processing = false;
    }

    private Cell[] map;
    private int boardSize;
    private Random random = new Random();
    private int maxHeight = 0, minHeight = 0;

    public ContinentMapController() {
        this(DEFAULT_MAP_HEIGHTS);
    }

    @VisibleForTesting
    ContinentMapController(Integer[] mapHeights) {
        boardSize = (int) (Math.sqrt(mapHeights.length));
        map = new Cell[boardSize * boardSize];
        for (int i = 0; i < boardSize * boardSize; i++) {
            map[i] = new Cell();
            map[i].height = mapHeights[i];
        }
        maxHeight = Collections.max(Arrays.asList(mapHeights));
    }

    /**
     * Gets the cell at a specific x, y location on the board.
     */
    public Cell getCell(int x, int y) {
        if (x >=0 && x < boardSize && y >= 0 && y < boardSize)
            return map[x + boardSize * y];
        else
            return null;
    }

    /**
     * Returns the size of the board. The board is always a square, so a 4x4 board
     * of 16 squares has size 4.
     */
    public int getBoardSize() {
        return boardSize;
    }

    /**
     * Gets the max height of the current board.
     */
    public int getMaxHeight() {
        return maxHeight;
    }

    /**
     * Gets the minimum height of the current board.
     */
    public int getMinHeight() {
        return minHeight;
    }

    /**
     * Resets the continental divide info for each cell (except the height)
     */
    public void clearContinentalDivide() {
        for (int i = 0; i < boardSize * boardSize; i++) {
            map[i].flowsNW = false;
            map[i].flowsSE = false;
            map[i].basin = false;
            map[i].processing = false;
        }
    }

    /**
     * Labels each cell's continental divide status by starting from the coasts and working uphill.
     * @param oneStep Note that this method takes a oneStep parameter which allows you to build the
     *                solution incrementally. This will be handy in debugging your own solution.
     */
    public void buildUpContinentalDivide(boolean oneStep) {
        if (!oneStep) {
            clearContinentalDivide();
        }
        boolean iterated = false;
        for (int x = 0; x < boardSize; x++) {
            for (int y = 0; y < boardSize; y++) {
                Cell cell = getCell(x, y);
                if ((x == 0 || y == 0 || x == boardSize - 1 || y == boardSize - 1)) {
                    buildUpContinentalDivideRecursively(
                            x, y, x == 0 || y == 0, x == boardSize - 1 || y == boardSize - 1, -1);
                    if (oneStep) {
                        iterated = true;
                        break;
                    }
                }
            }
            if (iterated && oneStep)
                break;
        }
    }

    /**
     * Helper for the above buildUpContinentalDivide, which builds it up for just one cell.
     * @param flowsNW Whether the neighbor before this cell flows NW
     * @param flowsSE Whether the neighbor before this cell flows SE
     * @param previousHeight The height of the neighbor before this cell
     */
    private void buildUpContinentalDivideRecursively(
            int x, int y, boolean flowsNW, boolean flowsSE, int previousHeight) {
        /**
         **
         **  YOUR CODE GOES HERE
         **
         **/
    }

    /**
     * Labels each cell's continental divide status by starting from the peaks and working downhill.
     * @param oneStep  Note that this method takes a oneStep parameter which allows you to build the
     *                 solution incrementally. This will be handy in debugging your own solution.
     */
    public void buildDownContinentalDivide(boolean oneStep) {
        if (!oneStep)
            clearContinentalDivide();
        while (true) {
            int maxUnprocessedX = -1, maxUnprocessedY = -1, foundMaxHeight = -1;
            for (int y = 0; y < boardSize; y++) {
                for (int x = 0; x < boardSize; x++) {
                    Cell cell = getCell(x, y);
                    if (!(cell.flowsNW || cell.flowsSE || cell.basin) && cell.height > foundMaxHeight) {
                        maxUnprocessedX = x;
                        maxUnprocessedY = y;
                        foundMaxHeight = cell.height;
                    }
                }
            }
            if (maxUnprocessedX != -1) {
                buildDownContinentalDivideRecursively(maxUnprocessedX, maxUnprocessedY, foundMaxHeight + 1);
                if (oneStep) {
                    break;
                }
            } else {
                break;
            }
        }
    }

    /**
     * Helper for the above buildDownContinentalDivide, which builds down the continental divide
     * starting at a single cell. This calculates the cell at the X and Y position given recursively
     * @param previousHeight The height of the previous neighbor who called this function.
     */
    private Cell buildDownContinentalDivideRecursively(int x, int y, int previousHeight) {
        Cell workingCell = new Cell();
        /**
         **
         **  YOUR CODE GOES HERE
         **
         **/
        return workingCell;
    }

    /**
     * Method to pseudo-randomly generate other continent maps.
     * This is an extension for this unit's activity.
     */
    public void generateTerrain(int detail) {
        int newBoardSize = (int) (Math.pow(2, detail) + 1);
        if (newBoardSize != boardSize * boardSize) {
            boardSize = newBoardSize;
            map = new Cell[boardSize * boardSize];
            for (int i = 0; i < boardSize * boardSize; i++) {
                map[i] = new Cell();
            }
        }
        /**
         **
         **  YOUR CODE GOES HERE
         **
         **/
    }
}


text:
namespace NQuery.Authoring.QuickInfo
{
    public abstract class QuickInfoModelProvider<T> : IQuickInfoModelProvider
        where T : SyntaxNode
    {
        public QuickInfoModel GetModel(SemanticModel semanticModel, int position)
        {
            var syntaxTree = semanticModel.SyntaxTree;
            return syntaxTree.Root.FindNodes<T>(position)
                                  .Select(node => CreateModel(semanticModel, position, node))
                                  .FirstOrDefault();
        }

        protected abstract QuickInfoModel CreateModel(SemanticModel semanticModel, int position, T node);
    }
}

redpajama_set_name: RedPajamaGithub


text:
package com.hazelcast.simulator.utils;

import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;

import static com.hazelcast.simulator.utils.CommonUtils.rethrow;

public final class HostAddressPicker {

    private HostAddressPicker() {
    }

    public static String pickHostAddress() {
        try {
            Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
            String loopbackHost = null;
            while (interfaces.hasMoreElements()) {
                NetworkInterface networkInterface = interfaces.nextElement();
                if (!networkInterface.isUp()) {
                    continue;
                }
                if (networkInterface.isPointToPoint()) {
                    continue;
                }
                if (!networkInterface.isLoopback()) {
                    String candidateAddress = getHostAddressOrNull(networkInterface);
                    if (candidateAddress != null) {
                        return candidateAddress;
                    }
                } else {
                    if (loopbackHost == null) {
                        loopbackHost = getHostAddressOrNull(networkInterface);
                    }
                }
            }
            if (loopbackHost != null) {
                return loopbackHost;
            } else {
                throw new IllegalStateException("Cannot find local host address");
            }
        } catch (SocketException e) {
            throw rethrow(e);
        }
    }

    private static String getHostAddressOrNull(NetworkInterface networkInterface) {
        Enumeration<InetAddress> addresses = networkInterface.getInetAddresses();
        while (addresses.hasMoreElements()) {
            InetAddress address = addresses.nextElement();
            if (!(address instanceof Inet6Address)) {
                return address.getHostAddress();
            }
        }
        return null;
    }
}


text:
'
' Lightbox Gallery Module for DotNetNuke
' Project Contributors - Will Strohl (http://www.WillStrohl.com), Armand Datema (http://www.schwingsoft.com)
'
'Copyright (c) 2009-2016, Will Strohl
'All rights reserved.
'
'Redistribution and use in source and binary forms, with or without modification, are
'permitted provided that the following conditions are met:
'
'Redistributions of source code must retain the above copyright notice, this list of
'conditions and the following disclaimer.
'
'Redistributions in binary form must reproduce the above copyright notice, this list
'of conditions and the following disclaimer in the documentation and/or other
'materials provided with the distribution.
'
'Neither the name of Will Strohl, Armand Datema, Lightbox Gallery, nor the names of its contributors may be
'used to endorse or promote products derived from this software without specific prior
'written permission.
'
'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
'EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
'OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
'SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
'INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
'TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
'BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
'CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
'ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
'DAMAGE.
'

Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.UI.Skins.Skin
Imports DotNetNuke.UI.Skins.Controls.ModuleMessage
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.FileSystem
Imports System.Collections.Generic
Imports System.Drawing
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Web.UI
Imports WillStrohl.Modules.Lightbox.LightboxController

Namespace WillStrohl.Modules.Lightbox

    Partial Public MustInherit Class ViewLightbox
        Inherits WNSPortalModuleBase
        Implements IActionable

#Region " Private Members "

        Private Const EDIT_KEY As String = "Edit"
        Private Const MENU_ITEM_TITLE_KEY As String = "EditLightbox.MenuItem.Title"
        Private Const MENU_ITEM_CHANGEORDER_KEY As String = "EditLightbox.MenuItem.ChangeOrder"
        Private Const CHANGE_ORDER As String = "ChangeOrder"
        Private Const LIGHTBOX_KEY As String = "lightbox_clientscript"
        Private Const ERROR_WRAP As String = "{0}"
        Private Const EDIT_IMAGE_PATH As String = "/images/edit.gif"
        Private Const ORDER_IMAGE_PATH As String = "/images/copy.gif"
        Private Const IMAGE_TEMPLATE As String = "

 "
        Private Const IMAGE_EDIT_TEMPLATE As String = "
{6}
 "
        Private Const MAX_IMAGE_HEIGHT As Integer = 100

        Private p_Albums As LightboxInfoCollection = Nothing
        Private p_AlbumIds As List(Of Integer) = Nothing
        Private p_EditImage As String = Null.NullString
        Private p_OrderImage As String = Null.NullString

#End Region

#Region " Private Properties "

        Private ReadOnly Property Albums() As LightboxInfoCollection
            Get
                If Me.p_Albums Is Nothing Then
                    Me.p_Albums = New LightboxInfoCollection

                    Dim ctlLightbox As New LightboxController

                    Dim blnCount As Boolean = ctlLightbox.DoesDisplayOrderNeedUpdate
                    If blnCount Then
                        ctlLightbox.UpdateDisplayOrder()
                    End If

                    Me.p_Albums = ctlLightbox.GetLightboxes(Me.ModuleId)
                End If

                Return Me.p_Albums
            End Get
        End Property

        Private ReadOnly Property AlbumIds() As List(Of Integer)
            Get
                If Me.p_AlbumIds Is Nothing Then
                    Dim ctlModule As New LightboxController
                    Me.p_AlbumIds = New List(Of Integer)
                    Me.p_AlbumIds = ctlModule.GetLightboxIds(Me.ModuleId)
                End If

                Return Me.p_AlbumIds
            End Get
        End Property

        Protected ReadOnly Property EditImage() As String
            Get
                If Not String.IsNullOrEmpty(p_EditImage) Then
                    Return p_EditImage
                End If

                p_EditImage = String.Concat(DotNetNuke.Common.Globals.ApplicationPath, Entities.Icons.IconController.IconURL("Edit", "16x16"))

                Return p_EditImage
            End Get
        End Property

        Protected ReadOnly Property OrderImage() As String
            Get
                If Not String.IsNullOrEmpty(Me.p_OrderImage) Then
                    Return Me.p_OrderImage
                End If

                p_OrderImage = String.Concat(DotNetNuke.Common.Globals.ApplicationPath, Entities.Icons.IconController.IconURL("Synchronize", "16x16"))

                Return p_OrderImage
            End Get
        End Property

#End Region

#Region " Event Handlers "

        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Try

                ' only load the scripts if we need them (when there is 1 or more albums)
                If Not Me.Albums Is Nothing AndAlso Me.Albums.Count > 0 Then

                    ' Load the Lightbox plugin client script on every page load
                    If Not Page.ClientScript.IsClientScriptBlockRegistered(LIGHTBOX_KEY) Then
                        Page.ClientScript.RegisterClientScriptBlock( _
                            Me.GetType, _
                            LIGHTBOX_KEY, _
                            String.Format(SCRIPT_TAG_FORMAT, String.Concat(Me.ControlPath, "js/fancybox/jquery.fancybox-1.3.4.pack.js")), _
                            False)
                    End If

                    Me.Page.Header.Controls.Add(New LiteralControl(String.Format(STYLESHEET_TAG_FORMAT, String.Concat(Me.ControlPath, "js/fancybox/jquery.fancybox-1.3.4.css"))))

                End If

                If Not Me.Page.IsPostBack Then
                    Me.BindData()
                End If

            Catch exc As Exception ' Module failed to load
                ProcessModuleLoadException(Me, exc, Me.IsEditable)
            End Try
        End Sub

#End Region

#Region " Helper Methods "

        Private Sub BindData()
            Me.rptGallery.Visible = False

            If Not Me.Albums Is Nothing AndAlso Me.Albums.Count > 0 Then
                Me.rptGallery.DataSource = Me.Albums
                Me.rptGallery.DataBind()
                Me.rptGallery.Visible = True

                Me.WriteOutLightboxConstructors()
            Else
                AddModuleMessage(Me, Me.GetLocalizedString("Error.NoAlbums"), ModuleMessageType.BlueInfo)
            End If

        End Sub

        Protected Function GetImageFiles(ByVal LightboxId As String, ByVal FolderName As String, ByVal GalleryName As String) As String

            Dim strReturn As String = String.Empty

            If Regex.IsMatch(FolderName, FOLDER_NAME_MATCH_PATTERN) Then
                FolderName = Regex.Replace(FolderName, FOLDER_NAME_REPLACE_PATTERN, FOLDER_NAME_REPLACEMENT_PATTERN)
            End If

            If FolderManager.Instance().FolderExists(Me.PortalId, FolderName) Then

                Dim intLightboxId As Integer = Integer.Parse(LightboxId, Globalization.NumberStyles.Integer)
                Dim arrImages As ArrayList

                ' grab a list of only images from the directory (folder)
                Dim oFolder = FolderManager.Instance.GetFolder(PortalId, FolderName)
                arrImages = VerifiedFileList(FolderManager.Instance.GetFiles(oFolder, True))

                ' create a thumbnail for each image
                CreateThumbnails(arrImages)

                ' delete any references to missing/deleted files
                SyncImagesWithDatabase(intLightboxId, arrImages)

                If arrImages.Count > 0 Then

                    Dim ctlModule As New LightboxController
                    Dim oLightbox As LightboxInfo = ctlModule.GetLightbox(intLightboxId)
                    Dim sb As New StringBuilder(50)

                    sb.AppendFormat("
", GetGalleryListId(GalleryName))

                    ' create the image tiles
                    For Each oImage As IFileInfo In arrImages

                        If Not String.IsNullOrEmpty(oImage.FileName) Then

                            Dim imgFileName As String = GetFileName(oImage.FileName)

                            ' attempt to get a reference to the image
                            Dim img As ImageInfo = ctlModule.GetImageByFileName(intLightboxId, imgFileName)

                            If img Is Nothing Then
                                ' create a reference to the image
                                ctlModule.AddImage(intLightboxId, imgFileName, imgFileName, String.Empty, 0, UserId)
                                ' reload the reference
                                img = ctlModule.GetImageByFileName(intLightboxId, imgFileName)
                            End If

                        End If
                    Next

                    ' get a collection of the images to display
                    Dim collImage As ImageInfoCollection = ctlModule.GetImages(intLightboxId)
                    Dim oLightboxFolder As IFolderInfo = FolderManager.Instance().GetFolder(PortalId, oLightbox.GalleryFolder)

                    For Each objImage As ImageInfo In collImage

                        Dim oImage As IFileInfo = ctlModule.GetImageFromProvider(PortalId, oLightboxFolder, objImage.FileName)
                        Dim oImageThumbnail As IFileInfo = ctlModule.GetImageFromProvider(PortalId, oLightboxFolder, GetThumbnailImageName(objImage.FileName, Me.PortalSettings, True))

                        ' this check is necessary for use cases where the same "album" is used, but the folder is changed
                        If (oImage Is Nothing) then
                            ' drop from the database
                            ctlModule.DeleteImageById(objImage.ImageId)
                            ' skip to the next image
                            Continue For
                        End If

                        If IsEditable AndAlso PortalSettings.UserMode = Entities.Portals.PortalSettings.Mode.Edit Then
                            sb.AppendFormat( _
                                IMAGE_EDIT_TEMPLATE, _
                                CleanNameForRel(GalleryName), _
                                GetImageFileUrl(oImage), _
                                GetImageFileUrl(oImageThumbnail), _
                                objImage.Title, _
                                objImage.Description, _
                                GetImageEditUrl(objImage), _
                                Me.GetLocalizedString("ImageEdit.Text") _
                            )
                        Else
                            sb.AppendFormat( _
                                IMAGE_TEMPLATE, _
                                CleanNameForRel(GalleryName), _
                                GetImageFileUrl(oImage), _
                                GetImageFileUrl(oImageThumbnail), _
                                objImage.Title, _
                                objImage.Description _
                            )
                        End If

                    Next

                    sb.Append("
")

                    strReturn = sb.ToString
                Else
                    strReturn = String.Format(ERROR_WRAP, Me.GetLocalizedString("Error.NoImagesFound"))
                End If
            Else
                If Me.IsEditable Then
                    strReturn = String.Format(ERROR_WRAP, Me.GetLocalizedString("Error.PathNotFound"))
                    strReturn = String.Format(strReturn, FolderName)
                Else
                    strReturn = String.Format(ERROR_WRAP, Me.GetLocalizedString("Error.PathNotFound.Anonymous"))
                End If
            End If

            Return strReturn
        End Function

        Private Sub SyncImagesWithDatabase(ByVal LightboxId As Integer, ByVal FilesOnServer As ArrayList)

            Dim arrFilesOnServer As New ArrayList

            ' prepare a list of the valid files in the filesystem
            For Each strFile As IFileInfo In FilesOnServer
                If Not String.IsNullOrEmpty(strFile.FileName) Then
                    arrFilesOnServer.Add(GetFileName(strFile.FileName))
                End If
            Next

            Dim ctlLightbox As New LightboxController
            Dim collImagesInDb As ImageInfoCollection = ctlLightbox.GetImages(LightboxId)

            If Not collImagesInDb Is Nothing AndAlso collImagesInDb.Count > 0 Then

                ' iterate through the DB image list
                Dim arrFilesInDatabase As New ArrayList
                For Each oImageInDb As ImageInfo In collImagesInDb

                    arrFilesInDatabase.Add(oImageInDb.FileName)

                Next ' For Each oImageInDb As ImageInfo In collImagesInDb

                ' determine which files are orphaned
                Dim arrDifference As ArrayList = GetOrphanedFiles(arrFilesInDatabase, arrFilesOnServer)

                If Not arrDifference Is Nothing Then

                    For Each strFile As String In arrDifference

                        Dim oLightbox As LightboxInfo = ctlLightbox.GetLightbox(LightboxId)
                        Dim oImage As ImageInfo = ctlLightbox.GetImageByFileName(LightboxId, strFile)

                        ' need to get the thumbnail file name
                        Dim strThumbnail As String = GetThumbnailImageName(oImage.FileName, Me.PortalSettings, False)

                        ' need to map to the file
                        If Not Regex.IsMatch(strThumbnail, "[/\\]+", RegexOptions.IgnoreCase) Then
                            strThumbnail = String.Concat(Me.PortalSettings.HomeDirectoryMapPath, oLightbox.GalleryFolder, strThumbnail)
                            strThumbnail = ReformatPathForLocal(strThumbnail)
                        End If

                        Dim oFolder As IFolderInfo = FolderManager.Instance().GetFolder(Me.PortalId, oLightbox.GalleryFolder)

                        If FileManager.Instance().FileExists(oFolder, strThumbnail) Then
                            Try
                                ' delete the thumbnail
                                Dim oFile As IFileInfo = ctlLightbox.GetImageFromProvider(PortalId, oFolder, strThumbnail)
                                FileManager.Instance().DeleteFile(oFile)
                            Catch ex As Exception
                                LogException(ex)
                            End Try
                        End If

                        ' drop from the database
                        ctlLightbox.DeleteImageById(oImage.ImageId)

                    Next

                End If

            End If ' If Not collImagesInDb Is Nothing AndAlso collImagesInDb.Count > 0 Then

        End Sub

        Private Function GetOrphanedFiles(ByVal FilesOnDatabase As ArrayList, ByRef FilesOnServer As ArrayList) As ArrayList

            Dim arrDifference As New ArrayList

            For Each item As String In FilesOnDatabase
                If Not FilesOnServer.Contains(item) Then
                    arrDifference.Add(item)
                End If
            Next

            Return arrDifference

        End Function

        Private Sub CreateThumbnails(ByVal Files As ArrayList)

            Dim oImage As Image = Nothing
            Dim oThumbnail As Image = Nothing

            For Each oFile As IFileInfo In Files

                ' only proceed if this is a real file name, and the file name doesn't already exist
                If Not String.IsNullOrEmpty(oFile.FileName) AndAlso Not Regex.IsMatch(oFile.FileName, THUMBNAIL_MATCH_PATTERN, RegexOptions.IgnoreCase) Then

                    ' only create a thumbnail if it doesn't exist
                    Dim strThumbnailFileName As String = GetThumbnailImageName(oFile.FileName, Me.PortalSettings, False)
                    Dim oFolder As IFolderInfo = FolderManager.Instance().GetFolder(Me.PortalId, oFile.Folder)

                    If Not FileManager.Instance().FileExists(oFolder, strThumbnailFileName) Then

                        Try
                            ' get an instance of the image
                            oImage = Image.FromStream(FileManager.Instance().GetFileContent(oFile))
                        Catch ex As Exception
                            LogException(ex)
                        End Try

                        If Not oImage Is Nothing Then
                            Dim intNewWidth As Integer = 100

                            If oImage.Width <= intNewWidth Then
                                intNewWidth = oImage.Width
                            End If

                            Dim intNewHeight As Integer = CType(oImage.Height * intNewWidth / oImage.Width, Integer)

                            If intNewHeight > MAX_IMAGE_HEIGHT Then
                                intNewWidth = CType(oImage.Width * MAX_IMAGE_HEIGHT / oImage.Height, Integer)
                                intNewHeight = MAX_IMAGE_HEIGHT
                            End If

                            ' create and save a thumbnail
                            oThumbnail = oImage.GetThumbnailImage(intNewWidth, intNewHeight, Nothing, Nothing)

                            ' save the image in memory
                            Dim ms As New MemoryStream

                            ' branch the save statement to avoid encoder errors
                            Select Case oFile.Extension.ToLower()
                                Case "jpg"
                                    oThumbnail.Save(ms, Imaging.ImageFormat.Jpeg)
                                Case "gif"
                                    oThumbnail.Save(ms, Imaging.ImageFormat.Gif)
                                Case "png"
                                    oThumbnail.Save(ms, Imaging.ImageFormat.Png)
                            End Select

                            ' save the image in the DNN file system
                            FileManager.Instance().AddFile(oFolder, strThumbnailFileName, ms)
                        End If

                    End If ' If Not File.Exists(ThumbnailImageName(oFile)) Then

                End If ' If Not String.IsNullOrEmpty(oFile) Then

            Next

        End Sub

        '''
        ''' WriteOutLightboxConstructors - builds the JS constructors to add to the page for the fancybox plugin
        '''
        ''' <remarks></remarks>
        ''' <history>
        ''' 20101013 - wstrohl - Added newlines to prevent javascript errors
        ''' </history>
        Private Sub WriteOutLightboxConstructors()

            If Not Me.AlbumIds Is Nothing Then

                Dim ctlLightbox As New LightboxController
                Dim objAlbum As New LightboxInfo
                Dim objSetting As New SettingInfo
                Dim sb As New StringBuilder(500)
                Dim strUlId As String = Null.NullString

                sb.Append("")
                sb.Append(Environment.NewLine)

                If Not sb Is Nothing Then
                    Me.phScript.Controls.Add(New LiteralControl(sb.ToString))
                End If

            End If ' If Not Me.p_AlbumIds Is Nothing Then

        End Sub

        Private Function GetGalleryListId(ByVal GalleryName As String) As String
            Return String.Format("ul{0}_{1}", CleanNameForRel(GalleryName), Me.ModuleId)
        End Function

        Private Function GetFileName(ByVal FilePath As String) As String

            Return Path.GetFileName(FilePath)

        End Function

#End Region

#Region " URL Helper Methods "

        Protected Function GetEditUrl(ByVal GalleryId As Object) As String
            If Not GalleryId Is Nothing Then
                Return EditUrl("AlbumId", GalleryId.ToString, "Edit")
            Else
                Return "#"
            End If
        End Function

        Protected Function GetReorderUrl(ByVal GalleryId As Object) As String
            If Not GalleryId Is Nothing Then
                Return EditUrl("Album", GalleryId.ToString, "ChangeImageOrder")
            Else
                Return "#"
            End If
        End Function

        Private Function GetImageEditUrl(ByVal oImage As ImageInfo) As String

            Return EditUrl("Image", oImage.ImageId.ToString, "EditImage", String.Format("&Album={0}", oImage.LightboxId))

        End Function

        Private Function GetImageFileUrl(ByVal Image As IFileInfo) As String

            Try
                Dim ctlModule As New LightboxController
                Return ctlModule.GetImageFileUrl(Image)
            Catch ex As Exception
                If IsEditable AndAlso PortalSettings.UserMode = Entities.Portals.PortalSettings.Mode.Edit Then
                    ProcessModuleLoadException(Me, ex, True)
                Else
                    LogException(ex)
                End If
                Return String.Empty
            End Try

        End Function

#End Region

#Region " Clean Helper Methods "

        Protected Function CleanNameForRel(ByVal AlbumName As Object) As String
            If Not AlbumName Is Nothing Then
                Return CleanNameForRel(AlbumName.ToString)
            Else
                Return String.Empty
            End If
        End Function

        Protected Function CleanNameForRel(ByVal AlbumName As String) As String
            If Not String.IsNullOrEmpty(AlbumName) Then
                ' remove any non-alphanumeric characters from the GalleryName, and append to create a stand-alone lightbox album
                Return String.Concat("lightbox-", Regex.Replace(AlbumName, "\W", String.Empty))
            Else
                Return String.Empty
            End If
        End Function

        Private Function CleanForClientScript(ByVal Text As String) As String
            Return Regex.Replace(Text, "'", "\'")
        End Function

#End Region

#Region " IActionable Implementation "

        Public ReadOnly Property ModuleActions() As DotNetNuke.Entities.Modules.Actions.ModuleActionCollection Implements IActionable.ModuleActions
            Get
                Dim Actions As New Actions.ModuleActionCollection
                Actions.Add(GetNextActionID, Me.GetLocalizedString(MENU_ITEM_TITLE_KEY), _
                    String.Empty, String.Empty, String.Empty, _
                    EditUrl(String.Empty, String.Empty, EDIT_KEY), _
                    False, DotNetNuke.Security.SecurityAccessLevel.Edit, True, False)

                ' if there is more than one album, allow the change order view to be displayed

                Dim ctlModule As New LightboxController
                Dim intCount As Integer = ctlModule.GetLightboxCount(Me.ModuleId)

                If intCount > 1 Then

                    Actions.Add(GetNextActionID, Me.GetLocalizedString(MENU_ITEM_CHANGEORDER_KEY), _
                        String.Empty, String.Empty, String.Empty, _
                        EditUrl(String.Empty, String.Empty, CHANGE_ORDER), _
                        False, DotNetNuke.Security.SecurityAccessLevel.Edit, True, False)

                End If

                Return Actions
            End Get
        End Property

#End Region

    End Class

End Namespace


text:
import { Injectable } from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable'
import {ApiUrl} from '../shared/apiurl.service'
import {Headers, RequestOptions} from '@angular/http';
import {ILoginResponse} from '../login/loginResponse'

@Injectable()
export class SignupService {

    constructor(private _apiUrl:ApiUrl, private _http:Http) { }
    signup(payload): Observable<ILoginResponse> {
        let body = JSON.stringify(payload);
        let headers = new Headers({ 'Content-Type': 'application/json' });
        let options = new RequestOptions({ headers: headers });

     return this._http.post(this._apiUrl.signupUrl,body, options)
        .map((response: Response) => <ILoginResponse>response.json())
        .do(data=>console.log("SignUp:", JSON.stringify(data)))
        .catch(this.handleError)
    }
     private handleError(error: Response) {
        console.error(error);
        return Observable.throw(error.json().error || 'Server error');
    }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace DoubleCursor
{
    /// <summary>
    /// LocalCursor.xaml 的交互逻辑
    /// </summary>
    public partial class LocalCursor : Window
    {
        public LocalCursor()
        {
            InitializeComponent();
        }
    }
}


text:
using System.Windows.Forms;
using SIL.Windows.Forms.Extensions;

namespace Glyssen.ReferenceTextUtility
{
	public partial class OutputForm : Form
	{
		private int m_totalMessages = 0;
		private bool m_messageLimitReached = false;
		public OutputForm()
		{
			InitializeComponent();
			m_logBox.ShowCopyToClipboardMenuItem = true;
			m_logBox.ShowFontMenuItem = true;
		}

		public void Clear()
		{
			m_logBox.Clear();
		}

		public void DisplayMessage(string message, bool isError)
		{
			if (m_messageLimitReached)
				return;
			this.SafeInvoke(() =>
			{
				m_totalMessages++;
				if (m_totalMessages < 10000)
				{
					if (isError)
						m_logBox.WriteError(message);
					else
						m_logBox.WriteMessage(message);
				}
				else if (!m_messageLimitReached)
				{
					m_logBox.WriteError("Maximum number of messages reached!");
					m_messageLimitReached = true;
				}

			}, GetType().FullName + ".DisplayMessage");
		}
	}
}


text:
layout: contact
title: Contact
image: contact-bg.jpg
heading: Contact Me
subheading: Have questions? I have answers (maybe).
contact:
    prompt: Want to get in touch with me? Fill out the form below to send me a message and I will try to
        get back to you within 24 hours!
---


text:
This system uses WebApps at every node, each performing node specific
behaviors.

## Open Source

This application is initially created by  David E. Smyth
under the MIT License, and therefore is and will remain open source software.

## Implementation Technology

This application is implemented using Ruby on Rails, specifically Ruby 2.0.0
and Rails 4.0.8.

The development process closely follows that suggested by [Michael
Hartl](http://michaelhartl.com/) in  the [*Ruby on Rails
Tutorial*](http://railstutorial.org/). Hence, RSpec is used for test driven
development, with Capybara and Selenium for automated user testing. Hence it
is and will forever remain bug free ;-)

## Other things to be covered better and better:

* System dependencies
Ruby on Rails, of course. Also, OpenCV for image processing via the opencv
gem.

* Configuration
brew install opencv
gem install ruby-opencv -- --with-opencv-dir=/usr/local/lib

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

Uses Devise for confirmation using email. Therefore, need mailcatcher. To download and start:
---
% gem install mailcatcher
% mailcatcher
---

To do test runs, can monitor mail activity at http://localhost:1080

* Deployment instructions


text:
[![Build Status](https://travis-ci.org/shamoh/mega-examples.svg?branch=master)](https://travis-ci.org/shamoh/mega-examples)
[![Code Coverage](http://codecov.io/github/shamoh/mega-examples/coverage.svg?branch=master)](http://codecov.io/github/shamoh/mega-examples?branch=master)
[![JitPack Status](https://jitpack.io/v/shamoh/mega-examples.svg)](https://jitpack.io/#shamoh/mega-examples)

Mega Examples
=============

Examples of Application Micro container based on CDI named [Mega](https://github.com/shamoh/mega).

Hello World
-----------

Example [Hello World](hello-world) just prints "Hello World!" to console.

HTTP Static Content Example
---------------------------

Example [HTTP Static Content](http-static-content) demonstrates
how to integrate with Grizzly HTTP Server to provide static content.

JAX-RS Hello World Example
--------------------------

Example [JAX-RS Hello World](jaxrs-hello-world) demonstrates using JAX-RS Server.

Build it
--------

```shell
gradle -t installDist
```


text:
package com.v7lin.android.env.webkit;

import android.annotation.TargetApi;
import android.os.Build;
import android.webkit.WebSettings;

/**
 * @author v7lin E-mail:v7lin@qq.com
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
class WebSettingsCompatJellyBean {

	public static void setAllowFileAccessFromFileURLs(WebSettings settings, boolean flag) {
		settings.setAllowFileAccessFromFileURLs(flag);
	}

	public static void setAllowUniversalAccessFromFileURLs(WebSettings settings, boolean flag) {
		settings.setAllowUniversalAccessFromFileURLs(flag);
	}
}


text:
if [ -e ./Makefile ]; then
	echo "Renaming Makefile to Makefile.save"
	mv Makefile Makefile.save
fi
echo "# Makefile for Glasgow SRPC system" >Makefile
echo "# Customized for `uname -n` running `uname -s` on `date`" >>Makefile
echo "# " >>Makefile
echo "OS=`uname -s | sed '/^CYGWIN/s/^.*$/Cygwin/'`" >>Makefile

cat <<!endoftemplate! >>Makefile
# Template makefile for Glasgow SRPC system
#
# Conditionalized upon the value of \$(OS) - if unspecified in the command
# line, OS is assumed to be the value defined above
#
# e.g.
#      make			# makes appropriate binaries for $OS
#      make OS=Cygwin 		# makes appropriate binaries for Cygwin
#      make OS=Darwin 		# makes appropriate binaries for OSX
#      make OS=Linux 		# makes appropriate binaries for Linux

# base definitions
CC = gcc
# comment out the next line if you are using valgrind or gdb
OPT=-O2

CFL_BASE = -W -Wall
LFL_COMMON =
CFL_COMMON = \$(CFL_BASE)
# enable debugging with
# CFL_COMMON = \$(CFL_BASE) -DLOG -DVLOG -DWARNING
# CFL_COMMON = \$(CFL_BASE) -g -DLOG -DVLOG -DWARNING -DDEBUG -DVDEBUG
# compile for valgrind with
# CFL_COMMON = \$(CFL_BASE) -g

ifeq (\$(OS),Cygwin)
    EXT=.exe
else
    EXT=
endif

OBJECTS = crecord.o ctable.o endpoint.o srpc.o stable.o tslist.o
PROGRAMS = mthclient\$(EXT) callbackserver\$(EXT) callbackclient\$(EXT) echoserver\$(EXT) echoclient\$(EXT) sinkclient\$(EXT) sgenclient\$(EXT) sinktest\$(EXT) conntest\$(EXT)

LIBS = -lpthread
CFLAGS=\$(CFL_COMMON) \$(OPT)
LDFLAGS = \$(LFL_COMMON)

# OS-specific definitions
ifeq (\$(OS),Cygwin)
    LIBS =
endif
ifeq (\$(OS),Darwin)
    CFLAGS = \$(CFL_COMMON) -DHAVE_SOCKADDR_LEN \$(OPT)
endif

all: \$(PROGRAMS)

clean:
	rm -f *.o *.exe *~ *.stackdump \$(PROGRAMS) libsrpc.a

libsrpc.a: \$(OBJECTS)
	rm -f libsrpc.a
	ar r libsrpc.a \$(OBJECTS)
	ranlib libsrpc.a

mthclient.o: mthclient.c srpc.h
callbackserver.o: callbackserver.c callback.h srpc.h
callbackclient.o: callbackclient.c callback.h srpc.h
echoserver.o: echoserver.c srpc.h
echoclient.o: echoclient.c srpc.h
sinkclient.o: sinkclient.c srpc.h
sgenclient.o: sgenclient.c srpc.h
sinktest.o: sinktest.c srpc.h
conntest.o: conntest.c srpc.h
crecord.o: crecord.c crecord.h ctable.h endpoint.h stable.h
ctable.o: ctable.c ctable.h endpoint.h crecord.h
endpoint.o: endpoint.c endpoint.h
srpc.o: srpc.c srpc.h srpcdefs.h tslist.h endpoint.h ctable.h crecord.h stable.h
stable.o: stable.c stable.h tslist.h
tslist.o: tslist.c tslist.h

mthclient\$(EXT): mthclient.o libsrpc.a
	gcc -o mthclient\$(EXT) \$(LIBS) mthclient.o libsrpc.a

callbackserver\$(EXT): callbackserver.o libsrpc.a
	gcc -o callbackserver\$(EXT) \$(LIBS) callbackserver.o libsrpc.a

callbackclient\$(EXT): callbackclient.o libsrpc.a
	gcc -o callbackclient\$(EXT) \$(LIBS) callbackclient.o libsrpc.a

echoserver\$(EXT): echoserver.o libsrpc.a
	gcc -o echoserver\$(EXT) \$(LIBS) echoserver.o libsrpc.a

echoclient\$(EXT): echoclient.o libsrpc.a
	gcc -o echoclient\$(EXT) \$(LIBS) echoclient.o libsrpc.a

sinkclient\$(EXT): sinkclient.o libsrpc.a
	gcc -o sinkclient\$(EXT) \$(LIBS) sinkclient.o libsrpc.a

sgenclient\$(EXT): sgenclient.o libsrpc.a
	gcc -o sgenclient\$(EXT) \$(LIBS) sgenclient.o libsrpc.a

sinktest\$(EXT): sinktest.o libsrpc.a
	gcc -o sinktest\$(EXT) \$(LIBS) sinktest.o libsrpc.a

conntest\$(EXT): conntest.o libsrpc.a
	gcc -o conntest\$(EXT) \$(LIBS) conntest.o libsrpc.a

!endoftemplate!


text:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 *	Contains code for an AABB collider.
 *	\file		OPC_AABBCollider.h
 *	\author		Pierre Terdiman
 *	\date		January, 1st, 2002
 */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Include Guard
#ifndef __OPC_AABBCOLLIDER_H__
#define __OPC_AABBCOLLIDER_H__

	struct OPCODE_API AABBCache : VolumeCache
	{
						AABBCache() : FatCoeff(1.1f)
						{
							FatBox.mCenter.Zero();
							FatBox.mExtents.Zero();
						}

		// Cached faces signature
		CollisionAABB	FatBox;		//!< Box used when performing the query resulting in cached faces
		// User settings
		float			FatCoeff;	//!< mRadius2 multiplier used to create a fat sphere
	};

	class OPCODE_API AABBCollider : public VolumeCollider
	{
		public:
		// Constructor / Destructor
											AABBCollider();
		virtual								~AABBCollider();

		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 *	Generic collision query for generic OPCODE models. After the call, access the results:
		 *	- with GetContactStatus()
		 *	- with GetNbTouchedPrimitives()
		 *	- with GetTouchedPrimitives()
		 *
		 *	\param		cache			[in/out] a box cache
		 *	\param		box				[in] collision AABB in world space
		 *	\param		model			[in] Opcode model to collide with
		 *	\return		true if success
		 *	\warning	SCALE NOT SUPPORTED. The matrices must contain rotation & translation parts only.
		 */
		///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
							bool			Collide(AABBCache& cache, const CollisionAABB& box, const Model& model);
		//
							bool			Collide(AABBCache& cache, const CollisionAABB& box, const AABBTree* tree);
		protected:
							CollisionAABB	mBox;			//!< Query box in (center, extents) form
							Point			mMin;			//!< Query box min point
							Point			mMax;			//!< Query box max point
		// Leaf description
							Point			mLeafVerts[3];	//!< Triangle vertices
		// Internal methods
							void			_Collide(const AABBCollisionNode* node);
							void			_Collide(const AABBNoLeafNode* node);
							void			_Collide(const AABBQuantizedNode* node);
							void			_Collide(const AABBQuantizedNoLeafNode* node);
							void			_Collide(const AABBTreeNode* node);
							void			_CollideNoPrimitiveTest(const AABBCollisionNode* node);
							void			_CollideNoPrimitiveTest(const AABBNoLeafNode* node);
							void			_CollideNoPrimitiveTest(const AABBQuantizedNode* node);
							void			_CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node);
			// Overlap tests
		inline_				BOOL			AABBContainsBox(const Point& bc, const Point& be);
		inline_				BOOL			AABBAABBOverlap(const Point& b, const Point& Pb);
		inline_				BOOL			TriBoxOverlap();
			// Init methods
							BOOL			InitQuery(AABBCache& cache, const CollisionAABB& box);
	};

	class OPCODE_API HybridAABBCollider : public AABBCollider
	{
		public:
		// Constructor / Destructor
											HybridAABBCollider();
		virtual								~HybridAABBCollider();

							bool			Collide(AABBCache& cache, const CollisionAABB& box, const HybridModel& model);
		protected:
							Container		mTouchedBoxes;
	};

#endif // __OPC_AABBCOLLIDER_H__


text:
import Service from '@ember/service';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { setupIntl } from 'ember-intl/test-support';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { component } from 'ilios/tests/pages/components/learnergroup-cohort-user-manager';

module('Integration | Component | learnergroup cohort user manager', function (hooks) {
  setupRenderingTest(hooks);
  setupIntl(hooks, 'en-us');
  setupMirage(hooks);

  test('it renders', async function (assert) {
    const user1 = this.server.create('user', {
      firstName: 'Jasper',
      lastName: 'Dog',
      campusId: '1234',
      email: 'testemail',
      enabled: true,
    });
    const user2 = this.server.create('user', {
      firstName: 'Jackson',
      lastName: 'Doggy',
      campusId: '123',
      email: 'testemail2',
      enabled: false,
    });
    const userModel1 = await this.owner.lookup('service:store').find('user', user1.id);
    const userModel2 = await this.owner.lookup('service:store').find('user', user2.id);

    this.set('users', [userModel1, userModel2]);

    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="lastName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{(noop)}}
    />`);

    assert.strictEqual(component.title, 'Cohort Members NOT assigned to top level group (2)');
    assert.strictEqual(component.users.length, 2);
    assert.strictEqual(component.users[0].name.userNameInfo.fullName, 'Jasper M. Dog');
    assert.strictEqual(component.users[0].campusId.text, '1234');
    assert.strictEqual(component.users[0].email.text, 'testemail');
    assert.ok(component.users[0].name.isClickable);
    assert.ok(component.users[0].campusId.isClickable);
    assert.ok(component.users[0].email.isClickable);
    assert.notOk(component.users[0].isDisabled);
    assert.strictEqual(component.users[1].name.userNameInfo.fullName, 'Jackson M. Doggy');
    assert.strictEqual(component.users[1].campusId.text, '123');
    assert.strictEqual(component.users[1].email.text, 'testemail2');
    assert.notOk(component.users[1].name.isClickable);
    assert.notOk(component.users[1].campusId.isClickable);
    assert.notOk(component.users[1].email.isClickable);
    assert.ok(component.users[1].isDisabled);
  });

  test('sort by full name', async function (assert) {
    const user1 = this.server.create('user', { firstName: 'Jasper' });
    const user2 = this.server.create('user', { firstName: 'Jackson' });
    const user3 = this.server.create('user', { firstName: 'Jayden', displayName: 'Captain J' });
    const userModel1 = await this.owner.lookup('service:store').find('user', user1.id);
    const userModel2 = await this.owner.lookup('service:store').find('user', user2.id);
    const userModel3 = await this.owner.lookup('service:store').find('user', user3.id);

    this.set('users', [userModel1, userModel2, userModel3]);

    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="fullName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{(noop)}}
    />`);

    assert.strictEqual(component.users.length, 3);
    assert.strictEqual(component.users[0].name.userNameInfo.fullName, 'Captain J');
    assert.strictEqual(component.users[1].name.userNameInfo.fullName, 'Jackson M. Mc1son');
    assert.strictEqual(component.users[2].name.userNameInfo.fullName, 'Jasper M. Mc0son');
  });

  test('add multiple users', async function (assert) {
    assert.expect(5);

    const user = this.server.create('user', { enabled: true });
    const userModel = await this.owner.lookup('service:store').find('user', user.id);

    this.set('users', [userModel]);
    this.set('addMany', ([user]) => {
      assert.strictEqual(userModel, user);
    });

    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="firstName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{this.addMany}}
    />`);

    assert.notOk(component.membersCanBeAdded);
    await component.users[0].select();
    assert.ok(component.membersCanBeAdded);
    assert.strictEqual(component.addButtonText, 'Move learner to this group');
    await component.add();
    assert.notOk(component.membersCanBeAdded);
  });

  test('add single user', async function (assert) {
    assert.expect(1);

    const user = this.server.create('user', { enabled: true });
    const userModel = await this.owner.lookup('service:store').find('user', user.id);

    this.set('users', [userModel]);
    this.set('addOne', (user) => {
      assert.strictEqual(userModel, user);
    });

    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="firstName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{this.addOne}}
      @addUsersToGroup={{(noop)}}
    />`);

    await component.users[0].add();
  });

  test('when users are selected single action is disabled', async function (assert) {
    assert.expect(2);

    const user = this.server.create('user', { enabled: true });
    const userModel = await this.owner.lookup('service:store').find('user', user.id);

    this.set('users', [userModel]);

    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="firstName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{(noop)}}
    />`);

    assert.ok(component.users[0].canBeAdded);
    await component.users[0].select();
    assert.notOk(component.users[0].canBeAdded);
  });

  test('checkall', async function (assert) {
    assert.expect(7);

    const user1 = this.server.create('user', { firstName: 'Jasper' });
    const user2 = this.server.create('user', { firstName: 'Jackson' });
    const userModel1 = await this.owner.lookup('service:store').find('user', user1.id);
    const userModel2 = await this.owner.lookup('service:store').find('user', user2.id);

    this.set('users', [userModel1, userModel2]);
    this.set('addMany', ([userA, userB]) => {
      assert.strictEqual(userModel1, userA);
      assert.strictEqual(userModel2, userB);
    });

    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="firstName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{this.addMany}}
    />`);

    assert.notOk(component.users[0].isSelected);
    assert.notOk(component.users[0].isSelected);
    await component.selectAll.toggle();
    assert.ok(component.users[0].isSelected);
    assert.ok(component.users[0].isSelected);
    assert.strictEqual(component.addButtonText, 'Move 2 learners to this group');
    await component.add();
  });

  test('checking one puts checkall box into indeterminate state', async function (assert) {
    const user1 = this.server.create('user', { enabled: true });
    const user2 = this.server.create('user', { enabled: true });
    const userModel1 = await this.owner.lookup('service:store').find('user', user1.id);
    const userModel2 = await this.owner.lookup('service:store').find('user', user2.id);

    this.set('users', [userModel1, userModel2]);

    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="firstName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{(noop)}}
    />`);

    assert.notOk(component.users[0].isSelected);
    assert.notOk(component.users[1].isSelected);
    assert.notOk(component.selectAll.isChecked);
    assert.notOk(component.selectAll.isIndeterminate);
    await component.users[0].select();
    assert.notOk(component.selectAll.isChecked);
    assert.ok(component.selectAll.isIndeterminate);
    await component.users[1].select();
    assert.ok(component.selectAll.isChecked);
    assert.notOk(component.selectAll.isIndeterminate);
    assert.ok(component.users[0].isSelected);
    assert.ok(component.users[1].isSelected);
    await component.selectAll.toggle();
    assert.notOk(component.users[0].isSelected);
    assert.notOk(component.users[1].isSelected);
  });

  test('filtering and bulk-selection', async function (assert) {
    const user1 = this.server.create('user', { enabled: true, displayName: 'Alpha' });
    const user2 = this.server.create('user', { enabled: true, displayName: 'Beta' });
    const user3 = this.server.create('user', { enabled: true, displayName: 'Gamma' });
    const userModel1 = await this.owner.lookup('service:store').find('user', user1.id);
    const userModel2 = await this.owner.lookup('service:store').find('user', user2.id);
    const userModel3 = await this.owner.lookup('service:store').find('user', user3.id);

    this.set('users', [userModel1, userModel2, userModel3]);

    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="firstName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{(noop)}}
    />`);

    assert.strictEqual(component.users.length, 3);
    assert.strictEqual(component.users[0].name.userNameInfo.fullName, 'Alpha');
    assert.strictEqual(component.users[1].name.userNameInfo.fullName, 'Beta');
    assert.strictEqual(component.users[2].name.userNameInfo.fullName, 'Gamma');
    assert.notOk(component.users[0].isSelected);
    assert.notOk(component.users[1].isSelected);
    assert.notOk(component.users[2].isSelected);
    assert.notOk(component.selectAll.isChecked);
    assert.notOk(component.selectAll.isIndeterminate);

    await component.filter('Zzzz');
    assert.strictEqual(component.users.length, 0);
    assert.notOk(component.selectAll.isChecked);
    assert.notOk(component.selectAll.isIndeterminate);

    await component.filter('');
    assert.strictEqual(component.users.length, 3);
    assert.notOk(component.selectAll.isChecked);
    assert.notOk(component.selectAll.isIndeterminate);

    await component.users[2].select();
    assert.notOk(component.selectAll.isChecked);
    assert.ok(component.selectAll.isIndeterminate);

    await component.filter('Alpha');
    assert.notOk(component.selectAll.isChecked);
    assert.ok(component.selectAll.isIndeterminate);
    assert.strictEqual(component.users.length, 1);
    assert.strictEqual(component.users[0].name.userNameInfo.fullName, 'Alpha');
    assert.notOk(component.users[0].isSelected);

    await component.selectAll.toggle();
    assert.ok(component.selectAll.isChecked);
    assert.ok(component.selectAll.isIndeterminate);
    assert.ok(component.users[0].isSelected);

    await component.filter('');
    assert.strictEqual(component.users.length, 3);
    assert.ok(component.selectAll.isChecked);
    assert.ok(component.selectAll.isIndeterminate);
    assert.ok(component.users[0].isSelected);
    assert.notOk(component.users[1].isSelected);
    assert.ok(component.users[2].isSelected);

    await component.selectAll.toggle();
    assert.ok(component.selectAll.isChecked);
    assert.notOk(component.selectAll.isIndeterminate);
    assert.ok(component.users[0].isSelected);
    assert.ok(component.users[1].isSelected);
    assert.ok(component.users[2].isSelected);

    await component.selectAll.toggle();
    assert.notOk(component.selectAll.isChecked);
    assert.notOk(component.selectAll.isIndeterminate);
    assert.notOk(component.users[0].isSelected);
    assert.notOk(component.users[1].isSelected);
    assert.notOk(component.users[2].isSelected);
  });

  test('root users can manage disabled users', async function (assert) {
    const currentUserMock = Service.extend({
      isRoot: true,
    });
    this.owner.register('service:currentUser', currentUserMock);

    const user = this.server.create('user', { enabled: false });
    const userModel = await this.owner.lookup('service:store').find('user', user.id);

    this.set('users', [userModel]);
    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="firstName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{(noop)}}
    />`);

    assert.ok(component.users[0].canBeSelected, 'Checkbox visible');
    assert.ok(component.users[0].name.isClickable);
    assert.ok(component.users[0].campusId.isClickable);
    assert.ok(component.users[0].email.isClickable);
    assert.ok(component.users[0].isDisabled, 'User is labeled as disabled.');
  });

  test('non-root users cannot manage disabled users', async function (assert) {
    const currentUserMock = Service.extend({
      isRoot: false,
    });
    this.owner.register('service:currentUser', currentUserMock);

    const user = this.server.create('user', { enabled: false });
    const userModel = await this.owner.lookup('service:store').find('user', user.id);

    this.set('users', [userModel]);

    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="firstName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{(noop)}}
    />`);

    assert.notOk(component.users[0].canBeSelected, 'Checkbox visible');
    assert.notOk(component.users[0].name.isClickable);
    assert.notOk(component.users[0].campusId.isClickable);
    assert.notOk(component.users[0].email.isClickable);
    assert.ok(component.users[0].isDisabled, 'User is labeled as disabled.');
  });

  test('filter users', async function (assert) {
    const user1 = this.server.create('user', {
      firstName: 'Jasper',
      lastName: 'Dog',
      email: 'jasper.dog@example.edu',
    });
    const user2 = this.server.create('user', {
      firstName: 'Jackson',
      lastName: 'Doggy',
      email: 'jackson.doggy@example.edu',
    });
    const user3 = this.server.create('user', {
      firstName: 'Jayden',
      lastName: 'Pup',
      displayName: 'Just Jayden',
      email: 'jayden@example.edu',
    });
    const userModel1 = await this.owner.lookup('service:store').find('user', user1.id);
    const userModel2 = await this.owner.lookup('service:store').find('user', user2.id);
    const userModel3 = await this.owner.lookup('service:store').find('user', user3.id);

    this.set('users', [userModel1, userModel2, userModel3]);
    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="lastName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{(noop)}}
    />`);

    assert.strictEqual(component.users.length, 3);
    assert.strictEqual(component.users[0].name.userNameInfo.fullName, 'Jasper M. Dog');
    assert.strictEqual(component.users[1].name.userNameInfo.fullName, 'Jackson M. Doggy');
    assert.strictEqual(component.users[2].name.userNameInfo.fullName, 'Just Jayden');
    await component.filter('Just');
    assert.strictEqual(component.users[0].name.userNameInfo.fullName, 'Just Jayden');
    await component.filter(' Just     ');
    assert.strictEqual(component.users[0].name.userNameInfo.fullName, 'Just Jayden');
    await component.filter('JASPER.DOG@EXAMPLE.EDU');
    assert.strictEqual(component.users[0].name.userNameInfo.fullName, 'Jasper M. Dog');
    await component.filter('jasper d');
    assert.strictEqual(component.users[0].name.userNameInfo.fullName, 'Jasper M. Dog');
  });

  test('click on name', async function (assert) {
    const user = this.server.create('user', { enabled: true });
    const userModel = await this.owner.lookup('service:store').find('user', user.id);
    this.set('users', [userModel]);
    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="firstName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{(noop)}}
    />`);
    assert.notOk(component.users[0].isSelected);
    await component.users[0].name.click();
    assert.ok(component.users[0].isSelected);
  });

  test('click on campus id', async function (assert) {
    const user = this.server.create('user', { enabled: true });
    const userModel = await this.owner.lookup('service:store').find('user', user.id);
    this.set('users', [userModel]);
    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="firstName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{(noop)}}
    />`);
    assert.notOk(component.users[0].isSelected);
    await component.users[0].campusId.click();
    assert.ok(component.users[0].isSelected);
  });

  test('click on email', async function (assert) {
    const user = this.server.create('user', { enabled: true });
    const userModel = await this.owner.lookup('service:store').find('user', user.id);
    this.set('users', [userModel]);
    await render(hbs`<LearnergroupCohortUserManager
      @users={{this.users}}
      @canUpdate={{true}}
      @learnerGroupTitle="this group"
      @topLevelGroupTitle="top level group"
      @sortBy="firstName"
      @setSortBy={{(noop)}}
      @addUserToGroup={{(noop)}}
      @addUsersToGroup={{(noop)}}
    />`);
    assert.notOk(component.users[0].isSelected);
    await component.users[0].email.click();
    assert.ok(component.users[0].isSelected);
  });
});


text:
export class User {
    _id: string;
    username: string;
    password: string;
    firstName: string;
    lastName: string;
    userRole: string;
}