Skip to content

Instantly share code, notes, and snippets.

@aturgarg
aturgarg / read-xml-via-linq.cs
Created July 29, 2012 08:51
read xml via linq
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml;
namespace linqtoxml
{
class Program
@aturgarg
aturgarg / linq-on-json.cs
Created July 29, 2012 08:50
Linq on Json
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*
* download NewtonSoft josn library from
* http://json.codeplex.com/
* http://www.codeplex.com/json/Release/ProjectReleases.aspx
* */
using Newtonsoft.Json;
@aturgarg
aturgarg / json-from-linq.cs
Created July 29, 2012 08:49
Json from linq
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*
* download NewtonSoft josn library from
* http://json.codeplex.com/
* http://www.codeplex.com/json/Release/ProjectReleases.aspx
* */
using Newtonsoft.Json.Linq;
@aturgarg
aturgarg / bucket-sort-algorithm.cs
Created July 29, 2012 08:48
Bucket sort Algorithm
public virtual int[] BucketSorting(int[] integers)
{
//Verify input
if (integers == null || integers.Length == 0)
{
return null;
}
//Find the maximum and minimum values in the array
int maxValue = integers[0]; //start with first element
@aturgarg
aturgarg / ps-kill-process.sh
Created July 29, 2012 08:46
ps kill process
//find running processes pid
$ ps
//kill process [ kill processid]
$ kill 2065
//OR
$ kill -9 2065
//Where, -9 is special Kill signal, which will kill the process.
@aturgarg
aturgarg / cron-job-in-windows.bat
Created July 29, 2012 08:45
cron job in windows
REM cron job in Windows
REM command is schtasks
schtasks /create /tn "Drupal Cron Job" /tr "C:\PROGRA~1\MOZILL~1\firefox.exe http://www.example.com/cron.php"
@aturgarg
aturgarg / to-check-if-table-exists.sql
Created July 29, 2012 08:43
sql to check if sqlserver DB table exists
IF EXISTS (SELECT 1
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE='BASE TABLE'
AND TABLE_NAME='tablename')
SELECT 'tablename exists.'
ELSE
SELECT 'tablename does not exist.'
--To identify whether a particular table exists in a database, the following query can --be used in the application:
@aturgarg
aturgarg / sqlserver-from-command-prompt.bat
Created July 29, 2012 08:42
SQLserver from command prompt
-- to use sqlCmd ( command line sql tool)
-- open command prompt and execute the "sqlcmd.exe" probably located at
-- "C:\Program Files\Microsoft SQL Server\100\Tools\Binn"
> sqlcmd.exe -U username -P password -S .\sqlServer
This will open sql server in cmd
1> select DB_Name()
@aturgarg
aturgarg / multiple-db-backup.sql
Created July 29, 2012 08:41
Multiple DB backup
DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name
SET @path = 'C:\Backup\'
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)
DECLARE db_cursor CURSOR FOR
@aturgarg
aturgarg / count-tables-views-stored-procedures-and-functions-in-database.sql
Created July 29, 2012 08:40
Count tables, views, stored procedures and functions in Database
--- /* Count Number Of Tables In A Database */
SELECT COUNT(*) AS TABLE_COUNT FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE='BASE TABLE'
--- /* Count Number Of Views In A Database */
SELECT COUNT(*) AS VIEW_COUNT FROM INFORMATION_SCHEMA.VIEWS
--- /* Count Number Of Stored Procedures In A Database */
SELECT COUNT(*) AS PROCEDURE_COUNT FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE'