Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Sticky Footer , fixed footer, pinned footer

1. through css

    #footer {

   position:fixed;

   left:0px;

   bottom:0px;

   height:30px;

   width:100%;

   background:#999;

}

2. jQuery Easy Pinned Footer

http://johnpatrickgiven.com/jquery/pinned-footer/

Sticky Footer , fixed footer, pinned footer

1. through css

    #footer {

   position:fixed;

   left:0px;

   bottom:0px;

   height:30px;

   width:100%;

   background:#999;

}

2. jQuery Easy Pinned Footer

http://johnpatrickgiven.com/jquery/pinned-footer/

How to write a javascript function will callback parameter

    <script type="text/javascript">

        function doWork(someId, callbackFunction) {

            var func = (typeof callbackFunction == ‘function’) ?

                callbackFunction : new Function(callbackFunction);

            func();

        }

        doWork(1, function () { alert(‘do callback’); });

    </script>

Fibonacci series up to n in Python

>>> def fib(n):
…      a, b = 0, 1
…      while b < n:
…          print b,
…          a, b = b, a+b

>>> fib(50)
1 1 2 3 5 8 13 21 34

Func vs. Action vs. Predicate

The difference between Func and Action is simply whether you want the delegate to return a value (use Func) or doesn’t (use Action).

Func is probably most commonly used in LINQ – for example in projections:

list.Select(x => x.SomeProperty)

or filtering:

list.Where(x => x.SomeValue == someOtherValue)

or key selection:

list.Join(otherList, x => x.FirstKey, y => y.SecondKey, …)

Action is more commonly used for things like List<T>.ForEach: execute the given action for each item in the list. I use this less often than Func, although I do sometimes use the parameterless version for things like Control.BeginInvoke and Dispatcher.BeginInvoke.

Predicate is just a special cased Func<T, bool> really, introduced before all of the Func and most of the Action delegates came along. I suspect that if we’d already had Func and Action in their various guises, Predicate wouldn’t have been introduced… although it does impart a certain meaning to the use of the delegate, whereas Func and Action are used for widely disparate purposes.

Predicate is mostly used in List<T> for methods like FindAll and RemoveAll.

jQuery 2.0 will not support IE 6/7/8 any more

This version leaves behind the older Internet Explorer 6, 7, and 8 browsers. In return it is smaller, faster, and can be used in JavaScript environments where the code needed for old-IE compatibility often causes problems of its own. But don’t worry, the jQuery team still supports the 1.x branch which does run on IE 6/7/8. You can (and should) continue to use jQuery 1.9 (and the upcoming 1.10) on web sites that need to accommodate older browsers.

With the release of jQuery 2.0, there are a few environments where the jQuery team will no longer support use of the 1.x line because 2.x is a far better choice. These are typically non-web-site scenarios where support for older IE isn’t relevant. They include:

  • Google Chrome add-ons
  • Mozilla XUL apps and Firefox extensions
  • Firefox OS apps
  • Chrome OS apps
  • Windows 8 Store (“Modern/Metro UI”) apps
  • BlackBerry 10 WebWorks apps
  • PhoneGap/Cordova apps
  • Apple UIWebView class
  • Microsoft WebBrowser control
  • node.js (combined with jsdom or similar)