Optimized way for Counting total no of record in Portal in Filemaker.

As we know that we generally we use count () function for counting total no of record in related table, but it’s take time when we have large number of data. So there is a function called Get(FoundCount) which calculate total no of record in portal in fastest way.

Put a Field Called Found_Record_Count  in Related table on wich Portal is displayed and make it Unstored Calculation field with Get ( FoundCount ) function and mark calculation result as Number.

What are P, NP, NP-complete, and NP-hard ?

P (Polynomial time decidable problems) is a class of problems which can be decided in polynomial time i.e., there’s an algorithm for such a problem which tells whether the solution of a given instance of a problem is true/false in O(n^k) time for some constant k.
For example, deciding whether there exists a path of at most k links between two vertices u and v is in P.

NP (Non-deterministic polynomial time decidable problems) is a class of problems which have short accepting certificates and efficient verification algorithms i.e., given a certificate of a solution, it is easy to check if the problem is satisfied.
Accepting certificate is information which can be used to decide if the answer is true or false.
Formally, a problem is in NP if there exists a verification algorithm A such that for any input x for which the answer is “true”, there is a certificate c such that |c| is polynomial and A(x,c) = true. For any x for which the answer is true, there is no certificate c such that |c| is polynomial and A(x,c) is true.
For example, given a graph G and a number k, deciding whether there exists a clique (complete subgraph) of size k, is in NP.

P is a subset of NP i.e., any problem that is in P is also in NP. It is easy to see that for any problem that can be decided in polynomial time, there exists a verification algorithm that given any certificate just ignores the certificate and returns the result of the polynomial-time algorithm.

Whether NP is also a subset of P (i.e., P = NP) is an open question. No one knows yet.

NP-hard is a class of problems which are hardest of all problems in NP. These are the problems such that if we can solve them fast, then we can solve all problems in NP fast and P would equal NP. NP-hard problems may be of any type: decision problems, search problems, or optimization problems so they may not even be in NP.
For example, the clique problem discussed above is NP-hard.

NP-complete is a class of problems which are in NP and are NP-hard. NP-complete problems transform to each-other by polynomial-time many-one reductions so if a polynomial-time algorithm exists for any one of them, then polynomial algorithms exist for all of them. However, no polynomial algorithm for any NP-complete problem has yet been found.
For example, the clique problem discussed above is NP-complete.

How to add JavaScript file dynamically from JavaScript on client Side

We can add java script file on client side under head tag by JavaScript dynamically. Below is working code

            var filename = 'http://code.jquery.com/jquery-2.0.0.js';
            var fileref = document.createElement('script');
                fileref.setAttribute("type", "text/javascript");
                fileref.setAttribute("src", filename);
                fileref.setAttribute("ID", "jsScript");
                document.getElementsByTagName("head")[0].appendChild(fileref);

Let’s Understand the above code We have to put script under head tag in below format

<script src="http://code.jquery.com/jquery-2.0.0.js" type="text/javascript"></script>


So for doing this have to define filename = which can be file name and absolute and relative JS file path name.Now we have to create script element which can be done using document.createElement(‘script’) method. And for adding attribute can be used setAttribute method.


Note: Here I have also set ID property fileref.setAttribute(“ID”, “jsScript”); which is optional. It will be helpfull when you want to check whether already page contains script with this ID or not.

Below code is used for check whether already have included Js file if yes then don’t include So It can be used to Check to see if script is present before adding one.

        var jsSelector = document.getElementById("jsScript");

        if (!jsSelector) {

            var filename = 'http://code.jquery.com/jquery-2.0.0.js';
            var fileref = document.createElement('script');
            fileref.setAttribute("type", "text/javascript");
            fileref.setAttribute("src", filename);
            fileref.setAttribute("ID", "jsScript");
            document.getElementsByTagName("head")[0].appendChild(fileref);
        }
 

Page Keyword: How to check js file already loaded or not, add js file dynamically, add java script file by java script

umbraco : How to retrieve drop down value and drop down text in umbraco using c#.

