(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| {{define "body"}} | |
| This is the start page. | |
| <br><br> | |
| Check out <a href="/user/5">user 5</a> or <a href="/user/7">user 7</a>. | |
| {{end}} | |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| <script type="text/javascript"> | |
| (function () { | |
| "use strict"; | |
| // once cached, the css file is stored on the client forever unless | |
| // the URL below is changed. Any change will invalidate the cache | |
| var css_href = './index_files/web-fonts.css'; | |
| // a simple event handler wrapper | |
| function on(el, ev, callback) { | |
| if (el.addEventListener) { | |
| el.addEventListener(ev, callback, false); |
I wanted to figure out the fastest way to load non-critical CSS so that the impact on initial page drawing is minimal.
TL;DR: Here's the solution I ended up with: https://github.com/filamentgroup/loadCSS/
For async JavaScript file requests, we have the async attribute to make this easy, but CSS file requests have no similar standard mechanism (at least, none that will still apply the CSS after loading - here are some async CSS loading conditions that do apply when CSS is inapplicable to media: https://gist.github.com/igrigorik/2935269#file-notes-md ).
Seems there are a couple ways to load and apply a CSS file in a non-blocking manner:
Google Chrome Developers says:
The new WOFF 2.0 Web Font compression format offers a 30% average gain over WOFF 1.0 (up to 50%+ in some cases). WOFF 2.0 is available since Chrome 36 and Opera 23.
Some examples of file size differences: WOFF vs. WOFF2
| # -*- coding: utf-8 -*- | |
| """ | |
| More info: | |
| http://flask.pocoo.org/docs/patterns/wtforms/ | |
| http://pythonhosted.org/Flask-SQLAlchemy/ | |
| https://flask-login.readthedocs.org/en/latest/ | |
| """ | |
| from flask import current_app, request, render_template, redirect, url_for | |
| from myapp.models import User |
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "net" | |
| "net/mail" | |
| "net/smtp" | |
| "crypto/tls" | |
| ) |
| class Ticket < ActiveRecord::Base | |
| belongs_to :grouper | |
| belongs_to :user | |
| validate :user_cant_be_blacklisted, on: :confirmation | |
| validate :user_cant_double_book, on: :confirmation | |
| validate :grouper_cant_be_full, on: :confirmation | |
| validate :grouper_cant_have_occurred, on: :confirmation |
I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.
| package main | |
| import ( | |
| "fmt" | |
| "github.com/gorilla/mux" | |
| "github.com/gorilla/securecookie" | |
| "net/http" | |
| ) | |
| // cookie handling |