Search Google Visually

Today I came across an online tool that allows you to see the screenshot of pages in the google search result. You can give it a try at “Veesual.com

Veesual

Veesual Result

While I found the concept to be interesting, I was wondering what could be the use of looking at screenshots of pages in search result. What matters to me is getting a list of relevant search results. A thumbnail of a particular page in search result won’t help me in determining how relevant that page is to my search.

However, I do see one use for getting search results along with thumbnails. It can be used to come up with ideas for designing web-sites for a particular theme. You can search on Veesual using a keyword that describes the theme of your site and then take a quick look at the design of pages in the result. This can help you to come up with your own web-page design.

Do let me know if you can think of some more applications of Veesual.com

Simple equivalent of “With” statement in C#

Consider the following class in C#

	public class Person
	{
		private string name;
		private int age;
		
		public string Name{
			get {return name;}
			set { name = value; }
		}
		
		public int Age{
			get {return age;}
			set { age = value; }
		}
	}

If I want to set the value of Name and Age property on the instance of Person class, I’ll need to refer to that instance for every property I need to set in the code. For example:

var person = new Person();
person.Name = "Super Man";
person.Age = 30;

It would have been great if C# had an equivalent of VB’s “With..End” statement, where we could refer to the instance of Person class only once and then refer to properties only.

Today, I came across this post “mucking about with hashes…“, which shows how C# lambdas could be used as hashes. Using this concept, I implemented a simple extension method that simulates the behavior of VB’s “With..End” statement to some extent.

Here is the code for extension method:

	public static class MetaExtensions
	{	
		public static void Set(this object obj,params Func<string,object>[] hash){
				foreach(Func<string,object> member in hash){
					var propertyName = member.Method.GetParameters()[0].Name;
					var propertyValue = member(string.Empty);
					obj.GetType()
						.GetProperty(propertyName)
							.SetValue(obj,propertyValue,null);
				};
		}
	}

Using this extension method, we can set the value of properties on instance of Person class as follows:

var person = new Person();
person.Set(
	Name => "Super Man",
	Age => 30
);

Isn’t that cool?

Fixing SyntaxHighligher plugin in WordPress Blass2 theme

Yesterday I installed and activated Blass2 theme for this blog. I liked this theme as it was very simple and free from any extra graphics. After installing the theme, I discovered that “SyntaxHighlighter Evolved” plugin which I use to display code segments, was not working. I searched for other themes which are similar to blass2 and can run syntaxhighlighter plugin, but couldn’t find anything better. Finally, this is how I fixed it.

To fix it, I had to edit ‘footer.php’ of Blass2 theme using inbuilt theme editor of WordPress (Appearance > Editor). The original ‘footer.php’ looked like this:

<div id="footer">



 <p>&copy; <?php echo date("Y")?> <!-- Please leave this line intact --><?php if (is_home()) : ?><?php bloginfo('name'); ?> | Theme <a href="http://1000ff.de/wordpress-theme-blass-english-version/">Blass</a> by <a href="http://1000ff.de/">1000ff</a><?php else : ?>Theme Blass by 1000ff<?php endif; ?> | Powered by <a href="http://wordpress.org/">WordPress</a></p>

</div>

To fix the plugin, you need to add a call to ‘wp_footer’ function in ‘footer.php’.

<div id="footer">



 <p>&copy; <?php echo date("Y")?> <!-- Please leave this line intact --><?php if (is_home()) : ?><?php bloginfo('name'); ?> | Theme <a href="http://1000ff.de/wordpress-theme-blass-english-version/">Blass</a> by <a href="http://1000ff.de/">1000ff</a><?php else : ?>Theme Blass by 1000ff<?php endif; ?> | Powered by <a href="http://wordpress.org/">WordPress</a></p>
<?php wp_footer() ?>
</div>

After making this change, syntaxhighlighter plugin started working again.

After file and photo sharing, it’s time for “code sharing”

If we want to share a file or photos while chatting with our friends on internet using IM tools like GTalk, we use file sharing services available online. These services allow us to upload a file to their servers and give us a link which we can share with our friends. But what if you are a developer and want to share a small piece of code with your friend? You are left with following choices:

  • Paste it in your chat: I know most of us do this when we quickly want to share the code. However, its annoying as it becomes unreadable and makes your code look as if its obfuscated :)
  • Email: This approach is better compared to previous approach, however the recipient wil need to manually compile the code and run it if he wants to know the output.

I won’t say these approaches are useless. But I would like to have a place, where I can put my code fragment and then share it using a link. I can use this link in my gtalk status, chat or even in twitter posts.

Luckily, there is a site called “codepad” that allows us to do exactly the same thing. It allows us to share a piece of code using a small url.

You can try it now at “http://codepad.org/” or take a look at this example code posted by me at “http://codepad.org/XZpSNngW

Finally, one thing I would like to see is support for C# code.