This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var validateEmail = function (email) { | |
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
return re.test(email); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONVERT(INT, (SELECT CONVERT(VARCHAR(8), SALE_TIMESTAMP, 112) AS [YYYYMMDD])) AS DateKey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT CONVERT(DATETIME, CONVERT(VARCHAR, DateKey) + ' ' + | |
SUBSTRING(RIGHT('000000' + CONVERT(VARCHAR, DateKey), 6), 1, 2) + ':' + | |
SUBSTRING(RIGHT('000000' + CONVERT(VARCHAR, TimeKey), 6), 3, 2) + ':' + | |
SUBSTRING(RIGHT('000000' + CONVERT(VARCHAR, TimeKey), 6), 5, 2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--===== Create and populate the Tally table on the fly | |
SELECT TOP 11000 --equates to more than 30 years of dates | |
IDENTITY(INT,1,1) AS N | |
INTO dbo.Tally | |
FROM Master.dbo.SysColumns sc1, | |
Master.dbo.SysColumns sc2 | |
--===== Add a Primary Key to maximize performance | |
ALTER TABLE dbo.Tally | |
ADD CONSTRAINT PK_Tally_N |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE RetDay.dimProductCategoryHierarchy SET | |
ParentCategoryKey = ( | |
SELECT TOP 1 ProductCategoryMappingKey | |
FROM RetDay.dimProductCategoryHierarchy | |
WHERE ProductCategoryCode = P.ParentCategoryCode | |
AND DETL_RowIsCurrent = 1) | |
FROM RetDay.dimProductCategoryHierarchy P | |
WHERE P.ParentCategoryKey IS NULL | |
AND P.ParentCategoryCode <> ' ' | |
AND P.ParentCategoryCode IS NOT NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO X (...) | |
SELECT ... | |
FROM ( | |
SELECT <group by keys>, COUNT(*) - 1 AS K | |
FROM <table with dups> | |
WHERE ... | |
GROUP BY <group by keys> | |
HAVING COUNT(*) > 1 | |
) A | |
JOIN Tally on Tally.N <= A.K |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET IDENTITY_INSERT <table to init> ON | |
GO | |
INSERT INTO <table to init>(...) | |
VALUES (...including key) | |
SET IDENTITY_INSERT <table to init> OFF | |
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
-- ============================================= | |
-- Author: Mark Moloney | |
-- Create date: 4/10/2012 | |
-- Description: Convert a time to the appropriate hour block | |
-- ============================================= | |
CREATE FUNCTION ConvertTimeToHourBlock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static <T> Iterable<T> once(final Iterator<T> source) { | |
return new Iterable<T>() { | |
private AtomicBoolean exhausted = new AtomicBoolean(); | |
@Override | |
public Iterator<T> iterator() { | |
Preconditions.checkState(!exhausted.getAndSet(true)); | |
return source; | |
} | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package diamond.models | |
import java.util.Date | |
/** | |
* @param entity String entity id (usually hashed) | |
* @param eventType String attribute name | |
* @param ts Date event timestamp | |
* @param namespace String logical grouping | |
* @param session Option[String] session id |
OlderNewer