Skip to content

Instantly share code, notes, and snippets.

@timothyclifford
timothyclifford / FileExtensionRegularExpression.cs
Created March 18, 2012 03:22
Regular expression file extension filter
<asp:RegularExpressionValidator ID="regexFileUpload" runat="server" ControlToValidate="FileUploadControlID" ErrorMessage="Uploaded file should be .doc, .docx or .pdf files only" ValidationExpression="^.*\.(doc|DOC|docx|DOCX|pdf|PDF)$"></asp:RegularExpressionValidator>
@timothyclifford
timothyclifford / emailAttachFromPostedFile.cs
Created February 24, 2012 05:39
.net email attachment from posted file
string fileName = Path.GetFileName(UploadedFile.PostedFile.FileName);
Attachment attachment = new Attachment(UploadedFile.FileContent, fileName);
myMailMessage.Attachments.Add(attachment);
SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.Send(myMailMessage);
@timothyclifford
timothyclifford / woo.cs
Created January 5, 2012 22:42
Interesting dynamic control init and string concatenation
((Literal)e.Item.FindControl("ltDay")).Text = "<span class='weekend'>" + string.Format("<input type='text' " + weekend + " autocomplete='off' size='3' value='{0}' tabindex='{3}' onclick='this.select()' onblur='GuruAllocator.Allocation.checkTime(this)' id='Day_{1}_{2}' name='Day${1}${2}' {4} style='{5}' {6}/>", (ta.Hours > 0 ? ta.Hours.ToString("0.#") : ""), weekIndex, e.Item.ItemIndex, tabIndexNumber, strDisabled, strStyleDisabled, strOnKeyPressEvent) + "</span>";
@timothyclifford
timothyclifford / JS Cookie Class.js
Created December 29, 2011 02:05
Simple cookie management class
@timothyclifford
timothyclifford / GitIgnoreGlobal.txt
Created December 18, 2011 03:44
Git global ignore config
git config --global core.excludesfile ~/.gitignore
@timothyclifford
timothyclifford / Vs2010GitIgnore.txt
Created December 18, 2011 03:42
Visual Studio 2010 & Resharper .gitignore
[Oo]bj
[Bb]in
*.user
*.suo
*.[Cc]ache
*.bak
*.ncb
*.log
*.DS_Store
[Tt]humbs.db
@timothyclifford
timothyclifford / WinCommandPromptRename
Created December 18, 2011 03:38
Windows Command Prompt Rename
[drive:]\Users\[username]\[textfile].txt .gitignore
@timothyclifford
timothyclifford / gist:1170653
Created August 25, 2011 13:27
SQL restore locked DB
-- Get all the current SPID's
EXEC sp_who2
-- Kill a given SPID
KILL <SPID>
-- Set database offline
ALTER DATABASE <DATABASENAME> SET OFFLINE WITH NO_WAIT
@timothyclifford
timothyclifford / gist:1170646
Created August 25, 2011 13:25
C# Regex convert camel case to proper English
Regex.Replace(stringValue, "((?<=[a-z])[A-Z]|[A-Z](?=[a-z]))", " $1")
@timothyclifford
timothyclifford / gist:1102131
Created July 24, 2011 02:25
Detecting iPhone & iPad using Javascript
if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1))
{
// Do something for iPhone / iPad / iPod here
}