Skip to content

Instantly share code, notes, and snippets.

@garethrees
garethrees / alaveteli-install.sh
Last active November 9, 2021 16:13
Alaveteli dev install
# Host
# ------------------------------------------------------------------------------
# Go to your main code directory
cd ~/Code
# Clone alaveteli
git clone --recursive https://github.com/mysociety/alaveteli.git
cd alaveteli
git checkout master # Or the specific version a site is running on, e.g. `0.20.0.14`
@rkh
rkh / chat.rb
Created December 14, 2011 12:55
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@lizconlan
lizconlan / CouchDB security - prevent non-admins from editing
Created July 26, 2010 12:37
CouchDB security - prevent non-admins from editing
function(newDoc, oldDoc, userCtx) {
if (userCtx.roles.indexOf('_admin') !== -1) {
return;
} else {
throw({forbidden: 'Only admins may edit the database'});
}
}