Skip to content

Instantly share code, notes, and snippets.

@bobbychopra
bobbychopra / DoubleExt.cs
Created February 27, 2014 14:42
Helpful Extension Methods for Double
namespace System
{
public static class DoubleExt
{
public static bool IsZero(this double input)
{
return Math.Abs(0 - input) < Double.Epsilon;
}
public static double Divide(this double numerator, double denominator)
@bobbychopra
bobbychopra / DateTimeExt.cs
Last active August 29, 2015 13:56
Helpful Extension Methods for DateTime
namespace System
{
public static class DateTimeExt
{
public static DateTime ToUnspecified(this DateTime dt)
{
return DateTime.SpecifyKind(dt, DateTimeKind.Unspecified);
}
}
}
@bobbychopra
bobbychopra / StringExt.cs
Created February 27, 2014 14:45
Helpful Extension Methods for Strings
namespace System
{
public static class StringExt
{
public static bool EqualsWithCaseIgnore(this string a, string b)
{
if (a == null && b == null)
return true;
else if (a == null && b != null)
@bobbychopra
bobbychopra / ObjectExt.cs
Created April 23, 2014 15:44
Helpful Extension Methods for any object
using Newtonsoft.Json;
namespace System
{
public static class ObjectExt
{
public static string Dump(this object obj)
{
return JsonConvert.SerializeObject(obj, Formatting.Indented);
@bobbychopra
bobbychopra / naukri-watir.rb
Created March 17, 2012 12:01
Watir script to scrape data from 1st page of Naukri
#!/usr/bin/env ruby
##################################################
## Sample script for friend to pull some info ##
## from the website ... Only did it for 1 page ##
##################################################
require 'rubygems'
require 'safariwatir'
@bobbychopra
bobbychopra / lastpriceupdates.cs
Created April 8, 2012 21:59
Last Price every 1 sec or every 5 entries (rx framework)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reactive;
using System.Reactive.Linq;
using System.Reactive.Concurrency;
namespace LastPriceUpdate
{
@bobbychopra
bobbychopra / message.cs
Created April 8, 2012 23:38
Take Initial Messages until Timeout Received (rx framework)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reactive.Linq;
namespace ScratchApp
{
enum MessageType { Initial, Update }
@bobbychopra
bobbychopra / LFtoCRLF.sh
Created April 12, 2012 14:28
Change files from LF to CRLF
$ find MyDirectoryWithCSharpFiles -regex '.*cs' | while read file; do dos2unix.exe -D $file; done;
@bobbychopra
bobbychopra / EmailUtility.cs
Created June 1, 2012 13:47
Utility to send email, also includes embedded image
using System.Net.Mail;
using System.Net.Mime;
namespace BinaryElephant
{
public static class EmailUtility
{
public static void Send(string to, string subject, string body)
{
SendReport("daemon@bobbychopra.com", to, subject, body, false);
@bobbychopra
bobbychopra / CommandLineOptions.cs
Created June 1, 2012 13:43
Use Plossum CommandLine to parse and verify DateTime
using System;
using Plossum.CommandLine;
namespace ConsoleApp
{
[CommandLineManager(ApplicationName = "ProgramName", Copyright = "Copyright (c) Bobby Chopra")]
internal class CommandLineOptions
{
private string _date;