Skip to content

Instantly share code, notes, and snippets.

@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 / 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;
@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 / ConfluenceClientUtil.cs
Created June 1, 2012 13:55
Confluence (XML-RPC) Client code to access and create new page with permissions
public const string SECTION_OWNER_TEXT = "I AM A PARENT PAGE";
public static IEnumerable<RemotePage> getWeeklyParentPages(this ConfluenceClient client, string token, RemotePageSummary[] pages)
{
var pageContent = pages.Select(p => client.getPage(token, p.id));
var weeklyParentPages = pageContent.Where(p => p.content.Contains(SECTION_OWNER_TEXT));
return weeklyParentPages;
}
@bobbychopra
bobbychopra / notify.cs
Created June 8, 2012 11:57
Notify Property Changed using Expression Tree
private string _filePath;
public string FilePath
{
get { return _filePath; }
set { _filePath = value; NotifyOfPropertyChange(()=> FilePath); }
}
private void NotifyOfPropertyChange<TValue>(Expression<Func<TValue>> propertySelector)
{
@bobbychopra
bobbychopra / DelegateCommand.cs
Created June 8, 2012 12:59
WPF Delegate Command
using System;
using System.Windows.Input;
namespace MyNameSpace
{
/// <summary>
/// DelegateCommand borrowed from
/// http://www.wpftutorial.net/DelegateCommand.html
/// </summary>
public class DelegateCommand : ICommand
@bobbychopra
bobbychopra / App.xaml.cs
Created June 8, 2012 17:42
Log4Net Configuration in WPF
using System.Windows;
using log4net;
namespace Namespace
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{