core error

Archive for September 2011


Many times we need to center align a DIV inside another div. If we know the width of the inner DIV in before hand it is really simple, we can just add the width, margins to 0px and auto and that’s it:

div.inner {
	width:500px;
	margin:0px auto;
}

BUT, things may be more complicated if we don’t know the width of the inner DIV. In this case we need use a different type of display for the DIV (inline-block) and make sure that the outer div text-aligns everything to the center:

div.outer {
	text-align: center;
}
div.inner {
	display: inline-block;
}

The reason to this is that DIVs are by default display: block. This kind of display expands to the entire width except if we specify a fixed width but in this case, margin:0px auto. The inline-block display wraps its size around the its contents and allows to be aligned as text inside a div.

Note: Since IE7 doesn't understand the inline-block property, it will be needed to make a small hack to the inner div class for IE7 to work properly:

div.inner {
	display: inline-block;
	zoom: 1;
	*display: inline; #this will be ignored by all browsers except IE
}
Advertisements

1. Clean Code

This book  is divided into three parts. The first describes the principles, patterns, and practices of writing clean code. The second part consists of several case studies of increasing complexity. Each case study is an exercise in cleaning up code—of transforming a code base that has some problems into one that is sound and efficient. The third part is the payoff: a single chapter containing a list of heuristics and “smells” gathered while creating the case studies. The result is a knowledge base that describes the way we think when we write, read, and clean code.

2. Head First. Design Patterns

This is a gimmicky book that actually works for once. It is an intelligent and well thought-out discussion of Java design patterns, and if you dont know what a design pattern is then this is an excellent way to find out. It is also an interested discussion of object-oriented design. I found that the authors often anticipated my reaction to their initial explanations and asked the questions that I would have asked had it been a lecture.

 

3. High Performance Websites

Want your web site to display more quickly? This book presents 14 specific rules that will cut 25% to 50% off response time when users request a page. Author Steve Souders, in his job as Chief Performance Yahoo!, collected these best practices while optimizing some of the most-visited pages on the Web. Even sites that had already been highly optimized, such as Yahoo! Search and the Yahoo! Front Page, were able to benefit from these surprisingly simple performance guidelines.

 

4. High Performance MySQL

High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. High Performance MySQL teaches you advanced techniques in depth so you can bring out MySQL’s full power. Learn how to design schemas, indexes, queries and advanced MySQL features for maximum performance, and get detailed guidance for tuning your MySQL server, operating system, and hardware to their fullest potential.

5. Succeeding with Agile. Software development using SCRUM

This is the definitive, realistic, actionable guide to starting fast with Scrum and agile–and then succeeding over the long haul. Leading agile consultant and practitioner Mike Cohn presents detailed recommendations, powerful tips, and real-world case studies drawn from his unparalleled experience helping hundreds of software organizations make Scrum and agile work.

 


What

NoSQL is a movement promoting a loosely defined class of non-relational data stores that break with a long history of relational databases. These data stores may not require fixed table schemas, usually avoid join operations and typically scale horizontally.

Why

Since usually the NoSQL data stores scale horizontally quite good, they are a serious choice when handling massive amounts of data. These kind of databases may not have the searching, joining and grouping capabilities a SQL data store may offer but on the other hand they provide really quick access to big amounts of data.

How

some of the most known databases are: BigTable, Cassandra, CouchDB, MongoDB or Membase

This is an example on how to work with MongoDB:

{
    "username" : "bob",
    "address" : {
        "street" : "123 Main Street",
        "city" : "Springfield",
        "state" : "NY"
    }
}

db.users.find({"address.state" : "NY"})

In the first part you can see an example of a ‘document’ (row in the SQL World) to be stored in MongoDB. The second exampleis how you can make a query.


What

!important declared after a CSS directive ensures that directive is applied preferred over other styles for the same locator no matter if the former is preceding the later or not.

Why

if you are combining several CSS files in a webpage you may need to have to define two or more different styles for the same locator. For these cases, by using the rule !important you can ensure that style is applied over other conflicting styles for the same element/s.

How

Here is a simple example to ilustrate how to use this rule:

p { color: #ff0000 !important; }
p { color: #000000; }

In this example all the <p> elements affected by this stylesheet will have a red color for the text inside instead of black.

Node.js

Posted on: 06/09/2011


What

Node.js is a programming framework based in Javascript. Node.js runs in the server side and it is events-driven.

Why

It was created to allow developers to build scalable network events-driven applications such as web servers.

How

Here is a ‘Hello world’ example of a web server in Node.js:

var http = require('http');

http.createServer(function (request, response) {
    response.writeHead(200, {'Content-Type': 'text/plain'});
    response.end('Hello World\n');
}).listen(8000);

console.log('Server running at http://127.0.0.1:8000/');

 

 


Cross Site Scripting is a type of computer security vulnerability in web applications which consists in inserting JavaScript code into the attacked page’s html/js code.

For example:


With this setup and if the site is not well protected we could inject some code really easily:

Any website allowing users to send data which is going to be part of the page itself (forums, blogs, forms, etc.) is a potential victim form XSS. To protect our sites from this technique we should server-sid detect any dangerous input coming from the users and escape it or strip it when displaying our html/javascript code.



  • None
  • Justin Cooney: Great comic, this made me laugh!
  • Justin Cooney: Interesting, I didn't know about the Google App Engine, I'm glad I found your article on it!

Categories