// Changes for Essential JS design patterns
// jQuery Module pattern for plugins
!function(exports, $, undefined){
var Plugin = function(){
// Our private API
// Boring | |
if (isThisAwesome) { | |
alert('yes'); // it's not | |
} | |
// Awesome | |
isThisAwesome && alert('yes'); | |
// Also cool for guarding your code | |
var aCoolFunction = undefined; |
{ | |
// -------------------------------------------------------------------- | |
// JSHint Configuration, Strict Edition | |
// -------------------------------------------------------------------- | |
// | |
// This is a options template for [JSHint][1], using [JSHint example][2] | |
// and [Ory Band's example][3] as basis and setting config values to | |
// be most strict: | |
// | |
// * set all enforcing options to true |
#!/bin/bash -e | |
# Install WordPress and clean the folder | |
echo "======================" | |
echo " Installing WordPress " | |
echo "======================" | |
echo "" | |
# Download the files (cURL works fine here too) | |
wget http://wordpress.org/latest.tar.gz |
#coding: utf-8 | |
from bottle import route, error, post, get, run, static_file, abort, redirect, response, request, template | |
@route('/') | |
@route('/index.html') | |
def index(): | |
return '<a href="/hello">Go to Hello World page</a>' | |
@route('/hello') | |
def hello(): |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title>Backbone.js • TodoMVC</title> | |
<link rel="stylesheet" href="../../assets/base.css"> | |
<!--[if IE]> | |
<script src="../../assets/ie.js"></script> | |
<![endif]--> |
// Changes for Essential JS design patterns
// jQuery Module pattern for plugins
!function(exports, $, undefined){
var Plugin = function(){
// Our private API
Generally one implements notifications by listening for events on specific models but if one wishes to have a single global message interchange, it could be done as follows:
var pubsub = new Backbone.Model;
View1 = Backbone.View.extend({
initialize: function(){
pubsub.bind('custom event', callback);
}
// ...
var Product = Backbone.Model.extend({}); | |
var ProductView = Backbone.View.extend({ | |
template: _.template("<h1 id='name'></h1><p id='price'></p>"), | |
bindings: { | |
"#name": { modelAttr: "name" }, | |
"#price": { modelAttr: "price", format: 'formatPrice' } | |
}, | |
render: function() { | |
this.el.innerHTML = this.template(); |
from bottle import route, run, auth_basic | |
from passlib.hash import sha256_crypt | |
def check_pass(username, password): | |
hashed = ''.join(redis.hmget(username, "password")) | |
return sha256_crypt.verify(password, hashed) | |
@route('/', method='GET') | |
@auth_basic(check_pass) # <-- decorator | |
def index(): |