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
using System.Diagnostics; | |
using System.ServiceModel.Web; | |
using System.ServiceModel.Description; | |
namespace WCFRest.ConsoleServiceHost | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
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
public Stream GetPage() | |
{ | |
var page = Properties.Resources.Status; // page from resources | |
// Get site relative base url for use in javascript ajax requests | |
var baseUrl = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BaseUri.AbsolutePath; | |
page = page.Replace("%BaseURL%", baseUrl); | |
MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(page)); | |
WebOperationContext.Current.OutgoingResponse.ContentType = "text/html"; |
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
function ASDFClass() { | |
var self = this; // used when you want to reference an instance of this object from private methods | |
this.PublicIVar = "asdafd"; | |
var privateIVar = "encapsulated"; | |
function PrivateFunction() { | |
} | |
this.PublicFunction = function () { |
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
Imports Newtonsoft.Json | |
Imports System.Web | |
' Gets and auth cookie and stores an object in JSON format in userData | |
' Useful for storing ids, roles information, and email address | |
Public Class FormsAuthenticationExtensions | |
' Calls this to get cookie when logging a user in | |
Public Shared Function GetAuthCookie(ByVal userName As String, ByVal userData As Object, Optional ByVal createPersistentCookie As Boolean = True) As HttpCookie | |
Dim cookie = FormsAuthentication.GetAuthCookie(userName, createPersistentCookie) | |
Dim ticket = FormsAuthentication.Decrypt(cookie.Value) |
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
public DateTime FindNthOccurenceOfWeekDayForMonth(int month, int year, DayOfWeek weekDay, int occurence) | |
{ | |
if(occurence < 1) | |
{ | |
throw new ArgumentOutOfRangeException("occurence must be greater than 0"); | |
} | |
// iterate over days, beginning with the first day of the given month and year | |
// loop until occurence = 0 | |
// when loop exits current will be set to the nth occurence of weekDay |
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
public static partial class FileInfoExtensions | |
{ | |
public static string ToWebSiteRelativePath(this FileInfo fileInfo) | |
{ | |
var applicationPhysicalPath = HostingEnvironment.ApplicationPhysicalPath; | |
var filePhysicalPath = fileInfo.FullName; | |
if (filePhysicalPath.StartsWith(applicationPhysicalPath) == false) | |
throw new ArgumentOutOfRangeException(filePhysicalPath + " is not within application physical path: " + applicationPhysicalPath); | |
return filePhysicalPath.Replace(applicationPhysicalPath, HostingEnvironment.ApplicationVirtualPath + "/").Replace("\\", "/"); | |
} |
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
namespace Extensions | |
{ | |
public static class DateTimeExtensions | |
{ | |
public static DateTime StartOfWeek(DateTime value) | |
{ | |
var startOfWeek_ = DayOfWeek.Sunday; | |
var delta = value.DayOfWeek - startOfWeek_; | |
if (delta < 0) |
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
-- http://www.i-programmer.info/programming/database/3208-improve-sql-performance-find-your-missing-indexes.html | |
SET TRANSACTION ISOLATION LEVEL | |
READ UNCOMMITTED | |
SELECT TOP 20 | |
ROUND(s.avg_total_user_cost * | |
s.avg_user_impact | |
* (s.user_seeks + s.user_scans),0) | |
AS [Total Cost] | |
,d.[statement] AS [Table Name] |
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
(function(global, $){ | |
var keyCodes = { | |
13: 'enter', | |
38: 'up', | |
40: 'down', | |
37: 'left', | |
39: 'right' | |
}; | |
var spreadsheet = { |
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 count = function(tree) { | |
if(!tree) { | |
return 0; | |
} | |
return 1 + count(tree.left) + count(tree.right); | |
}; | |
*/ |
OlderNewer