Skip to content

Instantly share code, notes, and snippets.

@vkbandi
vkbandi / DomainSearch.cs
Last active September 17, 2015 17:02
A simple C# class for demonstrating the use of whois to check the availability of a domain name - code snippet for coderbuddy.wordpress.com
public class DomainSearch
{
/// <summary>
/// Check whether a given domain name is available or not
/// </summary>
/// <param name="domainName">domain name to be verified</param>
/// <returns></returns>
public static bool IsDomainNameAvailable(string domainName)
{
string whoisData = Whois.Lookup(domainName);
@vkbandi
vkbandi / DomainNameExtract.sql
Created September 16, 2015 19:46
T-SQL Query will retrieve anything that is after the @ symbol, the query can be very useful for retrieving the domain of an email address
SELECT SUBSTRING(T.Email,(CHARINDEX('@',T.Email)+1),LEN(T.Email) - (CHARINDEX('@',T.Email))) as DomainName FROM EmailTable T
public class ConditionalPerformance
{
//If block
public long WithOnlyIf(int myFlag)
{
Stopwatch myTimer = new Stopwatch();
string someString = "";
myTimer.Start();
for (int i = 0; i < 1000000; i++)
{
@vkbandi
vkbandi / Whois.cs
Last active February 23, 2016 19:56
A C#.net class to fetch whois information for a .com domain name
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace DomainTools
{
@vkbandi
vkbandi / Program.cs
Last active September 17, 2015 15:39
A sample code to display the usage of the whois class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DomainTools
{
class Program
{
static void Main(string[] args)
@vkbandi
vkbandi / Tweets.cs
Created September 16, 2015 20:07
C#.net class can be used to update statuses, delete, retweet statuses, obtain information regarding a particular status and any body who retweeted a particular status using status id
using System;
using System.Text;
using System.Collections.Generic;
namespace TwitterAPI
{
public class Tweets
{
#region Class-Level-Declarations
@vkbandi
vkbandi / OauthTwitterInitilizeDemo.cs
Created September 16, 2015 20:13
A sample code to show how to initalize oAuthTwitter instance
oAuthTwitter oauth = new oAuthTwitter();
//Replace the vlues with the one's provided by twitter
oauth.ConsumerKey = "Your-twitter-oauth-consumerkey";
oauth.ConsumerSecret = "Your-twitter-oauth-consumersecret";
//Launches your default browser for requesting //authentication
System.Diagnostics.Process.Start(oauth.AuthorizationLinkGet());
//Copy the pin provided after you authenticating and save to a string
//I am assuming you store it in a string twitterpin
//Now the real authentication takes place
//you will exchange the authtoken and pin for Access token
@vkbandi
vkbandi / OAuthTwitterQueryDemo.cs
Created September 16, 2015 20:15
A simple code to show how to query using the OAuth twitter class
//Replace the term search_keyword with a term you want to search
//rpp=100 in the url means results per page is 100, and lang=en means
//Language is english
string result = oauth.oAuthWebRequest(oAuthTwitter.Method.GET, "http://search.twitter.com/search.json", "q=" + search_keyword + "&rpp=100&lang=en");
@vkbandi
vkbandi / OAuthTwitterProcessResultsDemo.cs
Created September 16, 2015 20:19
A simple C# script for showing how to analyze the results from twitter json - code snippet for coderbuddy.wordpress.com
//The following code is a straight copy from jamiedigi.com
HashTable jsonHash = (Hashtable)JSON.JsonDecode(jsonCode);
ArrayList jsonResults = (ArrayList)jsonHash["results"];
foreach (object objResult in jsonResults)
{
Hashtable jsonResult = (Hashtable)objResult;
System.Diagnostics.Debug.WriteLine("User ID: "
+ jsonResult["from_user_id"].ToString());
System.Diagnostics.Debug.WriteLine("Tweet text: "
+ jsonResult["text"].ToString());
@vkbandi
vkbandi / CheckInternetConnection.cs
Created September 16, 2015 20:22
C# class to check for internet Connection
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace Coderbuddy
{
public class CheckInternetConnection
{