Skip to content

Instantly share code, notes, and snippets.

@qiaosu
qiaosu / chat.rb
Created July 17, 2012 16:03 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@qiaosu
qiaosu / dbnotes.py
Created February 14, 2012 01:55 — forked from jjgod/dbnotes.py
Backup Douban Notes
#!/usr/bin/env python
# Douban Notes Grab
import sys, urllib, re, HTMLParser, time, os
def save(url, title, t):
f = urllib.urlopen(url)
fname = "%s.txt" % title
startstr = '<pre class="note">'
endstr = '</pre></div>'
@qiaosu
qiaosu / editor.css
Created January 28, 2012 04:41 — forked from nakhli/editor.css
Backbone.js tutorial - Part 1 - www.javageneration.com
.shape{
height: 100%;
width: 100%;
}
.circle {
border-radius: 50%/50%;
-moz-border-radius: 50%/50%;
-webkit-border-radius: 50%/50%;
}
.hide {

#Understanding MVC And MVP (For JavaScript & Backbone Developers)

Before exploring any JavaScript frameworks that assist in structuring applications, it can be useful to gain a basic understanding of architectural design patterns. Design patterns are proven solutions to common development problems and can suggest structural paradigms to help guide us in adding some organization to our application.

I think patterns are exciting as they're effectively a grass roots effort that build upon the collective experience of skilled developers who have previously faced similar problems as we do now. Although developers 10 or 20 years ago may not have been using the same programming languages for implementing patterns, there are many lessons we can learn from their efforts.

In this section, we're going to review two popular patterns - MVC and MVP. The context of our exploration will be how these patterns are related to the popular JavaScript framework Backbone.js, which will be explored in greater detail later on.

@qiaosu
qiaosu / jsconf-eu-2011.md
Created October 8, 2011 07:45 — forked from mattpodwysocki/jsconf-eu-2011.md
JSConf.EU Slides