This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EventBus | |
@@events = {} | |
def self.register(name, callback) | |
@@events[name] ||= [] | |
@@events[name] << callback | |
end | |
def self.publish(name, *args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# data resource | |
angular.module('resources').factory 'DataResource', ['$resource', (resource) -> | |
resource '/api/v1/data/:id', | |
{ id: '@id' }, | |
get: { method: 'GET', isArray: false }, | |
query: { method: 'GET', isArray: true } | |
] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream some_app_server { | |
server 127.0.0.1:9393; | |
} | |
server { | |
listen 80; | |
server_name my-upload-endpoint.com ; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is a very customized implementation of the jQuery File Upload plugin | |
* configured to work with nginx. | |
*/ | |
$(function() { | |
var calculateProgress, cancelAllUploads, cancelUpload, createProgressBar, | |
fileName, files, maxChunkSize, startAllUploads, startUpload, uploadedFilePath; | |
// A container to hold all of the upload data objects. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery File Uploader (blueimp) and nginx benchmark notes. | |
Hypothesis: | |
Assigning the chunk size to be greater than the client_body_buffer_size will result in slower uploads and corrupt files. | |
Table 1: Stability | |
------------------ | |
The table below shows the number of successful file uploads after a random number of pause and resume operations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream app_server { | |
server unix:/tmp/file_acceptor.sock fail_timeout=0; | |
} | |
server { | |
listen <%= port %>; | |
server_name localhost; | |
client_max_body_size 4G; | |
client_body_buffer_size 128k; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>jQuery File Upload Example</title> | |
<style> | |
table { | |
width: 90%; | |
border: 1px solid #ccc; | |
color: #888; |