text:
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_LastSearch]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_LastSearch](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[UserID] [int] NOT NULL,
	[PortalID] [int] NOT NULL,
	[SearchText] [nvarchar](150) NULL,
	[Status] [nvarchar](50) NULL,
	[Priority] [nvarchar](50) NULL,
	[CreatedDate] [datetime] NULL,
	[DueDate] [datetime] NULL,
	[AssignedRoleID] [int] NULL,
	[Categories] [nvarchar](2000) NULL,
	[CurrentPage] [int] NULL,
	[PageSize] [int] NULL,
 CONSTRAINT [PK_ADefHelpDesk_LastSearch] PRIMARY KEY CLUSTERED
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_LastSearch]') AND name = N'IX_ADefHelpDesk_LastSearch')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_LastSearch] ON [dbo].[ADefHelpDesk_LastSearch]
(
	[UserID] ASC,
	[PortalID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Categories]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_Categories](
	[CategoryID] [int] IDENTITY(1,1) NOT NULL,
	[PortalID] [int] NOT NULL,
	[ParentCategoryID] [int] NULL,
	[CategoryName] [nvarchar](50) NULL,
	[Level] [int] NOT NULL,
	[RequestorVisible] [bit] NOT NULL,
	[Selectable] [bit] NOT NULL,
 CONSTRAINT [PK_ADefHelpDesk_Categories] PRIMARY KEY CLUSTERED
(
	[CategoryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Categories]') AND name = N'IX_ADefHelpDesk_Categories')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_Categories] ON [dbo].[ADefHelpDesk_Categories]
(
	[PortalID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Settings]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_Settings](
	[SettingID] [int] IDENTITY(1,1) NOT NULL,
	[PortalID] [int] NOT NULL,
	[SettingName] [nvarchar](150) NOT NULL,
	[SettingValue] [nvarchar](250) NOT NULL,
 CONSTRAINT [PK_ADefHelpDesk_Settings] PRIMARY KEY CLUSTERED
(
	[SettingID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Settings]') AND name = N'IX_ADefHelpDesk_Settings_PortalID')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_Settings_PortalID] ON [dbo].[ADefHelpDesk_Settings]
(
	[PortalID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Roles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_Roles](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[PortalID] [int] NOT NULL,
	[RoleName] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_ADefHelpDesk_Roles] PRIMARY KEY CLUSTERED
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Roles]') AND name = N'IX_ADefHelpDesk_Roles')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_Roles] ON [dbo].[ADefHelpDesk_Roles]
(
	[PortalID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Tasks]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_Tasks](
	[TaskID] [int] IDENTITY(1,1) NOT NULL,
	[PortalID] [int] NOT NULL,
	[Description] [nvarchar](150) NOT NULL,
	[Status] [nvarchar](50) NOT NULL,
	[Priority] [nvarchar](50) NOT NULL,
	[CreatedDate] [datetime] NOT NULL,
	[EstimatedStart] [datetime] NULL,
	[EstimatedCompletion] [datetime] NULL,
	[DueDate] [datetime] NULL,
	[AssignedRoleID] [int] NOT NULL,
	[TicketPassword] [nvarchar](50) NOT NULL,
	[RequesterUserID] [int] NOT NULL,
	[RequesterName] [nvarchar](350) NULL,
	[RequesterEmail] [nvarchar](350) NULL,
	[RequesterPhone] [nvarchar](50) NULL,
	[EstimatedHours] [int] NULL,
 CONSTRAINT [PK_ADefHelpDeskTasks] PRIMARY KEY CLUSTERED
(
	[TaskID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Tasks]') AND name = N'IX_ADefHelpDesk_Tasks_AssignedRoleID')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_Tasks_AssignedRoleID] ON [dbo].[ADefHelpDesk_Tasks]
(
	[AssignedRoleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Tasks]') AND name = N'IX_ADefHelpDesk_Tasks_CreatedDate')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_Tasks_CreatedDate] ON [dbo].[ADefHelpDesk_Tasks]
(
	[CreatedDate] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Tasks]') AND name = N'IX_ADefHelpDesk_Tasks_Status')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_Tasks_Status] ON [dbo].[ADefHelpDesk_Tasks]
(
	[Status] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Version]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_Version](
	[VersionNumber] [varchar](10) NOT NULL,
 CONSTRAINT [PK_ADefHelpDesk_Version] PRIMARY KEY CLUSTERED
(
	[VersionNumber] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Users]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_Users](
	[UserID] [int] IDENTITY(1,1) NOT NULL,
	[Username] [nvarchar](100) NOT NULL,
	[FirstName] [nvarchar](50) NOT NULL,
	[LastName] [nvarchar](50) NOT NULL,
	[IsSuperUser] [bit] NOT NULL,
	[Email] [nvarchar](256) NOT NULL,
	[Password] [nvarchar](50) NOT NULL,
	[RIAPassword] [nvarchar](50) NULL,
	[VerificationCode] [nvarchar](50) NULL,
 CONSTRAINT [PK_ADefHelpDesk_Users] PRIMARY KEY CLUSTERED
(
	[UserID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Users]') AND name = N'IX_ADefHelpDesk_Users')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_Users] ON [dbo].[ADefHelpDesk_Users]
(
	[Username] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Users]') AND name = N'IX_ADefHelpDesk_Users_Email')
CREATE UNIQUE NONCLUSTERED INDEX [IX_ADefHelpDesk_Users_Email] ON [dbo].[ADefHelpDesk_Users]
(
	[Email] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_UserRoles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_UserRoles](
	[UserRoleID] [int] IDENTITY(1,1) NOT NULL,
	[UserID] [int] NOT NULL,
	[RoleID] [int] NOT NULL,
 CONSTRAINT [PK_ADefHelpDesk_UserRoles] PRIMARY KEY CLUSTERED
(
	[UserRoleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskDetails]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_TaskDetails](
	[DetailID] [int] IDENTITY(1,1) NOT NULL,
	[TaskID] [int] NOT NULL,
	[DetailType] [nvarchar](50) NOT NULL,
	[InsertDate] [datetime] NOT NULL,
	[UserID] [int] NOT NULL,
	[Description] [nvarchar](max) NOT NULL,
	[StartTime] [datetime] NULL,
	[StopTime] [datetime] NULL,
 CONSTRAINT [PK_ADefHelpDesk_TaskDetails] PRIMARY KEY CLUSTERED
(
	[DetailID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskDetails]') AND name = N'IX_ADefHelpDesk_TaskDetails')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_TaskDetails] ON [dbo].[ADefHelpDesk_TaskDetails]
(
	[TaskID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskCategories]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_TaskCategories](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[TaskID] [int] NOT NULL,
	[CategoryID] [int] NOT NULL,
 CONSTRAINT [PK_ADefHelpDesk_TaskCategories] PRIMARY KEY CLUSTERED
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskCategories]') AND name = N'IX_ADefHelpDesk_TaskCategories')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_TaskCategories] ON [dbo].[ADefHelpDesk_TaskCategories]
(
	[TaskID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskAssociations]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_TaskAssociations](
	[TaskRelationID] [int] IDENTITY(1,1) NOT NULL,
	[TaskID] [int] NOT NULL,
	[AssociatedID] [int] NOT NULL,
 CONSTRAINT [PK_ADefHelpDesk_TaskAssociations] PRIMARY KEY CLUSTERED
(
	[TaskRelationID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskAssociations]') AND name = N'IX_ADefHelpDesk_TaskAssociations')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_TaskAssociations] ON [dbo].[ADefHelpDesk_TaskAssociations]
(
	[TaskID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Log]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_Log](
	[LogID] [int] IDENTITY(1,1) NOT NULL,
	[TaskID] [int] NOT NULL,
	[LogDescription] [nvarchar](500) NOT NULL,
	[DateCreated] [datetime] NOT NULL,
	[UserID] [int] NOT NULL,
 CONSTRAINT [PK_ADefHelpDesk_Log] PRIMARY KEY CLUSTERED
(
	[LogID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Log]') AND name = N'IX_ADefHelpDesk_Log')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_Log] ON [dbo].[ADefHelpDesk_Log]
(
	[TaskID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Attachments]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ADefHelpDesk_Attachments](
	[AttachmentID] [int] IDENTITY(1,1) NOT NULL,
	[DetailID] [int] NOT NULL,
	[AttachmentPath] [nvarchar](1000) NOT NULL,
	[FileName] [nvarchar](150) NOT NULL,
	[OriginalFileName] [nvarchar](150) NOT NULL,
	[UserID] [int] NOT NULL,
 CONSTRAINT [PK_ADefHelpDesk_Attachments] PRIMARY KEY CLUSTERED
(
	[AttachmentID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Attachments]') AND name = N'IX_ADefHelpDesk_Attachments')
CREATE NONCLUSTERED INDEX [IX_ADefHelpDesk_Attachments] ON [dbo].[ADefHelpDesk_Attachments]
(
	[DetailID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_Attachments_ADefHelpDesk_TaskDetails]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Attachments]'))
ALTER TABLE [dbo].[ADefHelpDesk_Attachments]  WITH CHECK ADD  CONSTRAINT [FK_ADefHelpDesk_Attachments_ADefHelpDesk_TaskDetails] FOREIGN KEY([DetailID])
REFERENCES [dbo].[ADefHelpDesk_TaskDetails] ([DetailID])

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_Attachments_ADefHelpDesk_TaskDetails]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Attachments]'))
ALTER TABLE [dbo].[ADefHelpDesk_Attachments] CHECK CONSTRAINT [FK_ADefHelpDesk_Attachments_ADefHelpDesk_TaskDetails]

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_Log_ADefHelpDesk_Tasks]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Log]'))
ALTER TABLE [dbo].[ADefHelpDesk_Log]  WITH CHECK ADD  CONSTRAINT [FK_ADefHelpDesk_Log_ADefHelpDesk_Tasks] FOREIGN KEY([TaskID])
REFERENCES [dbo].[ADefHelpDesk_Tasks] ([TaskID])

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_Log_ADefHelpDesk_Tasks]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_Log]'))
ALTER TABLE [dbo].[ADefHelpDesk_Log] CHECK CONSTRAINT [FK_ADefHelpDesk_Log_ADefHelpDesk_Tasks]

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_TaskAssociations_ADefHelpDesk_Tasks]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskAssociations]'))
ALTER TABLE [dbo].[ADefHelpDesk_TaskAssociations]  WITH CHECK ADD  CONSTRAINT [FK_ADefHelpDesk_TaskAssociations_ADefHelpDesk_Tasks] FOREIGN KEY([TaskID])
REFERENCES [dbo].[ADefHelpDesk_Tasks] ([TaskID])

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_TaskAssociations_ADefHelpDesk_Tasks]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskAssociations]'))
ALTER TABLE [dbo].[ADefHelpDesk_TaskAssociations] CHECK CONSTRAINT [FK_ADefHelpDesk_TaskAssociations_ADefHelpDesk_Tasks]

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_TaskCategories_ADefHelpDesk_Categories]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskCategories]'))
ALTER TABLE [dbo].[ADefHelpDesk_TaskCategories]  WITH CHECK ADD  CONSTRAINT [FK_ADefHelpDesk_TaskCategories_ADefHelpDesk_Categories] FOREIGN KEY([CategoryID])
REFERENCES [dbo].[ADefHelpDesk_Categories] ([CategoryID])

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_TaskCategories_ADefHelpDesk_Categories]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskCategories]'))
ALTER TABLE [dbo].[ADefHelpDesk_TaskCategories] CHECK CONSTRAINT [FK_ADefHelpDesk_TaskCategories_ADefHelpDesk_Categories]

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_TaskCategories_ADefHelpDesk_Tasks]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskCategories]'))
ALTER TABLE [dbo].[ADefHelpDesk_TaskCategories]  WITH CHECK ADD  CONSTRAINT [FK_ADefHelpDesk_TaskCategories_ADefHelpDesk_Tasks] FOREIGN KEY([TaskID])
REFERENCES [dbo].[ADefHelpDesk_Tasks] ([TaskID])

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_TaskCategories_ADefHelpDesk_Tasks]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskCategories]'))
ALTER TABLE [dbo].[ADefHelpDesk_TaskCategories] CHECK CONSTRAINT [FK_ADefHelpDesk_TaskCategories_ADefHelpDesk_Tasks]

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_TaskDetails_ADefHelpDesk_Tasks]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskDetails]'))
ALTER TABLE [dbo].[ADefHelpDesk_TaskDetails]  WITH CHECK ADD  CONSTRAINT [FK_ADefHelpDesk_TaskDetails_ADefHelpDesk_Tasks] FOREIGN KEY([TaskID])
REFERENCES [dbo].[ADefHelpDesk_Tasks] ([TaskID])

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_TaskDetails_ADefHelpDesk_Tasks]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_TaskDetails]'))
ALTER TABLE [dbo].[ADefHelpDesk_TaskDetails] CHECK CONSTRAINT [FK_ADefHelpDesk_TaskDetails_ADefHelpDesk_Tasks]

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_UserRoles_ADefHelpDesk_Users]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_UserRoles]'))
ALTER TABLE [dbo].[ADefHelpDesk_UserRoles]  WITH CHECK ADD  CONSTRAINT [FK_ADefHelpDesk_UserRoles_ADefHelpDesk_Users] FOREIGN KEY([UserID])
REFERENCES [dbo].[ADefHelpDesk_Users] ([UserID])

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ADefHelpDesk_UserRoles_ADefHelpDesk_Users]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_UserRoles]'))
ALTER TABLE [dbo].[ADefHelpDesk_UserRoles] CHECK CONSTRAINT [FK_ADefHelpDesk_UserRoles_ADefHelpDesk_Users]

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserRoles_ADefHelpDesk_Roles]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_UserRoles]'))
ALTER TABLE [dbo].[ADefHelpDesk_UserRoles]  WITH CHECK ADD  CONSTRAINT [FK_UserRoles_ADefHelpDesk_Roles] FOREIGN KEY([RoleID])
REFERENCES [dbo].[ADefHelpDesk_Roles] ([ID])

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserRoles_ADefHelpDesk_Roles]') AND parent_object_id = OBJECT_ID(N'[dbo].[ADefHelpDesk_UserRoles]'))
ALTER TABLE [dbo].[ADefHelpDesk_UserRoles] CHECK CONSTRAINT [FK_UserRoles_ADefHelpDesk_Roles]

