Skip to content

Instantly share code, notes, and snippets.

View theShiva's full-sized avatar
🎯
Focusing

Shiva Kumar theShiva

🎯
Focusing
View GitHub Profile
@theShiva
theShiva / generate_dto.sql
Created November 19, 2017 05:36 — forked from evgeny-myasishchev/generate_dto.sql
TSQL script to generate POCO/DTO from database table
DECLARE @tableName NVARCHAR(MAX), @schemaName NVARCHAR(MAX), @className NVARCHAR(MAX)
--------------- Input arguments ---------------
SET @tableName = 'Incidents'
SET @schemaName = 'dbo'
SET @className = 'IncidentDto'
--------------- Input arguments end -----------
DECLARE tableColumns CURSOR LOCAL FOR
SELECT cols.name, cols.system_type_id, cols.is_nullable FROM sys.columns cols
@theShiva
theShiva / bootstrap-infiniteScroll.js
Created April 13, 2016 17:22 — forked from andrewburgess/bootstrap-infiniteScroll.js
Twitter Bootstrap plugin that enables infinite scrolling
/* ============================================
* bootstrap-infiniteScroll.js
* ============================================ */
!function ($) {
'use strict';
var InfiniteScroll = function (el, options) {
this.$element = $(el);
this.$data = $(el).data();
this.$options = options;
/// <summary>
/// Serializes an object.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="serializableObject"></param>
/// <param name="fileName"></param>
public void SerializeObject<T>(T serializableObject, string fileName)
{
if (serializableObject == null) { return; }
// Source: http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
[XmlRoot("dictionary")]
public class SerializableDictionary<TKey, TValue>
: Dictionary<TKey, TValue>, IXmlSerializable
@theShiva
theShiva / C# Dictionary To Object Mapper Using Generic Extension Methods
Created November 20, 2013 18:47
C# Dictionary To Object Mapper Using Generic Extension Methods:
// Source: http://stackoverflow.com/a/4944547/325521
public static class ObjectExtensions
{
public static T ToObject<T>(this IDictionary<string, object> source)
where T : class, new()
{
T someObject = new T();
Type someObjectType = someObject.GetType();
@theShiva
theShiva / Software Application Architecture Resources
Created November 20, 2013 17:52
Software Application Architecture Resources: List of Resource for Application Architecture. Includes SOA, Microsoft's Application Architecture and more!
MSDN: Service Oriented Architecture (SOA): http://msdn.microsoft.com/en-us/library/bb833022.aspx
Microsoft Application Architecture Guide: http://msdn.microsoft.com/en-us/library/ff650706.aspx
@theShiva
theShiva / Motivational Posts:
Created November 20, 2013 17:13
Motivational Posts: Posts from Instagram, Wordpress and around the Internets for staying Motivated to work on your Pet Projects.
Devote Yourself To Your Idea: http://sallysbakingaddiction.com/wp-content/uploads/2013/11/3dd80d241a162a94b311378f2bebf477.jpg
@theShiva
theShiva / REST API Design and Development Resources
Last active December 28, 2015 21:49
List of useful resources for designing and implementing REST-ful APIs. General Technology-independent resources are listed first, followed by C# / ASP.Net Web API specific resources for accomplishing specific tasks within REST API Development.
REST Design
===========
Richardson Maturity Model: Steps toward the glory of REST http://martinfowler.com/articles/richardsonMaturityModel.html
PowerShell
==========
Invoke REST Endpoint: Invoke-RestMethod: http://technet.microsoft.com/en-us/library/hh849971(v=wps.620).aspx
ASP.Net MVC Web API
===================
@theShiva
theShiva / Regex Find and Replace First X Characters In Every Line
Created November 20, 2013 17:05
Regex Find and Replace First X Characters In Every Line: See expression in the gist. ^ is for beginning of line, and . is for 1 character.
To replace the first 4 characters in every line, use the find Expression below.
^.{4}
If the Editor does not honor the {3} i.e. the Regex find fails, use actual number of . like the following
^....
Leave Replace Expression Blank
@theShiva
theShiva / sql-find-all-columns-with-string.sql
Created October 2, 2012 17:44
Search All Column Names In Sql Server Tables For A String / Pattern
use Northwind
go
-- SQL run against Northwind sample database to find all tables
-- that have CustomerID in their column / field names.
-- replace CustomerID in between % % with whatever it is you are searching for
select distinct tab.name + '.' + col.name as 'Table.ColumnName'
from sys.tables tab