Skip to content

Instantly share code, notes, and snippets.

@twetzel
twetzel / server_setup.md
Created June 17, 2012 15:42 — forked from erotte/server_setup.md
Server Setup Ubuntu 10.4/rvm/nginx/passenger Hosteurope VM

Server Setup

Unsere Setup-Routine für eine Rails-App mit Nginx, Passenger, rvm auf einen Host Europe-VPS mit Ubuntu 10.4.

Installation der benötigten Pakete

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'
@twetzel
twetzel / partial_helper.js.coffee
Created June 21, 2012 04:02
.eco - Partials .. Render Partials in .jst.eco templates (for Rails + Spine / maybe Backbone)
# Render Partials in ECO-Templates like in Rails-ERB
#
# usefull to clean up structure in spine.js and other js-mvc´s like backbone
#
# usage:
# <%- render_partial 'path/to/partial' %> .. will render ../spine-app/views/path/to/_partial.jst.eco
# <%- render_partial 'path/to/partial', foo: 'bar' %> .. will render ../spine-app/views/path/to/_partial.jst.eco .. locals = @foo
#
window.render_partial = ( path, options = {} ) ->
# add the leading underscore (like rails-partials)
@twetzel
twetzel / ajax_error.js.coffee
Created June 21, 2012 22:08
Handle spine ajax errors with jQuery .. by Ian White
Handle global ajax errors with jQuery:
$(document).ajaxError (xhr, status, error) =>
console.log("Global ajaxError", arguments)
if xhr.status is 403
window.location = "http://backend.myapp.com/login"
Handle individual jQuery ajax requests:
$.ajax(
url: url
# 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:
@twetzel
twetzel / navigation_tabs.js
Created July 10, 2012 20:40
jquery tabs with back & forward buttons
// Form-Tabs with 'previous' & 'next' buttons
var $the_tabs = $('#tabs').tabs();
$("#tabs .ui-tabs-panel").each(function(i){
var totalSize = $("#tabs .ui-tabs-panel").size() - 1;
log( totalSize );
if (i != totalSize) {
next = i + 2;
$(this).find('.editable-tab-box .headline')
.append("<a href='#' class='next-tab trigger right' rel='#" + $(this).next('.ui-tabs-panel').attr('id') + "'></a>");
}
@twetzel
twetzel / jquery_ujs.js
Created July 11, 2012 14:46
jquery_ujs with 2 custom events to show loader / progressbar
(function($, undefined) {
/**
* Unobtrusive scripting adapter for jQuery
*
* Requires jQuery 1.6.0 or later.
* https://github.com/rails/jquery-ujs
* Uploading file using rails.js
* =============================
@twetzel
twetzel / server_setup.md
Created July 21, 2012 18:38 — forked from erotte/server_setup.md
Server Setup Ubuntu 10.4/rvm/nginx/passenger Hosteurope VM

Server Setup

Unsere Setup-Routine für eine Rails-App mit Nginx, Passenger, rvm auf einen Host Europe-VPS mit Ubuntu 10.4.

Installation der benötigten Pakete

apt-get update

apt-get install -y build-essential bison openssl libreadline5 libreadline5-dev curl \

@twetzel
twetzel / pp_deamon.rb
Created July 22, 2012 00:35
private_pub Deamon .. kill process @ port
# => Start private_pub (Faye) as Deamon
RAILS_ENV=production bundle exec rackup private_pub.ru -s thin -E production -D
# => find Process on Port x
fuser -n tcp 9292
-> 9292/tcp: 3748
# => kill process
kill -9 3748
@twetzel
twetzel / private_pub-on-nginx.md
Created July 22, 2012 00:58
private_pub/faye on nginx