127 hours

Danny Boyle has done it again.This time is based on true story of a mountain climber who gets trapped under a boulder for 5 days.

 


 

I coudn't watch a particular scene either.

Mark 9/10

Never Let Me Go

Great movie , really looking forward to read the novel. Carey Mulligan is amazing.

 

 

Mark 9/10

Notes on MongoDB: The Definitive Guide ( O'Reilly Media September 2010 )

MongoDB The Definitive Guide

Chapter 1 : Introduction

- The basic idea is to replace the concept of a “row” with a more flexible model, the “document.”
- MongoDB was designed from the beginning to scale out. Its document-oriented data model allows it to automatically split up data across multiple servers

Features :
  a) Indexing
  b) stored Javascript
 c) Agreggation
d)Fixed-size collections
e)File storage

Chapter 2 : Gettting Started

• A document is the basic unit of data for MongoDB, roughly equivalent to a row in
a relational database management system (but much more expressive).
• Similarly, a collection can be thought of as the schema-free equivalent of a table.
• A single instance of MongoDB can host multiple independent databases, each of
which can have its own collections and permissions.
• MongoDB comes with a simple but powerful JavaScript shell, which is useful for
the administration of MongoDB instances and data manipulation.
• Every document has a special key, "_id", that is unique across the document’s
collection.


- A document  is an ordered set of keys with associated values.
Concepts on a document :
-  Key/value pairs in documents are ordered
- Values in documents are not just “blobs.”

MongoDB is type-sensitive and case-sensitive.

- The shell is a full-featured JavaScript interpreter, capable of running arbitrary JavaScript
programs and you can even defined JS functions
- The real power of the shell lies in the fact that it is also a stand-alone MongoDB client

Insert :

post = {"title" : "My Blog Post",
"content" : "Here's my blog post.",
"date" : new Date()}

db.blog.insert(post) ( Insert in the collection blog the post object)
db.blog.find() - return all the documents in a collection
Update
update takes (at least) two parameters: the first is the criteria to find which document to update, and the second is the new document.


Detele
db.blog.remove({title : "My Blog Post"})  - remove the document that has the title “My Blog Post”

Help on commands :
A good way of figuring out what a function is doing is to type it without the parentheses.

Basic data types
On the other hand, JSON’s expressive capabilities are limited, because the only types are null, boolean, numeric, string, array, and object.

In a single collection, every document must have a unique value for "_id", which ensures that every document in a collection can be uniquely identified.

Chapter 3 : Creating, Updating, and Deleting Documents

BSON -  Binary JSON ( http://bsonspec.org/ )

Using Modifiers :
1)  $inc

{
   "_id" : ObjectId("4b253b067525f35f94b60a31"),
   "url" : "www.example.com",
   "pageviews" : 52
}


> db.analytics.update({"url" : "www.example.com"},
                                   {"$inc" : {"pageviews" : 1}})
 =>
{
   "_id" : ObjectId("4b253b067525f35f94b60a31"),
   "url" : "www.example.com",
   "pageviews" : 53
}

2) $set
db.users.update({"name" : "joe"},
  {"$set" : {"favorite book" : "green eggs and ham"}})

3) $unset

> db.users.update({"name" : "joe"},
  {"$unset" : {"favorite book" : 1}})

Array modifiers

- $push" adds an element to the end of an array if the specified key already exists and
creates a new array if it does not
- Updates, by default, update only the first document found that matches the criteria. If there are more matching documents, they will remain unchanged. To modify all of the
documents matching the criteria, you can pass true as the fourth parameter to update.
- The same getLastError command that powers safe mode also contains
functionality for checking that operations have been successfully repli-
cated.

Chapter 4 : Querying

1) collection.find() - get all the documents from a collection
2) collection.find({"age" : 27}) - get all the document that have the age 27
3)  collection.find({"age" : 27},{"username" : 1, "email" : 1}) -   get all the documents only the keys username and email
4)  collection.find({"age" : 27},{"username" : 0 , “_id” :0 })  - return all except username and id                   

