Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@j-mcnally
j-mcnally / proxy.py
Last active August 29, 2015 14:19 — forked from bxt/proxy.py
# Originally from http://sharebear.co.uk/blog/2009/09/17/very-simple-python-caching-proxy/
#
# Usage:
# A call to http://localhost:80000/example.com/foo.html will cache the file
# at http://example.com/foo.html on disc and not redownload it again.
# To clear the cache simply do a `rm *.cached`. To stop the server simply
# send SIGINT (Ctrl-C). It does not handle any headers or post data.
import BaseHTTPServer
import hashlib
#
#!/bin/sh -e
#
# Startup script for Red5
export RED5_HOME=/usr/share/red5/
start_red5="$RED5_HOME/red5-highperf.sh start"
stop_red5="$RED5_HOME/red5-shutdown.sh stop"

This is just a jotting of notes on how to embed Faye into a single Rails process. Makes it nice to do simple real time things without the need for a separate Faye server/process.

Also uses Faye Redis to work across load balanced Rails apps.

You also need to copy the compiled javascript into vendor/assets/javascripts and include into application.js manifest.

Ignore the numbers in the file names... just used to add order to the Gist.

This uses the faye/faye Github repo at edc5b42f6560d31eae61caf00f6765a90e1818d1 since I wanted to use with the Puma rack server and that is only available in the master branch (until Faye 1.0)

contentArrayContains: function(id, type) {
var contains = null;
Ember.get(type, 'collection').forEach(function(item) {
if (item.get('id') === id) {
contains = item;
}
});
return contains;
@j-mcnally
j-mcnally / Watchfile.coffee
Created September 7, 2012 22:30 — forked from lancejpollard/Watchfile.coffee
Tower + Ember Views
coffeecup = require('coffeecup')
watch /app\/views.*\.coffee$/
update: (path, callback) ->
try
nodes = path.replace("app/views/", "").split("/")
name = {}
data = File.read(path)
id = nodes.join("/")