DO's:
- Use explicit contracts to pipe data & events between systems
- Business rules should bubble towards the top, UI and semantics should sink towards the bottom
DONT's:
| <?xml version="1.0" encoding="UTF-8"?> | |
| <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> | |
| <CORSRule> | |
| <AllowedOrigin>*</AllowedOrigin> | |
| <AllowedMethod>PUT</AllowedMethod> | |
| <AllowedMethod>POST</AllowedMethod> | |
| <AllowedMethod>GET</AllowedMethod> | |
| <AllowedMethod>HEAD</AllowedMethod> | |
| <MaxAgeSeconds>3000</MaxAgeSeconds> | |
| <AllowedHeader>*</AllowedHeader> |
| var EventEmitter = require('events').EventEmitter, | |
| _ = require('lodash'); | |
| /** | |
| * Creates an action functor object | |
| */ | |
| exports.createAction = function() { | |
| var action = new EventEmitter(), | |
| eventLabel = "action", |
| class API::V1::BaseController < ApplicationController | |
| skip_before_filter :verify_authenticity_token | |
| before_filter :cors_preflight_check | |
| after_filter :cors_set_access_control_headers | |
| def cors_set_access_control_headers | |
| headers['Access-Control-Allow-Origin'] = '*' | |
| headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS' |
| (function() { | |
| 'use strict'; | |
| function AnotherController($scope, socket) { | |
| // use the socket factory through your app, but you must use socket.then | |
| // so that the actions occur once the socket is established | |
| socket.then(function(socket) { | |
| socket.emit('some_socket_event', {}); | |
| }); | |
| #https://gist.github.com/tlowrimore/5162327 | |
| #http://stackoverflow.com/a/15413611/270511 | |
| module ActiveRecord::UnionScope | |
| def self.included(base) | |
| base.send :extend, ClassMethods | |
| end | |
| module ClassMethods | |
| def union_scope(*scopes) |
Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
| function download(fileUrl, apiPath, callback) { | |
| var url = require('url'), | |
| http = require('http'), | |
| p = url.parse(fileUrl), | |
| timeout = 10000; | |
| var file = fs.createWriteStream(apiPath); | |
| var timeout_wrapper = function( req ) { | |
| return function() { |
The final result: require() any module on npm in your browser console with browserify
This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.
Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5