Query Criteria

comparison operators :
"$lt" : <
"$lte" : <=
"$gt" :  >
"$gte" : >=
Ex :
> start = new Date("04/04/2007")
> db.users.find({"registered" : {"$lt" : start}}) - show all the registered users before 04 04 2007

- "$ne" : which stands for “not equal.”
> db.users.find({"username" : {"$ne" : "joe"}}) - show all users that aren’t called joe

OR Queries  -can be user “$or” or “$in” (  "$nin" is the opposite of “$in” }
db.cinema.find({"seat" : {"$in" : [7, 42, 90]}})

"$not"  is used to negate a statement

If we only want to find keys whose value is null, we can check that the key is null and
exists using the "$exists" conditional:
> db.c.find({"z" : {"$in" : [null], "$exists" : true}})

Regular expressions :
> db.users.find({"name" : /joey?/i}) - Find all the users that are joey ( case insensitive)

Cursors
> while (cursor.hasNext()) {
... obj = cursor.next();
... // execute
... }

Limits, Skips, and Sorts
> db.c.find().limit(3) - return only 3 results
> db.c.find().skip(3) - will skip the first three matching documents and return the rest of the matches
> db.c.find().sort({username : 1, age : -1})   sort the results by "username" ascending and "age" descending

Chapter 5 - Indexing

- MongoDB’s indexes work almost identically to typical relational data-
base indexes
- To create the index, use the ensureIndex method:
Example : if we want to index on the people
> db.people.ensureIndex({"username" : 1})
- If you have more than one key, you need to start thinking about index direction.
> db.status.ensureIndex({user : 1, date : -1}) ( query by user and date to pull up all of a user’s recent statuses )
- Indexes can be created on keys in embedded documents in the same way that they are
created on normal keys.
- Unique indexes guarantee that, for a given key, every document in the collection will
have a unique value.
> db.people.ensureIndex({"username" : 1}, {"unique" : true})
- explain will return information about the indexes used for the query (if any) and stats
about timing and the number of documents scanned.
> db.people.find().explain()

> db.people.ensureIndex({"username" : 1}, {"background" : true})
Building indexes is time-consuming and resource-intensive. Using the {"background" :
true} option builds the index in the background, while handling incoming requests. If
you do not include the background option, the database will block all other requests
while the index is being built.
- you can remove it with the dropIndexes command and the index name.
> db.runCommand({"dropIndexes" : "foo", "index" : "alphabet"})

Geospatial Indexing
A geospatial index can be created using the ensureIndex function, but by passing "2d" as a value instead of 1 or -1:
> db.map.ensureIndex({"gps" : "2d"})
The "gps" key must be some type of pair value, that is, a two-element array or embedded
document with two keys. These would all be valid:
{ "gps" : [ 0, 100 ] }
{ "gps" : { "x" : -30, "y" : 30 } }
{ "gps" : { "latitude" : -180, "longitude" : 180 } }

For example, the following code returns the 10 nearest documents to (40, -73) coordinates:
> db.map.find({"gps" : {"$near" : [40, -73]}}).limit(10)

MongoDB also allows you to find all of the documents within a shape, as well as near
a point.There are two options: you can query for all points within a rectangle or a circle.
To use a rectangle, use the "$box" option:
> db.map.find({"gps" : {"$within" : {"$box" : [[10, 20], [15, 30]]}}})
"$box" takes a two-element array: the first element specifies the coordinates of the
lower-left corner, the second element the upper right.
Also, you can find all points within a circle with "$center", which takes an array with
the center point and then a radius:
> db.map.find({"gps" : {"$within" : {"$center" : [[12, 25], 5]}}})


Chapter 6 - Aggregation

- count
> db.foo.count()

