Skip to content

Instantly share code, notes, and snippets.

View fly2melb's full-sized avatar

fly2melb fly2melb

  • Melbourne
View GitHub Profile
@fly2melb
fly2melb / DbccPage.sql
Created May 31, 2016 02:41
Display raw data of specified page in Microsoft SQL Server.
DBCC PAGE('[DB_NAME]', [PAGE_FILE_ID], [PAGE_ID], -1)
@fly2melb
fly2melb / gist:b10fd435d52bb711ed664d0cddf835de
Created May 31, 2016 02:31
Display basic page information of specified table in Microsoft SQL Server.
DBCC IND('[DB_NAME]', '[TABLE_NAME]', -1)
SELECT [First]
FROM [sys].[sysindexes]
WHERE [id] = OBJECT_ID('[TABLE_NAME]')
AND [indid] IN (0, 1)
DBCC SHOWCONTIG('[TABLE_NAME]') WITH TABLERESULTS
SELECT alloc_unit_type_desc
, page_count
, avg_page_space_used_in_percent
, record_count
FROM sys.dm_db_index_physical_stats(
DB_ID('[DB_NAME]')
, OBJECT_ID(N'[TABLE_NAME]')
, NULL
@fly2melb
fly2melb / DbccTraceOn.sql
Created May 31, 2016 02:24
Redirect DBCC output to client in Microsoft SQL Server.
DBCC TRACEON(3604)
@fly2melb
fly2melb / SpaceUsed.sql
Created May 31, 2016 02:19
Display space used by specified table in Microsoft SQL Server.
SP_SPACEUSED '[TABLE_NAME]'
@fly2melb
fly2melb / IfDebug.cs
Last active April 19, 2016 23:59
Code executed only when debugging.
#if DEBUG
Console.WriteLine("This is debugging code.");
#endif
@fly2melb
fly2melb / CascadingDropDown.cshtml
Created September 10, 2015 01:19
Cascading drop-down in MVC - step 3/3
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.DropDownListFor(model =>
model.ContinentId, new SelectList(Model.ContinentList, "Key", "Value", Model.ContinentId),
"- Continent -", new { id = "continentId" })
@fly2melb
fly2melb / DemoController.cs
Created September 10, 2015 01:06
Cascading drop-down in MVC - step 2/3
public ViewResult CascadingDropDown()
{
var viewModel = new CascadingDropDownViewModel();
viewModel.ContinentList = GetContinents();
return View(viewModel);
}
[HttpPost, ValidateAntiForgeryToken]
public ViewResult CascadingDropDown(CascadingDropDownViewModel viewModel)
@fly2melb
fly2melb / CascadingDropDownViewModel.cs
Last active September 10, 2015 01:02
Cascading drop-dwon in MVC - step 1
public class CascadingDropDownViewModel
{
public CascadingDropDownViewModel()
{
ContinentList = new List<KeyValuePair<int, string>>();
CountryList = new List<KeyValuePair<int, string>>();
}
public List<KeyValuePair<int, string>> ContinentList { get; set; }
@fly2melb
fly2melb / Command.bat
Last active September 2, 2015 05:29
Set proxy environment variables.
SET http_proxy=http://192.168.1.1:8080
SET http_user=domain\\username
SET http_pass=password