Thursday, March 28, 2013

How to create Enumerations in C#? [keyword: enum].


Enumeration are basically symbols that have fixed values. It is generally used in situations where we have to provide user with various fixed, per-defined choices or options. Let us consider an example of directions.

enum Directions{North, South, East, West};// syntax to declare an enum.

//Now creating an instance of Directions.
Directions D = Directions.East;
Console.WriteLine("{0}.", D); // Displays "East"

Thus the output is symbol itself rather than its value!

Given below is an example of a code implementing enum on a structure.
using System;
using System.Collections.Generic;
using System.Text;

namespace Enumerations
{
    class Program
    {

        static void Main(string[] args)
        {
            Employee E = new Employee("Shantanu", "Shirpure", 666,Employee.Genders.Male);
            Console.WriteLine(E.ToString());
            Console.ReadLine();
// if you dont use this command the console would compile and close immediately, and you wont be able to see the result.

        }

        struct Employee
        {
            public string firstName;
            public string lastName;
            public int id;
            public Genders gender;
            public Employee(string firstName, string lastName, int id, Genders gender) // this is a constructor.
            {

               //   firstName = firstName;
                this.firstName = firstName;
               // Here string firstName of struct Employee has scope
               //all through the methods hence to distinguish from parameters invoke this method.

                this.lastName = lastName;
                this.id = id;
               this.gender = gender;
            }


            public override string ToString() // this is a method.
            //override is a key word used to duplicate the systems method ToString with our own method
            //this is called as polymorphism
            {

                return firstName + " " + lastName + " (" + gender + "), ID " + id;

            }
           public enum Genders : int { Male, Female };
        }
    }
}


Conclusion:-

Enums therefore improve the code readability by providing symbols for set of values.

Modernizr


Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser. Modernizr makes it easy for you to write conditional JavaScript and CSS to handle each situation, whether a browser supports a feature or not.Taking advantage of cool new web technologies is great fun, until you have to support browsers that lag behind.It’s perfect for doing progressive enhancement easily.
Modernizr runs quickly on page load to detect features; it then creates a JavaScript object with the results, and adds classes to the html element for you to key your CSS on. Here is a nice article on Taking Advantage of HTML5 and CSS3 with Modernizr.

Please keep in mind, that Modernizr doesn’t actually magically enable these properties for browsers that don’t support them. It just tells the page whether that feature is supported on the browser the visitor is using or not.
You can download this javascript library from here.
To implement modernizr,
First step: include the library

script src="js/modernizr-1.0.min.js"
Second Step: include on your html tag a class of "no-js" (Not mandatory)
html class="no-js">
class="no-js"
NOTE:-
If You try to use such a class while havin a HTML or XHTML Doctype it won’t validate. But if You use the HMTL5 Doctype declaration there is issue on that. Intrestingly, If you have a look into the HTML5 specification You will find that the class attribute is allowed on the html element.


We have to add this tag because that will be the default state of the page. If JavaScript (js) isn’t on, then Modernizr won’t work at all so it’s good that we have a fallback for that case.

If JavaScript is indeed enabled, once that page is loaded on the browser, that class will be replaced dynamically and it may look something like this:rgba hsla no-multiplebgs borderimage (You  can find these classes in the html tag by checking the source code)

What does this mean?
For Firefox 3.5., this browser (sadly) doesn’t support multiple backgrounds, CSS gradients or CSS transforms, therefore,
Modernizr outputs:
"no-multipebgs", "no-cssgradients" and "no-csstransforms". On the other hand, it does support canvas and border-radius, which explains "canvas" and "borderradius". Etc.
Using Modernizr, your CSS will look instead like this:
#nice {
background: url(bg-1.png) top left repeat-x;
}
.multiplebgs #nice {
background: url(bg-1.png) top left repeat-x,
url(bg-2.png) bottom left repeat-x;
}

We can also detect features using Modernizr in your JavaScript, using this syntax:

