This presentation uses a souped-up version of reveal.js
Go here on your laptop, smartphone or tablet:
There was SQL.
And it was okay.
There was noSQL!
And it scaled and it was all javascripty and all the hipsters loved it and everyone was happy.
var request = http.request({
host: 'couchdb.internet.com',
path: '/awesomedb/_all_docs',
auth: 'zer0c00l:God'
});
request.end();
var newrows = []
request.on('response', function (response) {
response.on('data', function (data) {
data.rows.forEach(function(row){
row.value.walkThe = "dinosaur";
newrows.push(row.value);
});
});
});
request.end();
var request = http.request({
host: 'couchdb.internet.com',
method: 'post'
path: '/awesomedb/_bulk_docs',
auth: 'zer0c00l:God'
});
request.write(JSON.stringify({docs:newrows}));
request.end()
https://github.com/sgentle/unql-node
It's like SQL for NoSQL
> delete from checkins where username.match(/\d{4}$/) && timestamp > (new Date()).getTime()-1000*60*60*24*7
> create collection nag_old_users
> insert into nag_old_users select {username: username, email: email} from user where last_login < (new Date()).getTime()-1000*60*60*24*7
handle /delete from (\S+)(?: where (.*))?/, (db, expr, cb) ->
query = "update #{db} set _deleted = true"
query += " where #{expr}" if expr
processExpr query, cb
So you want to add some persistence to your simple web app.
Okay so just require that each user have a couch installation.
Or make redis a dependency. Probably include some build scripts or something to make it easier since it's the only thing in the app that needs to be compiled.
Maybe it would be easier to build SQLite?
SQL < noSQL < noDB
var users = JSON.parse(fs.readFileSync('data/users.json'))
users.push({name: "newguy"});
fs.writeFileSync('data/users.json', JSON.stringify(users));
res.send('success');
var store = new express.session.MemoryStore;
store.sessions = JSON.parse(fs.readFileSync('data/sessions.json'));
setInterval(function(){
fs.writeFileSync('data/sessions.json', JSON.stringify(store.sessions));
}, 2000);
But they're kind of crappy
On nginx or express or something!
But load balancing and updates and bugs and oh no.
Augh. I wish I could just shove all this right on Akamai
...
...
...
Why not?
Use whatever you want. We really like Jade.
!!! 5
include includes/head.jade
body
include includes/header.jade
// BEGIN Content
.inner-bg
#content-wrapper
Welcome to zombocom!
JADE = $(shell find pages/*.jade)
HTML = $(JADE:.jade=.html)
all: $(HTML)
%.html: %.jade
./jade/bin/jade < $< --path $< > $@
clean:
rm -f $(HTML)
.PHONY: clean
It's cheap. 18c per GB
You don't have to deal directly with Akamai. Keep your soul!
There's a node library for that.
There's also some tooling for that.
https://github.com/PinionTech/cloud-loader
coffee cloud-loader.coffee -x localDir cloudContainer
curl -i -X GET -H "X-Auth-User: pinion" -H "X-Auth-Key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "https://auth.api.rackspacecloud.com/v1.0"
curl -X POST -H "X-Container-Meta-Web-Index: index.html" -H "X-Auth-Token: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" "https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_ad499859-aaed-43c6-813b-5e1c545f85cf/pinion-www
Never ever care about whether your website is up.
Go do something useful instead.
Yeah, it's harder to do pretty URLs.