This file contains hidden or 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
public class StringHelper | |
{ | |
public struct transform | |
{ | |
public string UrlChar; | |
public string DescChar; | |
} | |
public enum transformDirection | |
{ | |
UrlToDescription, |
This file contains hidden or 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
protected void Application_BeginRequest() | |
{ | |
if (Request.Headers.AllKeys.Contains("Origin") && Request.HttpMethod == "OPTIONS") | |
{ | |
Response.Flush(); | |
} | |
} |
This file contains hidden or 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
struct Resource<A> { | |
let pathComponent: String | |
let parse: AnyObject -> A? | |
} | |
extension Resource { | |
func loadAsynchronous(callback: A? -> ()) { | |
let session = NSURLSession.sharedSession() | |
let resourceURL = webserviceURL.URLByAppendingPathComponent(pathComponent) | |
session.dataTaskWithURL(resourceURL) { |
This file contains hidden or 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
-- xml retrieval | |
declare @xml xml | |
SET @xml = '<Categories> | |
<Category ID="4"> | |
<name>Accessories</name> | |
</Category> | |
<Category ID="1"> | |
<name>Bikes</name> | |
</Category> | |
<Category ID="3"> |
This file contains hidden or 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
with SalesData as | |
( | |
select sum(soh.TotalDue) as 'TotalSold' | |
, year(soh.OrderDate) as 'OrderYear' | |
, st.Name AS 'TerritoryName' | |
from sales.SalesOrderHeader as soh | |
inner join sales.SalesTerritory as st ON soh.TerritoryID = st.TerritoryID | |
group by year(soh.OrderDate) | |
, st.Name | |
) |
This file contains hidden or 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 row_number() over (order by Name) as 'RowNUmber' | |
, Name | |
, ListPrice | |
from Production.Product | |
Order by Name | |
offset 20 rows | |
fetch next 10 rows only |
This file contains hidden or 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 ListPrice | |
, Name | |
, row_number() over (order by ListPrice desc) as 'row_number' | |
, rank() over (order by ListPrice desc) as 'rank' | |
, dense_rank() over (order by ListPrice desc) as 'dense_rank' | |
, ntile(5) over (order by ListPrice desc) as 'ntile' | |
from Production.Product | |
where ProductSubcategoryID = 1 | |
order by ListPrice desc |
This file contains hidden or 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 testRepo = new TestRepo(); | |
//var start = DateTime.Now; | |
var t1 = testRepo.Task1(); | |
var t2 = testRepo.Task2(); | |
int[] r = await Task.WhenAll(t1, t2); | |
//var end = (DateTime.Now - start).Seconds; | |
return new int[] { r[0], r[1] }; | |
/***************************/ | |
public class TestRepo |
This file contains hidden or 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
public static string Encrypt(string clearText) | |
{ | |
string EncryptionKey = "my-secret-key"; | |
byte[] clearBytes = Encoding.Unicode.GetBytes(clearText); | |
using (Aes encryptor = Aes.Create()) | |
{ | |
Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 }); | |
encryptor.Key = pdb.GetBytes(32); | |
encryptor.IV = pdb.GetBytes(16); | |
using (MemoryStream ms = new MemoryStream()) |
This file contains hidden or 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
<system.webServer> | |
<staticContent> | |
<remove fileExtension=".woff" /> | |
<!-- In case IIS already has this mime type --> | |
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" /> | |
<remove fileExtension=".woff2" /> | |
<!-- In case IIS already has this mime type --> | |
<mimeMap fileExtension=".woff2" mimeType="application/x-font-woff2" /> | |
</staticContent> | |
</system.webServer> |