Tuesday, March 13, 2012

CSS Guidelines

Here is the key points from this open source guidelines, have not got time reading all inline links, but it is really awesome
https://github.com/csswizardry/CSS-Guidelines
  • Use hyphen delimited, lowercase selectors
  • Always use a trailing semi-colon on the last declaration in a rule set
  • Comment as much as you can as often as you can
  • If you have to build a new component, split it into structure and skin
  • Never ever set heights on p, ul, div, anything. You can normally achieve the desired effect with line-heights which are far more flexible
  • You should never apply any styles to a grid item, they are for layout purposes only
  • Shorthand is good, but easily misused, so be explicit
  • Make sure styles aren’t dependent on location where possible, and make sure selectors are nice and short
  • An over-qualified selector is one like div.promo. We could probably get the same effect from just using .promo
  • Be explicit; target the element you want to affect, not its parent
  • Never assume that markup won’t change
  • Do not use IDs in CSS at all
  • It is okay to use !important on helper classes only
  • Every hard-coded measurement you set is a commitment you might not necessarily want to keep
  • IE stylesheets can, by and large, be totally avoided. As a general rule, all layout and box-model rules can and will work without an IE stylesheet if you refactor and rework your CSS
  • The difference between IDs/classes and types/descendants is fairly huge… The difference between themselves is slight
  • The key selector, as discussed, is the right-most part of a larger CSS selector. Key selector is the one which determines just how much work the browser will have to do
  • Overqualified selectors make the browser work harder than it needs to and uses up its time

March stock mania

Here is the list of stock from money.cnn.com/markets/march-stock-mania/?iid=HP_LN

Apple
Zynga
McDonald's
Baidu
Wal-Mart
Sears Holdings
Pfizer
Chesapeake Energy
IBM
Netflix
Bank of America
Disney
Procter & Gamble
Groupon
Verizon
Ford
Exxon Mobil
First Solar
Citigroup
Boeing
General Electric
Green Mountain Coffee Roasters
Coca-cola
Starbucks
Microsoft
Tesla
Amazon
Caterpillar
Google
Alcoa
Intel
General Motors

Thursday, March 8, 2012

Notes from Javascript in 10 mins

  • You won’t run into any trouble if you always end lines with semicolons.
  • Every function returns a value.If you don’t use a return statement, then your function returns undefined
  • Be careful how you define a variable. Always use var keyword
  • Lazy scoping and mutability. The simplest way to fix this is to wrap our assignment in an anonymous
    function that is evaluated immediately, introducing another layer of scope.
  • Never use the == operator unless you really want this behavior, x == null might be an exception
  • Boxed values are always truthy and can store properties. Unboxed values will
    silently fail to store properties 
  • All HTML objects, whether or not they’re somehow native, will be boxed.
  • Throwing things - throw new Error(3)
  • Implied global variables should never be used
  • In JavaScript blocks do not have scope. Only functions have scope. Do not use blocks except as required by the compound statements.  
  • The eval function is the most misused feature of JavaScript. Avoid it.
  • The eval function has aliases. Do not use the Function constructor. Do not pass strings to setTimeout or setInterval.

Wednesday, March 7, 2012

First-class function

In programming languages, first-class object means
  1. can be stored in variables and data structures
  2. can be passed as a parameter to a subroutine
  3. can be returned as the result of a subroutine
  4. can be constructed at run-time
  5. has intrinsic identity (independent of any given name)
In Javascript, first-class function (which is also an object) has below characteristics
  1. passing functions as arguments
  2. returning functions as results
  3. assigning functions to variables     
  4. storing them inside (global) data structures