if (Modernizr.geolocation) {
// code using geolocation api goes here.
}
else
{
// fallback strategy comes here.
}

We can’t rely on the fact that browsers support the full spectrum of features we want to use, this is the best tool out there to provide for both worlds.
Modernizr is good but not always needed. The simple multiple backgrounds effect in this post above for example can be achieved without it. In one css rule you can declare the widely supported CSS2.1 single image background style, then directly afterward declare the advanced CSS3 rule with multiple images.
Like this:

#nice {
background: url(bg-1.png) top left repeat-x;
background: url(bg-1.png) top left repeat-x,
url(bg-2.png) bottom left repeat-x;
}

Older browsers will not understand the second statement and so ignore it, CSS3 supporting browsers will use the cascade and apply the second rule. Your page is progressively enhanced and no js is required.
There are still some features which go undetected with modernizr. For that please refer this.

Monday, March 25, 2013

Funny today money tomorrow


There is a sudden rise in number of patents applied. Here is a list of hilarious yet interesting patents:-
1.Shoe phone case/ holder
2.Airbag for phone.(By Amazon founder Jeff Bezos)
3.Vibrating tatoo notification.(Nokia)
4.Banana phone protector.
5.Rotatable keyboard.(Blackberry)
6.Air Expelling keyboard.(Apple)
7.Sliding modular bay for phones (Microsoft).
(Source )
As you might have noticed a few big guns who have patented utterly  vague ideas, so if tomorrow while brushing your teeth if you get an idea on squeezing toothpaste back into the tube dont forget to patent it. Or wait may be its already patented.

Intellectual property rights or IPR is now an issue which can have serious ramifications. It is still a debate if IPR hinders innovation or rewards the inventor.
For decades, the Patent's Trademark Office (PTO) was generally reluctant to issue patents that covered software. But in the mid-1990s, the Federal Circuit (the court that hears patent appeals) first held that an algorithm implemented in a general-purpose computer could be patentable.

This opened the floodgates for software patents. The PTO now issues about 40,000 software patents a year. That's more than 100 per day. Unfortunately, the quality of these patents has tended to be very low. On average, examiners spend only 18 hours reviewing each patent application. This is not nearly enough time to properly check if the invention is new. To make things worse, the claims in software patents (this is the language that is supposed to mark the boundaries of the invention) are often vague and overbroad—giving unscrupulous patent owners the ability to claim that their patent covers a wide range of technology.

This loopholes in patents are breeding grounds for patent trolls. Patent trolls are the firms which instead of inventing something buy patents and earn from litigation suites  on those who seem to have infringed their IPR. These litigations can cost a fortune, patent trolls target small time startups and individuals who are less likely to fight back. These patent trolls then ask for out of court settlements which can also cost in millions of USD. For more on this read .(Source).

Now your funny patent ideas earn you fortune or costs you one depends on how genuine it is.

Saturday, March 23, 2013

Monetize the Content

In India with e-commerce still being a new kid on the block, its growing and so fast that we surely cannot ignore. The websites are getting added every day and the Indian giants like flipkart have lost there monopoly. (Though flipkarts profits are soaring everyday.) But soon there will be many other websites with same quality and exciting prices. Thus to maintain its position a good website must have a good content which forces the users to open up there wallets. A good design and a freshlook helps to keep the user glooed to the platform. Flipkart currently sells 20 products per minute (ref wiki).  Thus its the rise of the content and thus the responsibilities of content writers to sell their products.
Quote:

Traditional content outlets, including magazines and newspapers, will find their way onto social media including Facebook, Youtube and Pinterest and build meaningful businesses within other companies’ platforms rather than just relying on their own digital destinations.
Editorial staff, from editors to reporters, will start out-shining their respective publication brands and will rise as tastemakers. As brands themselves, they will have the ability to generate revenue beyond their content generation.

