Skip to content

Instantly share code, notes, and snippets.

@gscattolin
gscattolin / new_gist_file
Created September 10, 2013 18:29
see properties of a table
EXEC sp_help TableName;
@gscattolin
gscattolin / new_gist_file
Created September 10, 2013 18:30
Insert special values (Guid, Time)
use ProjectCode
insert into dbo.BlogPosts values(newid(),'Post1','Content1',CURRENT_TIMESTAMP,'F26D2321-FE49-472D-AE80-0FDECF0BF6BC')
go
insert into prices (group, id, price)
select
7, articleId, 1.50
from article where name like 'ABC%';
@gscattolin
gscattolin / new_gist_file
Created September 10, 2013 18:31
Drop a Table
use DataBaseName
go
EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"
go
@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;
}
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 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.
@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.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.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.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