diff --git a/fixed.html b/fixed.html new file mode 100644 index 0000000..8e182df --- /dev/null +++ b/fixed.html @@ -0,0 +1,455 @@ + + + + + + + There I Fixed It + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+
+

There I Fixed It

+

Dumb hacks that end up being great

+ +
+ +
+

Heads Up

+

+ This presentation uses a souped-up version of reveal.js +

+

+ Go here on your laptop, smartphone or tablet: +

+ +

http://www.pinion.gg/sydjs/index.html

+

http://bit.ly/Nlf8Aw

+
+ +
+
+

Who the hell are you?

+ + + +
+
+

What the hell is this?

+ +
+
+ +
+
+ + +
+
+

In the beginning.

+

+ There was SQL. +

+

+ And it was okay. +

+
+
+

And then...

+

There was noSQL!

+

And it scaled and it was all javascripty and all the hipsters loved it and everyone was happy. +

+
+

But then you want to actually use it

+
+
+

+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()
+
+
+
+ +
+
+

unql-node

+

+ + https://github.com/sgentle/unql-node + +

+

It's like SQL for NoSQL

+ +
+
+

Deletin' stuff

+

+> delete from checkins where username.match(/\d{4}$/) && timestamp > (new Date()).getTime()-1000*60*60*24*7
+						
+
+
+

Why don't we take all the data...

+

+> 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
+						
+

And put it over here!

+
+
+

Want to see my awesome LALR recursive descent parser?

+ +
+
+

Nope!

+

+handle /delete from (\S+)(?: where (.*))?/, (db, expr, cb) ->
+  query = "update #{db} set _deleted = true"
+  query += " where #{expr}" if expr
+  processExpr query, cb
+						
+
+
+

There I fixed it.

+ +
+
+ +
+
+

noDB

+

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?

+
+
+

Nope!

+ +
+
+

noDB

+

SQL < noSQL < noDB

+
+
+

Super simple

+

+var users = JSON.parse(fs.readFileSync('data/users.json'))
+
+users.push({name: "newguy"});
+fs.writeFileSync('data/users.json', JSON.stringify(users));
+res.send('success');
+						
+
+
+

Session storage too!

+

+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);
+						
+
+
+

It's basically Redis

+ It's not really +
+
+

But it is:

+
    +
  • Deployable
  • +
  • Dependency free
  • +
  • Easily backed up
  • +
  • Debuggable
  • +
+
+
+

Databases: Fixed

+ +
+
+ +
+
+

I would like to make some information available on the internet.

+
+
+

So find a shared hosting provider or something.

+

But they're kind of crappy

+
+
+

So I'll just run my own

+

On nginx or express or something!

+

But load balancing and updates and bugs and oh no.

+
+
+

Oh I know!

+ +
+
+ +
+
+
+ Augh. I wish I could just shove all this right on Akamai +
+
+
+

...

+
+
+

...

+
+
+

...

+
+
+

Why not?

+
+
+

Step 0: Generate static site

+

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!
+						
+
+
+

make

+