count the number of results for that query:
> db.foo.insert({"x" : 2})
distinct command finds all of the distinct values for a given key. You must specify
a collection and key:
> db.runCommand({"distinct" : "people", "key" : "age"})
group - similar to group by
> db.runCommand({"group" : {
... "ns" : "stocks",
... "key" : "day",
... "initial" : {"time" : 0},
... "$reduce" : function(doc, prev) {
...     if (doc.time > prev.time) {
...         prev.price = doc.price;
...         prev.time = doc.time;
...     }
... }}})

Chapter 7 - Advanced Topics

- getLastError command to check the number of documents af-
fected by an update:

Drop a collection :
db.test.drop() or db.runCommand({"drop" : "test"});

Capped Collections :
- fixed in size
- capped collections automatically age-out the oldest documents as new documents are inserted.
-  Documents cannot be removed or deleted (aside from the automatic age-out described earlier), and updates that would cause documents to move (in general updates that cause documents to grow in size) are disallowed.
- capped collections ideal for use cases like logging
> db.createCollection("my_collection", {capped: true, size: 100000, max: 100});
> db.runCommand({convertToCapped: "test", size: 10000}); - converts a regular collection to a capped

db.my_collection.find().sort({"$natural" : -1})  -  sort in reverse insertion order with a natural sort

GridFS is a mechanism for storing large binary files in MongoDB.
- can store Javascript
-  DBRef is an embedded document, just like any other embedded document in
MongoDB. A DBRef, however, has specific keys that must be present. A simple example
looks like the following:
{"$ref" : collection, "$id" : id_value}

Chapter 8 - Administration
addUser method is useful for more than just adding new users: it can be used to change a user’s password or read-only status. Just call addUser with the username and a new password or read-only setting for the user.

Backup:

> ./mongodump -d test -o backup

Restore from backup
./mongorestore -d foo --drop backup/test/

Chapter 9 - Replication

Master-slave replication is the most general replication mode supported by MongoDB.
This mode is very flexible and can be used for backup, failover, read scaling.

Chapter 10 - Sharding

Sharding is MongoDB’s approach to scaling out. Sharding allows you to add more
machines to handle increasing load and data size without affecting your application.

> db.runCommand({"enablesharding" : "foo"})
Remove a shard
> db.runCommand({"removeshard" : "localhost:10000"});

Chapter 11 Example Applications
- App : Chemical Search Engine in Java
- App : News Aggregator in  PHP
- App : Custom Submission Forms in Ruby
- App : Real-Time Analytics in  Python

 

Filed under  //   mongodb  

http://whaddado.com - Social bookmarking for things to do

Check out the social bookmarking tool for thing to do around : http://whaddado.com

Filed under  //   bookmarking   

CodeIgniter 1.7 Professional Development

 

09052

Chapter 1. Getting Started with CodeIgniter

- overview of the CI framework , the fact that it runs on Php4 & Php5 , is MVC , use Singleton & Active Record as design patterns

- install & easy upgrade to newer versions of CI

- very detailed MVC pattern presentation

- auto loading resources ,code format & naming convensions
- URLs in CI

To  remember :
 -  All Controller & Model class names should start with an uppercase letter, and the rest of the name should be lowercase
 - _remap() — this will be called every time that the controller is called, even if a different function is used
 - assign new name for the controller :      
               $this->load->model('model_name', 'different_name');
          Now you would call your model functions as follows:
          $this->different_name->function_name();

Chapter 2.Learning the Libraries

- overview of the benchmark & Profiler classes , if you have sites with lot of track to see where you can optimize 
- how to use Input and Security class
- basic usage of the Email class and afterwards builds a contact form example using all 3 libraries
- example of upload file using the Uploading class & Image Manipulation class
- overview of Pagination & Session class

To remember : 
 - {elapsed_time} can be put in view so you can see the total time elapsed.
 - {memory_usage} can be put in view so you ca see memory consumption
 - is_image property in the Upload class object to check images agains XSS attacks
 - retrieve both POST/GET data use $this->input->get_post('some_field', TRUE);
