Skip to content

Instantly share code, notes, and snippets.

@bobbychopra
bobbychopra / mailmergeppt.vba
Created July 12, 2013 20:18
Mail Merge for Powerpoint
Sub MailMergeFromFile()
Dim hf As Integer: hf = FreeFile
Dim lines() As String, i As Long
Open "c:\users.txt" For Input As #hf
lines = Split(Input$(LOF(hf), #hf), vbNewLine)
Close #hf
For i = 0 To UBound(lines)
' MsgBox "Line" & i & "=" & lines(i)
@bobbychopra
bobbychopra / object.sql
Created July 12, 2013 20:10
Find object in SQL Server
SELECT * FROM sys.objects WHERE name like '%tbl%'
@bobbychopra
bobbychopra / DynamicCsvReader.cs
Created April 25, 2013 11:01
Dynamic Reading Simple Csv
using System;
using System.Collections;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.IO;
using System.Threading.Tasks;
namespace TestTPL
{
@bobbychopra
bobbychopra / DateTimeExt.cs
Last active December 16, 2015 13:59
Frequently Used Extension Methods
namespace System
{
public static class DateTimeExt
{
public static DateTime ToUnspecified(this DateTime dt)
{
return DateTime.SpecifyKind(dt, DateTimeKind.Unspecified);
}
}
}
void Main()
{
Console.WriteLine(GetCode("A"));
Console.WriteLine(GetCode("Z"));
Console.WriteLine(GetCode("AA"));
Console.WriteLine(GetCode("AZ"));
Console.WriteLine(GetCode("AAA"));
}
// Define other methods and classes here
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Reflection;
using System.ServiceModel;
using log4net;
namespace Bobby.Chopra
{
static class SomeService
@bobbychopra
bobbychopra / AddColumn.ps1
Created October 9, 2012 21:28
Add Date column to an existing csv file
$today = [System.DateTime]::Today.ToString("yyyyMMdd")
Import-Csv -Header Column1,Column2 -Delim ',' 'C:\sample.csv' |
ForEach {
New-Object psobject -Property @{Date=$today;Col1=$_.Column1; Col2=$_.Column2}
} | Select-Object Date,Col1,Col2 | Export-Csv -NoTypeInformation 'C:\sample.csv'
@bobbychopra
bobbychopra / EnumerableToDataTable.cs
Created October 9, 2012 13:29
Converts a Generic Enumerable to a DataTable
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
namespace ConsoleApplication
{
public static class DataTableUtil
{
@bobbychopra
bobbychopra / filereader.cs
Created July 30, 2012 16:16
File Reader: does not throw process is using file error
// DO THIS
using (var filestream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var reader = new StreamReader(filestream))
{
records = reader.ReadToEnd();
reader.Close();
}
@bobbychopra
bobbychopra / PMUs.json
Created July 13, 2012 22:10
JSON Deserialize
[
{
"pmu":"Capital Markets",
"list":[
{
"fund":"AAA",
"strategy":"US Capital Markets"
},
{
"fund":"BBB",