/*** This script will only run if the version number in the database is less than 01.00.00 ***/
if((SELECT count(*) FROM ADefHelpDesk_Version) = 0)
BEGIN

	/** Update Version **/
	DELETE FROM ADefHelpDesk_Version
	INSERT INTO ADefHelpDesk_Version(VersionNumber) VALUES (N'01.00.00')

	DELETE FROM ADefHelpDesk_Settings WHERE (SettingName = N'SMTPServer')
	INSERT INTO ADefHelpDesk_Settings(PortalID, SettingName, SettingValue) VALUES (N'0', N'SMTPServer', N'')
	DELETE FROM ADefHelpDesk_Settings WHERE (SettingName = N'SMTPSecure')
	INSERT INTO ADefHelpDesk_Settings(PortalID, SettingName, SettingValue) VALUES (N'0', N'SMTPSecure', N'False')
	DELETE FROM ADefHelpDesk_Settings WHERE (SettingName = N'SMTPUserName')
	INSERT INTO ADefHelpDesk_Settings(PortalID, SettingName, SettingValue) VALUES (N'0', N'SMTPUserName', N'')
	DELETE FROM ADefHelpDesk_Settings WHERE (SettingName = N'SMTPPassword')
	INSERT INTO ADefHelpDesk_Settings(PortalID, SettingName, SettingValue) VALUES (N'0', N'SMTPPassword', N'')
	DELETE FROM ADefHelpDesk_Settings WHERE (SettingName = N'SMTPAuthendication')
	INSERT INTO ADefHelpDesk_Settings(PortalID, SettingName, SettingValue) VALUES (N'0', N'SMTPAuthendication', N'0')
	DELETE FROM ADefHelpDesk_Settings WHERE (SettingName = N'SMTPFromEmail')
	INSERT INTO ADefHelpDesk_Settings(PortalID, SettingName, SettingValue) VALUES (N'0', N'SMTPFromEmail', N'')
	DELETE FROM ADefHelpDesk_Settings WHERE (SettingName = N'FileUploadPath')
	INSERT INTO ADefHelpDesk_Settings(PortalID, SettingName, SettingValue) VALUES (N'0', N'FileUploadPath', N'')
	DELETE FROM ADefHelpDesk_Settings WHERE (SettingName = N'UploadPermission')
	INSERT INTO ADefHelpDesk_Settings(PortalID, SettingName, SettingValue) VALUES (N'0', N'UploadPermission', N'Administrator')
	DELETE FROM ADefHelpDesk_Settings WHERE (SettingName = N'AllowRegistration')
	INSERT INTO ADefHelpDesk_Settings(PortalID, SettingName, SettingValue) VALUES (N'0', N'AllowRegistration', N'False')
	DELETE FROM ADefHelpDesk_Settings WHERE (SettingName = N'VerifiedRegistration')
	INSERT INTO ADefHelpDesk_Settings(PortalID, SettingName, SettingValue) VALUES (N'0', N'VerifiedRegistration', N'False')
	DELETE FROM ADefHelpDesk_Settings WHERE (SettingName = N'ApplicationName')
	INSERT INTO ADefHelpDesk_Settings(PortalID, SettingName, SettingValue) VALUES (N'0', N'ApplicationName', N'ADefHelpDesk')
END


text:
package exception;

import com.sun.org.apache.xalan.internal.extensions.ExpressionContext;

/**
 * Created by cosmin on 11/15/16.
 */
public class UnknownComparisonExpression extends Exception {
    public UnknownComparisonExpression(String s) {
        super(s);
    }
}

redpajama_set_name: RedPajamaGithub


text:
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * @fileoverview Common page for reading and writing preferences from
 * the background context (background page or options page).
 *
 */

goog.provide('cvox.ChromeVoxPrefs');

goog.require('cvox.ChromeVox');
goog.require('cvox.ExtensionBridge');
goog.require('cvox.KeyMap');

/**
 * This object has default values of preferences and contains the common
 * code for working with preferences shared by the Options and Background
 * pages.
 * @constructor
 */
cvox.ChromeVoxPrefs = function() {
  var lastRunVersion = localStorage['lastRunVersion'];
  if (!lastRunVersion) {
    lastRunVersion = '1.16.0';
  }
  var loadExistingSettings = true;
  // TODO(dtseng): Logic below needs clarification. Perhaps needs a
  // 'lastIncompatibleVersion' member.
  if (lastRunVersion == '1.16.0') {
    loadExistingSettings = false;
  }
  localStorage['lastRunVersion'] = chrome.runtime.getManifest().version;

  /**
   * The current mapping from keys to command.
   * @type {!cvox.KeyMap}
   * @private
   */
  this.keyMap_ = cvox.KeyMap.fromLocalStorage() || cvox.KeyMap.fromDefaults();
  this.keyMap_.merge(cvox.KeyMap.fromDefaults());

  // Clear per session preferences.
  // This is to keep the position dictionary from growing excessively large.
  localStorage['position'] = '{}';

  // Default per session sticky to off.
  localStorage['sticky'] = false;

  this.init(loadExistingSettings);
};

/**
 * The default value of all preferences except the key map.
 * @const
 * @type {Object<Object>}
 */
cvox.ChromeVoxPrefs.DEFAULT_PREFS = {
  'active': true,
  'brailleCaptions': false,
  // TODO(dtseng): Leaking state about multiple key maps here until we have a
  // class to manage multiple key maps. Also, this doesn't belong as a pref;
  // should just store in local storage.
  'currentKeyMap' : cvox.KeyMap.DEFAULT_KEYMAP,
  'cvoxKey': '',
  'earcons': true,
  'focusFollowsMouse': false,
  'granularity': undefined,
  'position': '{}',
  'siteSpecificScriptBase':
      'https://ssl.gstatic.com/accessibility/javascript/ext/',
  'siteSpecificScriptLoader':
      'https://ssl.gstatic.com/accessibility/javascript/ext/loader.js',
  'sticky': false,
  'typingEcho': 0,
  'useIBeamCursor': cvox.ChromeVox.isMac,
  'useVerboseMode': true,
  'siteSpecificEnhancements': true
};

/**
 * Merge the default values of all known prefs with what's found in
 * localStorage.
 * @param {boolean} pullFromLocalStorage or not to pull prefs from local
 * storage. True if we want to respect changes the user has already made
 * to prefs, false if we want to overwrite them. Set false if we've made
 * changes to keyboard shortcuts and need to make sure they aren't
 * overridden by the old keymap in local storage.
 */
cvox.ChromeVoxPrefs.prototype.init = function(pullFromLocalStorage) {
  // Set the default value of any pref that isn't already in localStorage.
  for (var pref in cvox.ChromeVoxPrefs.DEFAULT_PREFS) {
    if (localStorage[pref] === undefined) {
      localStorage[pref] = cvox.ChromeVoxPrefs.DEFAULT_PREFS[pref];
    }
  }
};

/**
 * Switches to another key map.
 * @param {string} selectedKeyMap The id of the keymap in
 * cvox.KeyMap.AVAIABLE_KEYMAP_INFO.
*/
cvox.ChromeVoxPrefs.prototype.switchToKeyMap = function(selectedKeyMap) {
  // TODO(dtseng): Leaking state about multiple key maps here until we have a
  // class to manage multiple key maps.
  localStorage['currentKeyMap'] = selectedKeyMap;
  this.keyMap_ = cvox.KeyMap.fromCurrentKeyMap();
  this.keyMap_.toLocalStorage();
  this.keyMap_.resetModifier();
  this.sendPrefsToAllTabs(false, true);
};

/**
 * Get the prefs (not including keys).
 * @return {Object} A map of all prefs except the key map from localStorage.
 */
cvox.ChromeVoxPrefs.prototype.getPrefs = function() {
  var prefs = {};
  for (var pref in cvox.ChromeVoxPrefs.DEFAULT_PREFS) {
    prefs[pref] = localStorage[pref];
  }
  prefs['version'] = chrome.runtime.getManifest().version;
  return prefs;
};

/**
 * Reloads the key map from local storage.
 */
cvox.ChromeVoxPrefs.prototype.reloadKeyMap = function() {
  // Get the current key map from localStorage.
  // TODO(dtseng): We currently don't support merges since we write the entire
  // map back to local storage.
  var currentKeyMap = cvox.KeyMap.fromLocalStorage();
  if (!currentKeyMap) {
    currentKeyMap = cvox.KeyMap.fromCurrentKeyMap();
    currentKeyMap.toLocalStorage();
  }
  this.keyMap_ = currentKeyMap;
};

