A very interesting set of slides from Christophe Pettus looking at the features in PosgreSQL that would allow one to use it as a document database:
- XML
- built-in type
- can handle very large documents (2GB)
- XPath support
- export functions
- no indexing, except defining custom ones using…
Created by Andreas Mueller:
Then you can head to this Quora thread to read a bit more about the pros and cons of the different classification algorithms.
Original title and link: Machine Learning Cheatsheets (NoSQL database©myNoSQL)
Yeoman is a collection of tools (Yo, Bower, Grunt) to build webapps fast, increasing your productivity.
In other words: type your command, create a piece of your webapp!
Here you can find a list of officially maintained generators that provide you the commands to startup quickly an Angular based webapp, or a Backbone based webapp, and so on.
The interesting aspect of it is the support to create your own code generator. Here i will explain you how to create one, following the creation of YoCrud, a simple code generator to build the essential piece of a Express webapp.
First, set the environment:
1. install yeoman
npm install -g yeoman
2. create a folder and Gruntfile.js (this is needed otherwise yeoman will not find the path of the generator)
mkdir project && cd project
touch Gruntfile.js
3. create generator scaffold
yeoman init generator <generator-name>
this will create a folder lib/generators/ containing the generator files:
- an index.js file (the entry point that contains the constructor of the generator and a set of methods that will be executed in series),
- a folder templates/ containing template files used by generator
4. create a template file in generator template folder (the default template engine is underscore.js)
5. implement your generator, instatiating a template in a method of the generator (index.js). The following example generates a file called app.js in public/ folder
this.template(‘app.js’, path.join(‘public’, ‘app.js’ ),{name:this.name} )
// name is a parameter passed from command line, you can catch other parameters and options
// app.js is the template name
Now you can invoke your generator by command
yeoman init <generator-name> <name>
where name can be the name of the generated app.
Create sub-generators
An other interesting point is that you can create sub-generators, so you can divide the tasks of the generator in several subgenerators that can be invoked singly by typing:
yeoman init <generator-name>:<sub-generator-name> <name>
To assembly sub-generators you have to create them as normal generators, then move them in generator main folder, and update the constructor of main generator (located in lib/generators/yocrud/index.js file) by putting in it the following example code:
this.hookFor(‘yocrud’,{as:’dao’})
this.hookFor(‘yocrud’,{as:’model’})
this.hookFor(‘yocrud’,{as:’route’})
this.hookFor(‘yocrud’,{as:’angular’})
The code snippet above specifies 4 subgenerators, named dao, model, route and angular, that will be executed in series when the generator yocrud wil be invoked.
The generator folder structure is:
lib
generators
yocrud
dao //subgenerator ‘dao’
templates //template folder for subgenerator ‘dao’
index.js // code of subgenerator ‘dao’
model // subgenerator ‘model’
route // subgenerator ‘route’
angular // subgenerator ‘angular’
templates // template folder for yocrud generator
index.js // code of generator ‘yocrud’
So you can invoke all sub-generators by typing `yeoman init yocrud` or you can invoke the single subgenerator dao, for example, by typing `yeoman init yocrud:dao <name>`.
You can find the generator API here.
Package a generator
In a nutshell, you have to publish the generator as npm package and make a little trick to make findable the generator by yeoman after its installation. So
1. initialize package.json file
npm init
2. add to package.json the ‘postinstall’ script. Its purpose is to put the generator in a path known by yeoman (if yeoman doesn’t find the generator it will print to the consolle several paths where it searches the generator). Below there is the piece of package.json of YoCrud the specifies postinstall script:
…
“scripts”: {
“test”: “echo "Error: no test specified" && exit 1”,
“postinstall”:”mkdir -p ../../lib/yeoman/generators/ && mv ../yocrud/lib/generators/yocrud ../../lib/yeoman/generators/yocrud”
}
…
PS: the version of Yeoman used for this article is 0.9.6. Note that if you are using Yeoman 1.0 the command `yeoman init` is replaced by the command `yo`.
Bson sta per Binary Json.
Json, a sua volta, sta per Javascript Object Notation, ed è un formato testuale per rappresentare dati. Sebbene quest’ultimo includa la parola Javascript, è un formato che è indipendente da Javascript, e che è definito nell’rfc 4627.
Dunque Bson definisce un formato binario con cui codificare dati nel formato JSON. A questa si aggiungono anche altre 2 caratteristiche fondamentali:
- scansione veloce: può capitare infatti, nel formato json, di avere degli oggetti complessi, o nidificati, con altri oggetti al proprio interno. Si prenda, per esempio, un oggetto di 500kb; questo potrà contenere un attributo che a sua volta è un altro oggetto, per esempio di 200kb. Durante la scansione degli attributi dell’oggetto complesso, BSON consente di poter evitare la lettura dei dati dell’oggetto da 200KB potendo saltare direttamente al prossimo attributo
- supporto maggiore per i tipi di dati: sebbene BSON sia la codifica binaria di JSON, esso comprende 2 tipi di dati aggiuntivi rispetto a quelli già supportati da JSON (e che sono: String, Number, Boolean, Array, Null, Complex Object): Date, ObjectId, BinData (sostanzialmente un array di byte, utilizzato per codificare dati quali immagini, etc.)
Il formato BSON: dettagli
Di seguito viene specificato il formato nel quale viene codificato un documento JSON, elencando, in ordine con cui compaiono su disco, dei vari campi usati per la codifica
- len: specifica la lunghezza dell’intero BSON document; questo campo è lungo 32 bit
A seguire, per ogni attributo (ovvero per ogni coppia chiave-valore) del documento JSON:
- type: rappresenta il tipo dell’attributo (es. int32), campo lungo 8bit
- chiave: termina con il delimitatore “\0”, la lunghezza dipende da quanto è lunga la chiave, considerando un byte per ogni char
- valore, la lunghezza può variare a seconda del tipo di dato; per esempio se il tipo è int32, questo campo sarà lungo 32bit
Da aggiungere:
- nel caso in cui un attributo sia di tipo stringa, prima del suo valore vi è un campo che specifica la lunghezza della stringa
- per specificare la fine di un documento, viene usato il delimitatore “0”
Riguardo MongoDb
Di seguito alcune note su MongoDB, che utilizza proprio BSON per memorizzare dati su disco:
- nell’esecuzione di una query ad un server MongoDb, i dati giungono in BSON fino al client, sarà poi il client che trasforma questi dati in un formato opportuno, per esempio in oggetti Java nel caso in cui si sta utilizzando la piattaforma Java, etc.
- la codifica BSON favorisce la proprietà schemaless di MongoDb, meglio definita come “dynamic schema”, proprietà che favorisce sia l’uso di dati polimorfici, sia le iterazioni nelle metodologie agili
Questo post è nato da qualche appunto preso durante il corso offerto da 10gen Education per ottenere la certifcazione, rilasciata da 10gen stessa, di Database Administrator.
Per opinion expression si intende una espressione da cui è possibile dedurre l’orientamento dell’opinione presente in una frase, secondo determinate regole.
Tali espressioni sono raggruppate in 6 categorie concettuali:
- opinion word o phrase: da sole implicano una opinion positiva o negativa su delle object feature.
Un esempio di opinion word è “buono” nella frase “il pranzo era buono” - fatti desiderabili o non desiderabili: sono dichiarazioni di fatti, che non usano opinion word, ma che, nel contesto della entità target, implicano una opinione positiva (fatti desiderabili) o negativa (fatti non desiderabili)
- quantità elevate/basse o incrementate/decrementate di potential item: riguarda quei concetti che di per sè non indicano alcuna opinione, ma se quantificati indicano una opinione positiva.
Esempio: “costo”, da solo non indica nessuna opinione, mentre la indica se associato agli aggettivi “basso” (opinione positiva), oppure “alto” (opinione negativa) - quantità incrementate/decrementate di opinionated item: quantificazioni di opinionated item che modificano l’orientamento dell’opinione.
Esempio: “dolore” è una opinion word negativa, ma se espressa come “riduzione del dolore” assume un orientamento positivo - deviazione dalla norma o qualche desiderato range di valori: quando l’orientamento è determinato dall’essere dentro o fuori un range di valori.
Esempio: “questa droga mi fa schizzare la pressione a 200” - produzione o consumo di risorse e sprechi: esempio: “questa doccia consuma molta acqua”
Questa è solo una categorizzazione parziale e non completa, per cui altre categorie possono essere scoperte. Inoltre il loro riconoscimento può variare a seconda del dominio, per cui non è sempre facile riconoscerle.
Few steps!
1. Download node
wget http://nodejs.org/dist/v0.8.16/node-v0.8.16.tar.gz
2. Unzip
tar -xvzf node-v0.8.16.tar.gz
3. Enter directory
cd node-v0.8.16
4. Create the directory for node
mkdir ~/opt
5. Configure
./configure --prefix=~/opt
6. Install node
make && make install
7. Update your PATH variable
PATH=~/opt/bin:$PATH
8. Save PATH variable in your ~/.bashrc
echo 'export PATH=~/opt/bin:${PATH}' >> ~/.bashrc
Una villa nel verde, con sala relax, giardino per le riunioni all’aperto, bonus per chi arriva al lavoro in bici o smette di fumare, massaggio settimanale e una mappa della zona con tips&tricks condivisa su Google: sono alcuni degli strumenti con cui Marco Trombetti, 32enne fondatore di
Fantastico, a lavoro vorrei una location così!



