Skip to content

Instantly share code, notes, and snippets.

View mahizsas's full-sized avatar

MAHIZ mahizsas

View GitHub Profile
@mahizsas
mahizsas / urlacl add
Created October 9, 2012 05:58
webapi urlacl managment
netsh http add urlacl url=http://+:9090/ user=machine\username
@mahizsas
mahizsas / log-examples.txt
Created October 9, 2012 06:11 — forked from KevM/log-examples.txt
Adding the current web request URL to your log4net logging context
2012-10-04 17:25:25,241 DEBUG [|24] Dovetail.SDK.Bootstrap.Clarify.CurrentSDKUser / Setting the current user to be annie
2012-10-04 17:25:25,246 DEBUG [annie|24] Dovetail.SDK.Bootstrap.Clarify.ClarifySessionCache / Get session for annie. Found valid session in cache.
2012-10-04 17:25:39,695 DEBUG [|28] Dovetail.SDK.Bootstrap.Clarify.ClarifySessionCache /api/history/case/148 Getting application session.
2012-10-04 17:25:39,695 DEBUG [|28] Dovetail.SDK.Bootstrap.Clarify.ClarifySessionCache /api/history/case/148 Get session for sa. Found valid session in cache.
2012-10-04 17:25:39,695 DEBUG [|28] Dovetail.SDK.Bootstrap.Clarify.ClarifySessionCache /api/history/case/148 Get session for annie. Found valid session in cache.
2012-10-04 17:25:39,696 DEBUG [|28] Dovetail.SDK.Bootstrap.Authentication.PrincipalFactory /api/history/case/148 Creating principal for user annie with 165 permissions.
2012-10-04 17:25:39,696 DEBUG [|28] Dovetail.SDK.Bootstrap.Clarify.CurrentSDKUser /api/history/case/148 Setting the curren
@mahizsas
mahizsas / GetSizeReadable.cs
Created October 10, 2012 20:58
Display Size in reeadble format
public static string GetSizeReadable(long i)
{
string sign = (i < 0 ? "-" : "");
double readable = (i < 0 ? -i : i);
string suffix;
if (i >= 0x1000000000000000) // Exabyte
{
suffix = "EB";
readable = (double)(i >> 50);
}
@mahizsas
mahizsas / Javascript abstract console log
Created October 12, 2012 10:04
Javascript abstract console log
if (!(window.console && console.log)) {
(function() {
var noop = function() {};
var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'markTimeline', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'];
var length = methods.length;
var console = window.console = {};
while (length--) {
console[methods[length]] = noop;
}
}());
@mahizsas
mahizsas / KillSessionCookie.cs
Created October 24, 2012 00:42
ASP.NET - Kill session cookie
var sessionCookie = new HttpCookie("ASP.NET_SessionId", string.Empty);
sessionCookie.Expires = DateTime.Now.AddDays(-1);
sessionCookie.Domain = UrlInformation.GetHostDomain(HttpContext.Current.Request.Url.Host);
HttpContext.Current.Response.Cookies.Add(sessionCookie);
@mahizsas
mahizsas / DatabaseDeleter.cs
Created October 24, 2012 20:12 — forked from jbogard/DatabaseDeleter.cs
Delete all tables in DB with NHibernate
public class DatabaseDeleter
{
private readonly ISessionFactory _configuration;
private static readonly string[] _ignoredTables = new[] { "sysdiagrams", "usd_AppliedDatabaseScript" };
private static string[] _tablesToDelete;
private static string _deleteSql;
private static object _lockObj = new object();
private static bool _initialized;
public DatabaseDeleter(ISessionFactory sessionSource)
@mahizsas
mahizsas / GetMimeType.cs
Created October 25, 2012 23:45
C# - GetMimeType
static string GetMimeType(string fileName)
{
string mimeType = "application/unknown";
string ext = Path.GetExtension(fileName).ToLower();
Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
if (regKey != null && regKey.GetValue("Content Type") != null)
{
mimeType = regKey.GetValue("Content Type").ToString();
}
else if (ext == ".png")
@mahizsas
mahizsas / delete_tables_byprefix.sql
Created November 18, 2012 11:05 — forked from jasongaylord/delete_tables_byprefix.sql
TSQL - Delete Tables with a Prefix
declare @cmd varchar(4000)
declare cmds cursor for
Select 'drop table [' + Table_Name + ']'
From INFORMATION_SCHEMA.TABLES
Where Table_Name like 'prefix%'
open cmds
while 1=1
begin
@mahizsas
mahizsas / CsvActionResult.cs
Created November 24, 2012 16:51 — forked from simonech/CsvActionResult.cs
ActionResult for ASP.NET MVC that returns a CSV file from any list of objects
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace webnetconf.website.Helpers
@mahizsas
mahizsas / List-tables-as-wiki-markup.sql
Created November 30, 2012 00:17 — forked from colinangusmackay/List-tables-as-wiki-markup.sql
A T-SQL script that renders media wiki markup of a list of tables or views that can be used in the creation of a data dictionary. More details on my blog: http://colinmackay.co.uk/2012/06/14/creating-a-data-dictionary-with-sql-server-and-mediawiki-part-on
-- For more information about this script and its uses, visit:
-- http://colinmackay.co.uk/2012/06/14/creating-a-data-dictionary-with-sql-server-and-mediawiki-part-one-a-list-of-tables/
DECLARE @Type NVARCHAR(100) = 'BASE TABLE' -- 'VIEW' OR 'BASE TABLE'
DECLARE @catalogue SYSNAME;
DECLARE @schema SYSNAME;
DECLARE @name SYSNAME;
SET NOCOUNT ON