Unsere Setup-Routine für eine Rails-App mit Nginx, Passenger, rvm auf einen Host Europe-VPS mit Ubuntu 10.4.
apt-get update
apt-get install -y build-essential bison openssl libreadline5 libreadline5-dev curl \
| class App.Root extends Spine.Stack | |
| controllers: | |
| resources: App.Resources | |
| users: App.Users | |
| routes: | |
| '/resources' : 'resources' | |
| '/users' : 'users' | |
| default: 'users' |
| # These are my notes from the PragProg book on CoffeeScript of things that either | |
| # aren't in the main CS language reference or I didn't pick them up there. I wrote | |
| # them down before I forgot, and put it here for others but mainly as a reference for | |
| # myself. | |
| # assign arguments in constructor to properties of the same name: | |
| class Thingie | |
| constructor: (@name, @url) -> | |
| # is the same as: |
| # Update, upgrade and install development tools: | |
| sudo apt-get update | |
| sudo apt-get -y upgrade | |
| sudo apt-get -y install build-essential git-core libssl-dev libsqlite3-dev curl nodejs nginx | |
| # Install rvm | |
| \curl -sSL https://get.rvm.io | bash -s stable | |
| # Clear existing task so we can replace it rather than "add" to it. | |
| Rake::Task["deploy:compile_assets"].clear | |
| namespace :deploy do | |
| desc 'Compile assets' | |
| task :compile_assets => [:set_rails_env] do | |
| # invoke 'deploy:assets:precompile' | |
| invoke 'deploy:assets:precompile_local' | |
| invoke 'deploy:assets:backup_manifest' |
| // config/environment.js | |
| // This is not for production. But it will get your | |
| // console to stop screaming errors if your messing | |
| // around with ember cli | |
| module.exports = function(environment) { | |
| //lots of stuff | |
| // <Add this chunk> |
| // for demo: http://jsbin.com/jeqesisa/7/edit | |
| // for detailed comments, see my SO answer here http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional/21915381#21915381 | |
| /* a helper to execute an IF statement with any expression | |
| USAGE: | |
| -- Yes you NEED to properly escape the string literals, or just alternate single and double quotes | |
| -- to access any global function or property you should use window.functionName() instead of just functionName() | |
| -- this example assumes you passed this context to your handlebars template( {name: 'Sam', age: '20' } ), notice age is a string, just for so I can demo parseInt later | |
| <p> | |
| {{#xif " this.name == 'Sam' && this.age === '12' " }} |
| DB = (key) -> | |
| store = window.localStorage | |
| get: -> | |
| JSON.parse store[key] or "{}" | |
| put: (data) -> | |
| store[key] = JSON.stringify(data) |
| <!-- solution 1, 117b, inspired by http://www.p01.org/releases/140bytes_music_softSynth/ --> | |
| <button onclick="new Audio('data:audio/wav;base64,UklGRl9vT19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YU'+Array(1e3).join(123)).play()">Beep</button> | |
| <!-- Solution 2, 107b, inspired by http://xem.github.io/chip8/c8.html --> | |
| <button onclick="o=(A=new AudioContext()).createOscillator();o.connect(A.destination);o.start(0);setTimeout('o.stop(0)',500)">Boop</button> |