/**
 * Get the key map, from key binding to an array of [command, description].
 * @return {cvox.KeyMap} The key map.
 */
cvox.ChromeVoxPrefs.prototype.getKeyMap = function() {
  return this.keyMap_;
};

/**
 * Reset to the default key bindings.
 */
cvox.ChromeVoxPrefs.prototype.resetKeys = function() {
  this.keyMap_ = cvox.KeyMap.fromDefaults();
  this.keyMap_.toLocalStorage();
  this.sendPrefsToAllTabs(false, true);
};

/**
 * Send all of the settings to all tabs.
 * @param {boolean} sendPrefs Whether to send the prefs.
 * @param {boolean} sendKeyBindings Whether to send the key bindings.
 */
cvox.ChromeVoxPrefs.prototype.sendPrefsToAllTabs =
    function(sendPrefs, sendKeyBindings) {
  var context = this;
  var message = {};
  if (sendPrefs) {
    message['prefs'] = context.getPrefs();
  }
  if (sendKeyBindings) {
    // Note that cvox.KeyMap stringifies to a minimal object when message gets
    // passed to the content script.
    message['keyBindings'] = this.keyMap_.toJSON();
  }
  chrome.windows.getAll({populate: true}, function(windows) {
    for (var i = 0; i < windows.length; i++) {
      var tabs = windows[i].tabs;
      for (var j = 0; j < tabs.length; j++) {
        chrome.tabs.sendMessage(tabs[j].id, message);
      }
    }
  });
};

/**
 * Send all of the settings over the specified port.
 * @param {Port} port The port representing the connection to a content script.
 */
cvox.ChromeVoxPrefs.prototype.sendPrefsToPort = function(port) {
  port.postMessage({
    'keyBindings': this.keyMap_.toJSON(),
    'prefs': this.getPrefs()});
};

/**
 * Set the value of a pref and update all active tabs if it's changed.
 * @param {string} key The pref key.
 * @param {Object|string} value The new value of the pref.
 */
cvox.ChromeVoxPrefs.prototype.setPref = function(key, value) {
  if (localStorage[key] != value) {
    localStorage[key] = value;
    this.sendPrefsToAllTabs(true, false);
  }
};

/**
 * Delegates to cvox.KeyMap.
 * @param {string} command The command to set.
 * @param {cvox.KeySequence} newKey The new key to assign it to.
 * @return {boolean} True if the key was bound to the command.
 */
cvox.ChromeVoxPrefs.prototype.setKey = function(command, newKey) {
  if (this.keyMap_.rebind(command, newKey)) {
    this.keyMap_.toLocalStorage();
    this.sendPrefsToAllTabs(false, true);
    return true;
  }
  return false;
};


text:
package mockelb

import (
	"fmt"
	"sync"
	"time"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/elb"
	"github.com/aws/aws-sdk-go/service/elb/elbiface"
	"k8s.io/klog"
)

const elbZoneID = "FAKEZONE-CLOUDMOCK-ELB"

type MockELB struct {
	elbiface.ELBAPI

	mutex sync.Mutex

	LoadBalancers map[string]*loadBalancer
}

type loadBalancer struct {
	description elb.LoadBalancerDescription
	attributes  elb.LoadBalancerAttributes
	tags        map[string]string
}

func (m *MockELB) DescribeLoadBalancers(request *elb.DescribeLoadBalancersInput) (*elb.DescribeLoadBalancersOutput, error) {
	m.mutex.Lock()
	defer m.mutex.Unlock()

	klog.V(2).Infof("DescribeLoadBalancers %v", request)

	if request.PageSize != nil {
		klog.Warningf("PageSize not implemented")
	}
	if request.Marker != nil {
		klog.Fatalf("Marker not implemented")
	}

	var elbs []*elb.LoadBalancerDescription
	for _, elb := range m.LoadBalancers {
		match := false

		if len(request.LoadBalancerNames) > 0 {
			for _, name := range request.LoadBalancerNames {
				if aws.StringValue(elb.description.LoadBalancerName) == aws.StringValue(name) {
					match = true
				}
			}
		} else {
			match = true
		}

		if match {
			elbs = append(elbs, &elb.description)
		}
	}

	return &elb.DescribeLoadBalancersOutput{
		LoadBalancerDescriptions: elbs,
	}, nil
}

func (m *MockELB) DescribeLoadBalancersPages(request *elb.DescribeLoadBalancersInput, callback func(p *elb.DescribeLoadBalancersOutput, lastPage bool) (shouldContinue bool)) error {
	// For the mock, we just send everything in one page
	page, err := m.DescribeLoadBalancers(request)
	if err != nil {
		return err
	}

	callback(page, false)

	return nil
}

func (m *MockELB) CreateLoadBalancer(request *elb.CreateLoadBalancerInput) (*elb.CreateLoadBalancerOutput, error) {
	m.mutex.Lock()
	defer m.mutex.Unlock()

	klog.V(2).Infof("CreateLoadBalancer %v", request)
	createdTime := time.Now().UTC()

	dnsName := *request.LoadBalancerName + ".elb.cloudmock.com"

	lb := &loadBalancer{
		description: elb.LoadBalancerDescription{
			AvailabilityZones: request.AvailabilityZones,
			CreatedTime:       &createdTime,
			LoadBalancerName:  request.LoadBalancerName,
			Scheme:            request.Scheme,
			SecurityGroups:    request.SecurityGroups,
			Subnets:           request.Subnets,
			DNSName:           aws.String(dnsName),

			CanonicalHostedZoneNameID: aws.String(elbZoneID),
		},
		tags: make(map[string]string),
	}

	for _, listener := range request.Listeners {
		lb.description.ListenerDescriptions = append(lb.description.ListenerDescriptions, &elb.ListenerDescription{
			Listener: listener,
		})
	}

	// for _, tag := range input.Tags {
	// 	g.Tags = append(g.Tags, &autoscaling.TagDescription{
	// 		Key:               tag.Key,
	// 		PropagateAtLaunch: tag.PropagateAtLaunch,
	// 		ResourceId:        tag.ResourceId,
	// 		ResourceType:      tag.ResourceType,
	// 		Value:             tag.Value,
	// 	})
	// }

	if m.LoadBalancers == nil {
		m.LoadBalancers = make(map[string]*loadBalancer)
	}
	m.LoadBalancers[*request.LoadBalancerName] = lb

	return &elb.CreateLoadBalancerOutput{
		DNSName: aws.String(dnsName),
	}, nil
}

func (m *MockELB) DeleteLoadBalancer(request *elb.DeleteLoadBalancerInput) (*elb.DeleteLoadBalancerOutput, error) {
	m.mutex.Lock()
	defer m.mutex.Unlock()

	klog.Infof("DeleteLoadBalancer: %v", request)

	id := aws.StringValue(request.LoadBalancerName)
	o := m.LoadBalancers[id]
	if o == nil {
		return nil, fmt.Errorf("LoadBalancer %q not found", id)
	}
	delete(m.LoadBalancers, id)

	return &elb.DeleteLoadBalancerOutput{}, nil
}


text:
var assert   = require('assert');
var validate = require('../index');

describe('bval', function(){

	it('should allow proper bval contents', function () {
		var bval = '4 6 2 5 3 23 5';
		validate.bval({}, bval, function (issues) {
			assert.deepEqual(issues, []);
		});
	});

	it('should not allow more than one row', function () {
		var bval = '0 4 3 6 1 6 2 4 1\n 4 3 5 2 4 2 4 5';
		validate.bval({}, bval, function (issues) {
			assert(issues.length == 1 && issues[0].code == 30);
		});
	});

	it('should catch doublespace separators', function () {
		var bval = '4  6  2  5  3  23  5';
		validate.bval({}, bval, function (issues) {
            assert(issues.length == 1 && issues[0].code == 47);
		});
	});

});


text:
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>system_context::use_service</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../boost_asio.html" title="Boost.Asio">
<link rel="up" href="../system_context.html" title="system_context">
<link rel="prev" href="stopped.html" title="system_context::stopped">
<link rel="next" href="use_service/overload1.html" title="system_context::use_service (1 of 2 overloads)">

Home
Libraries
People
FAQ
More

system_context::use_service

Obtain
          the service object corresponding to the given type.

template<
    typename Service>
friend Service & use_service(
    execution_context & e);
  » more...

template<
    typename Service>
friend Service & use_service(
    io_context & ioc);
  » more...

Copyright © 2003-2018 Christopher M. Kohlhoff

        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)


text:
title: System Namespace
---
# System Namespace

## Classes

