Skip to content

Instantly share code, notes, and snippets.

@gscattolin
gscattolin / gist:9b214b20792467d27700
Created August 16, 2014 08:20
WPF Debug Bindings TraceLevel
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBlock Text="{Binding ThereIsNoDataContext,
diag:PresentationTraceSources.TraceLevel=High}"/>
</Grid>
</Window>
@gscattolin
gscattolin / new_gist_file.js
Created January 10, 2014 11:20
Init function to pass the MVC server ViewModel 2 Knockout viewModel
$(function ()
{
require(['WorkOrderStatusConfiguration'], function (workOrderStatusConfig)
{
var data = $.parseJSON('@Html.Raw(Json.Encode(Model))');
workOrderStatusConfig.Init({
services: {
SaveWOConfigUrl: '@Url.Action("SaveWorkOrderConfiguration", "WorkOrderStatusConfiguration")',
},
bindingContainerId: 'WorkOrderStatusContainer',
@gscattolin
gscattolin / new_gist_file.sql
Created November 14, 2013 12:50
how-do-i-query-for-all-dates-greater-than-a-certain-date-in-sql-server
select *
from dbo.March2010 A
where A.Date >= Convert(datetime, '2010-04-01' )
@gscattolin
gscattolin / new_gist_file.sql
Created November 5, 2013 14:21
Transaction with RollBack
SET XACT_ABORT ON
BEGIN TRY
BEGIN TRANSACTION
--work code here
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
--cleanup code
END CATCH
@gscattolin
gscattolin / new_gist_file.bat
Created October 24, 2013 09:29
Take owernship of a SQL instance CMD script to add a user to the SQL Server sysadmin role
@echo off
rem
rem ****************************************************************************
rem
rem Copyright (c) Microsoft Corporation. All rights reserved.
rem This code is licensed under the Microsoft Public License.
rem THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
rem ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
rem IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
rem PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
@gscattolin
gscattolin / new_gist_file.js
Created September 23, 2013 14:42
remove calendar datepicker
<style>
.calendar-off table.ui-datepicker-calendar {
display:none !important;
}
</style>
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {
$("#stockAgroForm").validate({});
$(".numeric").autoNumeric('init', { aSep: '', aDec: window.app.settings.decimalSeparator, vMin: '0.00', vMax: '99999999999.99' }); // aSep=thousand separator, aDec=decimal separatator
@gscattolin
gscattolin / new_gist_file
Created September 18, 2013 12:43
Developer command (open cmd line using dx button)
http://blogs.clariusconsulting.net/kzu/visual-studio-2012-developer-command-prompt-here/
@gscattolin
gscattolin / new_gist_file
Created September 17, 2013 16:21
Debugger Remote App with Visual Studio
Consider the following situation:
We have deployed a web application on a client machine and the client reports a bug. Then we try to replicate the problem in our local environment (where the code exists), but could not succeed. Now there are two ways to debug the client installation – either through log files or through visual studio debug mode. If our logging is not detailed, we will have nightmares in troubleshooting. The other option is installing visual studio in a server machine (which is not a great idea).
To solve this remote debug problem, we can use a tiny tool called Remote Debugging Monitor (MSVSMON.EXE). It lets you run, debug, and test an application that is running on one device (client machine) from another computer (local development environment) that is running Visual Studio.
Pre-Requisites:
The remote device and the Visual Studio computer must be connected over a network or connected directly through an Ethernet cable. Debugging over the internet is not supported.
function throttle( fn, time ) {
var t = 0;
return function() {
var args = arguments, ctx = this;
clearTimeout(t);
t = setTimeout( function() {
fn.apply( ctx, args );
}, time );
};
@gscattolin
gscattolin / new_gist_file
Created September 10, 2013 18:32
Collection, IEnumerable, GetEnumerator, IEnumerator
// Example adapted from MSDN showing how to use IEnumerable and IEnumerator
public class CollectionTestItem
{
public CollectionTestItem(string Name, double Value)
{
this.Name = Name;
this.Value = Value;
}