Skip to content

Instantly share code, notes, and snippets.

class EventBus
@@events = {}
def self.register(name, callback)
@@events[name] ||= []
@@events[name] << callback
end
def self.publish(name, *args)
@JAndritsch
JAndritsch / gist:8427309
Created January 14, 2014 22:35
A sample Angular app that fetches data from an API through a Poller service, caches it on another Service, then shows the latest data in the UI
# 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 }
]
upstream some_app_server {
server 127.0.0.1:9393;
}
server {
listen 80;
server_name my-upload-endpoint.com ;
/*
* 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.
@JAndritsch
JAndritsch / results.txt
Last active February 3, 2023 07:46
Nginx settings and jQuery File Uploader chunk sizes
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.
@JAndritsch
JAndritsch / nginx_configuration.conf
Created October 17, 2012 19:50
nginx configuration
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;
@JAndritsch
JAndritsch / example.html
Created October 16, 2012 16:06
jQuery File Uploader with nginx setup - Custom Example
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>jQuery File Upload Example</title>
<style>
table {
width: 90%;
border: 1px solid #ccc;
color: #888;