- if you want to keep the flash data use $this->session->keep_flashdata('item');

 

Chapter 3.Form Validation and database Interaction


- overview of the Form Validation library & the fact that you can save the validation rules in a config file

- create custom validation rules with callback functions
- Database interaction from simple query to advanced Active Record and also Active record caching
- Forge class for working with database and table manipulation

 

Chapter 4.User Authentication 1

 - create a login/register application from scratch 

 

Chapter 5.User Authentication 2

- first it implements a twitter login using the Twitter OAuth 
  ( consumer secret and cunsumer key are not kept in config file or constants )

- on the second part uses Facebook connect but he he should have guide the developer how to configure the app on Facebook develop app settings and to set xd_receiver.htm not to be redirect on rewrite


Chapter 6.Application Security

 - great chapter regarding the CI security
 Security on - URI  and suggest having  $config['global_xss_filtering'] = TRUE; all the time

                  - strong password policies and give us some password check for not having obvious validation functions using the Form Validation class

                  - advanced password salt that is kept in a CI plugin 
                  - database security (xss & sql injection)
                  - changing the default file structure

 

Chapter 7.Building a Large-Scale Application

-  this chapter is presenting all the  bottleneck of a web app , from database , server or code and possible fixes.
- CI. cache and  query caching
- mem cache example & the advantage of using multiple instances of the server
 

Capter 8.Web Services 

- overview of the popular web services and the support for XML-RPC

- writing a REST server & also the client on the same installation of CI that CRUD blog posts
- for more advance implementation you can check Philip Sturgeon aproach


Capter 9.Extending CodeIgniter

- cover hooks in detail and create a practical example of a site that is being maintained by setting a config variable
- extend the controller class to create a custom admin controller which can also extend on a administration part
- override the CI Session class to use php native sessions
- write a logged user helper and overview the less known helpers

 

Capter 10. Developing and Releasing Code to the Community

- share some ideas and guidelines in case you want to share some code that the community can use  and useful tips of how you can get notoriety

What I would have like to have :
- 2 step views something like http://avnetlabs.com/php/two-step-view-with-codeigniter
- could have mention about Apache Jmeter for testing on a Large-Scale Application
- Backendpro & Modular Extensions - HMVC
- Facebook updated their API , Facebook Graph API but the old API still working 

Mark 8/10

 

CodeIgniter 1.7 professional development available from April 2010

For a long time I was waiting a more advanced Codeigniter book .

Previous books about CodeIgniter  were addres to novice programmers that just started to use  MVC framework and were extending futher bit the User Guide with exemples.

CodeIgniter 1.7 and

CodeIgniter for Rapid PHP Application Development 

CodeIgniter 1.7 professional development  by Adam Griffiths  will feature:

- Authenticate users using Twitter oAuth and Facebook Connect which is adopted by more and more sites these days.
- futher secure your applications using the Security CI offers and more
- Build a RESTful Web Service, opening up your application to third-party developers , which I most excited of , there is a tutorial about this on Phil Sturgeon on Nettus
- extend the functionalities allready build in CI (MY_ )
- scale application and other tips

Best part is that I will receive a copy from Packt Publishing to review it in more details.

 

El secreto de sus ojos (The Secret in Their Eyes)

It deserve the Oscar for foreign best movie.Powerfull movie about love and revange.

Mark : 9/10

The Road

I think the book is better than the movie

Mark:8/10

Alice in Wonderland

Went to see the movie in 3D at cinema...little disappointed. Start to like less an less movies that are more than 80% computer generated.

Mark : 8/10

About

I am a 25 year old web developer from Iasi (Romania) who loves watching movies,reading books, play ping pong with friends and trips.

FriendfeedPicasaFlickrVimeoYoutubeScribd