(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.
from flask import Flask, request, redirect, url_for, make_response, abort | |
from werkzeug import secure_filename | |
from pymongo import Connection | |
from pymongo.objectid import ObjectId | |
from gridfs import GridFS | |
from gridfs.errors import NoFile | |
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif']) | |
DB = Connection().gridfs_server_test | |
FS = GridFS(DB) |
(defn uuid [] (str (java.util.UUID/randomUUID))) |
/** | |
* Show a notice when Mac's stupid scroll happens | |
* http://micho.biz/mac-osx-lion-horizontal-scroll-event/ | |
*/ | |
Global.preventStupidMacScroll = function () { | |
var self = this, | |
broken_browser = navigator.userAgent.match(/Macintosh/), | |
hide = Teambox.models.user.get('settings').hide_scroll_notice; | |
if (!broken_browser || hide) { |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
VAGRANTFILE_API_VERSION = "2" | |
digital_ocean_client_id = '' | |
digital_ocean_api_key = '' | |
Vagrant.require_plugin "vagrant-librarian-chef" | |
Vagrant.require_plugin "vagrant-omnibus" | |
Vagrant.require_plugin "vagrant-vbguest" | |
Vagrant.require_plugin "vagrant-digitalocean" |
(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.
#!/usr/bin/env python | |
def curry(func): | |
""" | |
Decorator to curry a function, typical usage: | |
>>> @curry | |
... def foo(a, b, c): | |
... return a + b + c |
/** @jsx React.DOM */ | |
'use strict'; | |
var React = require('react'), | |
{ PropTypes } = React; | |
var AudioPlayer = React.createClass({ | |
propTypes: { | |
source: PropTypes.string.isRequired, | |
isPlaying: PropTypes.bool.isRequired, |
extension NSTimer { | |
/** | |
Creates and schedules a one-time `NSTimer` instance. | |
- Parameters: | |
- delay: The delay before execution. | |
- handler: A closure to execute after `delay`. | |
- Returns: The newly-created `NSTimer` instance. | |
*/ |
#How to Construct Yourself UI in KeystoneJS
KeystoneJS provide Admin UI with one set of route controllers and view templates(list&item) for all of the models.But usually,you will need some custome views other than Admin UI to display models. Although the KeystoneJS documention don't tell us much about how to contruct custome view,we can learn this from the source code in skeleton project generated by yo keystone
,or you can just check out the keystone demo project's source code.We will walk through the blog feature's implementation in this demo application to demonstrate how to construct custome UI in KeystoneJS application.
As KeystoneJS documention described in Routes & Views section,there is a routes/index.js
file, where we bind application's URL patterns to the controllers that load and process data, and render the appropriate template.You can find following code in it:
app.get('/blog/:catego