Skip to content

Instantly share code, notes, and snippets.

View PKRacha001's full-sized avatar

Prashanth Kumar (PK) PKRacha001

  • Boston, MA
View GitHub Profile
@PKRacha001
PKRacha001 / esp-expediapartnersolutions-files-api.cs
Created October 19, 2018 22:19
Code to download expediapartnersolutions ESP Files API.
using System;
using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace EANAPI
{
class Program
{
static void Main(string[] args)
{
@PKRacha001
PKRacha001 / FileLookUpandCopyIntoAnotherFolder.py
Created October 6, 2018 02:20
Search and copies the files to destination directory by looking into another folder.
# Use case was, I had some pictures selected in Google Photos. But, they were of low quality and not good for printing. Hence, needed to find the same pictures in Camera Memory card.
import os
import shutil
# location of low quality images
googlePhotosalbumPath = '/Users/lowQualityImages'
# location of high quality images
originalPath = '/Volumes/MEMORY_CARD/DCIM/'
@PKRacha001
PKRacha001 / ssrs_export_format.cs
Created September 6, 2018 17:08
SSRS_Export_Format
=IIF( Globals!RenderFormat.Name="WORD" OR
Globals!RenderFormat.Name="XML" OR
Globals!RenderFormat.Name="CSV" OR
Globals!RenderFormat.Name="TAB" OR
Globals!RenderFormat.Name="PDF" OR
Globals!RenderFormat.Name="MHTML" OR
Globals!RenderFormat.Name="EXCEL",
Format(Fields!Revenue.Value, "#0.00"),
Format(Fields!Revenue.Value, "$#0.00")
)
@PKRacha001
PKRacha001 / SSIS_Package_Loop_Dates.sql
Created August 30, 2018 17:17
To run an SSIS package changing variable value. Here is an example of looping through last 30 days.
DECLARE @date date = getdate() -30, @cmd varchar(1000)
WHILE (@date < GETDATE())
BEGIN
SET @cmd = 'START DTExec.exe /f "<package>.dtsx" /set \package.variables[User::<variableName>].Value;' + CONVERT(char(10), @date,126);
exec master..xp_cmdshell @cmd
SET @date = DATEADD(day, 1, @date)
END
@PKRacha001
PKRacha001 / timeFromDateTime.sql
Created October 24, 2017 20:23
Avg time from datetime field
SELECT CAST(DateAdd(ms, AVG(CAST(DateDiff( ms, '00:00:00', cast([Date Time] as time)) AS BIGINT)), '00:00:00' ) as Time ) AvgTime
from table
@PKRacha001
PKRacha001 / gisttools.js
Created June 13, 2017 15:25
SSRS_ExpressionforDateTime
Replace(Replace(Replace( Substring((DT_WSTR,50) GETDATE(),1,19),"-",""),":","")," ","_")
@PKRacha001
PKRacha001 / sqlSSRS_Reports_Download.sql
Created February 15, 2017 21:23
SQL code to download all SSRS Reports and Datasources in same structure as in Reporting Services
/*
-- Updated the code from here: http://vinay.inkeysolutions.com/2013/08/ssrs-download-all-rdl-files-from-report.html
-- Allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- Update the currently configured value for advanced options.
RECONFIGURE
GO
@PKRacha001
PKRacha001 / RReadFileandTotalColumn.R
Created February 13, 2017 15:02
R script to read tab csv file and get the sum total of a column
myObj <- read.table("<file>.TAB", sep="\t", fill = T, header=TRUE, quote = "");
sprintf("%d $%f", sum(myObj$IntColumn, na.rm = T), sum(myObj$MoneyColumn, na.rm = T));
@PKRacha001
PKRacha001 / sqlDeleteDuplicateRows.sql
Created February 10, 2017 00:45
SQL Server, delete all duplicate rows expect one in a table without a primary key
WITH cte AS (
SELECT primaryKeyColumn,
row_number() OVER(PARTITION BY DateOrSomeColumn ORDER BY someColumn ASC) AS [rn]
FROM TableName
)
/* To verify the output first, comment the select and uncomment the delete statement to delete the rows */
SELECT * FROM cte WHERE [rn] > 1;
/* uncomment below to delete */
@PKRacha001
PKRacha001 / sqlssrsAllSubscriptionEmails.sql
Created February 10, 2017 00:37
SSRS, SQL Server Reporting Services, All subscriptions Email addresses by Report Name
IF (OBJECT_ID('tempdb..#AllEmails') IS NOT NULL)
DROP TABLE #AllEmails
;
WITH subscriptionXmL
AS ( SELECT SubscriptionID ,
OwnerID ,
Report_OID ,
Locale ,
InactiveFlags ,
ExtensionSettings ,