Commerce will become embedded within content to such a degree that commerce will be seen as content.  Fab.com and BureauofTrade.com are precursors of this seamless merge of content and commerce.
It’s unquestionably an exciting, albeit uncertain, time for those in the content business.
Source.: 

Wednesday, August 3, 2011

War 2.0


With the advent of web 2.0 the internet saw a massive growth of a new dimension SOCIAL MEDIA. Socializing is something that people used to do on the Web; gradually it is becoming the Web. This is an Era of Social Networks, Facebook has suddenly emerged as new yet solo commanding lead but our old dear Google hasn’t really started fighting yet. Now, the stage is set for us to witness the most gruesome and yet epic battle of our times. A few miles the Googleplex in Palo Alto, both in California, Facebook is fiercely brooding over to prepare for the upcoming Google Goliath (Google+). Here, too, Google isn’t sitting still, and we already know that. Improved search as a part of the rationale for the +1 feature, which allows users to elevate their favourite search results in queries from their friends. Well Google’s not done here and this +1 is just an acorn. The war on Facebook is just in beta condition.

The clash between the two titans has gone ugly as it was reviled that Facebook had hired public relations agency to muck Google’s social networking tactics. This it’s evident that, like the tussles between Windows vs. UNIX, CISC vs. RISC and mainframes vs. Micros this new battle between Google & Facebook will sculpt the web industry for coming years. What Google and Facebook have in addition to the old media of web 2.0 is the data about every user which they mine with a plethora of advance technology, software and math to appropriate money out of users efficaciously. The work-model for Google and Facebook is identical: Free services and Charges for advertising. And like any other industry more the popularity more money you can charge for ad space. That is why Google and Facebook are striving to become de facto home for web users. Both target with ads, the users, by the information they have about you, to give very specific and precise results but at the same time haunt you relentlessly bordering onto your privacy.

Google in this war, to capture ad space, has a clear edge, for its wide presence and wide popularity. It also monitors its users not only through search engine queries but also through chrome browser and android apps. Facebook on the other hand can monitor people’s choice (rather taste) only through its own website (Perhaps an explanation for Mark Zuckerberg’s desire to incept scary notions about privacy).

Facebook on the other hand has two lethal arrows in its quiver; namely, crowdsourcing and games. Though Google has immensely powerful data centres, they at times give distorted results thus the idea, of Facebook, that your friends and relations can guide (crowdsource) you to more suitable, relative and better answers, is a challenge for Google. Facebook has also made elegant use of games to keep people within its domain. Just Zynga’s Farmville and Cityville account for 250 million and 140 million people who play social games every month.

Thus the mainstay of this industry so far is data mining and as said more is always the merrier. But with more, arise the engineering problems. The capacities of data centres are exhaustive. The processing power demands are ever increasing. The social web ahead will be highly interactive; we now stay connected with it via our portables. Tomorrow like GPS in our cell phones ‘the network’ will monitor our exact coordinates and will send us feeds to our queries extremely precise to our location ambience and even conveyance. The Crowdsourcing will be so effective and so very well disguised in social gamming that it will cope with the need for more parallel processing and also eliminate the need for outsourcing. Well though future, it is quite evident and will also have surprising cultural consequences and the fundamental human need for companionship will be redefined. Social networking is freedom and not bonding, but this statement is only true when the divulgence of personal opinion and information is judicious.

Tuesday, June 7, 2011

The Linker Blog

This blog as it may appear is actually my personal linker. In this blog i intend to link the visitor to all my other blogs and as well the other facets of my web existence. It links all my social pages like my facebook , twitter etc. accounts my other blogs my articles and all my online updates to this page address.More or less this is like any social network page but i find it better as i have much more freedom to customize it as i muse.
This is an experimental page by me, to narrow down the search engines to one page that holds all the other pages on the internet about me. So you can surf around and find anything about me and my blogs right here and stay connected.

Shantanu Shirpure