Skip to content

Instantly share code, notes, and snippets.

View dejanstojanovic's full-sized avatar
🎧
Focusing

Dejan Stojanovic dejanstojanovic

🎧
Focusing
View GitHub Profile
var printMap = function(map) {
map.setOptions({
mapTypeControl: false,
zoomControl: false,
streetViewControl: false,
panControl: false
});
var popUpAndPrint = function() {
dataUrl = [];
public static Type GetClrType(SqlDbType sqlType)
{
switch (sqlType)
{
case SqlDbType.BigInt:
return typeof(long?);
case SqlDbType.Binary:
case SqlDbType.Image:
case SqlDbType.Timestamp:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE MigrateStoredProcedure
@ProcedureName VARCHAR(50),
@TargetDatabase VARCHAR(50)
AS
BEGIN
SELECT * FROM information_schema.parameters
WHERE specific_name='<stored_procedure_name>'
/// <summary>
/// Compares elements of two IEnumerables of same type regardless of element order in both Ienumrables
/// </summary>
/// <typeparam name="T">Type of IEnumerables to compare</typeparam>
/// <param name="Compare">IEnumareble to compare with</param>
/// <param name="CompareTo">IEnumerable to compare to</param>
/// <returns></returns>
public static bool Equals<T>(this IEnumerable<T> Compare, IEnumerable<T> CompareTo)
{
return new HashSet<T>(Compare ?? new List<T>()).SetEquals(CompareTo ?? new List<T>());
@dejanstojanovic
dejanstojanovic / Case insensitive SELECT
Created February 20, 2015 09:40
Perform case insensitive SELECT in Microsoft SQL Server
SELECT * FROM myTable WHERE myField = 'sOmeVal' COLLATE SQL_Latin1_General_CP1_CI_AS
@dejanstojanovic
dejanstojanovic / GetProcedureCode
Created February 18, 2015 15:58
SELECT stored procedure code in Microsoft SQL Server
SELECT ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME='spDateNow'
@dejanstojanovic
dejanstojanovic / ImageSize
Created February 18, 2015 15:06
Fast and short way to get image size in C#
using(var img = Image.FromFile(file.Name))
{
var height = img.Height;
var width = img.Width;
}
@dejanstojanovic
dejanstojanovic / DataAccessLayer
Last active August 29, 2015 14:15
Simple DataAccess layer base class which maps value from database to generic type POCO class instance
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using log4net;
@dejanstojanovic
dejanstojanovic / RandomEnumerable
Created February 6, 2015 18:12
Returning random element of any list of type T
public static class ExtensionMethods
{
public static Random random = new Random();
public static T Random<T>(this IEnumerable<T> list)
{
return list.ToArray().Random();
}
public static T Random<T>(this T[] array)
{