本質上Cell比較類似Controller,針對任一Resource的CRUD行為可以事件驅動方式被呼叫。
- Example FoosCell
| Funcaion | Function params | Event | Event params |
|---|---|---|---|
| index | event | 'foos:index' | - |
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: redis-server | |
| # Required-Start: $syslog | |
| # Required-Stop: $syslog | |
| # Should-Start: $local_fs | |
| # Should-Stop: $local_fs | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: redis-server - Persistent key-value db |
| class YahooToken < ConsumerToken | |
| YAHOO_SETTINGS={ | |
| :site => "https://api.login.yahoo.com", | |
| :request_token_path => "/oauth/v2/get_request_token", | |
| :access_token_path => "/oauth/v2/get_token", | |
| :authorize_path=> "/oauth/v2/request_auth" | |
| } | |
| def self.consumer |
| # install nginx in OSX | |
| brew install nginx | |
| PATH=$PATH:/usr/local/sbin | |
| nginx start | |
| nginx -V # 查看配置文件位置及版本 | |
| nginx -c filename # 指定配置文件 | |
| nginx -s [reload|reopen|stop|quit] |
| # 查foreign key | |
| # login in mysql | |
| mysql -u root -p | |
| use information_schema; | |
| select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from KEY_COLUMN_USAGE where REFERENCED_TABLE_NAME = '<TABLE NAME>'; | |
| # 列出wed_development的所有FK | |
| SELECT i.TABLE_SCHEMA, i.TABLE_NAME, i.CONSTRAINT_TYPE, i.CONSTRAINT_NAME, k.REFERENCED_TABLE_NAME, k.REFERENCED_COLUMN_NAME | |
| FROM information_schema.TABLE_CONSTRAINTS i | |
| LEFT JOIN information_schema.KEY_COLUMN_USAGE k ON i.CONSTRAINT_NAME = k.CONSTRAINT_NAME |
| class ApplicationController < ActionController::Base | |
| before_filter :mobile_view_redirect | |
| layout :which_layout | |
| def mobile_device? | |
| request.user_agent =~ /Mobile|webOS|Android/ | |
| end | |
| helper_method :mobile_device? |
| @include text-overflow; | |
| @include text-shadow(0 -1px 1px #21272B); | |
| @include border-radius(2px, 2px); | |
| @include border-bottom-left-radius(8px); | |
| @include box-shadow(rgba(0, 0, 0, 0.05) 3px 3px 5px); | |
| @include single-box-shadow(rgba(0, 0, 0, 0.075), 0, 0, 3px); | |
| @include single-transition(opacity, 0.2s, linear, 0s); | |
| @include background(linear-gradient($color-btn, darken($color-btn, 10%))); | |
| @include background-image(linear-gradient(lighten($color-btn, 5%), darken($color-btn, 15%))); | |
| @include background-image(none); |
| var logger = function () { | |
| var oldDebug = null, | |
| oldLog = null, | |
| oldInfo = null, | |
| oldWarn = null, | |
| oldError = null; | |
| return { | |
| enable: function () { | |
| if (oldLog === null) return; |
| <html> | |
| <head> | |
| <style type="text/css"> | |
| ul li { | |
| margin-bottom: 10px; | |
| cursor: move; | |
| } | |
| </style> | |
| </head> |
mkdir -p /Users/joshchang/Documents/vagrant_box
vagrant package --output /Users/joshchang/Documents/vagrant_box/mybox.box
vagrant box add mybox /Users/joshchang/Documents/vagrant_box/mybox.box
# New project
vagrant init mybox
vagrant up