We have some scenario where we want to fetch custom umbraco dropdown list field value and text. For Instance consider situation where you have defined prevalue A, B, C, D in umbraco dropdown list data types and you want to retrieve user selected value from code behind.

See Below Image

CustomDrop-downList

demodropdownlist used in demoDropdown document type as property data type.

documentType

Now In code Behind file we can retrieve user selected value. In content section it look like

content-section

In code behind file we can retrieve user selected value text I mean A, B, C, D or it’s value.

 // Define content node ID in which dropdown data type has been used
 int contentNodeID = 1200;
 Document docDropDown = new Document(contentNodeID);

// Retrive Prevalue of selected value
 int selectedPreVal = Convert.ToInt32(docDropDown.getProperty("dropdownabcd").Value);
 [/sourcecode ]

// Retrive corresponding Text value corrospond to prevalue
 string selectedTextVal = umbraco.library.GetPreValueAsString(selectedPreVal);

Important aspects to consider while designing the website

Knowing Audience(User): Clarifying this early on as it may affect theme, design, content, search engine optimization, usability and networking efforts. In short, everything revolves around target market or audience.

Search Engine Optimization (SEO): It is the process of improving the quality and volume of web traffic to a website by employing a series of proven SEO techniques that help a website achieve a higher ranking with the major search engines when certain keywords and phrases are put in the search field.

Responsive theming: The basic idea behind responsive web design is to avoid having to build unique websites for different devices — such as smartphones, tablets, and desktop browsers. Instead, responsive design allows us to have one site that reflows its layout in response to the size of the screen it’s displayed on.

Honing content/messages: For stronger marketing impact, content should be consistent and touch the hearts and minds of potential customers. By working on content that reach out to viewers but also inspire them to convert into clients.

Engaging in social networking: Social networking sites have won the hearts of not just individuals, but businesses as well. Leveraging website by being seen on the top sites, such as Facebook, Twitter, LinkedIn etc.

Starting a blog on website: Company blogs are partners of websites these days. If websites tell about the product or service, blogs tell about the people behind company and the issues in the industry.

Lightweight Components: Something that many people do not consider is the weight of the website. As computers are most powerful, and the internet is faster, but when we are working with web design, we still have one major goal to make our website as small as possible. The larger our website is, the longer it will take to load, and many people will simple move on if they find that website takes too long to appear.

Typography matters: Understand what audience’s purpose is, like reading, learning, or getting technical advice, hence using the proper typography.

Color Palette: Can be define using brand’s logo, an image, or by finding a color swatch. Every color has its own properties and signs. Proper shades combinations required for grabbing the attention.

Keeping it Coherent: The website should behave in a way that makes sense. It should be logical and consistent. For example if one part of the website uses a pop up menu, then it might be expected that other parts of the website would do the same.

Keeping changes noticeable: When a user makes a change in the program it should be reflected within the website accordingly. For example, when a user is trying to select an item it might be helpful to gray out the other choices and only highlight what they are selecting so that they are confident in what they are picking.

Shortcuts are key: Giving the user a way to complete a task by using a shortcut can be important. Once a user has experience with a program and feels comfortable with the results that they are having its nice for them to be able to get the same task completed, but with a shortcut.

The human eye is drawn to motion: The eye is drawn to movement more than static objects. An animated object is usually going to be noticed quicker than an object that is not moving. Anything that we want to stand out can often be benefited by adding a little movement to it.

The User needs to feel safe: A new user does not want to feel stupid. So, it might be important to make them feel comfortable and keep them from feeling overwhelmed with the program. In this case, we might want to consider having a tip menu or FAQs section.

Help: The user may at some point in time need help, and when they do it is important to understand the type of help that they might need. There can be five basic type of helps:
Goal oriented- what can I do with this program?
Descriptive- What is this?
procedural- How do I do this?
Interpretive- Why did this just happen?
Navigational- Where am I?

Non-Standard Links: Few things needs to be considered regarding links.
Make obvious what’s click able.
Differentiating visited and unvisited links.
Little description can be shown while hovering on link.

