Skip to content

Instantly share code, notes, and snippets.

Amit Choudhary vendettamit

Block or report user

Report or block vendettamit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@vendettamit
vendettamit / GetProcResultInTable.sql
Last active Jun 13, 2019
Get any procedure result in temp table without using OPENROWSET or OPENQUERY
View GetProcResultInTable.sql
create table #d
(is_hidden bit NULL, column_ordinal int NULL, name sysname NULL, is_nullable bit NULL, system_type_id int NULL, system_type_name nvarchar(256) NULL,
max_length smallint NULL, precision tinyint NULL, scale tinyint NULL, collation_name sysname NULL, user_type_id int NULL, user_type_database sysname NULL,
user_type_schema sysname NULL,user_type_name sysname NULL,assembly_qualified_type_name nvarchar(4000),xml_collection_id int NULL,xml_collection_database sysname NULL,
xml_collection_schema sysname NULL,xml_collection_name sysname NULL,is_xml_document bit NULL,is_case_sensitive bit NULL,is_fixed_length_clr_type bit NULL,
source_server sysname NULL,source_database sysname NULL,source_schema sysname NULL,source_table sysname NULL,source_column sysname NULL,is_identity_column bit NULL,
is_part_of_unique_key bit NULL,is_updateable bit NULL,is_computed_column bit NULL,is_sparse_column_set bit NULL,ordinal_in_order_by_list smallint NULL,
order_by_list_length smallint NULL,order_by_is_desce
View Incoming_Message_logger.cs
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization.Json;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.Text;
using System.Threading;
@vendettamit
vendettamit / SqlfunctionSplitIndexed.Sql
Created Jan 3, 2019
Split string with Index number
View SqlfunctionSplitIndexed.Sql
CREATE FUNCTION [dbo].[fnSplitIndexed](
@sInputList VARCHAR(8000) -- List of delimited items
, @sDelimiter VARCHAR(8000) = ',' -- delimiter that separates items
) RETURNS @List TABLE (idx integer, item VARCHAR(8000))
BEGIN
DECLARE @sItem VARCHAR(8000)
Declare @idx integer = 0
WHILE CHARINDEX(@sDelimiter,@sInputList,0) <> 0
@vendettamit
vendettamit / tablemanipulator.js
Created Jul 29, 2013
Remove rowspan/colspan and split the cells with duplicate values
View tablemanipulator.js
var tempTable = $('#tbl').clone(true);
var tableBody = $(tempTable).children();
$(tableBody).children().each(function(index , item){
var currentRow = item;
$(currentRow).children().each(function(index1, item1){
if($(item1).attr("rowspan"))
{
// copy the cell
var item2 = $(item1).clone(true);
// Remove rowspan
View GenericUnitOfWork_Sample.cs
public interface IUnitOfWork<TContext> where TContext: DbContext, new()
{
void Commit();
}
public interface IDbFactory<TContext> : IDisposable where TContext: DbContext, new()
{
TContext Init();
}
@vendettamit
vendettamit / DynamicLinqCSharp.cs
Created Feb 19, 2016
A dynamic linq class library source code. Download the original content from here - http://www.scottgu.com/blogposts/dynquery/dynamiclinqcsharp.zip
View DynamicLinqCSharp.cs
//Copyright (C) Microsoft Corporation. All rights reserved.
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
View InMemoryNunitTestRunner
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@vendettamit
vendettamit / ReferenceFinder.cs
Created Oct 7, 2015
This is a sample code that can be used to find references using Roslyn version Microsoft.CodeAnalysis 1.0.0
View ReferenceFinder.cs
class ReferenceFinder
{
public void Find(string methodName)
{
string solutionPath = @"C:\Users\achoudhary\Documents\Visual Studio 2013\Projects\ConsoleForEverything\ConsoleForEverything.sln";
var msWorkspace = MSBuildWorkspace.Create();
List<ReferencedSymbol> referencesToMethod = new List<ReferencedSymbol>();
Console.WriteLine("Searching for method \"{0}\" reference in solution {1} ", methodName, Path.GetFileName(solutionPath));
@vendettamit
vendettamit / min_max.cs
Created Aug 15, 2017
Get minimum or maximum of two number without using conditional statement. Max(a,b) MIN(a,b) implementation in CSharp/C#
View min_max.cs
int max(int a, int b)
{
/* max(a,b) = 1/2(a + b + |a-b|) */
Func<int, int> modValue = x => (int)Math.Sqrt(Math.Pow(x, 2));
return (int)Math.Ceiling((double)(a + b)/2 + ((double)modValue(a - b))/2);
}
int min(int a, int b)
{
View ApplicationLoderFromNTService.cs
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
namespace Shared.ApplicationLoaderUtil
{
/// <summary>
You can’t perform that action at this time.