Skip to content

Instantly share code, notes, and snippets.

@twetzel
twetzel / replace_ruby_hash_syntax.md
Last active December 18, 2015 16:49
regular expression to change ruby hash syntax for TextMate | Sublime | etc

Old => New:

Find:
  :(\w+)[\s]+=>[\s]+
Replace:
  $1: 

New => Old:

@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 / 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 / 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 / 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>");
}
# 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 / 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
class App.Root extends Spine.Stack
controllers:
resources: App.Resources
users: App.Users
routes:
'/resources' : 'resources'
'/users' : 'users'
default: 'users'
@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 \

@twetzel
twetzel / db.coffee
Last active September 5, 2015 21:39 — forked from jaigouk/db.coffee
Riot.js Todo MVC in coffeescript https://github.com/moot/riotjs
DB = (key) ->
store = window.localStorage
get: ->
JSON.parse store[key] or "{}"
put: (data) ->
store[key] = JSON.stringify(data)