Skip to content

Instantly share code, notes, and snippets.

View kmlprtsng's full-sized avatar

Kamalpreet Singh Chauhan kmlprtsng

View GitHub Profile
@kmlprtsng
kmlprtsng / css_min_width.txt
Created August 30, 2013 16:15
Min Width for Legacy IE
IE 6 doesn't support it but IE7+ does but IE7 support is bit buggy apparently.
IE6 supports width as min-width anyway. Doh!
_width: 200px;
@kmlprtsng
kmlprtsng / js_print_div.js
Created August 22, 2013 11:00
Print contents of a div tag
//<a href="javascript:void(0)" onclick="PrintElem('.panel-div')" class="btn">Print Div</a>
function PrintElem(elem)
{
PrintPopup($(elem).html());
}
function PrintPopup(data)
{
//Windows title in window.open itches the IE the wrong way.
@kmlprtsng
kmlprtsng / css_full_width_Textarea.css
Created August 21, 2013 15:27
Full Width Text Area
/*Put the margin/padding required on the parent and not on the text area*/
textarea.fullwidth {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
}
.Center-Container {
position: relative;
}
.Absolute-Center {
width: 50%;
height: 50%;
overflow: auto;
margin: auto;
position: absolute;
/*<div class="Center-Container is-Table">
<div class="Table-Cell">
<div class="Center-Block">
<!-- CONTENT -->
</div>
</div>
</div>
Nick the .center-container styles from above files.
*/
@kmlprtsng
kmlprtsng / sql_find_duplicate_record
Created August 15, 2013 11:12
Find Duplicated record
SELECT count(email), email
FROM Users
GROUP BY email
HAVING count(email) > 1
@kmlprtsng
kmlprtsng / asp_stop_browser_caching
Created August 14, 2013 15:37
Stop Browser Caching
//Stop Caching - Solution 1
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
//Solution 2
Response.AppendHeader("Cache-Control", "no-cache"); //HTTP 1.1
Response.AppendHeader("Cache-Control", "private"); // HTTP 1.1
Response.AppendHeader("Cache-Control", "no-store"); // HTTP 1.1
Response.AppendHeader("Cache-Control", "must-revalidate"); // HTTP 1.1
@kmlprtsng
kmlprtsng / csharp_random_string
Created August 14, 2013 15:31
Random String Generator
private string GenerateRandomString()
{
return Path.GetRandomFileName().Substring(0, 8);
}
@kmlprtsng
kmlprtsng / asp_web_app_user_account
Created August 14, 2013 14:56
Get user the web app service is running under
//http://stackoverflow.com/questions/275824/how-to-find-out-which-account-my-asp-net-code-is-running-under
var user = System.Security.Principal.WindowsIdentity.GetCurrent().User;
var userName = user.Translate(typeof (System.Security.Principal.NTAccount));
@kmlprtsng
kmlprtsng / asp_get_base_url.cs
Created August 14, 2013 14:54
Get Base URL or a part of URL
//*************** Solution 1 **************/
// http://forums.asp.net/t/1466607.aspx/1
//http://forums.asp.net/t/1383898.aspx
//would return http://localhost:2013 or http://localhost:2013/ApplicationPath
return string.Format("{0}://{1}{2}",
HttpContext.Current.Request.Url.Scheme,
HttpContext.Current.Request.ServerVariables["HTTP_HOST"],