Wednesday, August 5, 2009

Random learnings 2009-Aug-05

VIM split the screen:
:split
:vsplit

To determine the type of a Javascript object at runtime, use typeof(o)

I changed the DATE_FORMAT and TIME_FORMAT properties of the DjangoJSONEncoder in code.

In Python class attributes are declared in the class definition, wheres instance attributes are declared in the init method.

Friday, April 3, 2009

XML Prologue

An XML prologue is the part that appears before an XML document. The XML prologue is optional in XML documents. If present it could contain a declaration (version, and encoding), processing instructions, and the doctype.

The prologue must not have any blank lines or anything else before it.

For details: http://lachy.id.au/log/2006/09/xml-prolog

Saturday, March 21, 2009

Cascading Style Sheets

Learning about CSS Selectors in the CSS online tutorial

Selectors select (identify) HTML elements and apply a style to it. There are many selectors but the most important (common) ones are:

Type (Element) Selectors:
These selectors identify HTML based on the HTML type, such as body, p, h, etc. The CSS rule for a type is defined the the css file with the name of the type:

h1 {
background-color:black;
}

This rule will apply the defined style (background color is black) to all H1 heading elements.

Class Selectors:
These selectors identify HTML elements based on the class they belong to. The CSS rule for a class is defined in the css file with a .classname

.javacode {
font-size: 10pt;
}

This rule will be applied to all elements which have the class defined as javacode:


String s = new String("Hello World");


Id Selectors:
Id selectors select HTML elements based on the id of that element. An Id selector is defined in the css file as #idname

#prettyprint {
font-color: red;
}

This rule will be applied to all elements that have their id set to prettyprint


def s = 'hello'


One question that comes to mind is what happens if I have a rule defined for the class javacode and the id prettyprint, and I have an HTML element whose class is javacode and id is prettyprint. Which rule will take precedence?

I have asked this question as a comment on the blog post.

Sunday, March 15, 2009

Cascading style sheets

There are four levels at which stylesheets rules are defined - from the highest to the lowest priority:
  • Inline definitions
  • Embedded style sheets
  • External style sheets
  • Browser defaults

Tuesday, March 10, 2009

CVS Root file

If a project is under CVS control, every directory in the project will have a CVS folder which contains 3 files:
  • Entries
  • Repository
  • Root
The 'Entries' file contains an entry for every directory under the current directory which is under CVS control

The 'Repository' file contains details of the repository path

The 'Root' file contains details for CVSROOT.
:pserver:<user_name>:<password>@:<cvs_path>
The password is optional and ideally should not be used. However, it can be put in here if needed. </cvs_path></password></user_name>

Wednesday, September 24, 2008

equals and hashCode

Whenever we override the equals() method in any class, we must also override the hashCode() method.

if(o1.equals(o2))

then

o1.hashCode() == o2.hashCode()
must also be true.

For more details - http://www.ibm.com/developerworks/java/library/j-jtp05273.html

Creating Booleans

FindBugs suggests that we should not instntiate Boolean objects like this

Boolean b = new Boolean(false);

instead we must use the creational method

Boolean b = Boolean.valueOf(false);

This is better for performance, since the Boolean object caches 2 immutable Booelan objects for true and false values.