+JADE = $(shell find pages/*.jade)
+HTML = $(JADE:.jade=.html)
+
+all: $(HTML)
+
+%.html: %.jade
+      ./jade/bin/jade < $< --path $< > $@
+
+clean:
+      rm -f $(HTML)
+
+.PHONY: clean
+						
+ +
+ +
+

Rackspace == Akamai

+

It's cheap. 18c per GB

+

You don't have to deal directly with Akamai. Keep your soul!

+

http://www.rackspace.com/cloud/public/files/

+
+ +
+

Getting it there

+

There's a node library for that.

+

https://github.com/nodejitsu/node-cloudfiles

+
+ +
+

There's also some tooling for that.

+

https://github.com/PinionTech/cloud-loader

+

+coffee cloud-loader.coffee -x localDir cloudContainer
+						
+
+ +
+

Deep magic

+

+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
+						
+
+ +
+

Relax

+

Never ever care about whether your website is up.

+

Go do something useful instead.

+
+

Yeah, it's harder to do pretty URLs.

+
+
+

So fixed

+ +
+
+
+
+

It's not always the right thing to just fix it

+
+
+

But sometimes it is

+ +
+
+ +
+

ALL FIXED

+

BY David Banham and Sam Gentle

+ +
+
+ + + + + +
+ +
+ + + + + + + diff --git a/fixedmaster.html b/fixedmaster.html new file mode 100644 index 0000000..a744a98 --- /dev/null +++ b/fixedmaster.html @@ -0,0 +1,455 @@ + + + + + + + There I Fixed It + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+
+

There I Fixed It

+

Dumb hacks that end up being great

+ +
+ +
+

Heads Up

+

+ This presentation uses a souped-up version of reveal.js +

+

+ Go here on your laptop, smartphone or tablet: +

+ +

http://www.pinion.gg/sydjs/index.html

+

http://bit.ly/Nlf8Aw

+
+ +
+
+

Who the hell are you?

+ + + +
+
+

What the hell is this?

+ +
+
+ +
+
+ + +
+
+

In the beginning.

+

+ There was SQL. +

+

+ And it was okay. +

+
+
+

And then...

+

There was noSQL!

+

And it scaled and it was all javascripty and all the hipsters loved it and everyone was happy. +

+
+

But then you want to actually use it

+
+
+

+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()
+
+
+
+ +
+
+

unql-node

+

+ + https://github.com/sgentle/unql-node + +

+

It's like SQL for NoSQL

+ +
+
+

Deletin' stuff

+

+> delete from checkins where username.match(/\d{4}$/) && timestamp > (new Date()).getTime()-1000*60*60*24*7
+						
+
+
+

Why don't we take all the data...

+

+> 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
+						
+

And put it over here!

+
+
+

Want to see my awesome LALR recursive descent parser?

+ +
+
+

Nope!

+

+handle /delete from (\S+)(?: where (.*))?/, (db, expr, cb) ->
+  query = "update #{db} set _deleted = true"
+  query += " where #{expr}" if expr
+  processExpr query, cb
+						
+
+
+

There I fixed it.

+ +
+
+ +
+
+

noDB

+

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?

+
+
+

Nope!

+ +
+
+

noDB

+

SQL < noSQL < noDB

+
+
+

Super simple

+

+var users = JSON.parse(fs.readFileSync('data/users.json'))
+
+users.push({name: "newguy"});
+fs.writeFileSync('data/users.json', JSON.stringify(users));
+res.send('success');
+						
+
+
+

Session storage too!

+

+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);
+						
+
+
+

It's basically Redis

+ It's not really +
+
+

But it is:

+
    +
  • Deployable
  • +
  • Dependency free
  • +
  • Easily backed up
  • +
  • Debuggable
  • +
+
+
+

Databases: Fixed

+ +
+
+ +
+
+

I would like to make some information available on the internet.

+
+
+

So find a shared hosting provider or something.

+

But they're kind of crappy

+
+
+

So I'll just run my own

+

On nginx or express or something!

+

But load balancing and updates and bugs and oh no.

+
+
+

Oh I know!

+ +
+
+ +
+
+
+ Augh. I wish I could just shove all this right on Akamai +
+
+
+

...

+
+
+

...

+
+
+

...

+
+
+

Why not?

+
+
+

Step 0: Generate static site

+

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!
+						
+
+
+

make

+

+JADE = $(shell find pages/*.jade)
+HTML = $(JADE:.jade=.html)
+
+all: $(HTML)
+
+%.html: %.jade
+      ./jade/bin/jade < $< --path $< > $@
+
+clean:
+      rm -f $(HTML)
+
+.PHONY: clean
+						
+ +
+ +
+

Rackspace == Akamai

+

It's cheap. 18c per GB

+

You don't have to deal directly with Akamai. Keep your soul!

+

http://www.rackspace.com/cloud/public/files/

+
+ +
+

Getting it there

+

There's a node library for that.

+

https://github.com/nodejitsu/node-cloudfiles

+
+ +
+

There's also some tooling for that.

+

https://github.com/PinionTech/cloud-loader

+

+coffee cloud-loader.coffee -x localDir cloudContainer
+						
+
+ +
+

Deep magic

+

+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
+						
+
+ +
+

Relax

+

Never ever care about whether your website is up.

+

Go do something useful instead.

+
+

Yeah, it's harder to do pretty URLs.

+
+
+

So fixed

+ +
+
+
+
+

It's not always the right thing to just fix it

+
+
+

But sometimes it is

+ +
+
+ +
+

ALL FIXED

+

BY David Banham and Sam Gentle

+ +
+
+ + + + + +
+ +
+ + + + + + +