Sometimes you'll have objects that manage state along with event handling. This happens frequently in MVC apps. Let's start with a messy example:
var Launcher = function(rocket) {
this.rocket = rocket
}
Launcher.prototype.isReady = function() {
| fs = require 'fs' | |
| {exec} = require 'child_process' | |
| util = require 'util' | |
| growl = require 'growl' | |
| appFiles = [ | |
| 'src/hasToGoFirst.coffee' # put your files that must be loaded in first into the array | |
| 'src/notAsImportantButNeedsToGoBeforeTheRest.coffee' | |
| ] |
| namespace :deploy do | |
| task :compile, :roles => :app do | |
| run <<-CMD | |
| export PATH=#{node_path}:$PATH && | |
| cd #{latest_release} && | |
| mkdir lib && | |
| coffee -o lib -c src | |
| CMD | |
| end | |
| end |
| // https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works | |
| package main | |
| import ( | |
| "fmt" | |
| "golang.org/x/crypto/ssh" | |
| ) | |
| const privateKey = `content of id_rsa` |
| /* | |
| modified from original source: https://bitbucket.org/mattkotsenas/c-promises/overview | |
| */ | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| namespace Promises |
| /*jslint node: true */ | |
| "use strict"; | |
| var express = require("express"), | |
| consolidate = require("consolidate"), | |
| Handlebars = require("handlebars"), | |
| fs = require("fs"); | |
| var app = express(); |
Create a Meteor app and put the client_/server_ files in a client/server directories. Also, create a public dir to save the uploaded files.
| # | |
| # Slightly tighter CORS config for nginx | |
| # | |
| # A modification of https://gist.github.com/1064640/ to include a white-list of URLs | |
| # | |
| # Despite the W3C guidance suggesting that a list of origins can be passed as part of | |
| # Access-Control-Allow-Origin headers, several browsers (well, at least Firefox) | |
| # don't seem to play nicely with this. | |
| # |
| package fakeresponse | |
| import ( | |
| "testing" | |
| "net/http" | |
| ) | |
| type FakeResponse struct { | |
| t *testing.T | |
| headers http.Header |