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
// This example shows how to read and excel file using the Koogra library (http://sourceforge.net/projects/koogra/) | |
// Supports .xls and .xlsx example | |
public static string ReadExcelContent(string filePath) | |
{ | |
uint rowNum = 0; | |
uint colNum = 0; | |
var data = new StringBuilder(); | |
try | |
{ |
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
'============================== | |
'Remove old backups | |
'http://gordondurgha.com | |
'============================= | |
'Definitions | |
iDaysOld = 3 | |
strExtension = ".bak" | |
sDirectoryPath = "D:\MSSQL\Backups\" |
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 MyCompany.Web | |
{ | |
public class MyCompanySiteMapVisibilityProvider : MvcSiteMapProvider.SiteMapNodeVisibilityProviderBase | |
{ | |
public override bool IsVisible(ISiteMapNode node, IDictionary<string, object> sourceMetadata) | |
{ | |
if (node == null) | |
{ | |
return true; | |
} |
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 ActionResult LogOff() | |
{ | |
// Load Identity Configuration | |
FederationConfiguration config = FederatedAuthentication.FederationConfiguration; | |
// Get wtrealm from WsFederationConfiguation Section | |
string wtrealm = config.WsFederationConfiguration.Realm; | |
string wreply; | |
// Construct wreply value from wtrealm (This will be the return URL to your app) |
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
<% | |
' Use with a very short session (basically the page lifecycle, GET then POST) | |
Class AntiForgeryValidator | |
Private m_securityToken | |
Sub SetCookie() | |
m_securityToken = CreateWindowsGuid() | |
Response.Cookies("RequestVerificationToken") = m_securityToken |
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
# Generate Cert and Key in seperate file | |
# Provide the .cert to the end user | |
openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 -keyout QA.key -out QA.cert | |
# Merge cert and private key to make a p12 file, this file will be used by .NET's X509Certificate2 class, The private key will be accessible via the "PrivateKey" property | |
openssl pkcs12 -export -in qa.cert -inkey qa.key -out qa.p12 -name "QA" |
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
/* Useful for analyzing a Elmah logs stored in a SQL Server */ | |
/* Version 1 */ | |
/* --------------------------------------------------------------*/ | |
DECLARE @StartDateTime datetime | |
DECLARE @EndDateTime datetime | |
DECLARE @HourlyThreshold int -- If error count for an hour is greater than this number display in the threshold overflow report | |
SET @HourlyThreshold = 10 | |
SET @StartDateTime = DATEADD(d, -7, CAST(GETDATE() AS date)) |
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 SqlConnection GetSqlConnection(DbContext dbContext) | |
{ | |
var ec = dbContext.Database.Connection; | |
var adoConnStr = ec.ConnectionString; | |
return new SqlConnection(adoConnStr); | |
} |
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 class XmlDocumentPrettyExtension | |
{ | |
public static string Prettyify(this XmlDocument xmlDocument) | |
{ | |
var stringWriter = new StringWriter(new StringBuilder()); | |
var xmlTextWriter = new XmlTextWriter(stringWriter) { Formatting = Formatting.Indented }; | |
xmlDocument.Save(xmlTextWriter); | |
return stringWriter.ToString(); | |
} | |
} |
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
git config --global diff.tool bc4 | |
git config --global difftool.bc4.path "c:/Program Files/Beyond Compare 4/bcomp.exe" | |
git config --global merge.tool bc4 | |
git config --global mergetool.bc4.path "c:/Program Files/Beyond Compare 4/bcomp.exe" |
OlderNewer