ClassDescription![Public class](https://reactiveui.net/assets/img/Hh212009.pubclass(en-us,VS.103).gif "Public class")[ObservableExtensions](../ObservableExtensions/ObservableExtensions)Provides a set of static methods for subscribing delegates to observables.


text:
(function() {

module("can/view/ejs, rendering",{
	setup : function(){

		this.animals = ['sloth', 'bear', 'monkey']
		if(!this.animals.each){
			this.animals.each = function(func){
				for(var i =0; i < this.length; i++){
					func(this[i])
				}
			}
		}

		this.squareBrackets = "
<% this.animals.each(function(animal){%>" +
					   "
<%= animal %>
" +
				  "<%});%>
"
		this.squareBracketsNoThis = "
<% animals.each(function(animal){%>" +
					   "
<%= animal %>
" +
				  "<%});%>
"
		this.angleBracketsNoThis  = "
<% animals.each(function(animal){%>" +
					   "
<%= animal %>
" +
				  "<%});%>
";

	}
})

var getAttr = function(el, attrName){
		return attrName === "class"?
			el.className:
			el.getAttribute(attrName);
	}

test("registerNode, unregisterNode, and replace work", function(){

	var ids = function(arr){
		return can.map(arr, function(item){
			return item.id
		})
	},
		two = {id: 2},
		listOne = [{id: 1},two,{id: 3}];

	can.view.registerNode(listOne);
	var listTwo = [two];

	can.view.registerNode(listTwo);

	var newLabel = {id: 4}
	can.view.replace(listTwo, [newLabel])

	same( ids(listOne), [1,4,3], "replaced" )
	same( ids(listTwo), [4] );

	can.view.replace(listTwo,[{id: 5},{id: 6}]);

	same( ids(listOne), [1,5,6,3], "replaced" );

	same( ids(listTwo), [5,6], "replaced" );

	can.view.replace(listTwo,[{id: 7}])

	same( ids(listOne), [1,7,3], "replaced" );

	same( ids(listTwo), [7], "replaced" );

	can.view.replace( listOne, [{id: 8}])

	same( ids(listOne), [8], "replaced" );
	same( ids(listTwo), [7], "replaced" );

	can.view.unregisterNode(listOne);
	can.view.unregisterNode(listTwo);

	same(can.view.nodeMap, {} );
	same(can.view.nodeListMap ,{} )

});

test("render with left bracket", function(){
	var compiled = new can.EJS({text: this.squareBrackets, type: '['}).render({animals: this.animals})
	equals(compiled, "

sloth

bear

monkey

", "renders with bracket")
})
test("render with with", function(){
	var compiled = new can.EJS({text: this.squareBracketsNoThis, type: '['}).render({animals: this.animals}) ;
	equals(compiled, "

sloth

bear

monkey

", "renders bracket with no this")
})
test("default carrot", function(){
	var compiled = new can.EJS({text: this.angleBracketsNoThis}).render({animals: this.animals}) ;

	equals(compiled, "

sloth

bear

monkey

")
})
test("render with double angle", function(){
	var text = "<%% replace_me %>"+
			  "
<% animals.each(function(animal){%>" +
				   "
<%= animal %>
" +
			  "<%});%>
";
	var compiled = new can.EJS({text: text}).render({animals: this.animals}) ;
	equals(compiled, "<% replace_me %>

sloth

bear

monkey

", "works")
});

test("comments", function(){
	var text = "<%# replace_me %>"+
			  "
<% animals.each(function(animal){%>" +
				   "
<%= animal %>
" +
			  "<%});%>
";
	var compiled = new can.EJS({text: text}).render({animals: this.animals}) ;
	equals(compiled,"

sloth

bear

monkey

" )
});

test("multi line", function(){
	var text = "a \n b \n c",
		result = new can.EJS({text: text}).render({}) ;

	equals(result, text)
})

test("multi line elements", function(){
	var text = "<img\n class=\"<%=myClass%>\" />",
		result = new can.EJS({text: text}).render({myClass: 'a'}) ;

	ok(result.indexOf( "<img\n class=\"a\"" ) !== -1, "Multi-line elements render correctly.");
})

test("escapedContent", function(){
	var text = "<%= tags %>&<%= number %><input value='<%= quotes %>'/>";
	var compiled = new can.EJS({text: text}).render({tags: "foo < bar < car > zar > poo",
							quotes : "I use 'quote' fingers \"a lot\"",
							number : 123}) ;

	var div = document.createElement('div');
	div.innerHTML = compiled;

	equals(div.getElementsByTagName('span')[0].firstChild.nodeValue, "foo < bar < car > zar > poo" );
	equals(div.getElementsByTagName('strong')[0].firstChild.nodeValue, 123 );
	equals(div.getElementsByTagName('input')[0].value, "I use 'quote' fingers \"a lot\"" );
	equals(div.getElementsByTagName('label')[0].innerHTML, "&" );
})

test("unescapedContent", function(){
	var text = "<%== tags %>
<%= tags %>
<input value='<%== quotes %>'/>";
	var compiled = new can.EJS({text: text}).render({tags: "foobar",
							quotes : "I use 'quote' fingers \"a lot\""}) ;

	var div = document.createElement('div');
	div.innerHTML = compiled;

	equals(div.getElementsByTagName('span')[0].firstChild.nodeType, 1 );
	equals(div.getElementsByTagName('div')[0].firstChild.nodeValue.toLowerCase(), "foobar" );
	equals(div.getElementsByTagName('span')[0].innerHTML.toLowerCase(), "foobar" );
	equals(div.getElementsByTagName('input')[0].value, "I use 'quote' fingers \"a lot\"", "escapped no matter what" );
});

test("returning blocks", function(){
	var somethingHelper = function(cb){
		return cb([1,2,3,4])
	}

	var res = can.view.
		render("//can/view/ejs/test/test_template.ejs",{
			something: somethingHelper,
			items: ['a','b']
		});
	// make sure expected values are in res
	ok(/\s4\s/.test(res), "first block called" );
	equals(res.match(/ItemsLength4/g).length, 4, "innerBlock and each")
});

test("easy hookup", function(){
	var div = document.createElement('div');
	div.appendChild(can.view("//can/view/ejs/test/easyhookup.ejs",{text: "yes"}))

	ok( div.getElementsByTagName('div')[0].className.indexOf("yes") != -1, "has yes" )
});

test('multiple function hookups in a tag', function(){

	var text =	"<span <%= (el)-> can.data(can.$(el),'foo','bar') %>" +
		" <%= (el)-> can.data(can.$(el),'baz','qux') %>>lorem ipsum",
		compiled = new can.EJS({ text: text }).render(),
		div = document.createElement('div');

	div.appendChild(can.view.frag(compiled));
	var span = div.getElementsByTagName('span')[0];

	equals(can.data(can.$(span), 'foo'), 'bar', "first hookup");
	equals(can.data(can.$(span), 'baz'), 'qux', "second hookup");

})

test("helpers", function() {
	can.EJS.Helpers.prototype.simpleHelper = function()
	{
		return 'Simple';
	}

	can.EJS.Helpers.prototype.elementHelper = function()
	{
		return function(el) {
			el.innerHTML = 'Simple';
		}
	}

	var text = "
<%= simpleHelper() %>
";
	var compiled = new can.EJS({text: text}).render() ;
	equals(compiled, "
Simple
");

	text = "<div id=\"hookup\" <%= elementHelper() %>>
";
	compiled = new can.EJS({text: text}).render() ;
	can.append( can.$('#qunit-test-area'), can.view.frag(compiled));
	equals(can.$('#hookup')[0].innerHTML, "Simple");
});

test('list helper', function(){

	var text = "<% list(todos, function(todo){ %>
<%= todo.name %>
<% }) %>";
	var	Todos = new can.Observe.List([
			{id: 1, name: 'Dishes'}
		]),
		compiled = new can.EJS({text: text}).render({todos: Todos}),
		div = document.createElement('div');

		div.appendChild(can.view.frag(compiled))
		equals(div.getElementsByTagName('div').length, 1, '1 item in list')

		Todos.push({id: 2, name: 'Laundry'})
		equals(div.getElementsByTagName('div').length, 2, '2 items in list')

		Todos.splice(0, 2);
		equals(div.getElementsByTagName('div').length, 0, '0 items in list')

});

test("attribute single unescaped, html single unescaped", function(){

	var text = "<div id='me' class='<%== task.attr('completed') ? 'complete' : ''%>'><%== task.attr('name') %>
";
	var task = new can.Observe({
		name : 'dishes'
	})
	var compiled = new can.EJS({text: text}).render({task:  task}) ;

	var div = document.createElement('div');

	div.appendChild(can.view.frag(compiled))

	equals(div.getElementsByTagName('div')[0].innerHTML,"dishes", "html correctly dishes")
	equals(div.getElementsByTagName('div')[0].className,"", "class empty")

	task.attr('name','lawn')

	equals(div.getElementsByTagName('div')[0].innerHTML,"lawn", "html correctly lawn")
	equals(div.getElementsByTagName('div')[0].className,"", "class empty")

	task.attr('completed', true);

	equals(div.getElementsByTagName('div')[0].className,"complete", "class changed to complete")
});

test("event binding / triggering on options", function(){
	var frag = can.buildFragment("<select><option>a</option></select>",[document]);
	var qta = document.getElementById('qunit-test-area');
	qta.innerHTML = "";
	qta.appendChild(frag);

	/*qta.addEventListener("foo", function(){
		ok(false, "event handler called")
	},false)*/

	// destroyed events should not bubble

	qta.getElementsByTagName("option")[0].addEventListener("foo", function(ev){
		ok(true,"option called");
		ev.stopPropagation();
		//ev.cancelBubble = true;
	}, false);

	qta.getElementsByTagName("select")[0].addEventListener("foo", function(){
		ok(true,"select called")
	}, false)

	var ev = document.createEvent("HTMLEvents");
	ev.initEvent("foo", true , true);
	qta.getElementsByTagName("option")[0].dispatchEvent(ev);

	//can.trigger(qta,"foo")

	stop();
	setTimeout(function(){
		start();
		ok(true);
	},100)
})

test("select live binding", function() {
	var text = "<select><% todos.each(function(todo){ %><option><%= todo.name %></option><% }) %></select>";
		Todos = new can.Observe.List([
			{id: 1, name: 'Dishes'}
		]),
		compiled = new can.EJS({text: text}).render({todos: Todos}),
		div = document.createElement('div');

		div.appendChild(can.view.frag(compiled))
		equals(div.getElementsByTagName('option').length, 1, '1 item in list')

		Todos.push({id: 2, name: 'Laundry'})
		equals(div.getElementsByTagName('option').length, 2, '2 items in list')

		Todos.splice(0, 2);
		equals(div.getElementsByTagName('option').length, 0, '0 items in list')
});

test("block live binding", function(){

	var text = "
<% if( obs.attr('sex') == 'male' ){ %>"+
			"Mr."+
		"<% } else { %>"+
		  "Ms."+
		"<% } %>"+
		"
"

	var obs = new can.Observe({
		sex : 'male'
	})

	var compiled = new can.EJS({text: text}).render({obs: obs});

	var div = document.createElement('div');

	div.appendChild(can.view.frag(compiled))

	// toUpperCase added to normalize cases for IE8
	equals(div.getElementsByTagName('div')[0].innerHTML.toUpperCase(), "Mr.".toUpperCase(),"initial content")

	obs.attr('sex','female')

	equals(div.getElementsByTagName('div')[0].innerHTML.toUpperCase(), "Ms.".toUpperCase(),"updated label")

})

test("hookups in tables", function(){
	var text = "

<% if( obs.attr('sex') == 'male' ){ %>"+
			"
Mr.
"+
		"<% } else { %>"+
		  "
Ms.
"+
		"<% } %>"+
		"

"

	var obs = new can.Observe({
		sex : 'male'
	})

	var compiled = new can.EJS({text: text}).render({obs: obs});

	var div = document.createElement('div');

	div.appendChild(can.view.frag(compiled));

	equals(div.getElementsByTagName('tbody')[0].innerHTML.replace(/(\r|\n)+/g, "").toUpperCase(),
		"
Mr.
".toUpperCase(),"initial content")

	obs.attr('sex','female')

	equals(div.getElementsByTagName('tbody')[0].innerHTML.replace(/(\r|\n)+/g, "").toUpperCase(),
		"
Ms.
".toUpperCase(),"updated label")
})

test('multiple hookups in a single attribute', function() {
	var text =	'<div class=\'<%= obs.attr("foo") %>a<%= obs.attr("bar") %>b<%= obs.attr("baz") %>\'>
',

	obs = new can.Observe({
		foo: '1',
		bar: '2',
		baz: '3'
	}),

	compiled = new can.EJS({ text: text }).render({ obs: obs })

	var div = document.createElement('div');

	div.appendChild(can.view.frag(compiled));

	var innerDiv = div.childNodes[0];

	equals(getAttr(innerDiv, 'class'), "1a2b3", 'initial render');

	obs.attr('bar', '4');

	equals(getAttr(innerDiv, 'class'), "1a4b3", 'initial render');

	obs.attr('bar', '5');

	equals(getAttr(innerDiv, 'class'), "1a5b3", 'initial render');
});

test('adding and removing multiple html content within a single element', function(){

	var text =	'
<%== obs.attr("a") %><%== obs.attr("b") %><%== obs.attr("c") %>
',

	obs = new can.Observe({
		a: 'a',
		b: 'b',
		c: 'c'
	});

	compiled = new can.EJS({ text: text }).render({ obs: obs })

	var div = document.createElement('div');

	div.appendChild(can.view.frag(compiled));

	equals(div.innerHTML.toUpperCase(), '
abc
'.toUpperCase(), 'initial render');

	obs.attr({a: '', b : '', c: ''});

	equals(div.innerHTML.toUpperCase(), '

'.toUpperCase(), 'updated values');

	obs.attr({c: 'c'});

	equals(div.innerHTML.toUpperCase(), '
c
'.toUpperCase(), 'updated values');
});

test('live binding and removeAttr', function(){

	var text = '<% if(obs.attr("show")) { %>' +
			'<p <%== obs.attr("attributes") %> class="<%= obs.attr("className")%>"><%= obs.attr("message") %>
' +
		'<% } %>',

		obs = new can.Observe({
			show: true,
			className: 'myMessage',
			attributes: 'some=\"myText\"',
			message: 'Live long and prosper'
		}),

		compiled = new can.EJS({ text: text }).render({ obs: obs }),

		div = document.createElement('div');

	div.appendChild(can.view.frag(compiled));

	var p = div.getElementsByTagName('p')[0],
		span = p.getElementsByTagName('span')[0];

	equals(p.getAttribute("some"), "myText", 'initial render attr');
	equals(getAttr(p, "class"), "myMessage", 'initial render class');
	equals(span.innerHTML, 'Live long and prosper', 'initial render innerHTML');

	obs.removeAttr('className');

	equals(getAttr(p, "class"), '', 'class is undefined');

	obs.attr('className', 'newClass');

	equals(getAttr(p, "class"), 'newClass', 'class updated');

	obs.removeAttr('attributes');

	equals(p.getAttribute('some'), null, 'attribute is undefined');

	obs.attr('attributes', 'some="newText"');

	equals(p.getAttribute('some'), 'newText', 'attribute updated');

	obs.removeAttr('message');

	equals(span.innerHTML, 'undefined', 'text node value is undefined');

	obs.attr('message', 'Warp drive, Mr. Sulu');

	equals(span.innerHTML, 'Warp drive, Mr. Sulu', 'text node updated');

	obs.removeAttr('show');

	equals(div.innerHTML, '', 'value in block statement is undefined');

	obs.attr('show', true);

	var p = div.getElementsByTagName('p')[0],
		span = p.getElementsByTagName('span')[0];

	equals(p.getAttribute("some"), "newText", 'value in block statement updated attr');
	equals(getAttr(p, "class"), "newClass", 'value in block statement updated class');
	equals(span.innerHTML, 'Warp drive, Mr. Sulu', 'value in block statement updated innerHTML');

});

test('hookup within a tag', function () {
	var text =	'<div <%== obs.attr("foo") %> '
		+ '<%== obs.attr("baz") %>>lorem ipsum
',

	obs = new can.Observe({
		foo: 'class="a"',
		baz: 'some=\'property\''
	}),

	compiled = new can.EJS({ text: text }).render({ obs: obs });

	var div = document.createElement('div');
	div.appendChild(can.view.frag(compiled));
	var anchor = div.getElementsByTagName('div')[0];

	equals(getAttr(anchor, 'class'), 'a');
	equals(anchor.getAttribute('some'), 'property');

	obs.attr('foo', 'class="b"');
	equals(getAttr(anchor, 'class'), 'b');
	equals(anchor.getAttribute('some'), 'property');

	obs.attr('baz', 'some=\'new property\'');
	equals(getAttr(anchor, 'class'), 'b');
	equals(anchor.getAttribute('some'), 'new property');

	obs.attr('foo', 'class=""');
	obs.attr('baz', '');
	equals(getAttr(anchor, 'class'), "", 'anchor class blank');
	equals(anchor.getAttribute('some'), undefined, 'attribute "some" is undefined');
});

test('single escaped tag, removeAttr', function () {
	var text =	'<div <%= obs.attr("foo") %>>lorem ipsum
',

	obs = new can.Observe({
		foo: 'data-bar="john doe\'s bar"'
	}),

	compiled = new can.EJS({ text: text }).render({ obs: obs });

	var div = document.createElement('div');
	div.appendChild(can.view.frag(compiled));
	var anchor = div.getElementsByTagName('div')[0];

	equals(anchor.getAttribute('data-bar'), "john doe's bar");

	obs.removeAttr('foo');
	equals(anchor.getAttribute('data-bar'), null);

	obs.attr('foo', 'data-bar="baz"');
	equals(anchor.getAttribute('data-bar'), 'baz');
});

test('html comments', function(){
	var text =	'
 '
	+ '<%= obs.attr("foo") %>
',

	obs = new can.Observe({
		foo: 'foo'
	})

	compiled = new can.EJS({ text: text }).render({ obs: obs });

	var div = document.createElement('div');
	div.appendChild(can.view.frag(compiled));
})

test("hookup and live binding", function(){

	var text = "<div class='<%= task.attr('completed') ? 'complete' : '' %>' <%= (el)-> can.data(can.$(el),'task',task) %>>" +
		"<%== task.attr('name') %>" +
		"
",
		task = new can.Observe({
			completed: false,
			className: 'someTask',
			name: 'My Name'
		}),
		compiled = new can.EJS({ text: text }).render({ task: task }),
		div = document.createElement('div');

	div.appendChild(can.view.frag(compiled))
	var child = div.getElementsByTagName('div')[0];
	ok( child.className.indexOf("complete") == -1, "is incomplete" )
	ok( !!can.data(can.$(child), 'task'), "has data" )
	equals(child.innerHTML, "My Name", "has name")

	task.attr({
		completed: true,
		name: 'New Name'
	});

	ok( child.className.indexOf("complete") != -1, "is complete" )
	equals(child.innerHTML, "New Name", "has new name")

})

/*
test('multiple curly braces in a block', function() {
	var text =  '<% if(!obs.attr("items").length) { %>' +
				'
No items
' +
				'<% } else { each(obs.items, function(item) { %>' +
						'
<%= item.attr("name") %>
' +
				'<% }) }%>',

	obs = new can.Observe({
		items: []
	}),

	compiled = new can.EJS({ text: text }).render({ obs: obs });

	var ul = document.createElement('ul');
	ul.appendChild(can.view.frag(compiled));

	equals(ul.innerHTML, '
No items
', 'initial observable state');

	obs.attr('items', [{ name: 'foo' }]);
	equals(u.innerHTML, '
foo
', 'updated observable');
});
*/

test("unescape bindings change", function(){
	var l = new can.Observe.List([
		{complete: true},
		{complete: false},
		{complete: true}
	]);
	var completed = function(){
		l.attr('length');
		var num = 0;
		l.each(function(item){
			if(item.attr('complete')){
				num++;
			}
		})
		return num;
	};

	var text =	'
<%== completed() %>
',

	compiled = new can.EJS({ text: text }).render({ completed: completed });

	var div = document.createElement('div');
	div.appendChild(can.view.frag(compiled));

	var child = div.getElementsByTagName('div')[0];
	equals(child.innerHTML, "2", "at first there are 2 true bindings");
	var item = new can.Observe({complete: true, id: "THIS ONE"})
	l.push(item);

	equals(child.innerHTML, "3", "now there are 3 complete");

	item.attr('complete',false);

	equals(child.innerHTML, "2", "now there are 2 complete");

	l.pop();

	item.attr('complete',true);

	equals(child.innerHTML, "2", "there are still 2 complete");
});

test("escape bindings change", function(){
	var l = new can.Observe.List([
		{complete: true},
		{complete: false},
		{complete: true}
	]);
	var completed = function(){
		l.attr('length');
		var num = 0;
		l.each(function(item){
			if(item.attr('complete')){
				num++;
			}
		})
		return num;
	};

	var text =	'
<%= completed() %>
',

	compiled = new can.EJS({ text: text }).render({ completed: completed });

	var div = document.createElement('div');
	div.appendChild(can.view.frag(compiled));

	var child = div.getElementsByTagName('div')[0];
	equals(child.innerHTML, "2", "at first there are 2 true bindings");
	var item = new can.Observe({complete: true})
	l.push(item);

	equals(child.innerHTML, "3", "now there are 3 complete");

	item.attr('complete',false);

	equals(child.innerHTML, "2", "now there are 2 complete");
});

test("tag bindings change", function(){
	var l = new can.Observe.List([
		{complete: true},
		{complete: false},
		{complete: true}
	]);
	var completed = function(){
		l.attr('length');
		var num = 0;
		l.each(function(item){
			if(item.attr('complete')){
				num++;
			}
		})
		return "items='"+num+"'";
	};

	var text =	'<div <%= completed() %>>
',

	compiled = new can.EJS({ text: text }).render({ completed: completed });

	var div = document.createElement('div');
	div.appendChild(can.view.frag(compiled));

	var child = div.getElementsByTagName('div')[0];
	equals(child.getAttribute("items"), "2", "at first there are 2 true bindings");
	var item = new can.Observe({complete: true})
	l.push(item);

	equals(child.getAttribute("items"), "3", "now there are 3 complete");

	item.attr('complete',false);

	equals(child.getAttribute("items"), "2", "now there are 2 complete");
})

test("attribute value bindings change", function(){
	var l = new can.Observe.List([
		{complete: true},
		{complete: false},
		{complete: true}
	]);
	var completed = function(){
		l.attr('length');
		var num = 0;
		l.each(function(item){
			if(item.attr('complete')){
				num++;
			}
		})
		return num;
	};

	var text =	'<div items="<%= completed() %>">
',

	compiled = new can.EJS({ text: text }).render({ completed: completed });

	var div = document.createElement('div');
	div.appendChild(can.view.frag(compiled));

	var child = div.getElementsByTagName('div')[0];
	equals(child.getAttribute("items"), "2", "at first there are 2 true bindings");
	var item = new can.Observe({complete: true})
	l.push(item);

	equals(child.getAttribute("items"), "3", "now there are 3 complete");

	item.attr('complete',false);

	equals(child.getAttribute("items"), "2", "now there are 2 complete");
})

test("in tag toggling", function(){
		var text = "<div <%== obs.attr('val') %>>
"

	var obs = new can.Observe({
		val : 'foo="bar"'
	})

	var compiled = new can.EJS({text: text}).render({obs: obs});

	var div = document.createElement('div');

	div.appendChild(can.view.frag(compiled));

	obs.attr('val',"bar='foo'");
	obs.attr('val','foo="bar"')
	var d2 = div.getElementsByTagName('div')[0];
	// toUpperCase added to normalize cases for IE8
	equals( d2.getAttribute("foo") , "bar","bar set");
	equals( d2.getAttribute("bar") , null,"bar set")
});

test("parent is right with bock", function(){
	var text =  '
<% if(!obs.attr("items").length) { %>' +
				'
No items
' +
				'<% } else { %> <%== obs.attr("content") %>'+
				'<% } %>
',

	obs = new can.Observe({
		content : "
Hello
",
		items: [{name : "Justin"}]
	}),

	compiled = new can.EJS({ text: text }).render({ obs: obs });

	var div = document.createElement('div');

	div.appendChild(can.view.frag(compiled));
	var ul = div.getElementsByTagName('ul')[0];
	var li = div.getElementsByTagName('li')[0];

	ok(ul, "we have a ul");
	ok(li, "we have a li")

});

test("property name only attributes", function(){

	var text = "<input type='checkbox' <%== obs.attr('val') ? 'checked' : '' %>/>"

	var obs = new can.Observe({
		val : true
	})

	var compiled = new can.EJS({text: text}).render({obs: obs});

	var div = document.getElementById('qunit-test-area');

	div.appendChild(can.view.frag(compiled));

	var input = div.getElementsByTagName('input')[0];
	can.trigger(input, 'click');
	obs.attr('val',false)

	ok(!input.checked, "not checked")

	obs.attr('val',true);

	ok(input.checked, "checked")
	div.removeChild(input)
});

test("nested properties", function(){

	var text = "
<%= obs.attr('name.first')%>
"

	var obs = new can.Observe({
		name : {first : "Justin"}
	})

	var compiled = new can.EJS({text: text}).render({obs: obs});

	var div = document.createElement('div');

	div.appendChild(can.view.frag(compiled));

	var div = div.getElementsByTagName('div')[0];

	equals(div.innerHTML, "Justin")

	obs.attr('name.first',"Brian")

	equals(div.innerHTML, "Brian")

});

test("tags without chidren or ending with /> do not change the state", function(){
	var ta = can.$('#qunit-test-area')[0]
	ta.innerHTML = ""

	var hookup = can.view.hookup;
	can.view.hookup = function(frag){
		// check that there are no spans in this frag
		can.append(  can.$('#qunit-test-area'), frag );
		equal( ta.getElementsByTagName('span').length, 0, "there are no spans");
		equal( ta.getElementsByTagName('td').length, 2, "there are 2 td");
	}
	var text = "

<%== obs.attr('content') %>

"
	var obs = new can.Observe({
		content: "Justin	"
	})
	var compiled = new can.EJS({text: text}).render({obs: obs});

	var div = document.createElement('div');

	can.view.frag(compiled);
	can.view.hookup = hookup;
})

test("nested live bindings", function(){
	var items  = new can.Observe.List([
		{title: 0, is_done: false, id: 0}
	]);

	var div = document.createElement('div');
	div.appendChild(can.view("//can/view/ejs/test/nested_live_bindings.ejs",{items: items}))

	items.push({title: 1, is_done: false, id: 1});
	// this will throw an error unless EJS protects against
	// nested objects

	items[0].attr('is_done',true);
	console.log("html -",div.innerHTML)
});

// Similar to the nested live bindings test, this makes sure templates with control blocks
// will eventually remove themselves if at least one change happens
// before things are removed.
// It is currently commented out because
//
/*test("memory safe without parentElement of blocks", function(){

})*/

test("trailing text", function(){
	can.view.ejs("count","There are <%= this.attr('length') %> todos")
	var div = document.createElement('div');
	div.appendChild( can.view("count", new can.Observe.List([{},{}])) );
	ok(/There are 2 todos/.test(div.innerHTML), "got all text")
})

test("recursive views", function(){

	var data = new can.Observe.List([
			{label:'branch1', children:[{id:2, label:'branch2'}]}
		])

	var div = document.createElement('div');
	div.appendChild( can.view('//can/view/ejs/test/recursive.ejs',  {items: data}));
	ok(/class="leaf"/.test(div.innerHTML), "we have a leaf")

})

test("indirectly recursive views", function() {
	var unordered = new can.Observe.List([
		{ ol: [
			{ ul: [
				{ ol: [1, 2, 3] }
			]}
		]}
	]);

	can.view.cache = false;
	var div = document.createElement('div');
	div.appendChild(can.view('//can/view/ejs/test/indirect1.ejs', {unordered: unordered}));
	ok(can.trim(div.querySelectorAll('ul > li > ol > li > ul > li > ol > li')[0].innerHTML) === "1", "Uncached indirectly recursive EJS working.");

	can.view.cache = true;
	div.appendChild(can.view('//can/view/ejs/test/indirect1.ejs', {unordered: unordered}));
	ok(can.trim(div.querySelectorAll('ul + ul > li > ol > li > ul > li > ol > li')[0].innerHTML) === "1", "Cached indirectly recursive EJS working.");
});

test("live binding select", function(){
	var text = "<select><% items.each(function(ob) { %>" +
		"<option value='<%= ob.attr('id') %>'><%= ob.attr('title') %></option>" +
		"<% }); %></select>",
		items	 = new can.Observe.List([
			{title: "Make bugs", is_done: true, id: 0},
			{title: "Find bugs", is_done: false, id: 1},
			{title: "Fix bugs", is_done: false, id: 2}
		]),
		compiled = new can.EJS({text: text}).render({items: items}),
		div = document.createElement('div');

		div.appendChild(can.view.frag(compiled))
		equal(div.getElementsByTagName('option').length, 3, '3 items in list')

		equal(div.getElementsByTagName('option')[0].value, ""+items[0].id,
			   'value attr set');
		equal(div.getElementsByTagName('option')[0].textContent, items[0].title,
			   'content of option');

		items.push({id: 3, name: 'Go to pub'})
		equal(div.getElementsByTagName('option').length, 4, '4 items in list')
});

test("live binding textarea", function(){
	can.view.ejs("textarea-test","<textarea>Before<%= obs.attr('middle') %>After</textarea>");

	var obs = new can.Observe({middle: "yes"}),
		div = document.createElement('div');

	div.appendChild( can.view("textarea-test",{obs: obs}) )
	var textarea = div.firstChild

	equal(textarea.value, "BeforeyesAfter");

	obs.attr("middle","Middle")
	equal(textarea.value, "BeforeMiddleAfter")

})

test("A non-escaping live magic tag within a control structure and no leaks", function(){

	for(var prop in can.view.nodeMap){
		delete can.view.nodeMap[prop]
	}
	for(var prop in can.view.nodeListMap){
		delete can.view.nodeListMap[prop]
	}

	var text = "
<% items.each(function(ob) { %>" +
		"<%== ob.attr('html') %>" +
		"<% }); %>
",
		items	 = new can.Observe.List([
			{html: "Hello World"}
		]),
		compiled = new can.EJS({text: text}).render({items: items}),
		div = can.$('#qunit-test-area')[0]
		div.innerHTML = ""

	div.appendChild(can.view.frag(compiled))
	can.append( can.$('#qunit-test-area'), can.view.frag(compiled));

	ok(div.getElementsByTagName('label')[0], "label exists")

	items[0].attr("html","
hi
");

	equals(div.getElementsByTagName('label').length, 0, "label is removed")
	equals(div.getElementsByTagName('p').length, 1, "label is replaced by p")

	items.push({
		html: "
hola
"
	});

	equals(div.getElementsByTagName('p').length, 2, "label has 2 paragraphs")

	can.remove( can.$(div.firstChild) )

	same(can.view.nodeMap, {} );
	same(can.view.nodeListMap ,{} )
});

test("attribute unquoting", function() {
	var text = '<input type="radio" ' +
		'<%== facet.single ? \'name="facet-\' + facet.attr("id") + \'"\' : "" %> ' +
		'value="<%= facet.single ? "facet-" + facet.attr("id") : "" %>" />',
	facet = new can.Observe({
		id: 1,
		single: true
	}),

	compiled = new can.EJS({text: text}).render({ facet: facet }),
	div = document.createElement('div');
	div.appendChild(can.view.frag(compiled))

	equals(div.children[0].name, "facet-1");
	equals(div.children[0].value, "facet-1");
});

test("empty element hooks work correctly",function(){

	var text = '<div <%= function(e){ e.innerHTML = "1 Will show"; } %> />'+
		'<div <%= function(e){ e.innerHTML = "2 Will not show"; } %> />'+
		'3 Will not show';

	var compiled = new can.EJS({text: text}).render(),
		div = document.createElement('div');

	div.appendChild(can.view.frag(compiled));

	equal(div.childNodes.length, 3, "all three elements present")

});

test("live binding with parent dependent tags but without parent tag present in template",function(){

	var text = ['<% if( person.attr("first") ){ %>',
				'
<%= person.first %>
',
				'<% }%>',
				'<% if( person.attr("last") ){ %>',
				'
<%= person.last %>
',
				'<% } %>'];
	var person = new can.Observe({first: "Austin", last: "McDaniel"});

	var compiled = new can.EJS({text: text.join("\n")}).render({person: person});
	console.log(compiled)
	var table = document.createElement('table');
	//can.append( can.$('#qunit-test-area'), table )

	table.appendChild(can.view.frag(compiled));

	equal(table.innerHTML.replace(/[\s\n]/g,""),"
Austin

McDaniel
")

	person.removeAttr('first')
	equal(table.innerHTML.replace(/[\s\n]/g,""),"
McDaniel
")
	person.removeAttr('last');
	equal(table.innerHTML.replace(/[\s\n]/g,""),"");

	person.attr('first',"Justin");

	equal(table.innerHTML.replace(/[\s\n]/g,""),"
Justin
")
})

test("spaces between attribute name and value", function(){
	var text = '<input type="text" value = "<%= test %>" />',
		compiled = new can.EJS({text: text}).render({
			test : 'testing'
		}),
		div = document.createElement('div');

	div.appendChild(can.view.frag(compiled));
	var input = div.getElementsByTagName('input')[0];

	equal(input.value, 'testing');
	equal(input.type,"text")
})

test("live binding with computes", function() {
	var text = '<%= compute() %>',
		compute = can.compute(5),
		compiled = new can.EJS({text: text}).render({
			compute: compute
		}),
		div = document.createElement('div');

	div.appendChild(can.view.frag(compiled));

	var span = div.getElementsByTagName('span');
	equal(span.length, 1);

	span = span[0];

	equal(span.innerHTML, '5');
	compute(6);
	equal(span.innerHTML, '6');
	compute('Justin');
	equal(span.innerHTML, 'Justin');
	compute(true);
	equal(span.innerHTML, 'true');

})

})();


text:
package pool

import (
	"errors"
	"fmt"
	"sync"
	"sync/atomic"
	"time"

	"github.com/control-center/serviced/commons/queue"
)

// Item wrapper type for items stored in pool
type Item struct {
	Item         interface{}
	checkedOut   bool
	checkoutTime time.Time
	id           uint64
}

// ErrItemUnavailable Error when an item cannot be allocated fromt the pool
var ErrItemUnavailable = errors.New("Pool Item not avaialable")

// Pool interface for pooling arbitrary objects
type Pool interface {
	// Borrow item from pool, returns ErrItemUnavailable if none available
	Borrow() (*Item, error)

	// Borrow item from pool, wait timeout. If timeout < 0 wait indefinitely. Returns ErrItemUnavailable if object not available
	BorrowWait(timeout time.Duration) (*Item, error)

	// Return item back to pool
	Return(item *Item) error

	// Remove removes the object from the pool
	Remove(item *Item) error

	//Returns the current number of items borrowed
	Borrowed() int

	//Returns the current number of items in the pool (not borrowed)
	Idle() int
}

// ItemFactory function to create an item for the pool
type ItemFactory func() (interface{}, error)

// NewPool create a pool with a capacity and factory for creating items.
func NewPool(capacity int, itemFactory ItemFactory) (Pool, error) {

	q, err := queue.NewChannelQueue(capacity)
	if err != nil {
		return nil, err
	}

	itemMap := make(map[uint64]*Item)
	pool := itemPool{itemMap: itemMap, itemQ: q, capacity: capacity, itemFactory: itemFactory}
	return &pool, nil
}

type itemPool struct {
	itemMap map[uint64]*Item
	itemQ   queue.Queue

	idCounter   uint64
	capacity    int
	itemFactory ItemFactory
	poolLock    sync.RWMutex
}

func (p *itemPool) BorrowWait(timeout time.Duration) (*Item, error) {
	var (
		item, newItem *Item
		err           error
		itemOrError   = true
	)

	// function for locking purposes
	func() {
		p.poolLock.Lock()
		defer p.poolLock.Unlock()
		qItem, found := p.itemQ.Poll()
		if found {
			item = p.checkout(qItem)
			return
		}
		if !found {
			newItem, err = p.newItem()
			if err != nil && err != ErrItemUnavailable {
				return
			} else if err == nil {
				item = p.checkout(newItem)
				return
			}
		}
		itemOrError = false
	}()

	if itemOrError {
		return item, err
	}
	var qItem interface{}
	itemChan, timeoutChan := p.itemQ.TakeChan(timeout)
	select {
	case qItem = <-itemChan:
		return p.checkout(qItem), nil
	case <-timeoutChan:
		return nil, ErrItemUnavailable
	}
}

func (p *itemPool) Borrow() (*Item, error) {
	return p.BorrowWait(0)
}

func (p *itemPool) Return(item *Item) error {
	err := func() error {
		p.poolLock.RLock()
		defer p.poolLock.RUnlock()
		if pooledItem, found := p.itemMap[item.id]; !found {
			return fmt.Errorf("Pool Return error, item not found")
		} else if pooledItem != item { //check same object (pointer compare)
			return fmt.Errorf("Pool Return error, item not in pool")
		} else if !item.checkedOut {
			return fmt.Errorf("Pool Return error, item not checked out")
		}
		item.checkedOut = false
		return nil
	}()
	if err != nil {
		return err
	}

	if !p.itemQ.Offer(item) {
		return p.Remove(item)
	}
	return nil
}

func (p *itemPool) Remove(item *Item) error {
	p.poolLock.Lock()
	defer p.poolLock.Unlock()

	if pooledItem, found := p.itemMap[item.id]; !found {
		return fmt.Errorf("Pool Remove error, item not found")
	} else if pooledItem != item { //check same object (pointer compare)
		return fmt.Errorf("Pool Remove error, item not in pool")
	} else if !item.checkedOut {
		return fmt.Errorf("Pool Remove error, item not checked out")
	}

	delete(p.itemMap, item.id)
	item, err := p.newItem()
	if err == nil {
		p.itemQ.Offer(item)
	} else {
		fmt.Printf("Remove error %v\n", err)
	}
	return nil
}

//Returns the current number of items borrowed
func (p *itemPool) Borrowed() int {
	p.poolLock.RLock()
	defer p.poolLock.RUnlock()
	count := 0
	for _, item := range p.itemMap {
		if item.checkedOut {
			count++
		}
	}
	return count
}

// Idle Returns the current number of items in the pool (not borrowed)
func (p *itemPool) Idle() int {
	p.poolLock.RLock()
	defer p.poolLock.RUnlock()
	count := 0
	for _, item := range p.itemMap {
		if !item.checkedOut {
			count++
		}
	}
	return count
}

func (p *itemPool) checkout(item interface{}) *Item {
	poolItem := item.(*Item)
	poolItem.checkedOut = true
	poolItem.checkoutTime = time.Now()
	return poolItem
}

// creates a new Item if it can
func (p *itemPool) newItem() (*Item, error) {
	if len(p.itemMap) >= p.capacity {
		return nil, ErrItemUnavailable
	}
	i, err := p.itemFactory()
	if err != nil {
		return nil, err
	}

	pItem := &Item{id: p.nextID(), Item: i}
	p.itemMap[pItem.id] = pItem
	return pItem, nil
}

func (p *itemPool) nextID() uint64 {
	return atomic.AddUint64(&p.idCounter, 1)
}


text:
{-# LANGUAGE OverloadedStrings #-}

-- | Simple markdown page view.

module HL.View.Markdown where

import HL.View
import HL.View.Template

-- | Render a simple page.
markdownV :: [Route App] -> Text -> Html () -> FromLucid App
markdownV routes t inner =
  template routes t (const (container_ (row_ (span12_ [class_ "col-md-12"] inner))))


text:
package sbserver

import (
	"context"
	"fmt"

	"github.com/containerd/containerd/errdefs"
	"github.com/containerd/containerd/images"
	"github.com/containerd/containerd/tracing"

	runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

// RemoveImage removes the image.
// TODO(random-liu): Update CRI to pass image reference instead of ImageSpec. (See
// kubernetes/kubernetes#46255)
// TODO(random-liu): We should change CRI to distinguish image id and image spec.
// Remove the whole image no matter the it's image id or reference. This is the
// semantic defined in CRI now.
func (c *criService) RemoveImage(ctx context.Context, r *runtime.RemoveImageRequest) (*runtime.RemoveImageResponse, error) {
	span := tracing.SpanFromContext(ctx)
	image, err := c.localResolve(r.GetImage().GetImage())
	if err != nil {
		if errdefs.IsNotFound(err) {
			span.AddEvent(err.Error())
			// return empty without error when image not found.
			return &runtime.RemoveImageResponse{}, nil
		}
		return nil, fmt.Errorf("can not resolve %q locally: %w", r.GetImage().GetImage(), err)
	}
	span.SetAttributes(tracing.Attribute("image.id", image.ID))
	// Remove all image references.
	for i, ref := range image.References {
		var opts []images.DeleteOpt
		if i == len(image.References)-1 {
			// Delete the last image reference synchronously to trigger garbage collection.
			// This is best effort. It is possible that the image reference is deleted by
			// someone else before this point.
			opts = []images.DeleteOpt{images.SynchronousDelete()}
		}
		err = c.client.ImageService().Delete(ctx, ref, opts...)
		if err == nil || errdefs.IsNotFound(err) {
			// Update image store to reflect the newest state in containerd.
			if err := c.imageStore.Update(ctx, ref); err != nil {
				return nil, fmt.Errorf("failed to update image reference %q for %q: %w", ref, image.ID, err)
			}
			continue
		}
		return nil, fmt.Errorf("failed to delete image reference %q for %q: %w", ref, image.ID, err)
	}
	return &runtime.RemoveImageResponse{}, nil
}


text:
package com.acme.test;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import org.hamcrest.Matcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.junit.Assert.*;
import static org.hamcrest.Matchers.*;

public class AssertAndLogJUnit {
  private static final Logger log = LoggerFactory.getLogger(AssertAndLogJUnit.class);
  private static final String LOG_SUFFIX = " completed";

  private static String getLocation(Boolean helper) {
    int frameNum = helper ? 4 : 3;

    String fileName = Thread.currentThread().getStackTrace()[frameNum].getFileName();
    int lineNo = Thread.currentThread().getStackTrace()[frameNum].getLineNumber();

    return (fileName + "[" + lineNo + "]: ");
  }

  public static void assertTrueAndLog(String assertTitle, Boolean bool) {
    assertTrue(assertTitle, bool);
    log.info(getLocation(Boolean.FALSE) + assertTitle + LOG_SUFFIX);
  }

  public static void assertFalseAndLog(String assertTitle, Boolean bool) {
    assertFalse(assertTitle, bool);
    log.info(getLocation(Boolean.FALSE) + assertTitle + LOG_SUFFIX);
  }

  public static void assertNullAndLog(String assertTitle, Object obj) {
    assertNull(assertTitle, obj);
    log.info(getLocation(Boolean.FALSE) + assertTitle + LOG_SUFFIX);
  }

  public static void assertNotNullAndLog(String assertTitle, Object obj) {
    assertNotNull(assertTitle, obj);
    log.info(getLocation(Boolean.FALSE) + assertTitle + LOG_SUFFIX);
  }

  public static void assertEqualsAndLog(String assertTitle, Object expected, Object actual) {
    assertEquals(assertTitle, expected, actual);
    log.info(getLocation(Boolean.FALSE) + assertTitle + LOG_SUFFIX);
  }

  public static void failAndLog(String message) {
    log.error(getLocation(Boolean.FALSE) + message);
    fail(message);
  }

  public static void failAndLog(String message, Throwable e) {
    log.error(getLocation(Boolean.FALSE) + message, e);
    fail(message);
  }

  public static <T> void assertEqualsEitherAndLog(String message, T obj, T one, T other) {
    assertThat(message, obj, anyOf(equalTo(one), equalTo(other)));
  }

  public static void assertTrueAndLog(String assertTitle, Boolean assertion, Boolean helper) {
    assertTrue(assertTitle, assertion);
    log.info(getLocation(helper) + assertTitle + LOG_SUFFIX);
  }

  public static void assertFalseAndLog(String assertTitle, Boolean assertion, Boolean helper) {
    assertFalse(assertTitle, assertion);
    log.info(getLocation(helper) + assertTitle + LOG_SUFFIX);
  }

  public static void assertNullAndLog(String assertTitle, Object obj, Boolean helper) {
    assertNull(assertTitle, obj);
    log.info(getLocation(helper) + assertTitle + LOG_SUFFIX);
  }

  public static void assertNotNullAndLog(String assertTitle, Object obj, Boolean helper) {
    assertNotNull(assertTitle, obj);
    log.info(getLocation(helper) + assertTitle + LOG_SUFFIX);
  }

  public static void assertEqualsAndLog(String assertTitle, Object expected, Object actual,
      Boolean helper) {
    assertEquals(assertTitle, expected, actual);
    log.info(getLocation(helper) + assertTitle + LOG_SUFFIX);
  }

  public static void failAndLog(String message, Boolean helper) {
    log.error(getLocation(helper) + message);
    fail(message);
  }

  public static void failAndLog(String message, Throwable e, Boolean helper) {
    log.error(getLocation(helper) + message, e);
    fail(message);
  }

  public static void justLog(String message, Boolean helper) {
    log.info(getLocation(helper) + message);
  }

  public static void justLog(String message) {
    log.info(getLocation(Boolean.FALSE) + message);
  }

  public static <T> void assertEqualsEitherAndLog(String assertTitle, T obj, T one, T other,
      Boolean helper) {
    assertThat(assertTitle, obj, anyOf(equalTo(one), equalTo(other)));
    log.info(getLocation(helper) + assertTitle + LOG_SUFFIX);
  }

  public static <T> void assertEqualsAnyAndLog(String assertTitle, T obj, List<T> any,
      Boolean helper) {
    List<Matcher<? super T>> matchers = new ArrayList<Matcher<? super T>>();
    for (T a : any) {
      matchers.add(equalTo(a));
    }

    assertThat(assertTitle, obj, anyOf(matchers));
    log.info(getLocation(helper) + assertTitle + LOG_SUFFIX);
  }

  public static void assertUUIDEqualsAndLog(String assertTitle, UUID a, UUID b) {
    assertTrueAndLog(assertTitle, a.equals(b));
  }

  public static void assertStringEqualsAndLog(String assertTitle, String a, String b) {
    assertTrueAndLog(assertTitle, a.equals(b));
  }

  public static void assertZeroAndLog(String assertTitle, int size) {
    assertTrueAndLog(assertTitle, size == 0);
  }

  private static Boolean expOccurred = Boolean.FALSE;

  public static void expTestInit() {
    expOccurred = Boolean.FALSE;
  }

  public static void expTestOccurred(Exception e) {
    expOccurred = Boolean.TRUE;
    justLog(e.getMessage(), Boolean.TRUE);
  }

  public static void expTestAssert(String context) {
    assertTrueAndLog(context, expOccurred, Boolean.TRUE);
  }

}


text:
<template name="account.billing">

Credit Card

      {{#if state$hasCard}}

                <snap class="glyphicon glyphicon-credit-card"></snap>

            {{#with state$cardMeta}}

                    Number
                    **** **** **** {{lastFourDigits}}

                    Expires
                    {{expDate}}

            {{/with}}

                {{>render component="loadingButton"
                  id="update-card"
                  name="update-card"
                  class="btn btn-xs btn-default"
                  type="text|icon"
                  text="Update Card"
                  loadingIcon="glyphicon-refresh loading-icon"
                  loadingFn=stateFn$updatingCard
                }}

                {{>render component="loadingButton"
                  id="remove-card"
                  name="remove-card"
                  class="btn btn-xs btn-danger"
                  type="text|icon"
                  text="Remove Card"
                  loadingIcon="glyphicon-refresh loading-icon"
                  loadingFn=stateFn$removingCard
                }}

      {{else}}

          {{>render component="loadingButton"
            id="add-card"
            name="add-card"
            class="btn"
            type="text|icon"
            text="Add Credit Card"
            loadingIcon="glyphicon-refresh loading-icon"
            loadingFn=stateFn$updatingCard
          }}

      {{/if}}

Billing Info

        <form id="frm-billing-info">
            <input id="name" name="name" placeholder="Your Name" class="input name" type="text" pattern="[A-za-z ]+" value="{{state$billingInfo.name}}">

            <input id="email" name="email" placeholder="Email" class="input email" type="text" value="{{state$billingInfo.email}}">

            <input id="address-line-1" name="address-line-1" placeholder="Address Line 1" class="input address1" type="text" value="{{state$billingInfo.address1}}">

            <input id="address-line-2" name="address-line-2" placeholder="Address Line 2" class="input address2" type="text" value="{{state$billingInfo.address2}}">

            <input id="city" name="city" placeholder="City" class="input city" type="text" value="{{state$billingInfo.city}}">

            <input id="state" name="state" placeholder="State" class="input state" type="text" value="{{state$billingInfo.state}}">

            <input id="zip" name="zip" placeholder="Zip Code" class="input zip" type="text" value="{{state$billingInfo.zip}}">

            <input id="country" name="country" placeholder="Country" class="input country" type="text" value="{{state$billingInfo.country}}">

            <input id="other-info" name="other-info" placeholder="Other Information (Tax Id, etc)" class="input other" type="text" value="{{state$billingInfo.other}}">

            {{>render component="loadingButton"
              id="update-billing-info"
              name="update-billing-info"
              class="update btn btn-xs btn-warning"
              type="text|icon"
              action="submit"
              text="Update Billing Info"
              loadingIcon="glyphicon-refresh loading-icon"
              loadingFn=stateFn$updatingBillingInfo
            }}
        </form>

Current Month's Usage

    {{#render component="loading" isLoadingFn=stateFn$isChartLoading}}
      {{#if state$hasCurrentUsage}}

Total hosts count from {{state$currentUsage.startDate}}. Hosts counter will reset on {{state$currentUsage.resetDate}}.

          {{state$currentUsage.total}}/{{state$currentUsage.maximum}}

          {{>
            render component="pieChart"
            values=stateFn$appBreakdownChart
          }}

      {{/if}}
    {{/render}}

    {{>
      render component="account.billing.suggest"
    }}

    {{#if state$perHostBilledApps}}

 Per Host Billing Apps

      {{#each state$perHostBilledApps}}
        {{>
          render component="account.billing.timechartWrapper"
          yAxisTitle="Hosts"
          data=data
          plotLinesFn=stateFn$plotLines
          appName=name
          appId=appId
          endTime=state$endTime
        }}
      {{/each}}
    {{/if}}

    {{#if state$hasCard}}

Invoice History

      {{#render component="loading" isLoadingFn=stateFn$loadingTender}}

      {{/render}}
    {{/if}}

</template>


text:
package cognitoidentityiface

import (
	"github.com/aws/aws-sdk-go/aws/request"
	"github.com/aws/aws-sdk-go/service/cognitoidentity"
)

// CognitoIdentityAPI provides an interface to enable mocking the
// cognitoidentity.CognitoIdentity service client's API operation,
// paginators, and waiters. This make unit testing your code that calls out
// to the SDK's service client's calls easier.
//
// The best way to use this interface is so the SDK's service client's calls
// can be stubbed out for unit testing your code with the SDK without needing
// to inject custom request handlers into the the SDK's request pipeline.
//
//    // myFunc uses an SDK service client to make a request to
//    // Amazon Cognito Identity.
//    func myFunc(svc cognitoidentityiface.CognitoIdentityAPI) bool {
//        // Make svc.CreateIdentityPool request
//    }
//
//    func main() {
//        sess := session.New()
//        svc := cognitoidentity.New(sess)
//
//        myFunc(svc)
//    }
//
// In your _test.go file:
//
//    // Define a mock struct to be used in your unit tests of myFunc.
//    type mockCognitoIdentityClient struct {
//        cognitoidentityiface.CognitoIdentityAPI
//    }
//    func (m *mockCognitoIdentityClient) CreateIdentityPool(input *cognitoidentity.CreateIdentityPoolInput) (*cognitoidentity.IdentityPool, error) {
//        // mock response/functionality
//    }
//
//    TestMyFunc(t *testing.T) {
//        // Setup Test
//        mockSvc := &mockCognitoIdentityClient{}
//
//        myfunc(mockSvc)
//
//        // Verify myFunc's functionality
//    }
//
// It is important to note that this interface will have breaking changes
// when the service model is updated and adds new API operations, paginators,
// and waiters. Its suggested to use the pattern above for testing, or using
// tooling to generate mocks to satisfy the interfaces.
type CognitoIdentityAPI interface {
	CreateIdentityPoolRequest(*cognitoidentity.CreateIdentityPoolInput) (*request.Request, *cognitoidentity.IdentityPool)

	CreateIdentityPool(*cognitoidentity.CreateIdentityPoolInput) (*cognitoidentity.IdentityPool, error)

	DeleteIdentitiesRequest(*cognitoidentity.DeleteIdentitiesInput) (*request.Request, *cognitoidentity.DeleteIdentitiesOutput)

	DeleteIdentities(*cognitoidentity.DeleteIdentitiesInput) (*cognitoidentity.DeleteIdentitiesOutput, error)

	DeleteIdentityPoolRequest(*cognitoidentity.DeleteIdentityPoolInput) (*request.Request, *cognitoidentity.DeleteIdentityPoolOutput)

	DeleteIdentityPool(*cognitoidentity.DeleteIdentityPoolInput) (*cognitoidentity.DeleteIdentityPoolOutput, error)

	DescribeIdentityRequest(*cognitoidentity.DescribeIdentityInput) (*request.Request, *cognitoidentity.IdentityDescription)

	DescribeIdentity(*cognitoidentity.DescribeIdentityInput) (*cognitoidentity.IdentityDescription, error)

	DescribeIdentityPoolRequest(*cognitoidentity.DescribeIdentityPoolInput) (*request.Request, *cognitoidentity.IdentityPool)

	DescribeIdentityPool(*cognitoidentity.DescribeIdentityPoolInput) (*cognitoidentity.IdentityPool, error)

	GetCredentialsForIdentityRequest(*cognitoidentity.GetCredentialsForIdentityInput) (*request.Request, *cognitoidentity.GetCredentialsForIdentityOutput)

	GetCredentialsForIdentity(*cognitoidentity.GetCredentialsForIdentityInput) (*cognitoidentity.GetCredentialsForIdentityOutput, error)

	GetIdRequest(*cognitoidentity.GetIdInput) (*request.Request, *cognitoidentity.GetIdOutput)

	GetId(*cognitoidentity.GetIdInput) (*cognitoidentity.GetIdOutput, error)

	GetIdentityPoolRolesRequest(*cognitoidentity.GetIdentityPoolRolesInput) (*request.Request, *cognitoidentity.GetIdentityPoolRolesOutput)

	GetIdentityPoolRoles(*cognitoidentity.GetIdentityPoolRolesInput) (*cognitoidentity.GetIdentityPoolRolesOutput, error)

	GetOpenIdTokenRequest(*cognitoidentity.GetOpenIdTokenInput) (*request.Request, *cognitoidentity.GetOpenIdTokenOutput)

	GetOpenIdToken(*cognitoidentity.GetOpenIdTokenInput) (*cognitoidentity.GetOpenIdTokenOutput, error)

	GetOpenIdTokenForDeveloperIdentityRequest(*cognitoidentity.GetOpenIdTokenForDeveloperIdentityInput) (*request.Request, *cognitoidentity.GetOpenIdTokenForDeveloperIdentityOutput)

	GetOpenIdTokenForDeveloperIdentity(*cognitoidentity.GetOpenIdTokenForDeveloperIdentityInput) (*cognitoidentity.GetOpenIdTokenForDeveloperIdentityOutput, error)

	ListIdentitiesRequest(*cognitoidentity.ListIdentitiesInput) (*request.Request, *cognitoidentity.ListIdentitiesOutput)

	ListIdentities(*cognitoidentity.ListIdentitiesInput) (*cognitoidentity.ListIdentitiesOutput, error)

	ListIdentityPoolsRequest(*cognitoidentity.ListIdentityPoolsInput) (*request.Request, *cognitoidentity.ListIdentityPoolsOutput)

	ListIdentityPools(*cognitoidentity.ListIdentityPoolsInput) (*cognitoidentity.ListIdentityPoolsOutput, error)

	LookupDeveloperIdentityRequest(*cognitoidentity.LookupDeveloperIdentityInput) (*request.Request, *cognitoidentity.LookupDeveloperIdentityOutput)

	LookupDeveloperIdentity(*cognitoidentity.LookupDeveloperIdentityInput) (*cognitoidentity.LookupDeveloperIdentityOutput, error)

	MergeDeveloperIdentitiesRequest(*cognitoidentity.MergeDeveloperIdentitiesInput) (*request.Request, *cognitoidentity.MergeDeveloperIdentitiesOutput)

	MergeDeveloperIdentities(*cognitoidentity.MergeDeveloperIdentitiesInput) (*cognitoidentity.MergeDeveloperIdentitiesOutput, error)

	SetIdentityPoolRolesRequest(*cognitoidentity.SetIdentityPoolRolesInput) (*request.Request, *cognitoidentity.SetIdentityPoolRolesOutput)

	SetIdentityPoolRoles(*cognitoidentity.SetIdentityPoolRolesInput) (*cognitoidentity.SetIdentityPoolRolesOutput, error)

	UnlinkDeveloperIdentityRequest(*cognitoidentity.UnlinkDeveloperIdentityInput) (*request.Request, *cognitoidentity.UnlinkDeveloperIdentityOutput)

	UnlinkDeveloperIdentity(*cognitoidentity.UnlinkDeveloperIdentityInput) (*cognitoidentity.UnlinkDeveloperIdentityOutput, error)

	UnlinkIdentityRequest(*cognitoidentity.UnlinkIdentityInput) (*request.Request, *cognitoidentity.UnlinkIdentityOutput)

	UnlinkIdentity(*cognitoidentity.UnlinkIdentityInput) (*cognitoidentity.UnlinkIdentityOutput, error)

	UpdateIdentityPoolRequest(*cognitoidentity.IdentityPool) (*request.Request, *cognitoidentity.IdentityPool)

	UpdateIdentityPool(*cognitoidentity.IdentityPool) (*cognitoidentity.IdentityPool, error)
}

var _ CognitoIdentityAPI = (*cognitoidentity.CognitoIdentity)(nil)


text:
using Students.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Students.Controllers
{
    public class StudentsController : ApiController
    {
        //
        // GET api/values
        public HttpResponseMessage Get()
        {
            var students = StudentsFactory.GenerateStudents(new Random().Next(20));

            //return students;

            var msg = this.Request.CreateResponse(HttpStatusCode.OK, students);
            msg.Headers.Add("Access-Control-Allow-Origin", "*");

            return msg;
        }
    }
}


text:
@echo off
set PATH=lib;%PATH%;%systemroot%\SysWOW64
start javaw -cp bin;NullpoMino.jar;lib\log4j-1.2.15.jar;lib\sdljava.jar -Djava.library.path=lib mu.nu.nullpo.gui.sdl.NullpoMinoSDL