Forms: Few things regarding forms:
Cutting questions that are not needed.
Not making fields mandatory which are not required.
Supporting auto fill for fields like Gender, Country etc..
Taking input of phone numbers, credit card numbers etc. in a flexible way.

Parsing Json data from facebook in c#

When we use Facebook social authentication process ( I mean Login by Facebook) after successful authentication from Facebook we get user information in Json format. Now we have situation to how to deserialize json format data. For this purpose we have several option for deserialize json data. Either we can use some third party tool to parse json data or we can use JavaScriptSerializer.

Option Can we have when we think in terms of third party tool:
1)parsing JSon using JSon.net
2)JSON Checker
3)JAYROCK

So How we can achieve Json parsing without ant third party tool:

Json Data which We have to parse:

var responseText = @"{
"id":"100000891948867",
"name":"Nishant Sharma",
"first_name":"Nishant",
"last_name":"Sharma",
"link":"https:\/\/www.facebook.com\/profile.php?id=100000891948867",
"gender":"male",
"email":"nihantanu2010\u0040gmail.com",
"timezone":5.5,
"locale":"en_US",
"verified":true,
"updated_time":"2013-06-10T07:56:39+0000"
}"

So For above json format data you can create Class I have created


public class UserInformation
{
public string id { get; set; }
public string name { get; set; }
public string first_name { get; set; }
public string last_name { get; set; }
public string link { get; set; }
public string gender { get; set; }
public string email { get; set; }
public double timezone { get; set; }
public string locale { get; set; }
public bool verified { get; set; }
public string updated_time { get; set; }
}

User

Now use JavaScriptSerializer

JavaScriptSerializer objJavaScriptSerializer = new JavaScriptSerializer();
UserInformationparsedData = objJavaScriptSerializer.Deserialize(responseText);

It will successfully parse data to UserInformation object.

Umbraco: RSS Feed Burner

Introduction:
MfsFeedBurner project is used to show RSS Feed content of any provider on your portal. This will help to keep your site visitors updated with the latest happenings. For example you can show RSS feed provided by Google/ NDTV (TV Channel)/ Times of India (News Magazines) / etc. into your website. Also you can manage some styling like height/ width/ news title as well as description color etc.

Features:
• Administrator can enter any RSS link of choice
• Can set either latest news header only or news with description.
• Can set auto refresh time for get update
• Count of news feed to be shown can be set
• Can change display style
• Can change height and width of feed container
• Can change background or border color
• Can set background of container as transparent
• Can set header title length
• Can set news header title
• On Mouse Scroll effect

Compatibility:
The MfsFeedBurner module is well compatible with Umbraco 4.9.x. Talking of .net framework it is compatible with .NET 4.0 and above.

Download Here

 

Image

How to read html file in side asp.net application by c#.

 +Summary

In c# We can read data from Html file with help of System.IO.StreamReader(htmlFileNameWithPath).

 +Calling Function
    protected void Page_Load(object sender, EventArgs e)
    {
        string htmlContent = Convert.ToString(ReadHtmlFile(Server.MapPath("~\\HtmlTemplateExample.html")));
    }

Here Server.MapPath(“~\\EmailTemplate.html”)) is used to map exact path of your file which is currently you have attatched in your solution.

 +Code Example 
    /// <summary>
    /// Read Html file 
    /// </summary>
    /// <param name="htmlFileNameWithPath"></param>
    /// <returns></returns>
    public static System.Text.StringBuilder ReadHtmlFile(string htmlFileNameWithPath)
    {
        System.Text.StringBuilder htmlContent = new System.Text.StringBuilder();
        string line;
        try
        {
            using (System.IO.StreamReader htmlReader = new System.IO.StreamReader(htmlFileNameWithPath))
            {

                while ((line = htmlReader.ReadLine()) != null)
                {
                    htmlContent.Append(line);
                }
            }
        }
        catch (Exception objError)
        {
            throw objError;
        }

        return htmlContent;
    }